summaryrefslogtreecommitdiff
path: root/chromium/third_party/pdfium
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-14 17:41:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:37:36 +0000
commit399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch)
tree6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/third_party/pdfium
parent7366110654eec46f21b6824f302356426f48cd74 (diff)
downloadqtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/pdfium')
-rw-r--r--chromium/third_party/pdfium/.gn6
-rw-r--r--chromium/third_party/pdfium/BUILD.gn238
-rw-r--r--chromium/third_party/pdfium/DEPS76
-rw-r--r--chromium/third_party/pdfium/README.md118
-rw-r--r--chromium/third_party/pdfium/build/mac_find_sdk.py93
-rw-r--r--chromium/third_party/pdfium/build_gyp/all.gyp (renamed from chromium/third_party/pdfium/build/all.gyp)0
-rwxr-xr-xchromium/third_party/pdfium/build_gyp/gyp_pdfium (renamed from chromium/third_party/pdfium/build/gyp_pdfium)27
-rw-r--r--chromium/third_party/pdfium/build_gyp/gyp_pdfium.py (renamed from chromium/third_party/pdfium/build/gyp_pdfium.py)0
-rw-r--r--chromium/third_party/pdfium/build_gyp/set_clang_warning_flags.gypi (renamed from chromium/third_party/pdfium/build/set_clang_warning_flags.gypi)0
-rw-r--r--chromium/third_party/pdfium/build_gyp/standalone.gypi (renamed from chromium/third_party/pdfium/build/standalone.gypi)86
-rw-r--r--chromium/third_party/pdfium/build_overrides/README.md28
-rw-r--r--chromium/third_party/pdfium/build_overrides/build.gni8
-rw-r--r--chromium/third_party/pdfium/build_overrides/gtest.gni15
-rw-r--r--chromium/third_party/pdfium/build_overrides/pdfium.gni14
-rw-r--r--chromium/third_party/pdfium/build_overrides/v8.gni17
-rw-r--r--chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt.cpp48
-rw-r--r--chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt_sha.cpp98
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_basic_module.cpp35
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp22
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/editint.h24
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp461
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp1160
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_creator.h24
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp10
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_font.cpp59
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp6
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp19
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type1font.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.cpp40
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.h6
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3font.cpp22
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/font_int.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font.cpp37
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp22
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/include/cpdf_font.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.cpp35
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.h12
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_allstates.cpp7
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_color.cpp72
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp25
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp24
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_countedobject.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_form.cpp25
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_graphstate.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_image.cpp12
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_page.cpp116
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp19
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pagemodule.h37
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_parseoptions.h22
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.cpp7
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.h22
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp10
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp13
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h11
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_textobject.cpp9
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp12
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h18
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp121
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_func.cpp90
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp363
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp247
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp87
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_color.h16
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_form.h16
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_generalstatedata.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_page.h26
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_path.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_page/pageint.h59
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cfdf_document.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array.cpp93
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp181
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp (renamed from chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp)113
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h67
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp29
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp92
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_document.cpp1354
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp23
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_name.cpp8
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_number.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object.cpp4
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp41
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser.cpp84
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp16
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_reference.cpp5
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp (renamed from chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp)225
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_security_handler.h (renamed from chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h)38
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h64
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_string.cpp4
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp49
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h6
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp38
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp22
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_array.h39
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h63
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_document.h67
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_name.h3
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_object.h3
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_parser.h11
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_reference.h1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_string.h1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h45
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_occontext.cpp26
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_occontext.h23
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_security_handler.h36
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h1
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render.cpp70
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp13
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_image.cpp121
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp59
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp136
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_text.cpp42
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h6
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/fpdf_render/render_int.h78
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/include/cpdf_modulemgr.h35
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/ipdf_pagemodule.h28
-rw-r--r--chromium/third_party/pdfium/core/fpdfapi/ipdf_rendermodule.h29
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/cpdf_variabletext.cpp40
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/cpvt_color.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/cpvt_fontmap.cpp5
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.cpp203
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.h14
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/csection.cpp290
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/csection.h9
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/ctypeset.cpp496
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/ctypeset.h9
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_action.cpp19
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_annot.cpp29
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_basic.cpp153
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_basic_unittest.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_bookmark.cpp49
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_form.cpp54
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_formcontrol.cpp54
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_formfield.cpp34
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_link.cpp7
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_metadata.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_ocg.cpp81
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_tagged.cpp92
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_utils.cpp74
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_viewerPreferences.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/doc_vt.cpp736
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/include/cpdf_variabletext.h17
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/include/cpvt_wordprops.h2
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/include/fpdf_doc.h (renamed from chromium/third_party/pdfium/core/include/fpdfdoc/fpdf_doc.h)95
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/include/fpdf_tagged.h (renamed from chromium/third_party/pdfium/core/include/fpdfdoc/fpdf_tagged.h)47
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/pdf_vt.h32
-rw-r--r--chromium/third_party/pdfium/core/fpdfdoc/tagged_int.h32
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.cpp522
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.h247
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/fpdf_text_int_unittest.cpp5
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/include/cpdf_linkextract.h46
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/include/cpdf_textpage.h154
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/include/cpdf_textpagefind.h64
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/include/ipdf_linkextract.h26
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/include/ipdf_textpage.h70
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/include/ipdf_textpagefind.h29
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/unicodenormalization.cpp50
-rw-r--r--chromium/third_party/pdfium/core/fpdftext/unicodenormalization.h14
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_basicmodule.h32
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_bmpmodule.h46
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_faxmodule.h34
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_flatemodule.h51
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_gifmodule.h63
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_iccmodule.h95
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jbig2module.h34
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jpegmodule.h68
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jpxmodule.h36
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_pngmodule.h42
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_scanlinedecoder.h46
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/ccodec_tiffmodule.h35
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/codec_int.h387
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec.cpp96
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_bmp.cpp83
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_fax.cpp11
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_flate.cpp9
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_gif.cpp109
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_icc.cpp48
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jbig.cpp22
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp142
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpx_opj.cpp27
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_png.cpp60
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_progress.cpp73
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_tiff.cpp34
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/codec/include/ccodec_progressivedecoder.h (renamed from chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_progress.h)277
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/include/DEPS (renamed from chromium/third_party/pdfium/core/include/fxcodec/DEPS)0
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/include/fx_codec.h128
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/include/fx_codec_def.h (renamed from chromium/third_party/pdfium/core/include/fxcodec/fx_codec_def.h)6
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/include/fx_codec_flate.h (renamed from chromium/third_party/pdfium/core/include/fxcodec/fx_codec_flate.h)6
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.h2
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.h2
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Image.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxcodec/lgif/fx_gif.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/cfx_string_c_template.h168
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/cfx_string_data_template.h14
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/extension.h4
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_arabic.cpp181
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_array.cpp206
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring.cpp159
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring_unittest.cpp193
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_buffer.cpp17
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_gcc.cpp9
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_memmgr_unittest.cpp22
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_utf.cpp11
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_util.cpp52
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring.cpp1222
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring_unittest.cpp211
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_extension.cpp52
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_extension_unittest.cpp14
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_xml_composer.cpp20
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fx_xml_parser.cpp68
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fxcrt_posix.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/fxcrt_windows.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_arabic.h (renamed from chromium/third_party/pdfium/core/fxcrt/fx_arabic.h)67
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_arb.h17
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_basic.h123
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_coordinates.h1
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_ext.h10
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_safe_types.h2
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_stream.h2
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_string.h394
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_system.h37
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/include/fx_xml.h14
-rw-r--r--chromium/third_party/pdfium/core/fxcrt/xml_int.h2
-rw-r--r--chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp19
-rw-r--r--chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.h2
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.cpp100
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.h51
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.cpp10
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.h30
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.cpp28
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.h18
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fx_android_font.cpp68
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fx_android_font.h11
-rw-r--r--chromium/third_party/pdfium/core/fxge/android/fx_android_imp.cpp20
-rw-r--r--chromium/third_party/pdfium/core/fxge/apple/apple_int.h2
-rw-r--r--chromium/third_party/pdfium/core/fxge/apple/fx_apple_platform.cpp6
-rw-r--r--chromium/third_party/pdfium/core/fxge/apple/fx_mac_imp.cpp4
-rw-r--r--chromium/third_party/pdfium/core/fxge/apple/fx_quartz_device.cpp6
-rw-r--r--chromium/third_party/pdfium/core/fxge/dib/dib_int.h6
-rw-r--r--chromium/third_party/pdfium/core/fxge/dib/fx_dib_composite.cpp46
-rw-r--r--chromium/third_party/pdfium/core/fxge/dib/fx_dib_convert.cpp28
-rw-r--r--chromium/third_party/pdfium/core/fxge/dib/fx_dib_engine.cpp180
-rw-r--r--chromium/third_party/pdfium/core/fxge/dib/fx_dib_main.cpp124
-rw-r--r--chromium/third_party/pdfium/core/fxge/dib/fx_dib_transform.cpp233
-rw-r--r--chromium/third_party/pdfium/core/fxge/freetype/fx_freetype.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_ge.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_ge_device.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_ge_font.cpp4
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_ge_fontmap.cpp157
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_ge_linux.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_ge_path.cpp2
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_ge_ps.cpp8
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_ge_text.cpp32
-rw-r--r--chromium/third_party/pdfium/core/fxge/ge/fx_text_int.h4
-rw-r--r--chromium/third_party/pdfium/core/fxge/include/fx_dib.h (renamed from chromium/third_party/pdfium/core/include/fxge/fx_dib.h)87
-rw-r--r--chromium/third_party/pdfium/core/fxge/include/fx_font.h (renamed from chromium/third_party/pdfium/core/include/fxge/fx_font.h)63
-rw-r--r--chromium/third_party/pdfium/core/fxge/include/fx_freetype.h (renamed from chromium/third_party/pdfium/core/include/fxge/fx_freetype.h)6
-rw-r--r--chromium/third_party/pdfium/core/fxge/include/fx_ge.h (renamed from chromium/third_party/pdfium/core/include/fxge/fx_ge.h)46
-rw-r--r--chromium/third_party/pdfium/core/fxge/include/fx_ge_apple.h (renamed from chromium/third_party/pdfium/core/include/fxge/fx_ge_apple.h)6
-rw-r--r--chromium/third_party/pdfium/core/fxge/include/fx_ge_win32.h (renamed from chromium/third_party/pdfium/core/include/fxge/fx_ge_win32.h)6
-rw-r--r--chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.cpp585
-rw-r--r--chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.h14
-rw-r--r--chromium/third_party/pdfium/core/fxge/skia/fx_skia_device_unittest.cpp31
-rw-r--r--chromium/third_party/pdfium/core/fxge/win32/fx_win32_device.cpp23
-rw-r--r--chromium/third_party/pdfium/core/fxge/win32/fx_win32_dib.cpp4
-rw-r--r--chromium/third_party/pdfium/core/fxge/win32/fx_win32_dwrite.cpp4
-rw-r--r--chromium/third_party/pdfium/core/fxge/win32/fx_win32_gdipext.cpp10
-rw-r--r--chromium/third_party/pdfium/core/fxge/win32/fx_win32_print.cpp6
-rw-r--r--chromium/third_party/pdfium/core/fxge/win32/win32_int.h2
-rw-r--r--chromium/third_party/pdfium/core/include/fxcodec/fx_codec.h566
-rw-r--r--chromium/third_party/pdfium/core/include/fxge/fpf.h70
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/DEPS7
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/cfx_systemhandler.cpp138
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/cfx_systemhandler.h82
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.cpp22
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.h2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.cpp25
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.h2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_listbox.cpp47
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdf_ext.cpp7
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdf_flatten.cpp25
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdf_progressive.cpp9
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdf_searchex.cpp5
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdf_sysfontinfo.cpp2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdf_transformpage.cpp24
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfdoc.cpp13
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfdoc_embeddertest.cpp8
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfdoc_unittest.cpp9
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfedit_embeddertest.cpp88
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfeditpage.cpp13
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfformfill.cpp28
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfppo.cpp40
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfsave.cpp14
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdftext.cpp173
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp58
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfview_embeddertest.cpp40
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp85
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp135
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp72
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp20
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/DEPS (renamed from chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/DEPS)0
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_app.h (renamed from chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h)43
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h (renamed from chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h)30
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_page.h (renamed from chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h)39
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h (renamed from chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h)18
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fsdk_actionhandler.cpp4
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fsdk_annothandler.cpp41
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fsdk_baseannot.cpp121
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fsdk_baseform.cpp599
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fsdk_mgr.cpp225
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_ap.cpp171
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_edit.cpp1283
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_list.cpp65
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_module.cpp4
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_pageobjs.cpp615
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/include/DEPS (renamed from chromium/third_party/pdfium/fpdfsdk/include/fxedit/DEPS)0
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/include/fx_edit.h (renamed from chromium/third_party/pdfium/fpdfsdk/include/fxedit/fx_edit.h)16
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/include/fxet_edit.h (renamed from chromium/third_party/pdfium/fpdfsdk/include/fxedit/fxet_edit.h)16
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/fxedit/include/fxet_list.h (renamed from chromium/third_party/pdfium/fpdfsdk/include/fxedit/fxet_list.h)22
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/include/fsdk_actionhandler.h2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/include/fsdk_annothandler.h8
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseannot.h26
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseform.h12
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/include/fsdk_common.h6
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/include/fsdk_define.h8
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/include/fsdk_mgr.h29
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/include/fx_systemhandler.h106
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/Document.cpp44
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/Field.cpp27
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/JS_Define.h47
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.cpp57
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.h21
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.cpp4
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.h2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.cpp5
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.h4
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.cpp282
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.h12
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.cpp4
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.h2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/global.cpp34
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/global.h2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/public_methods_embeddertest.cpp32
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/javascript/util.cpp3
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/jsapi/fxjs_v8.cpp54
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/jsapi/include/fxjs_v8.h (renamed from chromium/third_party/pdfium/fpdfsdk/include/jsapi/fxjs_v8.h)35
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Caret.cpp4
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ComboBox.cpp8
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.cpp410
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.h27
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp138
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.h2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.cpp14
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.h12
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Icon.cpp6
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.cpp36
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.h14
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Label.cpp26
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.cpp14
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.h2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp2
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Note.cpp1513
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Note.h351
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp6
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Signature.cpp4
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.cpp810
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.h20
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.cpp74
-rw-r--r--chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.h49
-rw-r--r--chromium/third_party/pdfium/infra/config/cq.cfg13
-rw-r--r--chromium/third_party/pdfium/pdfium.gni11
-rw-r--r--chromium/third_party/pdfium/pdfium.gyp128
-rw-r--r--chromium/third_party/pdfium/public/fpdf_dataavail.h2
-rw-r--r--chromium/third_party/pdfium/public/fpdf_ext.h101
-rw-r--r--chromium/third_party/pdfium/public/fpdf_flatten.h46
-rw-r--r--chromium/third_party/pdfium/public/fpdf_fwlevent.h27
-rw-r--r--chromium/third_party/pdfium/public/fpdf_ppo.h38
-rw-r--r--chromium/third_party/pdfium/public/fpdf_searchex.h21
-rw-r--r--chromium/third_party/pdfium/public/fpdf_text.h30
-rw-r--r--chromium/third_party/pdfium/samples/BUILD.gn10
-rw-r--r--chromium/third_party/pdfium/samples/pdfium_test.cc113
-rw-r--r--chromium/third_party/pdfium/samples/samples.gyp2
-rw-r--r--chromium/third_party/pdfium/skia/BUILD.gn562
-rw-r--r--chromium/third_party/pdfium/skia/skia_gn_files.gypi45
-rw-r--r--chromium/third_party/pdfium/skia/skia_library.gypi7
-rw-r--r--chromium/third_party/pdfium/skia/skia_pdfium.gypi3
-rw-r--r--chromium/third_party/pdfium/testing/DEPS3
-rw-r--r--chromium/third_party/pdfium/testing/SUPPRESSIONS12
-rw-r--r--chromium/third_party/pdfium/testing/fx_string_testhelpers.cpp2
-rw-r--r--chromium/third_party/pdfium/testing/gtest_mac.h62
-rw-r--r--chromium/third_party/pdfium/testing/gtest_mac.mm98
-rw-r--r--chromium/third_party/pdfium/testing/js_embedder_test.h2
-rw-r--r--chromium/third_party/pdfium/testing/libfuzzer/pdf_fm2js_fuzzer.cc4
-rw-r--r--chromium/third_party/pdfium/testing/libfuzzer/pdf_jpx_fuzzer.cc2
-rw-r--r--chromium/third_party/pdfium/testing/libfuzzer/pdf_xml_fuzzer.cc2
-rw-r--r--chromium/third_party/pdfium/testing/resources/bug_602650.pdf105
-rw-r--r--chromium/third_party/pdfium/testing/resources/pixel/font_size.pdf72
-rw-r--r--chromium/third_party/pdfium/testing/test.gni232
-rw-r--r--chromium/third_party/pdfium/testing/test_support.cpp15
-rw-r--r--chromium/third_party/pdfium/testing/test_support.h3
-rwxr-xr-xchromium/third_party/pdfium/testing/tools/common.py7
-rwxr-xr-xchromium/third_party/pdfium/testing/tools/pngdiffer.py26
-rwxr-xr-xchromium/third_party/pdfium/testing/tools/run_corpus_tests.py168
-rwxr-xr-xchromium/third_party/pdfium/testing/tools/run_javascript_tests.py90
-rwxr-xr-xchromium/third_party/pdfium/testing/tools/run_pixel_tests.py98
-rwxr-xr-xchromium/third_party/pdfium/testing/tools/suppressor.py16
-rw-r--r--chromium/third_party/pdfium/testing/tools/test_runner.py231
-rw-r--r--chromium/third_party/pdfium/testing/utils/path_service.cpp2
-rw-r--r--chromium/third_party/pdfium/third_party/third_party.gyp37
-rw-r--r--chromium/third_party/pdfium/xfa.gyp144
-rw-r--r--chromium/third_party/pdfium/xfa/DEPS2
-rw-r--r--chromium/third_party/pdfium/xfa/fde/cfde_path.cpp (renamed from chromium/third_party/pdfium/xfa/fde/fde_geobject.cpp)103
-rw-r--r--chromium/third_party/pdfium/xfa/fde/cfde_path.h54
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_css.h639
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_csscache.cpp124
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_csscache.h41
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.cpp58
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.h44
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.cpp88
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.h49
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.cpp245
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.h629
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.cpp106
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.h55
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.h27
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_brush.h150
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_devbasic.cpp550
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_devbasic.h20
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_gedevice.cpp583
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_gedevice.h191
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_geobject.h57
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_image.h42
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_iterator.cpp80
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_iterator.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_object.cpp25
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_object.h234
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_path.h37
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_pen.h70
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_render.cpp226
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_render.h45
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_renderdevice.h110
-rw-r--r--chromium/third_party/pdfium/xfa/fde/fde_visualset.h75
-rw-r--r--chromium/third_party/pdfium/xfa/fde/tto/fde_textout.cpp299
-rw-r--r--chromium/third_party/pdfium/xfa/fde/tto/fde_textout.h210
-rw-r--r--chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.cpp154
-rw-r--r--chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.cpp140
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.h86
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.cpp253
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.h146
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.cpp101
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.cpp26
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.h26
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak.h53
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp82
-rw-r--r--chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h41
-rw-r--r--chromium/third_party/pdfium/xfa/fee/ifde_txtedtbuf.h39
-rw-r--r--chromium/third_party/pdfium/xfa/fee/ifde_txtedtengine.h138
-rw-r--r--chromium/third_party/pdfium/xfa/fee/ifde_txtedtpage.h9
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.cpp8
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_codepage.cpp18
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_encode.cpp12
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.cpp327
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_stream.cpp122
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_system.cpp8
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.cpp90
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.h259
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/font/fgas_font.h72
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/font/fgas_fontutils.cpp4
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.cpp71
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.cpp428
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.h58
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.cpp207
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.h210
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.cpp196
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.h240
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/layout/fgas_unicode.cpp4
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.cpp26
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.h31
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.cpp361
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.h54
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/localization/fgas_localeimp.h99
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.cpp9
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.h14
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax.cpp (renamed from chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax_imp.cpp)50
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax.h159
-rw-r--r--chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax_imp.h141
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.cpp77
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.h33
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.cpp112
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.h46
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.cpp153
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.h38
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.cpp600
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.h156
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp424
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.h113
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.cpp700
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.h121
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.cpp40
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.h23
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.cpp270
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.h52
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp345
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.h43
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.cpp60
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.h30
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp140
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.h35
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.cpp195
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.h62
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp224
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.h41
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp123
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.h65
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.cpp38
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.h74
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_barcode.h35
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_caret.h11
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_checkbox.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_combobox.h71
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_datetimepicker.h57
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_edit.h86
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_listbox.h85
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_monthcalendar.h83
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_picturebox.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_pushbutton.h13
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_scrollbar.h31
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_spinbutton.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_tooltip.h14
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/basewidget/ifx_barcode.h62
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/cfwl_event.h140
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/cfwl_message.h172
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/cfwl_note.h67
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/cfwl_themebackground.h6
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/cfwl_themepart.h82
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.cpp90
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.h41
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_contentimp.cpp94
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_contentimp.h35
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_error.h20
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.cpp620
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.h79
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_gridimp.cpp1382
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_gridimp.h197
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.cpp581
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.h104
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_panelimp.cpp155
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_panelimp.h32
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_sdadapterimp.cpp175
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_sdadapterimp.h89
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_targetimp.cpp44
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_targetimp.h27
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_threadimp.cpp39
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_threadimp.h41
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_timerimp.cpp16
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetdef.h25
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.cpp538
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.h105
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.cpp465
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.h74
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapternative.h24
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapterthreadmgr.h27
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapterwidgetmgr.h81
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_app.h58
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_content.h30
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_custom.h26
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_custompanel.h28
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_dataprovider.h4
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_form.h43
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_grid.h93
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_notedriver.h57
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_noteloop.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_notethread.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_panel.h30
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_proxy.h21
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_target.h52
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_themeprovider.h31
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_thread.h48
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_timer.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_tooltiptarget.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_widget.h120
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetdelegate.h10
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgr.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgrdelegate.h33
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/include/fwl_widgethit.h35
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/core/include/ifwl_adaptertimermgr.h10
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_app.cpp35
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_app.h31
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.cpp16
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.h45
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_caret.cpp55
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_caret.h28
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.cpp27
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.h13
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.cpp135
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.h86
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.cpp50
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.h31
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.cpp92
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.h45
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.cpp138
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.h71
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.cpp53
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.h23
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.cpp27
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.h10
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.cpp34
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.h14
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.cpp36
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.h27
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.cpp49
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.h33
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.cpp220
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.h57
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp18
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.h10
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.cpp12
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.cpp13
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.cpp182
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.h20
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.cpp86
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.h11
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickedtp.cpp66
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickertp.h9
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.cpp32
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.h12
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.cpp197
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.h26
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.cpp32
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.h12
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.cpp295
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.h24
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.cpp42
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.h21
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.cpp118
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.h17
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_utils.h40
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.cpp243
-rw-r--r--chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.h127
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp90
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/BC_ResultPoint.h5
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.cpp6
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/BC_UtilCodingConvert.cpp9
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/BC_Utils.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/BC_Writer.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/DEPS4
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.cpp19
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.h16
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.cpp19
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.h20
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.cpp19
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.h27
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_codebase.h6
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.h28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.h28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.h28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_onecode.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.h28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.cpp19
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.h28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.h25
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp62
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h12
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp18
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h11
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp66
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h16
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp14
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp26
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h16
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp39
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h15
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp29
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp123
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h17
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp27
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h38
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp14
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp46
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.cpp6
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp4
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp43
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.h6
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp6
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp10
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp8
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAReader.h1
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp4
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417.cpp10
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp16
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h3
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp18
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp3
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp136
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h6
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp13
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h7
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp18
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h7
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp107
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.h30
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h16
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp163
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h9
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp101
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h9
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp90
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.h6
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp103
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h10
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp19
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h16
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp13
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h20
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp12
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp14
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp42
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp120
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h21
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp97
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp49
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h33
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.h25
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp34
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.h7
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetector.cpp18
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp24
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h24
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp93
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h28
-rw-r--r--chromium/third_party/pdfium/xfa/fxbarcode/utils.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/DEPS3
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_checksum.cpp29
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffapp.cpp29
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.cpp22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.cpp43
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.h10
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.cpp82
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.h18
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdoc.cpp227
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdochandler.cpp6
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdocview.cpp136
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.cpp8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.h4
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.cpp8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.h4
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.cpp111
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.h15
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimage.cpp8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.cpp94
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.cpp542
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.h73
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpageview.cpp204
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpath.cpp8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.cpp57
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.cpp28
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.cpp8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.h4
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.cpp24
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.cpp120
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.h12
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidget.cpp135
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.cpp214
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgethandler.cpp30
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fontmgr.cpp69
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.cpp18
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.h23
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.cpp223
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.h42
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_rendercontext.cpp22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.cpp242
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.h84
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.cpp22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.h20
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.cpp58
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.h36
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp587
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.cpp124
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.h4
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.cpp54
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_program.cpp12
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.cpp58
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.h5
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/DEPS3
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/fxfa.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/fxfa.h)336
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/fxfa_basic.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/fxfa_basic.h)23
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/fxfa_widget.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/fxfa_widget.h)28
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_checksum.h78
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffapp.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffapp.h)30
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdoc.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdoc.h)15
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdochandler.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdochandler.h)8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdocview.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdocview.h)59
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffpageview.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffpageview.h)40
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffwidget.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffwidget.h)27
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffwidgethandler.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffwidgethandler.h)11
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_fontmgr.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_fontmgr.h)13
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/include/xfa_rendercontext.h (renamed from chromium/third_party/pdfium/xfa/include/fxfa/xfa_rendercontext.h)8
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/DEPS3
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_arc.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_assist.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_assist.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_bind.cpp16
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_bind.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_binditems.cpp27
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_binditems.h25
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_border.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_box.cpp168
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_box.h50
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_calculate.cpp32
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_calculate.h25
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_caption.cpp41
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_caption.h29
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_corner.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_data.cpp80
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_data.h35
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_edge.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_event.cpp49
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_event.h33
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_exdata.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_exdata.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_fill.cpp103
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_fill.h31
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_font.cpp92
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_font.h36
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_image.cpp54
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_image.h33
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_line.cpp22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_line.h25
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_margin.cpp32
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_margin.h25
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_occur.cpp67
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_occur.h26
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_para.cpp59
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_para.h29
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_rectangle.h19
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_script.cpp31
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_script.h32
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_stroke.cpp105
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_stroke.h45
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_submit.cpp27
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_submit.h26
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_text.cpp (renamed from chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp)15
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_text.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_tooltip.cpp15
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_tooltip.h22
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_validate.cpp119
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_validate.h44
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_value.cpp56
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_value.h35
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_widgetdata.cpp (renamed from chromium/third_party/pdfium/xfa/fxfa/parser/xfa_objectacc_imp.cpp)1668
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_widgetdata.h181
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.cpp1
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.cpp124
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_docdata.h16
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_doclayout.h9
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document.h24
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp16
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp190
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_imp.cpp139
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_layout_imp.cpp30
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.cpp63
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.h11
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.cpp29
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_itemlayout.cpp58
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp515
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_locale.cpp35
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.cpp49
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.h17
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.cpp55
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.h4
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object.h75
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object_imp.cpp1174
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_parser_imp.cpp103
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script.h10
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_datawindow.cpp1
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp97
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.h41
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp83
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.cpp225
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp11
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp1
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_nodehelper.cpp17
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp54
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.h1
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp11
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils.h55
-rw-r--r--chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils_imp.cpp40
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.cpp18
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.h10
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.cpp16
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.h8
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cfx_graphics.cpp494
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.cpp164
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.h96
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.cpp12
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/cfx_shading.h2
-rw-r--r--chromium/third_party/pdfium/xfa/fxgraphics/include/cfx_graphics.h217
-rw-r--r--chromium/third_party/pdfium/xfa/fxjse/DEPS2
-rw-r--r--chromium/third_party/pdfium/xfa/fxjse/class.cpp35
-rw-r--r--chromium/third_party/pdfium/xfa/fxjse/context.cpp84
-rw-r--r--chromium/third_party/pdfium/xfa/fxjse/include/fxjse.h25
-rw-r--r--chromium/third_party/pdfium/xfa/fxjse/runtime.cpp2
-rw-r--r--chromium/third_party/pdfium/xfa/fxjse/value.cpp39
-rw-r--r--chromium/third_party/pdfium/xfa/include/fxfa/fxfa_objectacc.h561
-rw-r--r--chromium/third_party/pdfium/xfa/include/fxfa/xfa_checksum.h74
961 files changed, 31481 insertions, 41370 deletions
diff --git a/chromium/third_party/pdfium/.gn b/chromium/third_party/pdfium/.gn
new file mode 100644
index 00000000000..fbcbf4bb4fc
--- /dev/null
+++ b/chromium/third_party/pdfium/.gn
@@ -0,0 +1,6 @@
+# Copyright 2016 PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+buildconfig = "//build/config/BUILDCONFIG.gn"
+secondary_source = "//build/secondary/"
diff --git a/chromium/third_party/pdfium/BUILD.gn b/chromium/third_party/pdfium/BUILD.gn
index b13a1bd3607..30fd1e04f3e 100644
--- a/chromium/third_party/pdfium/BUILD.gn
+++ b/chromium/third_party/pdfium/BUILD.gn
@@ -42,10 +42,7 @@ config("pdfium_config") {
}
if (is_win) {
- cflags += [
- "/wd4267",
- "/wd4701",
- ]
+ cflags += [ "/wd4267" ]
}
if (is_clang || is_posix) {
@@ -60,6 +57,8 @@ config("pdfium_config") {
static_library("pdfium") {
sources = [
+ "fpdfsdk/cfx_systemhandler.cpp",
+ "fpdfsdk/cfx_systemhandler.h",
"fpdfsdk/fpdf_dataavail.cpp",
"fpdfsdk/fpdf_ext.cpp",
"fpdfsdk/fpdf_flatten.cpp",
@@ -207,7 +206,9 @@ static_library("fpdfdoc") {
"core/fpdfdoc/cpvt_lineinfo.h",
"core/fpdfdoc/cpvt_sectioninfo.h",
"core/fpdfdoc/cpvt_wordinfo.h",
+ "core/fpdfdoc/csection.cpp",
"core/fpdfdoc/csection.h",
+ "core/fpdfdoc/ctypeset.cpp",
"core/fpdfdoc/ctypeset.h",
"core/fpdfdoc/doc_action.cpp",
"core/fpdfdoc/doc_annot.cpp",
@@ -232,11 +233,11 @@ static_library("fpdfdoc") {
"core/fpdfdoc/include/cpvt_wordplace.h",
"core/fpdfdoc/include/cpvt_wordprops.h",
"core/fpdfdoc/include/cpvt_wordrange.h",
+ "core/fpdfdoc/include/fpdf_doc.h",
+ "core/fpdfdoc/include/fpdf_tagged.h",
"core/fpdfdoc/ipvt_fontmap.h",
"core/fpdfdoc/pdf_vt.h",
"core/fpdfdoc/tagged_int.h",
- "core/include/fpdfdoc/fpdf_doc.h",
- "core/include/fpdfdoc/fpdf_tagged.h",
]
configs += [ ":pdfium_config" ]
}
@@ -310,7 +311,6 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp",
"core/fpdfapi/fpdf_edit/editint.h",
"core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp",
- "core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp",
"core/fpdfapi/fpdf_edit/include/cpdf_creator.h",
"core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h",
"core/fpdfapi/fpdf_font/cpdf_cidfont.cpp",
@@ -364,12 +364,12 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_page/cpdf_meshstream.cpp",
"core/fpdfapi/fpdf_page/cpdf_meshstream.h",
"core/fpdfapi/fpdf_page/cpdf_page.cpp",
+ "core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp",
+ "core/fpdfapi/fpdf_page/cpdf_pagemodule.h",
"core/fpdfapi/fpdf_page/cpdf_pageobject.cpp",
"core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp",
"core/fpdfapi/fpdf_page/cpdf_pageobjectlist.cpp",
"core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h",
- "core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp",
- "core/fpdfapi/fpdf_page/cpdf_parseoptions.h",
"core/fpdfapi/fpdf_page/cpdf_pathobject.cpp",
"core/fpdfapi/fpdf_page/cpdf_pattern.cpp",
"core/fpdfapi/fpdf_page/cpdf_pattern.h",
@@ -387,7 +387,6 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_page/fpdf_page_func.cpp",
"core/fpdfapi/fpdf_page/fpdf_page_parser.cpp",
"core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp",
- "core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp",
"core/fpdfapi/fpdf_page/include/cpdf_clippath.h",
"core/fpdfapi/fpdf_page/include/cpdf_color.h",
"core/fpdfapi/fpdf_page/include/cpdf_colorspace.h",
@@ -410,6 +409,8 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_parser/cpdf_array.cpp",
"core/fpdfapi/fpdf_parser/cpdf_boolean.cpp",
"core/fpdfapi/fpdf_parser/cpdf_boolean.h",
+ "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp",
+ "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h",
"core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp",
"core/fpdfapi/fpdf_parser/cpdf_data_avail.h",
"core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp",
@@ -424,11 +425,9 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_parser/cpdf_object.cpp",
"core/fpdfapi/fpdf_parser/cpdf_parser.cpp",
"core/fpdfapi/fpdf_parser/cpdf_reference.cpp",
+ "core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp",
+ "core/fpdfapi/fpdf_parser/cpdf_security_handler.h",
"core/fpdfapi/fpdf_parser/cpdf_simple_parser.cpp",
- "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp",
- "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h",
- "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp",
- "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h",
"core/fpdfapi/fpdf_parser/cpdf_stream.cpp",
"core/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp",
"core/fpdfapi/fpdf_parser/cpdf_string.cpp",
@@ -453,10 +452,6 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_parser/include/cpdf_string.h",
"core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h",
"core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h",
- "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h",
- "core/fpdfapi/fpdf_parser/ipdf_occontext.cpp",
- "core/fpdfapi/fpdf_parser/ipdf_occontext.h",
- "core/fpdfapi/fpdf_parser/ipdf_security_handler.h",
"core/fpdfapi/fpdf_render/cpdf_pagerendercache.h",
"core/fpdfapi/fpdf_render/fpdf_render.cpp",
"core/fpdfapi/fpdf_render/fpdf_render_cache.cpp",
@@ -470,8 +465,6 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h",
"core/fpdfapi/fpdf_render/render_int.h",
"core/fpdfapi/include/cpdf_modulemgr.h",
- "core/fpdfapi/ipdf_pagemodule.h",
- "core/fpdfapi/ipdf_rendermodule.h",
]
configs += [ ":pdfium_config" ]
}
@@ -479,13 +472,10 @@ static_library("fpdfapi") {
static_library("fpdftext") {
sources = [
"core/fpdftext/fpdf_text_int.cpp",
- "core/fpdftext/fpdf_text_int.h",
- "core/fpdftext/include/ipdf_linkextract.h",
- "core/fpdftext/include/ipdf_textpage.h",
- "core/fpdftext/include/ipdf_textpagefind.h",
+ "core/fpdftext/include/cpdf_linkextract.h",
+ "core/fpdftext/include/cpdf_textpage.h",
+ "core/fpdftext/include/cpdf_textpagefind.h",
"core/fpdftext/text_int.h",
- "core/fpdftext/unicodenormalization.cpp",
- "core/fpdftext/unicodenormalization.h",
"core/fpdftext/unicodenormalizationdata.cpp",
"core/fpdftext/unicodenormalizationdata.h",
]
@@ -502,6 +492,14 @@ static_library("fxcodec") {
"//third_party:jpeg",
]
sources = [
+ "core/fxcodec/codec/ccodec_basicmodule.h",
+ "core/fxcodec/codec/ccodec_faxmodule.h",
+ "core/fxcodec/codec/ccodec_flatemodule.h",
+ "core/fxcodec/codec/ccodec_iccmodule.h",
+ "core/fxcodec/codec/ccodec_jbig2module.h",
+ "core/fxcodec/codec/ccodec_jpegmodule.h",
+ "core/fxcodec/codec/ccodec_jpxmodule.h",
+ "core/fxcodec/codec/ccodec_scanlinedecoder.h",
"core/fxcodec/codec/codec_int.h",
"core/fxcodec/codec/fx_codec.cpp",
"core/fxcodec/codec/fx_codec_fax.cpp",
@@ -510,6 +508,9 @@ static_library("fxcodec") {
"core/fxcodec/codec/fx_codec_jbig.cpp",
"core/fxcodec/codec/fx_codec_jpeg.cpp",
"core/fxcodec/codec/fx_codec_jpx_opj.cpp",
+ "core/fxcodec/include/fx_codec.h",
+ "core/fxcodec/include/fx_codec_def.h",
+ "core/fxcodec/include/fx_codec_flate.h",
"core/fxcodec/jbig2/JBig2_ArithDecoder.cpp",
"core/fxcodec/jbig2/JBig2_ArithDecoder.h",
"core/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp",
@@ -549,19 +550,20 @@ static_library("fxcodec") {
"core/fxcodec/jbig2/JBig2_SymbolDict.h",
"core/fxcodec/jbig2/JBig2_TrdProc.cpp",
"core/fxcodec/jbig2/JBig2_TrdProc.h",
- "core/include/fxcodec/fx_codec.h",
- "core/include/fxcodec/fx_codec_def.h",
- "core/include/fxcodec/fx_codec_flate.h",
]
include_dirs = []
if (pdf_enable_xfa) {
sources += [
+ "core/fxcodec/codec/ccodec_bmpmodule.h",
+ "core/fxcodec/codec/ccodec_gifmodule.h",
+ "core/fxcodec/codec/ccodec_pngmodule.h",
+ "core/fxcodec/codec/ccodec_tiffmodule.h",
"core/fxcodec/codec/fx_codec_bmp.cpp",
"core/fxcodec/codec/fx_codec_gif.cpp",
"core/fxcodec/codec/fx_codec_png.cpp",
"core/fxcodec/codec/fx_codec_progress.cpp",
- "core/fxcodec/codec/fx_codec_progress.h",
"core/fxcodec/codec/fx_codec_tiff.cpp",
+ "core/fxcodec/codec/include/ccodec_progressivedecoder.h",
"core/fxcodec/lbmp/fx_bmp.cpp",
"core/fxcodec/lbmp/fx_bmp.h",
"core/fxcodec/lgif/fx_gif.cpp",
@@ -591,6 +593,7 @@ config("fxge_warnings") {
static_library("fxcrt") {
sources = [
+ "core/fxcrt/cfx_string_c_template.h",
"core/fxcrt/cfx_string_data_template.h",
"core/fxcrt/extension.h",
"core/fxcrt/fx_basic_array.cpp",
@@ -696,13 +699,12 @@ static_library("fxge") {
"core/fxge/ge/fx_ge_ps.cpp",
"core/fxge/ge/fx_ge_text.cpp",
"core/fxge/ge/fx_text_int.h",
- "core/include/fxge/fpf.h",
- "core/include/fxge/fx_dib.h",
- "core/include/fxge/fx_font.h",
- "core/include/fxge/fx_freetype.h",
- "core/include/fxge/fx_ge.h",
- "core/include/fxge/fx_ge_apple.h",
- "core/include/fxge/fx_ge_win32.h",
+ "core/fxge/include/fx_dib.h",
+ "core/fxge/include/fx_font.h",
+ "core/fxge/include/fx_freetype.h",
+ "core/fxge/include/fx_ge.h",
+ "core/fxge/include/fx_ge_apple.h",
+ "core/fxge/include/fx_ge_win32.h",
]
configs += [
@@ -736,9 +738,9 @@ static_library("fxedit") {
"fpdfsdk/fxedit/fxet_list.cpp",
"fpdfsdk/fxedit/fxet_module.cpp",
"fpdfsdk/fxedit/fxet_pageobjs.cpp",
- "fpdfsdk/include/fxedit/fx_edit.h",
- "fpdfsdk/include/fxedit/fxet_edit.h",
- "fpdfsdk/include/fxedit/fxet_list.h",
+ "fpdfsdk/fxedit/include/fx_edit.h",
+ "fpdfsdk/fxedit/include/fxet_edit.h",
+ "fpdfsdk/fxedit/include/fxet_list.h",
]
configs += [ ":pdfium_config" ]
}
@@ -767,8 +769,6 @@ static_library("pdfwindow") {
"fpdfsdk/pdfwindow/PWL_ListBox.h",
"fpdfsdk/pdfwindow/PWL_ListCtrl.cpp",
"fpdfsdk/pdfwindow/PWL_ListCtrl.h",
- "fpdfsdk/pdfwindow/PWL_Note.cpp",
- "fpdfsdk/pdfwindow/PWL_Note.h",
"fpdfsdk/pdfwindow/PWL_ScrollBar.cpp",
"fpdfsdk/pdfwindow/PWL_ScrollBar.h",
"fpdfsdk/pdfwindow/PWL_Signature.cpp",
@@ -790,7 +790,6 @@ static_library("javascript") {
]
if (pdf_enable_v8) {
sources += [
- "fpdfsdk/include/jsapi/fxjs_v8.h",
"fpdfsdk/javascript/Consts.cpp",
"fpdfsdk/javascript/Consts.h",
"fpdfsdk/javascript/Document.cpp",
@@ -831,6 +830,7 @@ static_library("javascript") {
"fpdfsdk/javascript/util.cpp",
"fpdfsdk/javascript/util.h",
"fpdfsdk/jsapi/fxjs_v8.cpp",
+ "fpdfsdk/jsapi/include/fxjs_v8.h",
]
include_dirs = [
"//v8",
@@ -877,10 +877,10 @@ if (pdf_enable_xfa) {
"fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp",
"fpdfsdk/fpdfxfa/fpdfxfa_page.cpp",
"fpdfsdk/fpdfxfa/fpdfxfa_util.cpp",
- "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h",
- "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h",
- "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h",
- "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h",
+ "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h",
+ "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h",
+ "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h",
+ "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h",
]
deps = [
":xfa",
@@ -894,6 +894,8 @@ if (pdf_enable_xfa) {
static_library("xfa") {
sources = [
+ "xfa/fde/cfde_path.cpp",
+ "xfa/fde/cfde_path.h",
"xfa/fde/css/fde_css.h",
"xfa/fde/css/fde_csscache.cpp",
"xfa/fde/css/fde_csscache.h",
@@ -907,23 +909,13 @@ if (pdf_enable_xfa) {
"xfa/fde/css/fde_cssstylesheet.h",
"xfa/fde/css/fde_csssyntax.cpp",
"xfa/fde/css/fde_csssyntax.h",
- "xfa/fde/fde_brush.h",
- "xfa/fde/fde_devbasic.cpp",
- "xfa/fde/fde_devbasic.h",
"xfa/fde/fde_gedevice.cpp",
- "xfa/fde/fde_gedevice.h",
- "xfa/fde/fde_geobject.cpp",
"xfa/fde/fde_geobject.h",
- "xfa/fde/fde_image.h",
"xfa/fde/fde_iterator.cpp",
"xfa/fde/fde_iterator.h",
- "xfa/fde/fde_object.cpp",
"xfa/fde/fde_object.h",
- "xfa/fde/fde_path.h",
- "xfa/fde/fde_pen.h",
"xfa/fde/fde_render.cpp",
"xfa/fde/fde_render.h",
- "xfa/fde/fde_renderdevice.h",
"xfa/fde/tto/fde_textout.cpp",
"xfa/fde/tto/fde_textout.h",
"xfa/fde/xml/fde_xml.h",
@@ -941,7 +933,6 @@ if (pdf_enable_xfa) {
"xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp",
"xfa/fee/fx_wordbreak/fx_wordbreak_impl.h",
"xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp",
- "xfa/fee/ifde_txtedtbuf.h",
"xfa/fee/ifde_txtedtengine.h",
"xfa/fee/ifde_txtedtpage.h",
"xfa/fgas/crt/fgas_algorithm.cpp",
@@ -980,9 +971,8 @@ if (pdf_enable_xfa) {
"xfa/fgas/localization/fgas_localeimp.h",
"xfa/fgas/localization/fgas_localemgr.cpp",
"xfa/fgas/localization/fgas_localemgr.h",
+ "xfa/fgas/xml/fgas_sax.cpp",
"xfa/fgas/xml/fgas_sax.h",
- "xfa/fgas/xml/fgas_sax_imp.cpp",
- "xfa/fgas/xml/fgas_sax_imp.h",
"xfa/fwl/basewidget/fwl_barcodeimp.cpp",
"xfa/fwl/basewidget/fwl_barcodeimp.h",
"xfa/fwl/basewidget/fwl_caretimp.cpp",
@@ -1026,70 +1016,38 @@ if (pdf_enable_xfa) {
"xfa/fwl/basewidget/ifwl_scrollbar.h",
"xfa/fwl/basewidget/ifwl_spinbutton.h",
"xfa/fwl/basewidget/ifwl_tooltip.h",
- "xfa/fwl/basewidget/ifx_barcode.h",
"xfa/fwl/core/cfwl_event.h",
"xfa/fwl/core/cfwl_message.h",
- "xfa/fwl/core/cfwl_note.h",
"xfa/fwl/core/cfwl_themebackground.h",
"xfa/fwl/core/cfwl_themepart.h",
"xfa/fwl/core/cfwl_themetext.h",
"xfa/fwl/core/cfwl_widgetimpproperties.h",
"xfa/fwl/core/fwl_appimp.cpp",
"xfa/fwl/core/fwl_appimp.h",
- "xfa/fwl/core/fwl_contentimp.cpp",
- "xfa/fwl/core/fwl_contentimp.h",
"xfa/fwl/core/fwl_error.h",
"xfa/fwl/core/fwl_formimp.cpp",
"xfa/fwl/core/fwl_formimp.h",
- "xfa/fwl/core/fwl_gridimp.cpp",
- "xfa/fwl/core/fwl_gridimp.h",
"xfa/fwl/core/fwl_noteimp.cpp",
"xfa/fwl/core/fwl_noteimp.h",
- "xfa/fwl/core/fwl_panelimp.cpp",
- "xfa/fwl/core/fwl_panelimp.h",
- "xfa/fwl/core/fwl_sdadapterimp.cpp",
- "xfa/fwl/core/fwl_sdadapterimp.h",
- "xfa/fwl/core/fwl_targetimp.cpp",
- "xfa/fwl/core/fwl_targetimp.h",
- "xfa/fwl/core/fwl_threadimp.cpp",
- "xfa/fwl/core/fwl_threadimp.h",
"xfa/fwl/core/fwl_timerimp.cpp",
"xfa/fwl/core/fwl_widgetdef.h",
"xfa/fwl/core/fwl_widgetimp.cpp",
"xfa/fwl/core/fwl_widgetimp.h",
"xfa/fwl/core/fwl_widgetmgrimp.cpp",
"xfa/fwl/core/fwl_widgetmgrimp.h",
- "xfa/fwl/core/ifwl_adapternative.h",
- "xfa/fwl/core/ifwl_adapterthreadmgr.h",
- "xfa/fwl/core/ifwl_adapterwidgetmgr.h",
"xfa/fwl/core/ifwl_app.h",
- "xfa/fwl/core/ifwl_content.h",
- "xfa/fwl/core/ifwl_custom.h",
- "xfa/fwl/core/ifwl_custompanel.h",
"xfa/fwl/core/ifwl_dataprovider.h",
"xfa/fwl/core/ifwl_form.h",
- "xfa/fwl/core/ifwl_grid.h",
- "xfa/fwl/core/ifwl_notedriver.h",
- "xfa/fwl/core/ifwl_noteloop.h",
- "xfa/fwl/core/ifwl_notethread.h",
- "xfa/fwl/core/ifwl_panel.h",
- "xfa/fwl/core/ifwl_proxy.h",
- "xfa/fwl/core/ifwl_target.h",
"xfa/fwl/core/ifwl_themeprovider.h",
- "xfa/fwl/core/ifwl_thread.h",
"xfa/fwl/core/ifwl_timer.h",
"xfa/fwl/core/ifwl_tooltiptarget.h",
"xfa/fwl/core/ifwl_widget.h",
"xfa/fwl/core/ifwl_widgetdelegate.h",
"xfa/fwl/core/ifwl_widgetmgr.h",
- "xfa/fwl/core/ifwl_widgetmgrdelegate.h",
+ "xfa/fwl/core/include/fwl_widgethit.h",
"xfa/fwl/core/include/ifwl_adaptertimermgr.h",
- "xfa/fwl/lightwidget/cfwl_app.cpp",
- "xfa/fwl/lightwidget/cfwl_app.h",
"xfa/fwl/lightwidget/cfwl_barcode.cpp",
"xfa/fwl/lightwidget/cfwl_barcode.h",
- "xfa/fwl/lightwidget/cfwl_caret.cpp",
- "xfa/fwl/lightwidget/cfwl_caret.h",
"xfa/fwl/lightwidget/cfwl_checkbox.cpp",
"xfa/fwl/lightwidget/cfwl_checkbox.h",
"xfa/fwl/lightwidget/cfwl_combobox.cpp",
@@ -1466,11 +1424,76 @@ if (pdf_enable_xfa) {
"xfa/fxfa/fm2js/xfa_program.h",
"xfa/fxfa/fm2js/xfa_simpleexpression.cpp",
"xfa/fxfa/fm2js/xfa_simpleexpression.h",
+ "xfa/fxfa/include/fxfa.h",
+ "xfa/fxfa/include/fxfa_basic.h",
+ "xfa/fxfa/include/fxfa_widget.h",
+ "xfa/fxfa/include/xfa_checksum.h",
+ "xfa/fxfa/include/xfa_ffapp.h",
+ "xfa/fxfa/include/xfa_ffdoc.h",
+ "xfa/fxfa/include/xfa_ffdochandler.h",
+ "xfa/fxfa/include/xfa_ffdocview.h",
+ "xfa/fxfa/include/xfa_ffpageview.h",
+ "xfa/fxfa/include/xfa_ffwidget.h",
+ "xfa/fxfa/include/xfa_ffwidgethandler.h",
+ "xfa/fxfa/include/xfa_fontmgr.h",
+ "xfa/fxfa/include/xfa_rendercontext.h",
+ "xfa/fxfa/parser/cxfa_arc.h",
+ "xfa/fxfa/parser/cxfa_assist.cpp",
+ "xfa/fxfa/parser/cxfa_assist.h",
+ "xfa/fxfa/parser/cxfa_bind.cpp",
+ "xfa/fxfa/parser/cxfa_bind.h",
+ "xfa/fxfa/parser/cxfa_binditems.cpp",
+ "xfa/fxfa/parser/cxfa_binditems.h",
+ "xfa/fxfa/parser/cxfa_border.h",
+ "xfa/fxfa/parser/cxfa_box.cpp",
+ "xfa/fxfa/parser/cxfa_box.h",
+ "xfa/fxfa/parser/cxfa_calculate.cpp",
+ "xfa/fxfa/parser/cxfa_calculate.h",
+ "xfa/fxfa/parser/cxfa_caption.cpp",
+ "xfa/fxfa/parser/cxfa_caption.h",
+ "xfa/fxfa/parser/cxfa_corner.h",
+ "xfa/fxfa/parser/cxfa_data.cpp",
+ "xfa/fxfa/parser/cxfa_data.h",
+ "xfa/fxfa/parser/cxfa_edge.h",
+ "xfa/fxfa/parser/cxfa_event.cpp",
+ "xfa/fxfa/parser/cxfa_event.h",
+ "xfa/fxfa/parser/cxfa_exdata.cpp",
+ "xfa/fxfa/parser/cxfa_exdata.h",
+ "xfa/fxfa/parser/cxfa_fill.cpp",
+ "xfa/fxfa/parser/cxfa_fill.h",
+ "xfa/fxfa/parser/cxfa_font.cpp",
+ "xfa/fxfa/parser/cxfa_font.h",
+ "xfa/fxfa/parser/cxfa_image.cpp",
+ "xfa/fxfa/parser/cxfa_image.h",
+ "xfa/fxfa/parser/cxfa_line.cpp",
+ "xfa/fxfa/parser/cxfa_line.h",
+ "xfa/fxfa/parser/cxfa_margin.cpp",
+ "xfa/fxfa/parser/cxfa_margin.h",
+ "xfa/fxfa/parser/cxfa_occur.cpp",
+ "xfa/fxfa/parser/cxfa_occur.h",
+ "xfa/fxfa/parser/cxfa_para.cpp",
+ "xfa/fxfa/parser/cxfa_para.h",
+ "xfa/fxfa/parser/cxfa_rectangle.h",
+ "xfa/fxfa/parser/cxfa_script.cpp",
+ "xfa/fxfa/parser/cxfa_script.h",
+ "xfa/fxfa/parser/cxfa_stroke.cpp",
+ "xfa/fxfa/parser/cxfa_stroke.h",
+ "xfa/fxfa/parser/cxfa_submit.cpp",
+ "xfa/fxfa/parser/cxfa_submit.h",
+ "xfa/fxfa/parser/cxfa_text.cpp",
+ "xfa/fxfa/parser/cxfa_text.h",
+ "xfa/fxfa/parser/cxfa_tooltip.cpp",
+ "xfa/fxfa/parser/cxfa_tooltip.h",
+ "xfa/fxfa/parser/cxfa_validate.cpp",
+ "xfa/fxfa/parser/cxfa_validate.h",
+ "xfa/fxfa/parser/cxfa_value.cpp",
+ "xfa/fxfa/parser/cxfa_value.h",
+ "xfa/fxfa/parser/cxfa_widgetdata.cpp",
+ "xfa/fxfa/parser/cxfa_widgetdata.h",
"xfa/fxfa/parser/xfa_basic_data.cpp",
"xfa/fxfa/parser/xfa_basic_data.h",
"xfa/fxfa/parser/xfa_basic_imp.cpp",
"xfa/fxfa/parser/xfa_basic_imp.h",
- "xfa/fxfa/parser/xfa_docdata.h",
"xfa/fxfa/parser/xfa_doclayout.h",
"xfa/fxfa/parser/xfa_document.h",
"xfa/fxfa/parser/xfa_document_datadescription_imp.cpp",
@@ -1496,7 +1519,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/xfa_localevalue.h",
"xfa/fxfa/parser/xfa_object.h",
"xfa/fxfa/parser/xfa_object_imp.cpp",
- "xfa/fxfa/parser/xfa_objectacc_imp.cpp",
"xfa/fxfa/parser/xfa_parser.h",
"xfa/fxfa/parser/xfa_parser_imp.cpp",
"xfa/fxfa/parser/xfa_parser_imp.h",
@@ -1536,20 +1558,6 @@ if (pdf_enable_xfa) {
"xfa/fxgraphics/cfx_shading.h",
"xfa/fxgraphics/include/cfx_graphics.h",
"xfa/fxjse/include/fxjse.h",
- "xfa/include/fxfa/fxfa.h",
- "xfa/include/fxfa/fxfa_basic.h",
- "xfa/include/fxfa/fxfa_objectacc.h",
- "xfa/include/fxfa/fxfa_widget.h",
- "xfa/include/fxfa/xfa_checksum.h",
- "xfa/include/fxfa/xfa_ffapp.h",
- "xfa/include/fxfa/xfa_ffdoc.h",
- "xfa/include/fxfa/xfa_ffdochandler.h",
- "xfa/include/fxfa/xfa_ffdocview.h",
- "xfa/include/fxfa/xfa_ffpageview.h",
- "xfa/include/fxfa/xfa_ffwidget.h",
- "xfa/include/fxfa/xfa_ffwidgethandler.h",
- "xfa/include/fxfa/xfa_fontmgr.h",
- "xfa/include/fxfa/xfa_rendercontext.h",
]
include_dirs = [ "." ]
if (pdf_enable_v8) {
@@ -1592,6 +1600,7 @@ test("pdfium_unittests") {
"core/fpdfapi/fpdf_font/fpdf_font_unittest.cpp",
"core/fpdfapi/fpdf_page/fpdf_page_parser_old_unittest.cpp",
"core/fpdfapi/fpdf_page/fpdf_page_parser_unittest.cpp",
+ "core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp",
"core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp",
"core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp",
"core/fpdfapi/fpdf_parser/cpdf_simple_parser_unittest.cpp",
@@ -1665,7 +1674,7 @@ test("pdfium_embeddertests") {
"//testing/gmock",
"//testing/gtest",
]
- include_dirs = []
+ include_dirs = [ "testing/gmock/include" ]
if (pdf_enable_v8) {
sources += [
"fpdfsdk/javascript/public_methods_embeddertest.cpp",
@@ -1685,3 +1694,12 @@ test("pdfium_embeddertests") {
}
configs += [ ":pdfium_config" ]
}
+
+if (pdf_is_standalone) {
+ source_set("samples") {
+ testonly = true
+ deps = [
+ "//samples",
+ ]
+ }
+}
diff --git a/chromium/third_party/pdfium/DEPS b/chromium/third_party/pdfium/DEPS
index 02561ad080f..32ae5ed5df6 100644
--- a/chromium/third_party/pdfium/DEPS
+++ b/chromium/third_party/pdfium/DEPS
@@ -4,21 +4,23 @@ vars = {
'chromium_git': 'https://chromium.googlesource.com',
'pdfium_git': 'https://pdfium.googlesource.com',
- 'buildtools_revision': 'c2f259809d5ede3275df5ea0842f0431990c4f98',
+ 'build_revision': 'c557a3544d31513394681f40c8c2512cf7ddcb9e',
+ 'buildtools_revision': '309289315767f615256eada4653b4917cf148c8e',
+ 'clang_revision': 'b6f620b311665e2d96d0921833f54295b9bbf925',
'cygwin_revision': 'c89e446b273697fadf3a10ff1007a97c0b7de6df',
+ 'gen_library_loader_revision': '916d4acd8b2cde67a390737dfba90b3c37de23a1',
'gmock_revision': '29763965ab52f24565299976b936d1265cb6a271',
'gtest_revision': '8245545b6dc9c4703e6496d1efd19e975ad2b038',
- 'icu_revision': '8d342a405be5ae8aacb1e16f0bc31c3a4fbf26a2',
- 'pdfium_tests_revision': 'eb87214cb2088536e96aae517f3a281818fbf5b0',
- 'skia_revision': '0a291c7b7eea1807bd58bdaa60c258fd0ebeb257',
+ 'icu_revision': 'c291cde264469b20ca969ce8832088acb21e0c48',
+ 'pdfium_tests_revision': '6c769320872e6ca82da4adaec1a497237f71b543',
+ 'skia_revision': '6f47dbaff54a7705ef3e98f1f65c765e56fd9bd0',
'trace_event_revision': 'd83d44b13d07c2fd0a40101a7deef9b93b841732',
- 'v8_revision': '3c3d7e7be80f45eeea0dc74a71d7552e2afc2985',
-
+ 'v8_revision': '5cd0d8f27e3f740179a8a3de7b9d2c0cfae7afb9',
}
deps = {
- "build/gyp":
- Var('chromium_git') + "/external/gyp",
+ "build":
+ Var('chromium_git') + "/chromium/src/build.git@" + Var('build_revision'),
"buildtools":
Var('chromium_git') + "/chromium/buildtools.git@" + Var('buildtools_revision'),
@@ -32,20 +34,27 @@ deps = {
"testing/gtest":
Var('chromium_git') + "/external/googletest.git@" + Var('gtest_revision'),
+ "third_party/icu":
+ Var('chromium_git') + "/chromium/deps/icu.git@" + Var('icu_revision'),
+
"third_party/skia":
Var('chromium_git') + '/skia.git' + '@' + Var('skia_revision'),
"tools/clang":
- Var('chromium_git') + "/chromium/src/tools/clang",
+ Var('chromium_git') + "/chromium/src/tools/clang@" + Var('clang_revision'),
+
+ "tools/generate_library_loader":
+ Var('chromium_git') + "/chromium/src/tools/generate_library_loader@" +
+ Var('gen_library_loader_revision'),
+
+ "tools/gyp":
+ Var('chromium_git') + "/external/gyp",
"v8":
Var('chromium_git') + "/v8/v8.git@" + Var('v8_revision'),
"v8/base/trace_event/common":
Var('chromium_git') + "/chromium/src/base/trace_event/common.git@" + Var('trace_event_revision'),
-
- "v8/third_party/icu":
- Var('chromium_git') + "/chromium/deps/icu.git@" + Var('icu_revision'),
}
deps_os = {
@@ -62,17 +71,17 @@ include_rules = [
'+third_party/base',
]
+specific_include_rules = {
+ # Allow embedder tests to use public APIs.
+ "(.*embeddertest\.cpp)": [
+ "+public",
+ ]
+}
+
hooks = [
- {
- # A change to a .gyp, .gypi, or to GYP itself should run the generator.
- 'name': 'gyp',
- 'pattern': '.',
- 'action': ['python', 'pdfium/build/gyp_pdfium'],
- },
# Pull GN binaries. This needs to be before running GYP below.
{
'name': 'gn_win',
- 'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=win32',
@@ -103,6 +112,24 @@ hooks = [
'-s', 'pdfium/buildtools/linux64/gn.sha1',
],
},
+ {
+ # Downloads the current stable linux sysroot to build/linux/ if needed.
+ # This sysroot updates at about the same rate that the chrome build deps
+ # change. This script is a no-op except for linux users who are doing
+ # official chrome builds or cross compiling.
+ 'name': 'sysroot',
+ 'pattern': '.',
+ 'action': ['python',
+ 'pdfium/build/linux/sysroot_scripts/install-sysroot.py',
+ '--running-as-hook'
+ ],
+ },
+ {
+ # A change to a .gyp, .gypi, or to GYP itself should run the generator.
+ 'name': 'gyp',
+ 'pattern': '.',
+ 'action': ['python', 'pdfium/build_gyp/gyp_pdfium'],
+ },
# Pull clang-format binaries using checked-in hashes.
{
'name': 'clang_format_win',
@@ -141,6 +168,15 @@ hooks = [
# Pull clang if needed or requested via GYP_DEFINES.
'name': 'clang',
'pattern': '.',
- 'action': ['python', 'pdfium/tools/clang/scripts/update.py', '--if-needed'],
+ 'action': ['python',
+ 'pdfium/tools/clang/scripts/update.py',
+ '--if-needed'
+ ],
+ },
+ {
+ # Update the Windows toolchain if necessary.
+ 'name': 'win_toolchain',
+ 'pattern': '.',
+ 'action': ['python', 'pdfium/build/vs_toolchain.py', 'update'],
},
]
diff --git a/chromium/third_party/pdfium/README.md b/chromium/third_party/pdfium/README.md
index 24fc1f3d7b3..dbbed5be62d 100644
--- a/chromium/third_party/pdfium/README.md
+++ b/chromium/third_party/pdfium/README.md
@@ -2,17 +2,54 @@
## News
-As of 2016-02-04, the XFA branch is deprecated. Instead, see the section on
-configuration below.
+As of 2016-05-04, GN is used to generate build files replacing GYP. GYP
+support will remain until it is disabled in Chromium and then will be removed
+from PDFium.
+
+As of 2016-04-28, the Visual Studio toolchain from depot_tools is used as the
+default Windows toolchain for Googlers. Please set DEPOT_TOOLS_WIN_TOOLCHAIN=0
+if you need to use the system toolchain. See
+[Windows development subsection](#WinDev) for details.
+
## Prerequisites
Get the chromium depot tools via the instructions at
http://www.chromium.org/developers/how-tos/install-depot-tools (this provides
-the gclient utilty needed below).
+the gclient utility needed below).
Also install Python, Subversion, and Git and make sure they're in your path.
+
+###<a name="WinDev"></a> Windows development
+
+PDFium uses a similar Windows toolchain as Chromium:
+
+#### Open source contributors
+Visual Studio 2015 Update 2 or later is highly recommended.
+
+Run `set DEPOT_TOOLS_WIN_TOOLCHAIN=0`, or set that variable in your global
+environment.
+
+Compilation is done through ninja, **not** Visual Studio.
+
+
+#### Google employees
+
+Run: `download_from_google_storage --config` and follow the
+authentication instructions. **Note that you must authenticate with your
+@google.com credentials**. Enter "0" if asked for a project-id.
+
+Once you've done this, the toolchain will be installed automatically for
+you in [the step](#GenBuild) below.
+
+The toolchain will be in `depot_tools\win_toolchain\vs_files\<hash>`, and windbg
+can be found in `depot_tools\win_toolchain\vs_files\<hash>\win_sdk\Debuggers`.
+
+If you want the IDE for debugging and editing, you will need to install
+it separately, but this is optional and not needed for building PDFium.
+
+
## Get the code
The name of the top-level directory does not matter. In our examples, we use
@@ -27,66 +64,59 @@ gclient sync
cd pdfium
```
-## Generate the build files
+##<a name="GenBuild"></a> Generate the build files
-We use the GYP library to generate the build files.
+We use GN to generate the build files and
+[Ninja](http://martine.github.io/ninja/) (also included with the depot\_tools
+checkout) to execute the build files.
-At this point, you have two options. The first option is to use the [Ninja]
-(http://martine.github.io/ninja/) build system (also included with the
-depot\_tools checkout). This is the default as of mid-September, 2015.
-Previously, the second option (platform-specific build files) was the default.
-Most PDFium developers use Ninja, as does our [continuous build system]
-(http://build.chromium.org/p/client.pdfium/).
-
- * On Windows: `build\gyp_pdfium`
- * For all other platforms: `build/gyp_pdfium`
+```
+gn gen <directory>
+```
-The second option is to generate platform-specific build files, i.e. Makefiles
-on Linux, sln files on Windows, and xcodeproj files on Mac. To do so, set the
-GYP\_GENERATORS environment variable appropriately (e.g. "make", "msvs", or
-"xcode") before running the above command.
+If you want to set <directory> to `out/Debug` or `out/Release` you'll need to
+export `GYP_PDFIUM_NO_ACTION=1` to stop `gclient sync` from executing GYP
+and overwriting your build files.
-### Selecting build configuration
+###<a name="BuildConfig"></a> Selecting build configuration
PDFium may be built either with or without JavaScript support, and with
or without XFA forms support. Both of these features are enabled by
default. Also note that the XFA feature requires JavaScript.
-To build without XFA, set `pdf_enable_xfa=0` before running `gyp_pdfium`.
-To build without JavaScript, set `pdf_enable_v8=0 pdf_enable_xfa=0` before
-running `gyp_pdfium`. For example
-```
-GYP_DEFINES='pdf_enable_v8=0 pdf_enable_xfa=0' build/gyp_pdfium
+Configuration is done by executing `gn args <directory>` to configure the build.
+This will launch an editor in which you can set the following arguments.
+
```
-gives the smallest possible build configuration.
+use_goma = true # Googlers only.
+is_debug = true # Enable debugging features.
-### Using goma (Googlers only)
+pdf_use_skia = false # Set true to enable experimental skia backend.
-If you would like to build using goma, pass `use_goma=1` to `gyp_pdfium`. If
-you installed goma in a non-standard location, you will also need to set
-`gomadir`. e.g.
+pdf_enable_xfa = true # Set false to remove XFA support (implies JS support).
+pdf_enable_v8 = true # Set false to remove Javascript support.
+pdf_is_standalone = true # Set for a non-embedded build.
-```
-build/gyp_pdfium -D use_goma=1 -D gomadir=path/to/goma
+clang_use_chrome_plugins = false # Currently must be false.
```
-## Building the code
+Note, you must set `pdf_is_standalone = true` if you want the sample
+applications like `pdfium_test` to build.
+
+When complete the arguments will be stored in `<directory>/args.gn`.
-If you used Ninja, you can build the sample program by: `ninja -C out/Debug
-pdfium_test` You can build the entire product (which includes a few unit
-tests) by: `ninja -C out/Debug`.
+## Building the code
-If you're not using Ninja, then building is platform-specific.
+If you used Ninja, you can build the sample program by:
+`ninja -C <directory>/pdfium_test` You can build the entire product (which
+includes a few unit tests) by: `ninja -C <directory>`.
- * On Linux: `make pdfium_test`
- * On Mac: `open build/all.xcodeproj`
- * On Windows: open build\all.sln
## Running the sample program
The pdfium\_test program supports reading, parsing, and rasterizing the pages of
a .pdf file to .ppm or .png output image files (windows supports two other
-formats). For example: `out/Debug/pdfium_test --ppm path/to/myfile.pdf`. Note
+formats). For example: `<directory>/pdfium_test --ppm path/to/myfile.pdf`. Note
that this will write output images to `path/to/myfile.pdf.<n>.ppm`.
## Testing
@@ -121,7 +151,7 @@ Note, the Reviews and Bugs lists are typically read-only.
## Bugs
- We will be using this
+ We use this
[bug tracker](https://code.google.com/p/pdfium/issues/list), but for security
bugs, please use [Chromium's security bug template]
(https://code.google.com/p/chromium/issues/entry?template=Security%20Bug)
@@ -135,9 +165,3 @@ as much as possible. The main exceptions is:
1. Code has to conform to the existing style and not Chromium/Google style.
-## Branches
-
-Prior to 2016-02-04, there existed an actively developed origin/xfa branch.
-The origin/xfa branch is now an evolutionary dead-end. Everything you need
-to build either with or without the XFA feature is on origin/master.
-
diff --git a/chromium/third_party/pdfium/build/mac_find_sdk.py b/chromium/third_party/pdfium/build/mac_find_sdk.py
deleted file mode 100644
index 230c2fd52ee..00000000000
--- a/chromium/third_party/pdfium/build/mac_find_sdk.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2016 PDFium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Prints the lowest locally available SDK version greater than or equal to a
-given minimum sdk version to standard output.
-
-Usage:
- python mac_find_sdk.py 10.6 # Ignores SDKs < 10.6
-"""
-
-import os
-import re
-import subprocess
-import sys
-
-
-from optparse import OptionParser
-
-
-def parse_version(version_str):
- """'10.6' => [10, 6]"""
- return map(int, re.findall(r'(\d+)', version_str))
-
-
-def main():
- parser = OptionParser()
- parser.add_option("--verify",
- action="store_true", dest="verify", default=False,
- help="return the sdk argument and warn if it doesn't exist")
- parser.add_option("--sdk_path",
- action="store", type="string", dest="sdk_path", default="",
- help="user-specified SDK path; bypasses verification")
- parser.add_option("--print_sdk_path",
- action="store_true", dest="print_sdk_path", default=False,
- help="Additionaly print the path the SDK (appears first).")
- options, args = parser.parse_args()
- if len(args) != 1:
- parser.error('Please specify a minimum SDK version')
- min_sdk_version = args[0]
-
- job = subprocess.Popen(['xcode-select', '-print-path'],
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
- out, err = job.communicate()
- if job.returncode != 0:
- print >> sys.stderr, out
- print >> sys.stderr, err
- raise Exception(('Error %d running xcode-select, you might have to run '
- '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
- 'if you are using Xcode 4.') % job.returncode)
- # The Developer folder moved in Xcode 4.3.
- xcode43_sdk_path = os.path.join(
- out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs')
- if os.path.isdir(xcode43_sdk_path):
- sdk_dir = xcode43_sdk_path
- else:
- sdk_dir = os.path.join(out.rstrip(), 'SDKs')
- sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)]
- sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6']
- sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6']
- if parse_version(s) >= parse_version(min_sdk_version)]
- if not sdks:
- raise Exception('No %s+ SDK found' % min_sdk_version)
- best_sdk = sorted(sdks, key=parse_version)[0]
-
- if options.verify and best_sdk != min_sdk_version and not options.sdk_path:
- print >> sys.stderr, ''
- print >> sys.stderr, ' vvvvvvv'
- print >> sys.stderr, ''
- print >> sys.stderr, \
- 'This build requires the %s SDK, but it was not found on your system.' \
- % min_sdk_version
- print >> sys.stderr, \
- 'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.'
- print >> sys.stderr, ''
- print >> sys.stderr, ' ^^^^^^^'
- print >> sys.stderr, ''
- return min_sdk_version
-
- if options.print_sdk_path:
- print subprocess.check_output(['xcodebuild', '-version', '-sdk',
- 'macosx' + best_sdk, 'Path']).strip()
-
- return best_sdk
-
-
-if __name__ == '__main__':
- if sys.platform != 'darwin':
- raise Exception("This script only runs on Mac")
- print main()
- sys.exit(0)
diff --git a/chromium/third_party/pdfium/build/all.gyp b/chromium/third_party/pdfium/build_gyp/all.gyp
index 47097e39b44..47097e39b44 100644
--- a/chromium/third_party/pdfium/build/all.gyp
+++ b/chromium/third_party/pdfium/build_gyp/all.gyp
diff --git a/chromium/third_party/pdfium/build/gyp_pdfium b/chromium/third_party/pdfium/build_gyp/gyp_pdfium
index fca2ca39b69..6a2540391c6 100755
--- a/chromium/third_party/pdfium/build/gyp_pdfium
+++ b/chromium/third_party/pdfium/build_gyp/gyp_pdfium
@@ -13,26 +13,42 @@ import sys
script_dir = os.path.dirname(os.path.realpath(__file__))
pdfium_root = os.path.abspath(os.path.join(script_dir, os.pardir))
+output_rel_dir = 'out'
-sys.path.insert(0, os.path.join(pdfium_root, 'build', 'gyp', 'pylib'))
+sys.path.insert(0, os.path.join(pdfium_root, 'tools', 'gyp', 'pylib'))
import gyp
+# vs_toolchain needs to be after gyp path setting since it also uses gyp.
+sys.path.insert(0, os.path.join(pdfium_root, 'build'))
+import vs_toolchain
def run_gyp(args):
rc = gyp.main(args)
+
+ # Copy Windows toolchain DLLs.
+ vs_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
+ if vs_runtime_dll_dirs:
+ x64_runtime, x86_runtime = vs_runtime_dll_dirs
+ vs_toolchain.CopyVsRuntimeDlls(
+ os.path.join(pdfium_root, output_rel_dir), (x86_runtime, x64_runtime))
+
if rc != 0:
print 'Error running GYP'
sys.exit(rc)
def main():
+ if int(os.environ.get('GYP_PDFIUM_NO_ACTION', 0)):
+ print 'Skipping gyp_pdfium due to GYP_PDFIUM_NO_ACTION env var.'
+ sys.exit(0)
+
args = sys.argv[1:]
- args.append(os.path.join(script_dir, 'all.gyp'))
+ args.append(os.path.join(pdfium_root, 'build_gyp', 'all.gyp'))
args.append('-I')
- args.append(os.path.join(pdfium_root, 'build', 'standalone.gypi'))
+ args.append(os.path.join(pdfium_root, 'build_gyp', 'standalone.gypi'))
- args.extend(['-D', 'gyp_output_dir=out'])
+ args.extend(['-D', 'gyp_output_dir=' + output_rel_dir])
# Set the GYP DEPTH variable to the root of the PDFium project.
args.append('--depth=' + os.path.relpath(pdfium_root))
@@ -42,6 +58,9 @@ def main():
print 'GYP_GENERATORS is not set, defaulting to ninja'
os.environ['GYP_GENERATORS'] = 'ninja'
+ # Set up the environment variables.
+ vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
+
print 'Updating projects from gyp files...'
sys.stdout.flush()
diff --git a/chromium/third_party/pdfium/build/gyp_pdfium.py b/chromium/third_party/pdfium/build_gyp/gyp_pdfium.py
index 6831702b54d..6831702b54d 100644
--- a/chromium/third_party/pdfium/build/gyp_pdfium.py
+++ b/chromium/third_party/pdfium/build_gyp/gyp_pdfium.py
diff --git a/chromium/third_party/pdfium/build/set_clang_warning_flags.gypi b/chromium/third_party/pdfium/build_gyp/set_clang_warning_flags.gypi
index f6d7aea700d..f6d7aea700d 100644
--- a/chromium/third_party/pdfium/build/set_clang_warning_flags.gypi
+++ b/chromium/third_party/pdfium/build_gyp/set_clang_warning_flags.gypi
diff --git a/chromium/third_party/pdfium/build/standalone.gypi b/chromium/third_party/pdfium/build_gyp/standalone.gypi
index 925326b7945..f191c28e426 100644
--- a/chromium/third_party/pdfium/build/standalone.gypi
+++ b/chromium/third_party/pdfium/build_gyp/standalone.gypi
@@ -7,6 +7,7 @@
{
'variables': {
'component%': 'static_library',
+ 'chromium_code%': 0,
'clang%': 0,
'asan%': 0,
'sanitizer_coverage%': 0,
@@ -49,7 +50,7 @@
'werror%': '-Werror',
'v8_optimized_debug%': 0,
'v8_use_external_startup_data%': 0,
- 'icu_gyp_path': '../v8/third_party/icu/icu.gyp',
+ 'icu_gyp_path': '../third_party/icu/icu.gyp',
'libjpeg_gyp_path': '../third_party/third_party.gyp',
'conditions': [
['OS == "win"', {
@@ -66,7 +67,7 @@
}],
# Set default gomadir.
['OS=="win"', {
- 'gomadir%': 'c:\\goma\\goma-win',
+ 'gomadir%': 'c:\\goma\\goma-win64',
}, {
'gomadir%': '<!(/bin/echo -n ${HOME}/goma)',
}],
@@ -172,11 +173,9 @@
'cflags': [
'-Wall',
'-Werror',
- '-W',
+ '-Wextra',
+ # Two common warning flags for Clang and GCC.
'-Wno-missing-field-initializers',
- # Code might someday be made clean for -Wsign-compare, but for now
- # this produces too much noise to be useful.
- '-Wno-sign-compare',
'-Wno-unused-parameter',
'-pthread',
'-fno-exceptions',
@@ -300,6 +299,7 @@
'EnableFunctionLevelLinking': 'true',
'RuntimeTypeInfo': 'false',
'WarningLevel': '3',
+ 'WarnAsError': 'true',
'DebugInformationFormat': '3',
'Detect64BitPortabilityProblems': 'false',
'conditions': [
@@ -311,13 +311,6 @@
}, {
'ExceptionHandling': '0',
}],
- ['target_arch=="x64"', {
- # 64-bit warnings need to be resolved.
- # https://code.google.com/p/pdfium/issues/detail?id=101
- 'WarnAsError': 'false',
- }, {
- 'WarnAsError': 'true',
- }],
['clang==1', {
'AdditionalOptions': [
# Don't warn about unused function parameters.
@@ -339,18 +332,14 @@
],
}],
['OS=="win" and clang==1 and MSVS_VERSION == "2013"', {
- 'VCCLCompilerTool': {
- 'AdditionalOptions': [
- '-fmsc-version=1800',
- ],
- },
+ 'AdditionalOptions': [
+ '-fmsc-version=1800',
+ ],
}],
['OS=="win" and clang==1 and MSVS_VERSION == "2015"', {
- 'VCCLCompilerTool': {
- 'AdditionalOptions': [
- '-fmsc-version=1900',
- ],
- },
+ 'AdditionalOptions': [
+ '-fmsc-version=1900',
+ ],
}],
],
},
@@ -370,6 +359,7 @@
'xcode_settings': {
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',
+ 'CLANG_CXX_LIBRARY': 'libc++', # -stdlib=libc++
'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
# (Equivalent to -fPIC)
@@ -381,6 +371,7 @@
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror
'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
+ 'MACOSX_DEPLOYMENT_TARGET': '10.7', # -mmacosx-version-min
'SYMROOT': '<(DEPTH)/xcodebuild',
'USE_HEADERMAP': 'NO',
'OTHER_CFLAGS': [
@@ -388,13 +379,17 @@
],
'WARNING_CFLAGS': [
'-Wall',
- '-Wendif-labels',
- '-W',
+ '-Werror',
+ '-Wextra',
'-Wno-unused-parameter',
],
},
'variables': {
- 'clang_warning_flags': [],
+ 'chromium_code%': '<(chromium_code)',
+ 'clang_warning_flags': [
+ # TODO(thakis): https://crbug.com/604888
+ '-Wno-undefined-var-template',
+ ],
},
'includes': [ 'set_clang_warning_flags.gypi', ],
'conditions': [
@@ -454,7 +449,7 @@
], # target_conditions
'variables': {
'mac_sdk_min': '10.10',
- 'mac_sdk%': '<!(python <(DEPTH)/build/mac_find_sdk.py <(mac_sdk_min))',
+ 'mac_sdk%': '<!(python <(DEPTH)/build/mac/find_sdk.py <(mac_sdk_min))',
},
'xcode_settings': {
'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
@@ -476,6 +471,43 @@
'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
}],
],
+ 'target_conditions': [
+ ['chromium_code==0', {
+ 'variables': {
+ 'clang_warning_flags': [
+ # Suppress unused variable warnings from third-party libraries.
+ '-Wno-unused-variable',
+ ],
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'WarningLevel': '3',
+ },
+ },
+ 'conditions': [
+ ['OS!="win"', {
+ # Remove -Wextra for third-party code.
+ 'cflags!': [ '-Wextra' ],
+ }],
+ ['OS!="win" and clang==0', {
+ 'cflags!': [
+ '-Wall',
+ ],
+ }],
+ ['OS=="mac"', {
+ 'xcode_settings': {
+ 'WARNING_CFLAGS!': ['-Wextra'],
+ },
+ }],
+ ],
+ }, { # chromium_code==1
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'WarningLevel': '4',
+ },
+ },
+ }],
+ ], # target_conditions for 'target_defaults'
},
'conditions': [
['OS=="linux" or OS=="mac"', {
diff --git a/chromium/third_party/pdfium/build_overrides/README.md b/chromium/third_party/pdfium/build_overrides/README.md
new file mode 100644
index 00000000000..cc0efbf4075
--- /dev/null
+++ b/chromium/third_party/pdfium/build_overrides/README.md
@@ -0,0 +1,28 @@
+# Build overrides in GN
+
+This directory is used to allow different products to customize settings
+for repos which are DEPS'ed in or shared.
+
+For example: V8 can be built on its own (in a "standalone" configuration),
+and it can be built as part of Chromium. V8 defines a top-level
+target, //v8:d8 (a simple executable), which will only be built in the
+standalone configuration. To indiate itis a standalone configuration, v8 can
+create a file, build_overrides/v8.gni, containing a variable,
+`build_standalone_d8 = true` and import it (as
+import("//build_overrides/v8.gni") from its top-level BUILD.gn file.
+
+Chromium, on the other hand, does not need to build d8, and so it would
+create its own build_overrides/v8.gni file, and in it set
+`build_standalone_d8 = false`.
+
+The two files should define the same set of variables, but the values may
+vary as appropriate to suit the the needs of the two different builds.
+
+The build.gni file provides a way for projects to override defaults for
+variables used in //build itself (which we want to be shareable between
+projects).
+
+TODO(crbug.com/588513): Ideally //build_overrides and, in particular,
+//build_overrides/build.gni will go away completely in favor of some
+mechanism that can re-use other required files like //.gn, so that we don't
+have to keep requiring projects to create a bunch of different files to use GN.
diff --git a/chromium/third_party/pdfium/build_overrides/build.gni b/chromium/third_party/pdfium/build_overrides/build.gni
new file mode 100644
index 00000000000..9d68f109332
--- /dev/null
+++ b/chromium/third_party/pdfium/build_overrides/build.gni
@@ -0,0 +1,8 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# See https://bugs.chromium.org/p/webrtc/issues/detail?id=5453.
+# These overrides are needed and should generally track Chromium settings.
+mac_deployment_target_build_override = "10.7"
+mac_sdk_min_build_override = "10.10"
diff --git a/chromium/third_party/pdfium/build_overrides/gtest.gni b/chromium/third_party/pdfium/build_overrides/gtest.gni
new file mode 100644
index 00000000000..bf30fb1d722
--- /dev/null
+++ b/chromium/third_party/pdfium/build_overrides/gtest.gni
@@ -0,0 +1,15 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Exclude support for registering main function in multi-process tests.
+gtest_include_multiprocess = false
+
+# Exclude support for platform-specific operations across unit tests.
+gtest_include_platform_test = false
+
+# Exclude support for testing Objective C code on OS X and iOS.
+gtest_include_objc_support = false
+
+# Exclude support for flushing coverage files on iOS.
+gtest_include_ios_coverage = false
diff --git a/chromium/third_party/pdfium/build_overrides/pdfium.gni b/chromium/third_party/pdfium/build_overrides/pdfium.gni
new file mode 100644
index 00000000000..246671bb62f
--- /dev/null
+++ b/chromium/third_party/pdfium/build_overrides/pdfium.gni
@@ -0,0 +1,14 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file contains PDFium-related build overrides.
+
+# Build PDFium either with or without v8 support.
+pdf_enable_v8_override = true
+
+# Build PDFium either with or without XFA Forms support.
+pdf_enable_xfa_override = false
+
+# Build PDFium against skia (experimental) rather than agg.
+pdf_use_skia_override = false
diff --git a/chromium/third_party/pdfium/build_overrides/v8.gni b/chromium/third_party/pdfium/build_overrides/v8.gni
new file mode 100644
index 00000000000..2b50795fd6b
--- /dev/null
+++ b/chromium/third_party/pdfium/build_overrides/v8.gni
@@ -0,0 +1,17 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if (is_android) {
+ import("//build/config/android/config.gni")
+}
+
+v8_optimized_debug = true
+v8_use_external_startup_data = false
+
+# V8 extras
+# Adding V8 extras files requires API owners review
+# Be sure to synchronize with build/common.gypi
+
+v8_extra_library_files = []
+v8_experimental_extra_library_files = []
diff --git a/chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt.cpp b/chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt.cpp
index f3665060f81..9e10f369ca0 100644
--- a/chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt.cpp
+++ b/chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt.cpp
@@ -62,14 +62,14 @@ struct md5_context {
uint32_t state[4];
uint8_t buffer[64];
};
-#define GET_FX_DWORD(n, b, i) \
+#define GET_UINT32(n, b, i) \
{ \
(n) = (uint32_t)((uint8_t*)b)[(i)] | \
(((uint32_t)((uint8_t*)b)[(i) + 1]) << 8) | \
(((uint32_t)((uint8_t*)b)[(i) + 2]) << 16) | \
(((uint32_t)((uint8_t*)b)[(i) + 3]) << 24); \
}
-#define PUT_FX_DWORD(n, b, i) \
+#define PUT_UINT32(n, b, i) \
{ \
(((uint8_t*)b)[(i)]) = (uint8_t)(((n)) & 0xFF); \
(((uint8_t*)b)[(i) + 1]) = (uint8_t)(((n) >> 8) & 0xFF); \
@@ -78,22 +78,22 @@ struct md5_context {
}
void md5_process(struct md5_context* ctx, const uint8_t data[64]) {
uint32_t A, B, C, D, X[16];
- GET_FX_DWORD(X[0], data, 0);
- GET_FX_DWORD(X[1], data, 4);
- GET_FX_DWORD(X[2], data, 8);
- GET_FX_DWORD(X[3], data, 12);
- GET_FX_DWORD(X[4], data, 16);
- GET_FX_DWORD(X[5], data, 20);
- GET_FX_DWORD(X[6], data, 24);
- GET_FX_DWORD(X[7], data, 28);
- GET_FX_DWORD(X[8], data, 32);
- GET_FX_DWORD(X[9], data, 36);
- GET_FX_DWORD(X[10], data, 40);
- GET_FX_DWORD(X[11], data, 44);
- GET_FX_DWORD(X[12], data, 48);
- GET_FX_DWORD(X[13], data, 52);
- GET_FX_DWORD(X[14], data, 56);
- GET_FX_DWORD(X[15], data, 60);
+ GET_UINT32(X[0], data, 0);
+ GET_UINT32(X[1], data, 4);
+ GET_UINT32(X[2], data, 8);
+ GET_UINT32(X[3], data, 12);
+ GET_UINT32(X[4], data, 16);
+ GET_UINT32(X[5], data, 20);
+ GET_UINT32(X[6], data, 24);
+ GET_UINT32(X[7], data, 28);
+ GET_UINT32(X[8], data, 32);
+ GET_UINT32(X[9], data, 36);
+ GET_UINT32(X[10], data, 40);
+ GET_UINT32(X[11], data, 44);
+ GET_UINT32(X[12], data, 48);
+ GET_UINT32(X[13], data, 52);
+ GET_UINT32(X[14], data, 56);
+ GET_UINT32(X[15], data, 60);
#define S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
#define P(a, b, c, d, k, s, t) \
{ \
@@ -226,16 +226,16 @@ void CRYPT_MD5Finish(void* pctx, uint8_t digest[16]) {
struct md5_context* ctx = (struct md5_context*)pctx;
uint32_t last, padn;
uint8_t msglen[8];
- PUT_FX_DWORD(ctx->total[0], msglen, 0);
- PUT_FX_DWORD(ctx->total[1], msglen, 4);
+ PUT_UINT32(ctx->total[0], msglen, 0);
+ PUT_UINT32(ctx->total[1], msglen, 4);
last = (ctx->total[0] >> 3) & 0x3F;
padn = (last < 56) ? (56 - last) : (120 - last);
CRYPT_MD5Update(ctx, md5_padding, padn);
CRYPT_MD5Update(ctx, msglen, 8);
- PUT_FX_DWORD(ctx->state[0], digest, 0);
- PUT_FX_DWORD(ctx->state[1], digest, 4);
- PUT_FX_DWORD(ctx->state[2], digest, 8);
- PUT_FX_DWORD(ctx->state[3], digest, 12);
+ PUT_UINT32(ctx->state[0], digest, 0);
+ PUT_UINT32(ctx->state[1], digest, 4);
+ PUT_UINT32(ctx->state[2], digest, 8);
+ PUT_UINT32(ctx->state[3], digest, 12);
}
void CRYPT_MD5Generate(const uint8_t* input,
uint32_t length,
diff --git a/chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt_sha.cpp b/chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt_sha.cpp
index 28b3ce37393..222ab9eb809 100644
--- a/chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt_sha.cpp
+++ b/chromium/third_party/pdfium/core/fdrm/crypto/fx_crypt_sha.cpp
@@ -159,12 +159,12 @@ typedef struct {
uint32_t state[8];
uint8_t buffer[64];
} sha256_context;
-#define GET_FX_DWORD(n, b, i) \
+#define GET_UINT32(n, b, i) \
{ \
(n) = ((uint32_t)(b)[(i)] << 24) | ((uint32_t)(b)[(i) + 1] << 16) | \
((uint32_t)(b)[(i) + 2] << 8) | ((uint32_t)(b)[(i) + 3]); \
}
-#define PUT_FX_DWORD(n, b, i) \
+#define PUT_UINT32(n, b, i) \
{ \
(b)[(i)] = (uint8_t)((n) >> 24); \
(b)[(i) + 1] = (uint8_t)((n) >> 16); \
@@ -187,22 +187,22 @@ void CRYPT_SHA256Start(void* context) {
static void sha256_process(sha256_context* ctx, const uint8_t data[64]) {
uint32_t temp1, temp2, W[64];
uint32_t A, B, C, D, E, F, G, H;
- GET_FX_DWORD(W[0], data, 0);
- GET_FX_DWORD(W[1], data, 4);
- GET_FX_DWORD(W[2], data, 8);
- GET_FX_DWORD(W[3], data, 12);
- GET_FX_DWORD(W[4], data, 16);
- GET_FX_DWORD(W[5], data, 20);
- GET_FX_DWORD(W[6], data, 24);
- GET_FX_DWORD(W[7], data, 28);
- GET_FX_DWORD(W[8], data, 32);
- GET_FX_DWORD(W[9], data, 36);
- GET_FX_DWORD(W[10], data, 40);
- GET_FX_DWORD(W[11], data, 44);
- GET_FX_DWORD(W[12], data, 48);
- GET_FX_DWORD(W[13], data, 52);
- GET_FX_DWORD(W[14], data, 56);
- GET_FX_DWORD(W[15], data, 60);
+ GET_UINT32(W[0], data, 0);
+ GET_UINT32(W[1], data, 4);
+ GET_UINT32(W[2], data, 8);
+ GET_UINT32(W[3], data, 12);
+ GET_UINT32(W[4], data, 16);
+ GET_UINT32(W[5], data, 20);
+ GET_UINT32(W[6], data, 24);
+ GET_UINT32(W[7], data, 28);
+ GET_UINT32(W[8], data, 32);
+ GET_UINT32(W[9], data, 36);
+ GET_UINT32(W[10], data, 40);
+ GET_UINT32(W[11], data, 44);
+ GET_UINT32(W[12], data, 48);
+ GET_UINT32(W[13], data, 52);
+ GET_UINT32(W[14], data, 56);
+ GET_UINT32(W[15], data, 60);
#define SHR(x, n) ((x & 0xFFFFFFFF) >> n)
#define ROTR(x, n) (SHR(x, n) | (x << (32 - n)))
#define S0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
@@ -340,20 +340,20 @@ void CRYPT_SHA256Finish(void* context, uint8_t digest[32]) {
uint8_t msglen[8];
high = (ctx->total[0] >> 29) | (ctx->total[1] << 3);
low = (ctx->total[0] << 3);
- PUT_FX_DWORD(high, msglen, 0);
- PUT_FX_DWORD(low, msglen, 4);
+ PUT_UINT32(high, msglen, 0);
+ PUT_UINT32(low, msglen, 4);
last = ctx->total[0] & 0x3F;
padn = (last < 56) ? (56 - last) : (120 - last);
CRYPT_SHA256Update(ctx, sha256_padding, padn);
CRYPT_SHA256Update(ctx, msglen, 8);
- PUT_FX_DWORD(ctx->state[0], digest, 0);
- PUT_FX_DWORD(ctx->state[1], digest, 4);
- PUT_FX_DWORD(ctx->state[2], digest, 8);
- PUT_FX_DWORD(ctx->state[3], digest, 12);
- PUT_FX_DWORD(ctx->state[4], digest, 16);
- PUT_FX_DWORD(ctx->state[5], digest, 20);
- PUT_FX_DWORD(ctx->state[6], digest, 24);
- PUT_FX_DWORD(ctx->state[7], digest, 28);
+ PUT_UINT32(ctx->state[0], digest, 0);
+ PUT_UINT32(ctx->state[1], digest, 4);
+ PUT_UINT32(ctx->state[2], digest, 8);
+ PUT_UINT32(ctx->state[3], digest, 12);
+ PUT_UINT32(ctx->state[4], digest, 16);
+ PUT_UINT32(ctx->state[5], digest, 20);
+ PUT_UINT32(ctx->state[6], digest, 24);
+ PUT_UINT32(ctx->state[7], digest, 28);
}
void CRYPT_SHA256Generate(const uint8_t* data,
uint32_t size,
@@ -369,7 +369,7 @@ typedef struct {
uint8_t buffer[128];
} sha384_context;
uint64_t FX_ato64i(const FX_CHAR* str) {
- FXSYS_assert(str);
+ ASSERT(str);
uint64_t ret = 0;
int len = (int)FXSYS_strlen(str);
len = len > 16 ? 16 : len;
@@ -384,7 +384,7 @@ uint64_t FX_ato64i(const FX_CHAR* str) {
} else if (str[i] >= 'A' && str[i] <= 'F') {
ret |= (str[i] - 'A' + 10) & 0xFF;
} else {
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
}
}
return ret;
@@ -468,7 +468,7 @@ static const FX_CHAR* constants[] = {
((uint64_t)(b)[(i) + 4] << 24) | ((uint64_t)(b)[(i) + 5] << 16) | \
((uint64_t)(b)[(i) + 6] << 8) | ((uint64_t)(b)[(i) + 7]); \
}
-#define PUT_FX_64DWORD(n, b, i) \
+#define PUT_UINT64(n, b, i) \
{ \
(b)[(i)] = (uint8_t)((n) >> 56); \
(b)[(i) + 1] = (uint8_t)((n) >> 48); \
@@ -582,18 +582,18 @@ void CRYPT_SHA384Finish(void* context, uint8_t digest[48]) {
uint64_t high, low;
high = (ctx->total[0] >> 29) | (ctx->total[1] << 3);
low = (ctx->total[0] << 3);
- PUT_FX_64DWORD(high, msglen, 0);
- PUT_FX_64DWORD(low, msglen, 8);
+ PUT_UINT64(high, msglen, 0);
+ PUT_UINT64(low, msglen, 8);
last = (uint32_t)ctx->total[0] & 0x7F;
padn = (last < 112) ? (112 - last) : (240 - last);
CRYPT_SHA384Update(ctx, sha384_padding, padn);
CRYPT_SHA384Update(ctx, msglen, 16);
- PUT_FX_64DWORD(ctx->state[0], digest, 0);
- PUT_FX_64DWORD(ctx->state[1], digest, 8);
- PUT_FX_64DWORD(ctx->state[2], digest, 16);
- PUT_FX_64DWORD(ctx->state[3], digest, 24);
- PUT_FX_64DWORD(ctx->state[4], digest, 32);
- PUT_FX_64DWORD(ctx->state[5], digest, 40);
+ PUT_UINT64(ctx->state[0], digest, 0);
+ PUT_UINT64(ctx->state[1], digest, 8);
+ PUT_UINT64(ctx->state[2], digest, 16);
+ PUT_UINT64(ctx->state[3], digest, 24);
+ PUT_UINT64(ctx->state[4], digest, 32);
+ PUT_UINT64(ctx->state[5], digest, 40);
}
void CRYPT_SHA384Generate(const uint8_t* data,
uint32_t size,
@@ -629,20 +629,20 @@ void CRYPT_SHA512Finish(void* context, uint8_t digest[64]) {
uint64_t high, low;
high = (ctx->total[0] >> 29) | (ctx->total[1] << 3);
low = (ctx->total[0] << 3);
- PUT_FX_64DWORD(high, msglen, 0);
- PUT_FX_64DWORD(low, msglen, 8);
+ PUT_UINT64(high, msglen, 0);
+ PUT_UINT64(low, msglen, 8);
last = (uint32_t)ctx->total[0] & 0x7F;
padn = (last < 112) ? (112 - last) : (240 - last);
CRYPT_SHA512Update(ctx, sha384_padding, padn);
CRYPT_SHA512Update(ctx, msglen, 16);
- PUT_FX_64DWORD(ctx->state[0], digest, 0);
- PUT_FX_64DWORD(ctx->state[1], digest, 8);
- PUT_FX_64DWORD(ctx->state[2], digest, 16);
- PUT_FX_64DWORD(ctx->state[3], digest, 24);
- PUT_FX_64DWORD(ctx->state[4], digest, 32);
- PUT_FX_64DWORD(ctx->state[5], digest, 40);
- PUT_FX_64DWORD(ctx->state[6], digest, 48);
- PUT_FX_64DWORD(ctx->state[7], digest, 56);
+ PUT_UINT64(ctx->state[0], digest, 0);
+ PUT_UINT64(ctx->state[1], digest, 8);
+ PUT_UINT64(ctx->state[2], digest, 16);
+ PUT_UINT64(ctx->state[3], digest, 24);
+ PUT_UINT64(ctx->state[4], digest, 32);
+ PUT_UINT64(ctx->state[5], digest, 40);
+ PUT_UINT64(ctx->state[6], digest, 48);
+ PUT_UINT64(ctx->state[7], digest, 56);
}
void CRYPT_SHA512Generate(const uint8_t* data,
uint32_t size,
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_basic_module.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_basic_module.cpp
index b77d998ed8a..75450bf9754 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_basic_module.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_basic_module.cpp
@@ -6,8 +6,8 @@
#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/fpdfapi/ipdf_rendermodule.h"
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
+#include "core/fxcodec/include/fx_codec.h"
namespace {
@@ -41,24 +41,31 @@ void CPDF_ModuleMgr::SetPrivateData(void* module_id,
PD_CALLBACK_FREEDATA callback) {
m_privateData.SetPrivateData(module_id, pData, callback);
}
+
void* CPDF_ModuleMgr::GetPrivateData(void* module_id) {
return m_privateData.GetPrivateData(module_id);
}
-ICodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() {
- return m_pCodecModule ? m_pCodecModule->GetFaxModule() : NULL;
+
+CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() {
+ return m_pCodecModule ? m_pCodecModule->GetFaxModule() : nullptr;
}
-ICodec_JpegModule* CPDF_ModuleMgr::GetJpegModule() {
- return m_pCodecModule ? m_pCodecModule->GetJpegModule() : NULL;
+
+CCodec_JpegModule* CPDF_ModuleMgr::GetJpegModule() {
+ return m_pCodecModule ? m_pCodecModule->GetJpegModule() : nullptr;
}
-ICodec_JpxModule* CPDF_ModuleMgr::GetJpxModule() {
- return m_pCodecModule ? m_pCodecModule->GetJpxModule() : NULL;
+
+CCodec_JpxModule* CPDF_ModuleMgr::GetJpxModule() {
+ return m_pCodecModule ? m_pCodecModule->GetJpxModule() : nullptr;
}
-ICodec_Jbig2Module* CPDF_ModuleMgr::GetJbig2Module() {
- return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : NULL;
+
+CCodec_Jbig2Module* CPDF_ModuleMgr::GetJbig2Module() {
+ return m_pCodecModule ? m_pCodecModule->GetJbig2Module() : nullptr;
}
-ICodec_IccModule* CPDF_ModuleMgr::GetIccModule() {
- return m_pCodecModule ? m_pCodecModule->GetIccModule() : NULL;
+
+CCodec_IccModule* CPDF_ModuleMgr::GetIccModule() {
+ return m_pCodecModule ? m_pCodecModule->GetIccModule() : nullptr;
}
-ICodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() {
- return m_pCodecModule ? m_pCodecModule->GetFlateModule() : NULL;
+
+CCodec_FlateModule* CPDF_ModuleMgr::GetFlateModule() {
+ return m_pCodecModule ? m_pCodecModule->GetFlateModule() : nullptr;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp
index b6a9132b5d0..119c42b5c14 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/CNS1/cmaps_cns1.cpp
@@ -8,6 +8,7 @@
#include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
#include "core/fpdfapi/fpdf_font/font_int.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_basic.h"
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp
index 702bf06c75d..34a43858b4f 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/GB1/cmaps_gb1.cpp
@@ -8,6 +8,7 @@
#include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
#include "core/fpdfapi/fpdf_font/font_int.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_basic.h"
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp
index 43f7e0ee2b7..62995790819 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Japan1/cmaps_japan1.cpp
@@ -8,6 +8,7 @@
#include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
#include "core/fpdfapi/fpdf_font/font_int.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_basic.h"
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp
index 77f65dfe3cd..ac6346cf7f3 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/Korea1/cmaps_korea1.cpp
@@ -8,6 +8,7 @@
#include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
#include "core/fpdfapi/fpdf_font/font_int.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_basic.h"
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
index 9248efb7181..e0c5b9b7d60 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
@@ -7,6 +7,7 @@
#include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
#include "core/fpdfapi/fpdf_font/font_int.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
void FPDFAPI_FindEmbeddedCMap(const char* name,
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
index af79fd31c1b..08bdb5bb076 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
@@ -58,29 +58,28 @@ void CPDF_PageContentGenerator::GenerateContent() {
}
CFX_ByteString CPDF_PageContentGenerator::RealizeResource(
CPDF_Object* pResourceObj,
- const FX_CHAR* szType) {
+ const CFX_ByteString& bsType) {
if (!m_pPage->m_pResources) {
m_pPage->m_pResources = new CPDF_Dictionary;
int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources);
m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum);
}
- CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(szType);
+ CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDictBy(bsType);
if (!pResList) {
pResList = new CPDF_Dictionary;
- m_pPage->m_pResources->SetAt(szType, pResList);
+ m_pPage->m_pResources->SetAt(bsType, pResList);
}
m_pDocument->AddIndirectObject(pResourceObj);
CFX_ByteString name;
int idnum = 1;
while (1) {
- name.Format("FX%c%d", szType[0], idnum);
- if (!pResList->KeyExist(name.AsByteStringC())) {
+ name.Format("FX%c%d", bsType[0], idnum);
+ if (!pResList->KeyExist(name)) {
break;
}
idnum++;
}
- pResList->AddReference(name.AsByteStringC(), m_pDocument,
- pResourceObj->GetObjNum());
+ pResList->AddReference(name, m_pDocument, pResourceObj->GetObjNum());
return name;
}
void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf,
@@ -129,11 +128,10 @@ void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) {
CFX_ByteTextBuf buf;
if (CPDF_Array* pArray = pContent->AsArray()) {
- int iCount = pArray->GetCount();
+ size_t iCount = pArray->GetCount();
CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount);
- int size = 0;
- int i = 0;
- for (i = 0; i < iCount; ++i) {
+ size_t size = 0;
+ for (size_t i = 0; i < iCount; ++i) {
pContent = pArray->GetObjectAt(i);
CPDF_Stream* pStream = ToStream(pContent);
if (!pStream)
@@ -146,7 +144,7 @@ void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) {
}
int pos = 0;
uint8_t* pBuf = FX_Alloc(uint8_t, size);
- for (i = 0; i < iCount; ++i) {
+ for (size_t i = 0; i < iCount; ++i) {
FXSYS_memcpy(pBuf + pos, pContentArray[i]->GetData(),
pContentArray[i]->GetSize());
pos += pContentArray[i]->GetSize() + 1;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/editint.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/editint.h
index 69a64b9aba4..a7774050ae6 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/editint.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/editint.h
@@ -18,26 +18,26 @@ class CPDF_Object;
class CPDF_ObjectStream {
public:
- CPDF_ObjectStream();
-
- FX_BOOL Start();
+ struct Item {
+ uint32_t objnum;
+ FX_STRSIZE offset;
+ };
- int32_t CompressIndirectObject(uint32_t dwObjNum, const CPDF_Object* pObj);
- int32_t CompressIndirectObject(uint32_t dwObjNum,
- const uint8_t* pBuffer,
- uint32_t dwSize);
+ CPDF_ObjectStream();
+ void Start();
FX_FILESIZE End(CPDF_Creator* pCreator);
+ void CompressIndirectObject(uint32_t dwObjNum, const CPDF_Object* pObj);
+ void CompressIndirectObject(uint32_t dwObjNum,
+ const uint8_t* pBuffer,
+ uint32_t dwSize);
- CFX_ArrayTemplate<uint32_t> m_ObjNumArray;
-
+ std::vector<Item> m_Items;
CFX_ByteTextBuf m_Buffer;
uint32_t m_dwObjNum;
int32_t m_index;
-
- protected:
- CFX_ArrayTemplate<uint32_t> m_OffsetArray;
};
+
class CPDF_XRefStream {
public:
struct Index {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index 323602b0e10..658b9782e5d 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -9,8 +9,8 @@
#include <vector>
#include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h"
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h"
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
@@ -20,7 +20,6 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
#include "core/fxcrt/include/fx_ext.h"
#include "third_party/base/stl_util.h"
@@ -54,7 +53,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
if (pFile->AppendString(" ") < 0) {
return -1;
}
- if ((len = pFile->AppendString(pObj->GetString().AsByteStringC())) < 0) {
+ if ((len = pFile->AppendString(pObj->GetString().AsStringC())) < 0) {
return -1;
}
offset += len + 1;
@@ -62,8 +61,8 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
case CPDF_Object::STRING: {
CFX_ByteString str = pObj->GetString();
FX_BOOL bHex = pObj->AsString()->IsHex();
- if ((len = pFile->AppendString(
- PDF_EncodeString(str, bHex).AsByteStringC())) < 0) {
+ if ((len = pFile->AppendString(PDF_EncodeString(str, bHex).AsStringC())) <
+ 0) {
return -1;
}
offset += len;
@@ -74,8 +73,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
return -1;
}
CFX_ByteString str = pObj->GetString();
- if ((len = pFile->AppendString(PDF_NameEncode(str).AsByteStringC())) <
- 0) {
+ if ((len = pFile->AppendString(PDF_NameEncode(str).AsStringC())) < 0) {
return -1;
}
offset += len + 1;
@@ -97,7 +95,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
}
offset += 1;
const CPDF_Array* p = pObj->AsArray();
- for (uint32_t i = 0; i < p->GetCount(); i++) {
+ for (size_t i = 0; i < p->GetCount(); i++) {
CPDF_Object* pElement = p->GetObjectAt(i);
if (pElement->GetObjNum()) {
if (pFile->AppendString(" ") < 0) {
@@ -134,8 +132,7 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
if (pFile->AppendString("/") < 0) {
return -1;
}
- if ((len = pFile->AppendString(PDF_NameEncode(key).AsByteStringC())) <
- 0) {
+ if ((len = pFile->AppendString(PDF_NameEncode(key).AsStringC())) < 0) {
return -1;
}
offset += len + 1;
@@ -192,12 +189,10 @@ int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument,
CFX_FileBufferArchive* pFile,
- CPDF_Array* pIDArray,
- FX_BOOL bCompress) {
+ CPDF_Array* pIDArray) {
FX_FILESIZE offset = 0;
int32_t len = 0;
- FXSYS_assert(pDocument && pFile);
- CPDF_Parser* pParser = (CPDF_Parser*)pDocument->GetParser();
+ CPDF_Parser* pParser = pDocument->GetParser();
if (pParser) {
CPDF_Dictionary* p = pParser->GetTrailer();
for (const auto& it : *p) {
@@ -208,14 +203,13 @@ int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument,
key == "XRefStm" || key == "Type" || key == "ID") {
continue;
}
- if (bCompress && key == "DecodeParms") {
+ if (key == "DecodeParms")
continue;
- }
+
if (pFile->AppendString(("/")) < 0) {
return -1;
}
- if ((len = pFile->AppendString(PDF_NameEncode(key).AsByteStringC())) <
- 0) {
+ if ((len = pFile->AppendString(PDF_NameEncode(key).AsStringC())) < 0) {
return -1;
}
offset += len + 1;
@@ -287,7 +281,7 @@ int32_t PDF_CreatorWriteEncrypt(const CPDF_Dictionary* pEncryptDict,
if (!pEncryptDict) {
return 0;
}
- FXSYS_assert(pFile);
+ ASSERT(pFile);
FX_FILESIZE offset = 0;
int32_t len = 0;
if (pFile->AppendString("/Encrypt") < 0) {
@@ -391,14 +385,15 @@ int32_t OutputIndex(CFX_FileBufferArchive* pFile, FX_FILESIZE offset) {
class CPDF_FlateEncoder {
public:
- CPDF_FlateEncoder();
+ CPDF_FlateEncoder(CPDF_Stream* pStream, FX_BOOL bFlateEncode);
+ CPDF_FlateEncoder(const uint8_t* pBuffer,
+ uint32_t size,
+ FX_BOOL bFlateEncode,
+ FX_BOOL bXRefStream = FALSE);
~CPDF_FlateEncoder();
- FX_BOOL Initialize(CPDF_Stream* pStream, FX_BOOL bFlateEncode);
- FX_BOOL Initialize(const uint8_t* pBuffer,
- uint32_t size,
- FX_BOOL bFlateEncode,
- FX_BOOL bXRefStream = FALSE);
+
void CloneDict();
+
uint8_t* m_pData;
uint32_t m_dwSize;
CPDF_Dictionary* m_pDict;
@@ -406,13 +401,7 @@ class CPDF_FlateEncoder {
FX_BOOL m_bNewData;
CPDF_StreamAcc m_Acc;
};
-CPDF_FlateEncoder::CPDF_FlateEncoder() {
- m_pData = NULL;
- m_dwSize = 0;
- m_pDict = NULL;
- m_bCloned = FALSE;
- m_bNewData = FALSE;
-}
+
void CPDF_FlateEncoder::CloneDict() {
if (!m_bCloned) {
m_pDict = ToDictionary(m_pDict->Clone());
@@ -420,8 +409,13 @@ void CPDF_FlateEncoder::CloneDict() {
m_bCloned = TRUE;
}
}
-FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream,
- FX_BOOL bFlateEncode) {
+
+CPDF_FlateEncoder::CPDF_FlateEncoder(CPDF_Stream* pStream, FX_BOOL bFlateEncode)
+ : m_pData(nullptr),
+ m_dwSize(0),
+ m_pDict(nullptr),
+ m_bCloned(FALSE),
+ m_bNewData(FALSE) {
m_Acc.LoadAllData(pStream, TRUE);
if ((pStream && pStream->GetDict() &&
pStream->GetDict()->KeyExist("Filter")) ||
@@ -440,10 +434,9 @@ FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream,
m_dwSize = m_Acc.GetSize();
m_pDict = pStream->GetDict();
}
- return TRUE;
+ return;
}
- m_pData = NULL;
- m_dwSize = 0;
+
m_bNewData = TRUE;
m_bCloned = TRUE;
::FlateEncode(m_Acc.GetData(), m_Acc.GetSize(), m_pData, m_dwSize);
@@ -451,118 +444,111 @@ FX_BOOL CPDF_FlateEncoder::Initialize(CPDF_Stream* pStream,
m_pDict->SetAtInteger("Length", m_dwSize);
m_pDict->SetAtName("Filter", "FlateDecode");
m_pDict->RemoveAt("DecodeParms");
- return TRUE;
}
-FX_BOOL CPDF_FlateEncoder::Initialize(const uint8_t* pBuffer,
- uint32_t size,
- FX_BOOL bFlateEncode,
- FX_BOOL bXRefStream) {
+
+CPDF_FlateEncoder::CPDF_FlateEncoder(const uint8_t* pBuffer,
+ uint32_t size,
+ FX_BOOL bFlateEncode,
+ FX_BOOL bXRefStream)
+ : m_pData(nullptr),
+ m_dwSize(0),
+ m_pDict(nullptr),
+ m_bCloned(FALSE),
+ m_bNewData(FALSE) {
if (!bFlateEncode) {
m_pData = (uint8_t*)pBuffer;
m_dwSize = size;
- return TRUE;
+ return;
}
m_bNewData = TRUE;
- if (bXRefStream) {
+ if (bXRefStream)
::FlateEncode(pBuffer, size, 12, 1, 8, 7, m_pData, m_dwSize);
- } else {
+ else
::FlateEncode(pBuffer, size, m_pData, m_dwSize);
- }
- return TRUE;
}
+
CPDF_FlateEncoder::~CPDF_FlateEncoder() {
- if (m_bCloned && m_pDict) {
+ if (m_bCloned && m_pDict)
m_pDict->Release();
- }
- if (m_bNewData) {
+ if (m_bNewData)
FX_Free(m_pData);
- }
}
+
class CPDF_Encryptor {
public:
- CPDF_Encryptor();
+ CPDF_Encryptor(CPDF_CryptoHandler* pHandler,
+ int objnum,
+ uint8_t* src_data,
+ uint32_t src_size);
~CPDF_Encryptor();
- FX_BOOL Initialize(IPDF_CryptoHandler* pHandler,
- int objnum,
- uint8_t* src_data,
- uint32_t src_size);
+
uint8_t* m_pData;
uint32_t m_dwSize;
FX_BOOL m_bNewBuf;
};
-CPDF_Encryptor::CPDF_Encryptor() {
- m_pData = NULL;
- m_dwSize = 0;
- m_bNewBuf = FALSE;
-}
-FX_BOOL CPDF_Encryptor::Initialize(IPDF_CryptoHandler* pHandler,
- int objnum,
- uint8_t* src_data,
- uint32_t src_size) {
- if (src_size == 0) {
- return TRUE;
- }
+
+CPDF_Encryptor::CPDF_Encryptor(CPDF_CryptoHandler* pHandler,
+ int objnum,
+ uint8_t* src_data,
+ uint32_t src_size)
+ : m_pData(nullptr), m_dwSize(0), m_bNewBuf(FALSE) {
+ if (src_size == 0)
+ return;
+
if (!pHandler) {
m_pData = (uint8_t*)src_data;
m_dwSize = src_size;
- m_bNewBuf = FALSE;
- return TRUE;
+ return;
}
m_dwSize = pHandler->EncryptGetSize(objnum, 0, src_data, src_size);
m_pData = FX_Alloc(uint8_t, m_dwSize);
pHandler->EncryptContent(objnum, 0, src_data, src_size, m_pData, m_dwSize);
m_bNewBuf = TRUE;
- return TRUE;
}
+
CPDF_Encryptor::~CPDF_Encryptor() {
- if (m_bNewBuf) {
+ if (m_bNewBuf)
FX_Free(m_pData);
- }
}
} // namespace
CPDF_ObjectStream::CPDF_ObjectStream() : m_dwObjNum(0), m_index(0) {}
-FX_BOOL CPDF_ObjectStream::Start() {
- m_ObjNumArray.RemoveAll();
- m_OffsetArray.RemoveAll();
+
+void CPDF_ObjectStream::Start() {
+ m_Items.clear();
m_Buffer.Clear();
m_dwObjNum = 0;
m_index = 0;
- return TRUE;
}
-int32_t CPDF_ObjectStream::CompressIndirectObject(uint32_t dwObjNum,
- const CPDF_Object* pObj) {
- m_ObjNumArray.Add(dwObjNum);
- m_OffsetArray.Add(m_Buffer.GetLength());
+
+void CPDF_ObjectStream::CompressIndirectObject(uint32_t dwObjNum,
+ const CPDF_Object* pObj) {
+ m_Items.push_back({dwObjNum, m_Buffer.GetLength()});
m_Buffer << pObj;
- return 1;
}
-int32_t CPDF_ObjectStream::CompressIndirectObject(uint32_t dwObjNum,
- const uint8_t* pBuffer,
- uint32_t dwSize) {
- m_ObjNumArray.Add(dwObjNum);
- m_OffsetArray.Add(m_Buffer.GetLength());
+
+void CPDF_ObjectStream::CompressIndirectObject(uint32_t dwObjNum,
+ const uint8_t* pBuffer,
+ uint32_t dwSize) {
+ m_Items.push_back({dwObjNum, m_Buffer.GetLength()});
m_Buffer.AppendBlock(pBuffer, dwSize);
- return 1;
}
+
FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) {
- FXSYS_assert(pCreator);
- if (m_ObjNumArray.GetSize() == 0) {
+ ASSERT(pCreator);
+ if (m_Items.empty())
return 0;
- }
+
CFX_FileBufferArchive* pFile = &pCreator->m_File;
- IPDF_CryptoHandler* pHandler = pCreator->m_pCryptoHandler;
FX_FILESIZE ObjOffset = pCreator->m_Offset;
if (!m_dwObjNum) {
m_dwObjNum = ++pCreator->m_dwLastObjNum;
}
CFX_ByteTextBuf tempBuffer;
- int32_t iCount = m_ObjNumArray.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- tempBuffer << m_ObjNumArray.ElementAt(i) << " "
- << m_OffsetArray.ElementAt(i) << " ";
- }
+ for (const auto& pair : m_Items)
+ tempBuffer << pair.objnum << " " << pair.offset << " ";
+
FX_FILESIZE& offset = pCreator->m_Offset;
int32_t len = pFile->AppendDWord(m_dwObjNum);
if (len < 0) {
@@ -573,7 +559,8 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) {
return -1;
}
offset += len;
- if ((len = pFile->AppendDWord((uint32_t)iCount)) < 0) {
+ uint32_t iCount = pdfium::CollectionSize<uint32_t>(m_Items);
+ if ((len = pFile->AppendDWord(iCount)) < 0) {
return -1;
}
offset += len;
@@ -587,49 +574,27 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) {
return -1;
}
offset += len + 15;
- if (!pCreator->m_bCompress && !pHandler) {
- if ((len = pFile->AppendDWord(
- (uint32_t)(tempBuffer.GetLength() + m_Buffer.GetLength()))) < 0) {
- return -1;
- }
- offset += len;
- if ((len = pFile->AppendString(">>stream\r\n")) < 0) {
- return -1;
- }
- if (pFile->AppendBlock(tempBuffer.GetBuffer(), tempBuffer.GetLength()) <
- 0) {
- return -1;
- }
- if (pFile->AppendBlock(m_Buffer.GetBuffer(), m_Buffer.GetLength()) < 0) {
- return -1;
- }
- offset += len + tempBuffer.GetLength() + m_Buffer.GetLength();
- } else {
- tempBuffer << m_Buffer;
- CPDF_FlateEncoder encoder;
- encoder.Initialize(tempBuffer.GetBuffer(), tempBuffer.GetLength(),
- pCreator->m_bCompress);
- CPDF_Encryptor encryptor;
- encryptor.Initialize(pHandler, m_dwObjNum, encoder.m_pData,
- encoder.m_dwSize);
- if ((len = pFile->AppendDWord(encryptor.m_dwSize)) < 0) {
- return -1;
- }
- offset += len;
- if (pCreator->m_bCompress) {
- if (pFile->AppendString("/Filter /FlateDecode") < 0) {
- return -1;
- }
- offset += 20;
- }
- if ((len = pFile->AppendString(">>stream\r\n")) < 0) {
- return -1;
- }
- if (pFile->AppendBlock(encryptor.m_pData, encryptor.m_dwSize) < 0) {
- return -1;
- }
- offset += len + encryptor.m_dwSize;
+
+ tempBuffer << m_Buffer;
+ CPDF_FlateEncoder encoder(tempBuffer.GetBuffer(), tempBuffer.GetLength(),
+ TRUE);
+ CPDF_Encryptor encryptor(pCreator->m_pCryptoHandler, m_dwObjNum,
+ encoder.m_pData, encoder.m_dwSize);
+ if ((len = pFile->AppendDWord(encryptor.m_dwSize)) < 0) {
+ return -1;
+ }
+ offset += len;
+ if (pFile->AppendString("/Filter /FlateDecode") < 0) {
+ return -1;
+ }
+ offset += 20;
+ if ((len = pFile->AppendString(">>stream\r\n")) < 0) {
+ return -1;
+ }
+ if (pFile->AppendBlock(encryptor.m_pData, encryptor.m_dwSize) < 0) {
+ return -1;
}
+ offset += len + encryptor.m_dwSize;
if ((len = pFile->AppendString("\r\nendstream\r\nendobj\r\n")) < 0) {
return -1;
}
@@ -647,11 +612,12 @@ FX_BOOL CPDF_XRefStream::Start() {
int32_t CPDF_XRefStream::CompressIndirectObject(uint32_t dwObjNum,
const CPDF_Object* pObj,
CPDF_Creator* pCreator) {
- if (!pCreator) {
+ if (!pCreator)
return 0;
- }
+
m_ObjStream.CompressIndirectObject(dwObjNum, pObj);
- if (m_ObjStream.m_ObjNumArray.GetSize() < pCreator->m_ObjectStreamSize &&
+ if (pdfium::CollectionSize<int32_t>(m_ObjStream.m_Items) <
+ pCreator->m_ObjectStreamSize &&
m_ObjStream.m_Buffer.GetLength() < PDF_OBJECTSTREAM_MAXLENGTH) {
return 1;
}
@@ -661,11 +627,12 @@ int32_t CPDF_XRefStream::CompressIndirectObject(uint32_t dwObjNum,
const uint8_t* pBuffer,
uint32_t dwSize,
CPDF_Creator* pCreator) {
- if (!pCreator) {
+ if (!pCreator)
return 0;
- }
+
m_ObjStream.CompressIndirectObject(dwObjNum, pBuffer, dwSize);
- if (m_ObjStream.m_ObjNumArray.GetSize() < pCreator->m_ObjectStreamSize &&
+ if (pdfium::CollectionSize<int32_t>(m_ObjStream.m_Items) <
+ pCreator->m_ObjectStreamSize &&
m_ObjStream.m_Buffer.GetLength() < PDF_OBJECTSTREAM_MAXLENGTH) {
return 1;
}
@@ -684,7 +651,7 @@ int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator* pCreator, FX_BOOL bEOF) {
if (!dwObjStmNum) {
dwObjStmNum = ++pCreator->m_dwLastObjNum;
}
- int32_t iSize = m_ObjStream.m_ObjNumArray.GetSize();
+ int32_t iSize = pdfium::CollectionSize<int32_t>(m_ObjStream.m_Items);
size_t iSeg = m_IndexArray.size();
if (!(pCreator->m_dwFlags & FPDFCREATE_INCREMENTAL)) {
if (m_dwTempObjNum == 0) {
@@ -697,7 +664,7 @@ int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator* pCreator, FX_BOOL bEOF) {
FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(m_dwTempObjNum);
if (offset) {
if (index >= iSize ||
- m_dwTempObjNum != m_ObjStream.m_ObjNumArray[index]) {
+ m_dwTempObjNum != m_ObjStream.m_Items[index].objnum) {
AppendIndex1(m_Buffer, *offset);
} else {
AppendIndex2(m_Buffer, dwObjStmNum, index++);
@@ -720,7 +687,7 @@ int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator* pCreator, FX_BOOL bEOF) {
++it) {
for (uint32_t m = it->objnum; m < it->objnum + it->count; ++m) {
if (m_ObjStream.m_index >= iSize ||
- m != m_ObjStream.m_ObjNumArray.ElementAt(it - m_IndexArray.begin())) {
+ m != m_ObjStream.m_Items[it - m_IndexArray.begin()].objnum) {
AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[m]);
} else {
AppendIndex2(m_Buffer, dwObjStmNum, m_ObjStream.m_index++);
@@ -819,21 +786,18 @@ FX_BOOL CPDF_XRefStream::GenerateXRefStream(CPDF_Creator* pCreator,
offset += len + 6;
}
FX_BOOL bPredictor = TRUE;
- CPDF_FlateEncoder encoder;
- encoder.Initialize(m_Buffer.GetBuffer(), m_Buffer.GetLength(),
- pCreator->m_bCompress, bPredictor);
- if (pCreator->m_bCompress) {
- if (pFile->AppendString("/Filter /FlateDecode") < 0) {
+ CPDF_FlateEncoder encoder(m_Buffer.GetBuffer(), m_Buffer.GetLength(), TRUE,
+ bPredictor);
+ if (pFile->AppendString("/Filter /FlateDecode") < 0) {
+ return FALSE;
+ }
+ offset += 20;
+ if (bPredictor) {
+ if ((len = pFile->AppendString("/DecodeParms<</Columns 7/Predictor 12>>")) <
+ 0) {
return FALSE;
}
- offset += 20;
- if (bPredictor) {
- if ((len = pFile->AppendString(
- "/DecodeParms<</Columns 7/Predictor 12>>")) < 0) {
- return FALSE;
- }
- offset += len;
- }
+ offset += len;
}
if (pFile->AppendString("/Length ") < 0) {
return FALSE;
@@ -844,15 +808,14 @@ FX_BOOL CPDF_XRefStream::GenerateXRefStream(CPDF_Creator* pCreator,
offset += len + 8;
if (bEOF) {
if ((len = PDF_CreatorWriteTrailer(pCreator->m_pDocument, pFile,
- pCreator->m_pIDArray,
- pCreator->m_bCompress)) < 0) {
+ pCreator->m_pIDArray)) < 0) {
return FALSE;
}
offset += len;
if (pCreator->m_pEncryptDict) {
uint32_t dwEncryptObjNum = pCreator->m_pEncryptDict->GetObjNum();
if (dwEncryptObjNum == 0) {
- dwEncryptObjNum = pCreator->m_dwEnryptObjNum;
+ dwEncryptObjNum = pCreator->m_dwEncryptObjNum;
}
if ((len = PDF_CreatorWriteEncrypt(pCreator->m_pEncryptDict,
dwEncryptObjNum, pFile)) < 0) {
@@ -911,35 +874,27 @@ void CPDF_XRefStream::AddObjectNumberToIndexArray(uint32_t objnum) {
else
m_IndexArray.push_back({objnum, 1});
}
-CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc) {
- m_pDocument = pDoc;
- m_pParser = (CPDF_Parser*)pDoc->m_pParser;
- m_bCompress = TRUE;
- if (m_pParser) {
- m_pEncryptDict = m_pParser->GetEncryptDict();
- m_pCryptoHandler = m_pParser->GetCryptoHandler();
- } else {
- m_pEncryptDict = NULL;
- m_pCryptoHandler = NULL;
- }
- m_bSecurityChanged = FALSE;
- m_bStandardSecurity = FALSE;
- m_pMetadata = NULL;
- m_bEncryptCloned = FALSE;
- m_bEncryptMetadata = FALSE;
- m_Offset = 0;
- m_iStage = -1;
- m_dwFlags = 0;
- m_Pos = NULL;
- m_XrefStart = 0;
- m_pXRefStream = NULL;
- m_ObjectStreamSize = 200;
- m_dwLastObjNum = m_pDocument->GetLastObjNum();
- m_pIDArray = NULL;
- m_FileVersion = 0;
- m_dwEnryptObjNum = 0;
- m_bNewCrypto = FALSE;
-}
+
+CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc)
+ : m_pDocument(pDoc),
+ m_pParser(pDoc->GetParser()),
+ m_bSecurityChanged(FALSE),
+ m_pEncryptDict(m_pParser ? m_pParser->GetEncryptDict() : nullptr),
+ m_dwEncryptObjNum(0),
+ m_bEncryptCloned(FALSE),
+ m_pCryptoHandler(m_pParser ? m_pParser->GetCryptoHandler() : nullptr),
+ m_bLocalCryptoHandler(FALSE),
+ m_pMetadata(nullptr),
+ m_ObjectStreamSize(200),
+ m_dwLastObjNum(m_pDocument->GetLastObjNum()),
+ m_Offset(0),
+ m_iStage(-1),
+ m_dwFlags(0),
+ m_Pos(nullptr),
+ m_XrefStart(0),
+ m_pIDArray(nullptr),
+ m_FileVersion(0) {}
+
CPDF_Creator::~CPDF_Creator() {
ResetStandardSecurity();
if (m_bEncryptCloned && m_pEncryptDict) {
@@ -979,7 +934,7 @@ int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) {
m_pXRefStream->AddObjectNumberToIndexArray(objnum);
if (m_pXRefStream->CompressIndirectObject(objnum, pObj, this) < 0)
return -1;
- if (!IsXRefNeedEnd(m_pXRefStream, m_dwFlags))
+ if (!IsXRefNeedEnd(m_pXRefStream.get(), m_dwFlags))
return 0;
if (!m_pXRefStream->End(this))
return -1;
@@ -999,7 +954,7 @@ int32_t CPDF_Creator::WriteIndirectObjectToStream(uint32_t objnum,
if (iRet < 1) {
return iRet;
}
- if (!IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) {
+ if (!IsXRefNeedEnd(m_pXRefStream.get(), m_dwFlags)) {
return 0;
}
if (!m_pXRefStream->End(this)) {
@@ -1015,7 +970,7 @@ int32_t CPDF_Creator::AppendObjectNumberToXRef(uint32_t objnum) {
return 1;
}
m_pXRefStream->AddObjectNumberToIndexArray(objnum);
- if (!IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) {
+ if (!IsXRefNeedEnd(m_pXRefStream.get(), m_dwFlags)) {
return 0;
}
if (!m_pXRefStream->End(this)) {
@@ -1028,15 +983,10 @@ int32_t CPDF_Creator::AppendObjectNumberToXRef(uint32_t objnum) {
}
int32_t CPDF_Creator::WriteStream(const CPDF_Object* pStream,
uint32_t objnum,
- IPDF_CryptoHandler* pCrypto) {
- CPDF_FlateEncoder encoder;
- encoder.Initialize(const_cast<CPDF_Stream*>(pStream->AsStream()),
- pStream == m_pMetadata ? FALSE : m_bCompress);
- CPDF_Encryptor encryptor;
- if (!encryptor.Initialize(pCrypto, objnum, encoder.m_pData,
- encoder.m_dwSize)) {
- return -1;
- }
+ CPDF_CryptoHandler* pCrypto) {
+ CPDF_FlateEncoder encoder(const_cast<CPDF_Stream*>(pStream->AsStream()),
+ pStream != m_pMetadata);
+ CPDF_Encryptor encryptor(pCrypto, objnum, encoder.m_pData, encoder.m_dwSize);
if ((uint32_t)encoder.m_pDict->GetIntegerBy("Length") != encryptor.m_dwSize) {
encoder.CloneDict();
encoder.m_pDict->SetAtInteger("Length", encryptor.m_dwSize);
@@ -1071,9 +1021,8 @@ int32_t CPDF_Creator::WriteIndirectObj(uint32_t objnum,
m_Offset += len;
if (pObj->IsStream()) {
- IPDF_CryptoHandler* pHandler = nullptr;
- pHandler =
- (pObj == m_pMetadata && !m_bEncryptMetadata) ? NULL : m_pCryptoHandler;
+ CPDF_CryptoHandler* pHandler =
+ pObj != m_pMetadata ? m_pCryptoHandler : nullptr;
if (WriteStream(pObj, objnum, pHandler) < 0)
return -1;
} else {
@@ -1118,7 +1067,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
if (m_File.AppendString(" ") < 0) {
return -1;
}
- if ((len = m_File.AppendString(pObj->GetString().AsByteStringC())) < 0) {
+ if ((len = m_File.AppendString(pObj->GetString().AsStringC())) < 0) {
return -1;
}
m_Offset += len + 1;
@@ -1128,31 +1077,28 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
FX_BOOL bHex = pObj->AsString()->IsHex();
if (!m_pCryptoHandler || !bEncrypt) {
CFX_ByteString content = PDF_EncodeString(str, bHex);
- if ((len = m_File.AppendString(content.AsByteStringC())) < 0) {
+ if ((len = m_File.AppendString(content.AsStringC())) < 0) {
return -1;
}
m_Offset += len;
break;
}
- CPDF_Encryptor encryptor;
- encryptor.Initialize(m_pCryptoHandler, objnum, (uint8_t*)str.c_str(),
- str.GetLength());
+ CPDF_Encryptor encryptor(m_pCryptoHandler, objnum, (uint8_t*)str.c_str(),
+ str.GetLength());
CFX_ByteString content = PDF_EncodeString(
CFX_ByteString((const FX_CHAR*)encryptor.m_pData, encryptor.m_dwSize),
bHex);
- if ((len = m_File.AppendString(content.AsByteStringC())) < 0) {
+ if ((len = m_File.AppendString(content.AsStringC())) < 0) {
return -1;
}
m_Offset += len;
break;
}
case CPDF_Object::STREAM: {
- CPDF_FlateEncoder encoder;
- encoder.Initialize(const_cast<CPDF_Stream*>(pObj->AsStream()),
- m_bCompress);
- CPDF_Encryptor encryptor;
- IPDF_CryptoHandler* pHandler = m_pCryptoHandler;
- encryptor.Initialize(pHandler, objnum, encoder.m_pData, encoder.m_dwSize);
+ CPDF_FlateEncoder encoder(const_cast<CPDF_Stream*>(pObj->AsStream()),
+ TRUE);
+ CPDF_Encryptor encryptor(m_pCryptoHandler, objnum, encoder.m_pData,
+ encoder.m_dwSize);
if ((uint32_t)encoder.m_pDict->GetIntegerBy("Length") !=
encryptor.m_dwSize) {
encoder.CloneDict();
@@ -1180,8 +1126,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
return -1;
}
CFX_ByteString str = pObj->GetString();
- if ((len = m_File.AppendString(PDF_NameEncode(str).AsByteStringC())) <
- 0) {
+ if ((len = m_File.AppendString(PDF_NameEncode(str).AsStringC())) < 0) {
return -1;
}
m_Offset += len + 1;
@@ -1203,7 +1148,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
}
m_Offset += 1;
const CPDF_Array* p = pObj->AsArray();
- for (uint32_t i = 0; i < p->GetCount(); i++) {
+ for (size_t i = 0; i < p->GetCount(); i++) {
CPDF_Object* pElement = p->GetObjectAt(i);
if (pElement->GetObjNum()) {
if (m_File.AppendString(" ") < 0) {
@@ -1229,12 +1174,11 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
break;
}
case CPDF_Object::DICTIONARY: {
- if (!m_pCryptoHandler || pObj == m_pEncryptDict) {
+ if (!m_pCryptoHandler || pObj == m_pEncryptDict)
return PDF_CreatorAppendObject(pObj, &m_File, m_Offset);
- }
- if (m_File.AppendString("<<") < 0) {
+ if (m_File.AppendString("<<") < 0)
return -1;
- }
+
m_Offset += 2;
const CPDF_Dictionary* p = pObj->AsDictionary();
bool bSignDict = p->IsSignatureDict();
@@ -1245,8 +1189,7 @@ int32_t CPDF_Creator::WriteDirectObj(uint32_t objnum,
if (m_File.AppendString("/") < 0) {
return -1;
}
- if ((len = m_File.AppendString(PDF_NameEncode(key).AsByteStringC())) <
- 0) {
+ if ((len = m_File.AppendString(PDF_NameEncode(key).AsStringC())) < 0) {
return -1;
}
m_Offset += len + 1;
@@ -1490,7 +1433,7 @@ void CPDF_Creator::AppendNewObjNum(uint32_t objbum) {
m_NewObjNumArray.InsertAt(iFind, objbum);
}
int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
- FXSYS_assert(m_iStage > -1 || m_iStage < 20);
+ ASSERT(m_iStage > -1 || m_iStage < 20);
if (m_iStage == 0) {
if (!m_pParser) {
m_dwFlags &= ~FPDFCREATE_INCREMENTAL;
@@ -1501,7 +1444,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
CPDF_Dictionary* pDict = m_pDocument->GetRoot();
m_pMetadata = pDict ? pDict->GetDirectObjectBy("Metadata") : NULL;
if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) {
- m_pXRefStream = new CPDF_XRefStream;
+ m_pXRefStream.reset(new CPDF_XRefStream);
m_pXRefStream->Start();
if ((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser) {
FX_FILESIZE prev = m_pParser->GetLastXRefOffset();
@@ -1585,7 +1528,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
return m_iStage;
}
int32_t CPDF_Creator::WriteDoc_Stage2(IFX_Pause* pPause) {
- FXSYS_assert(m_iStage >= 20 || m_iStage < 30);
+ ASSERT(m_iStage >= 20 || m_iStage < 30);
if (m_iStage == 20) {
if ((m_dwFlags & FPDFCREATE_INCREMENTAL) == 0 && m_pParser) {
m_Pos = (void*)(uintptr_t)0;
@@ -1622,7 +1565,7 @@ int32_t CPDF_Creator::WriteDoc_Stage2(IFX_Pause* pPause) {
}
m_ObjectOffset.Add(m_dwLastObjNum, 1);
m_ObjectOffset[m_dwLastObjNum] = saveOffset;
- m_dwEnryptObjNum = m_dwLastObjNum;
+ m_dwEncryptObjNum = m_dwLastObjNum;
if (m_dwFlags & FPDFCREATE_INCREMENTAL) {
m_NewObjNumArray.Add(m_dwLastObjNum);
}
@@ -1632,7 +1575,7 @@ int32_t CPDF_Creator::WriteDoc_Stage2(IFX_Pause* pPause) {
return m_iStage;
}
int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause* pPause) {
- FXSYS_assert(m_iStage >= 80 || m_iStage < 90);
+ ASSERT(m_iStage >= 80 || m_iStage < 90);
uint32_t dwLastObjNum = m_dwLastObjNum;
if (m_iStage == 80) {
m_XrefStart = m_Offset;
@@ -1648,7 +1591,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause* pPause) {
str = m_ObjectOffset.GetPtrAt(1)
? "xref\r\n"
: "xref\r\n0 1\r\n0000000000 65535 f\r\n";
- if (m_File.AppendString(str.AsByteStringC()) < 0) {
+ if (m_File.AppendString(str.AsStringC()) < 0) {
return -1;
}
m_Pos = (void*)(uintptr_t)1;
@@ -1746,7 +1689,7 @@ int32_t CPDF_Creator::WriteDoc_Stage3(IFX_Pause* pPause) {
}
int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
- FXSYS_assert(m_iStage >= 90);
+ ASSERT(m_iStage >= 90);
if ((m_dwFlags & FPDFCREATE_OBJECTSTREAM) == 0) {
FX_BOOL bXRefStream =
(m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser->IsXRefStream();
@@ -1777,7 +1720,7 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
if (m_File.AppendString(("/")) < 0) {
return -1;
}
- if (m_File.AppendString(PDF_NameEncode(key).AsByteStringC()) < 0) {
+ if (m_File.AppendString(PDF_NameEncode(key).AsStringC()) < 0) {
return -1;
}
if (pValue->GetObjNum()) {
@@ -1952,8 +1895,7 @@ int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
return m_iStage = 100;
}
void CPDF_Creator::Clear() {
- delete m_pXRefStream;
- m_pXRefStream = NULL;
+ m_pXRefStream.reset();
m_File.Clear();
m_NewObjNumArray.RemoveAll();
if (m_pIDArray) {
@@ -1991,7 +1933,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) {
} else {
std::vector<uint8_t> buffer =
PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum);
- CFX_ByteStringC bsBuffer(buffer.data(), buffer.size());
+ CFX_ByteString bsBuffer(buffer.data(), buffer.size());
m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument);
}
}
@@ -2006,24 +1948,24 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) {
}
std::vector<uint8_t> buffer =
PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum);
- CFX_ByteStringC bsBuffer(buffer.data(), buffer.size());
+ CFX_ByteString bsBuffer(buffer.data(), buffer.size());
m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument);
return;
}
m_pIDArray->Add(m_pIDArray->GetObjectAt(0)->Clone());
if (m_pEncryptDict && !pOldIDArray && m_pParser && bNewId) {
if (m_pEncryptDict->GetStringBy("Filter") == "Standard") {
- CPDF_StandardSecurityHandler handler;
CFX_ByteString user_pass = m_pParser->GetPassword();
uint32_t flag = PDF_ENCRYPT_CONTENT;
- handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass,
+
+ CPDF_SecurityHandler handler;
+ handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(),
user_pass.GetLength(), flag);
- if (m_bNewCrypto) {
+ if (m_bLocalCryptoHandler)
delete m_pCryptoHandler;
- }
- m_pCryptoHandler = new CPDF_StandardCryptoHandler;
+ m_pCryptoHandler = new CPDF_CryptoHandler;
m_pCryptoHandler->Init(m_pEncryptDict, &handler);
- m_bNewCrypto = TRUE;
+ m_bLocalCryptoHandler = TRUE;
m_bSecurityChanged = TRUE;
}
}
@@ -2064,21 +2006,14 @@ FX_BOOL CPDF_Creator::SetFileVersion(int32_t fileVersion) {
void CPDF_Creator::RemoveSecurity() {
ResetStandardSecurity();
m_bSecurityChanged = TRUE;
- m_pEncryptDict = NULL;
- m_pCryptoHandler = NULL;
+ m_pEncryptDict = nullptr;
+ m_pCryptoHandler = nullptr;
}
void CPDF_Creator::ResetStandardSecurity() {
- if (m_bStandardSecurity || m_bNewCrypto) {
- delete m_pCryptoHandler;
- m_pCryptoHandler = NULL;
- }
- m_bNewCrypto = FALSE;
- if (!m_bStandardSecurity) {
+ if (!m_bLocalCryptoHandler)
return;
- }
- if (m_pEncryptDict) {
- m_pEncryptDict->Release();
- m_pEncryptDict = NULL;
- }
- m_bStandardSecurity = FALSE;
+
+ delete m_pCryptoHandler;
+ m_pCryptoHandler = nullptr;
+ m_bLocalCryptoHandler = FALSE;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
deleted file mode 100644
index d70c04c6904..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
+++ /dev/null
@@ -1,1160 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include <limits.h>
-
-#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
-#include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
-#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
-#include "core/fpdfapi/fpdf_page/pageint.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
-#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/fpdfapi/ipdf_rendermodule.h"
-
-CPDF_Document::CPDF_Document() : CPDF_IndirectObjectHolder(NULL) {
- m_pRootDict = NULL;
- m_pInfoDict = NULL;
- m_bLinearized = FALSE;
- m_dwFirstPageNo = 0;
- m_dwFirstPageObjNum = 0;
- m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this);
- m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this);
-}
-void CPDF_Document::CreateNewDoc() {
- ASSERT(!m_pRootDict && !m_pInfoDict);
- m_pRootDict = new CPDF_Dictionary;
- m_pRootDict->SetAtName("Type", "Catalog");
- int objnum = AddIndirectObject(m_pRootDict);
- CPDF_Dictionary* pPages = new CPDF_Dictionary;
- pPages->SetAtName("Type", "Pages");
- pPages->SetAtNumber("Count", 0);
- pPages->SetAt("Kids", new CPDF_Array);
- objnum = AddIndirectObject(pPages);
- m_pRootDict->SetAtReference("Pages", this, objnum);
- m_pInfoDict = new CPDF_Dictionary;
- AddIndirectObject(m_pInfoDict);
-}
-static const uint16_t g_FX_CP874Unicodes[128] = {
- 0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018,
- 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A0, 0x0E01, 0x0E02, 0x0E03,
- 0x0E04, 0x0E05, 0x0E06, 0x0E07, 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C,
- 0x0E0D, 0x0E0E, 0x0E0F, 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15,
- 0x0E16, 0x0E17, 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E,
- 0x0E1F, 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
- 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, 0x0E30,
- 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, 0x0E38, 0x0E39,
- 0x0E3A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0E3F, 0x0E40, 0x0E41, 0x0E42,
- 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, 0x0E48, 0x0E49, 0x0E4A, 0x0E4B,
- 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54,
- 0x0E55, 0x0E56, 0x0E57, 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0000, 0x0000,
- 0x0000, 0x0000,
-};
-static const uint16_t g_FX_CP1250Unicodes[128] = {
- 0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021, 0x0000,
- 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179, 0x0000, 0x2018,
- 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0161,
- 0x203A, 0x015B, 0x0165, 0x017E, 0x017A, 0x00A0, 0x02C7, 0x02D8, 0x0141,
- 0x00A4, 0x0104, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC,
- 0x00AD, 0x00AE, 0x017B, 0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5,
- 0x00B6, 0x00B7, 0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E,
- 0x017C, 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, 0x0110,
- 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158, 0x016E,
- 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, 0x0155, 0x00E1, 0x00E2,
- 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D, 0x00E9, 0x0119, 0x00EB,
- 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4,
- 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD,
- 0x0163, 0x02D9,
-};
-static const uint16_t g_FX_CP1251Unicodes[128] = {
- 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, 0x20AC,
- 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, 0x0452, 0x2018,
- 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0459,
- 0x203A, 0x045A, 0x045C, 0x045B, 0x045F, 0x00A0, 0x040E, 0x045E, 0x0408,
- 0x00A4, 0x0490, 0x00A6, 0x00A7, 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC,
- 0x00AD, 0x00AE, 0x0407, 0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5,
- 0x00B6, 0x00B7, 0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455,
- 0x0457, 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
- 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420,
- 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429,
- 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, 0x0430, 0x0431, 0x0432,
- 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B,
- 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444,
- 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D,
- 0x044E, 0x044F,
-};
-static const uint16_t g_FX_CP1253Unicodes[128] = {
- 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x0000,
- 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018,
- 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0000,
- 0x203A, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A0, 0x0385, 0x0386, 0x00A3,
- 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x0000, 0x00AB, 0x00AC,
- 0x00AD, 0x00AE, 0x2015, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5,
- 0x00B6, 0x00B7, 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E,
- 0x038F, 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
- 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
- 0x03A1, 0x0000, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
- 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, 0x03B0, 0x03B1, 0x03B2,
- 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB,
- 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4,
- 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD,
- 0x03CE, 0x0000,
-};
-static const uint16_t g_FX_CP1254Unicodes[128] = {
- 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6,
- 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018,
- 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0161,
- 0x203A, 0x0153, 0x0000, 0x0000, 0x0178, 0x00A0, 0x00A1, 0x00A2, 0x00A3,
- 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC,
- 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5,
- 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE,
- 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x011E,
- 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9,
- 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, 0x00E0, 0x00E1, 0x00E2,
- 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB,
- 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4,
- 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131,
- 0x015F, 0x00FF,
-};
-static const uint16_t g_FX_CP1255Unicodes[128] = {
- 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6,
- 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018,
- 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0000,
- 0x203A, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A0, 0x00A1, 0x00A2, 0x00A3,
- 0x20AA, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC,
- 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5,
- 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE,
- 0x00BF, 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
- 0x05B8, 0x05B9, 0x0000, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF, 0x05C0,
- 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x05D0, 0x05D1, 0x05D2,
- 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB,
- 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4,
- 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x0000, 0x0000, 0x200E,
- 0x200F, 0x0000,
-};
-static const uint16_t g_FX_CP1256Unicodes[128] = {
- 0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6,
- 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688, 0x06AF, 0x2018,
- 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x06A9, 0x2122, 0x0691,
- 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA, 0x00A0, 0x060C, 0x00A2, 0x00A3,
- 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC,
- 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5,
- 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE,
- 0x061F, 0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
- 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630,
- 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7, 0x0637, 0x0638,
- 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643, 0x00E0, 0x0644, 0x00E2,
- 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB,
- 0x0649, 0x064A, 0x00EE, 0x00EF, 0x064B, 0x064C, 0x064D, 0x064E, 0x00F4,
- 0x064F, 0x0650, 0x00F7, 0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E,
- 0x200F, 0x06D2,
-};
-static const uint16_t g_FX_CP1257Unicodes[128] = {
- 0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021, 0x0000,
- 0x2030, 0x0000, 0x2039, 0x0000, 0x00A8, 0x02C7, 0x00B8, 0x0000, 0x2018,
- 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0000,
- 0x203A, 0x0000, 0x00AF, 0x02DB, 0x0000, 0x00A0, 0x0000, 0x00A2, 0x00A3,
- 0x00A4, 0x0000, 0x00A6, 0x00A7, 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC,
- 0x00AD, 0x00AE, 0x00C6, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5,
- 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE,
- 0x00E6, 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
- 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, 0x0160,
- 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141,
- 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, 0x0105, 0x012F, 0x0101,
- 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117,
- 0x0123, 0x0137, 0x012B, 0x013C, 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D,
- 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C,
- 0x017E, 0x02D9,
-};
-typedef struct {
- uint8_t m_Charset;
- const uint16_t* m_pUnicodes;
-} FX_CharsetUnicodes;
-const FX_CharsetUnicodes g_FX_CharsetUnicodes[] = {
- {FXFONT_THAI_CHARSET, g_FX_CP874Unicodes},
- {FXFONT_EASTEUROPE_CHARSET, g_FX_CP1250Unicodes},
- {FXFONT_RUSSIAN_CHARSET, g_FX_CP1251Unicodes},
- {FXFONT_GREEK_CHARSET, g_FX_CP1253Unicodes},
- {FXFONT_TURKISH_CHARSET, g_FX_CP1254Unicodes},
- {FXFONT_HEBREW_CHARSET, g_FX_CP1255Unicodes},
- {FXFONT_ARABIC_CHARSET, g_FX_CP1256Unicodes},
- {FXFONT_BALTIC_CHARSET, g_FX_CP1257Unicodes},
-};
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_)
-static void _InsertWidthArray(HDC hDC,
- int start,
- int end,
- CPDF_Array* pWidthArray) {
- int size = end - start + 1;
- int* widths = FX_Alloc(int, size);
- GetCharWidth(hDC, start, end, widths);
- int i;
- for (i = 1; i < size; i++)
- if (widths[i] != *widths) {
- break;
- }
- if (i == size) {
- int first = pWidthArray->GetIntegerAt(pWidthArray->GetCount() - 1);
- pWidthArray->AddInteger(first + size - 1);
- pWidthArray->AddInteger(*widths);
- } else {
- CPDF_Array* pWidthArray1 = new CPDF_Array;
- pWidthArray->Add(pWidthArray1);
- for (i = 0; i < size; i++) {
- pWidthArray1->AddInteger(widths[i]);
- }
- }
- FX_Free(widths);
-}
-CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName) {
- LOGFONTA lfa;
- FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa);
- CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName);
- if (face.GetLength() >= LF_FACESIZE) {
- return NULL;
- }
- FXSYS_strcpy(lfa.lfFaceName, face.c_str());
- return AddWindowsFont(&lfa, bVert, bTranslateName);
-}
-CFX_ByteString _FPDF_GetPSNameFromTT(HDC hDC) {
- CFX_ByteString result;
- DWORD size = ::GetFontData(hDC, 'eman', 0, NULL, 0);
- if (size != GDI_ERROR) {
- LPBYTE buffer = FX_Alloc(BYTE, size);
- ::GetFontData(hDC, 'eman', 0, buffer, size);
- result = GetNameFromTT(buffer, size, 6);
- FX_Free(buffer);
- }
- return result;
-}
-CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName) {
- pLogFont->lfHeight = -1000;
- pLogFont->lfWidth = 0;
- HGDIOBJ hFont = CreateFontIndirectA(pLogFont);
- HDC hDC = CreateCompatibleDC(NULL);
- hFont = SelectObject(hDC, hFont);
- int tm_size = GetOutlineTextMetrics(hDC, 0, NULL);
- if (tm_size == 0) {
- hFont = SelectObject(hDC, hFont);
- DeleteObject(hFont);
- DeleteDC(hDC);
- return NULL;
- }
- LPBYTE tm_buf = FX_Alloc(BYTE, tm_size);
- OUTLINETEXTMETRIC* ptm = (OUTLINETEXTMETRIC*)tm_buf;
- GetOutlineTextMetrics(hDC, tm_size, ptm);
- int flags = 0, italicangle, ascend, descend, capheight, bbox[4];
- if (pLogFont->lfItalic) {
- flags |= PDFFONT_ITALIC;
- }
- if ((pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH) {
- flags |= PDFFONT_FIXEDPITCH;
- }
- if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN) {
- flags |= PDFFONT_SERIF;
- }
- if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT) {
- flags |= PDFFONT_SCRIPT;
- }
- bool bCJK = pLogFont->lfCharSet == CHINESEBIG5_CHARSET ||
- pLogFont->lfCharSet == GB2312_CHARSET ||
- pLogFont->lfCharSet == HANGEUL_CHARSET ||
- pLogFont->lfCharSet == SHIFTJIS_CHARSET;
- CFX_ByteString basefont;
- if (bTranslateName && bCJK) {
- basefont = _FPDF_GetPSNameFromTT(hDC);
- }
- if (basefont.IsEmpty()) {
- basefont = pLogFont->lfFaceName;
- }
- italicangle = ptm->otmItalicAngle / 10;
- ascend = ptm->otmrcFontBox.top;
- descend = ptm->otmrcFontBox.bottom;
- capheight = ptm->otmsCapEmHeight;
- bbox[0] = ptm->otmrcFontBox.left;
- bbox[1] = ptm->otmrcFontBox.bottom;
- bbox[2] = ptm->otmrcFontBox.right;
- bbox[3] = ptm->otmrcFontBox.top;
- FX_Free(tm_buf);
- basefont.Replace(" ", "");
- CPDF_Dictionary* pBaseDict = new CPDF_Dictionary;
- pBaseDict->SetAtName("Type", "Font");
- CPDF_Dictionary* pFontDict = pBaseDict;
- if (!bCJK) {
- if (pLogFont->lfCharSet == ANSI_CHARSET ||
- pLogFont->lfCharSet == DEFAULT_CHARSET ||
- pLogFont->lfCharSet == SYMBOL_CHARSET) {
- if (pLogFont->lfCharSet == SYMBOL_CHARSET) {
- flags |= PDFFONT_SYMBOLIC;
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- }
- pBaseDict->SetAtName("Encoding", "WinAnsiEncoding");
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- int i;
- for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes);
- i++)
- if (g_FX_CharsetUnicodes[i].m_Charset == pLogFont->lfCharSet) {
- break;
- }
- if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
- CPDF_Dictionary* pEncoding = new CPDF_Dictionary;
- pEncoding->SetAtName("BaseEncoding", "WinAnsiEncoding");
- CPDF_Array* pArray = new CPDF_Array;
- pArray->AddInteger(128);
- const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
- for (int j = 0; j < 128; j++) {
- CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
- if (name.IsEmpty()) {
- pArray->AddName(".notdef");
- } else {
- pArray->AddName(name);
- }
- }
- pEncoding->SetAt("Differences", pArray);
- AddIndirectObject(pEncoding);
- pBaseDict->SetAtReference("Encoding", this, pEncoding);
- }
- }
- if (pLogFont->lfWeight > FW_MEDIUM && pLogFont->lfItalic) {
- basefont += ",BoldItalic";
- } else if (pLogFont->lfWeight > FW_MEDIUM) {
- basefont += ",Bold";
- } else if (pLogFont->lfItalic) {
- basefont += ",Italic";
- }
- pBaseDict->SetAtName("Subtype", "TrueType");
- pBaseDict->SetAtName("BaseFont", basefont);
- pBaseDict->SetAtNumber("FirstChar", 32);
- pBaseDict->SetAtNumber("LastChar", 255);
- int char_widths[224];
- GetCharWidth(hDC, 32, 255, char_widths);
- CPDF_Array* pWidths = new CPDF_Array;
- for (int i = 0; i < 224; i++) {
- pWidths->AddInteger(char_widths[i]);
- }
- pBaseDict->SetAt("Widths", pWidths);
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- pFontDict = new CPDF_Dictionary;
- CFX_ByteString cmap;
- CFX_ByteString ordering;
- int supplement;
- CPDF_Array* pWidthArray = new CPDF_Array;
- switch (pLogFont->lfCharSet) {
- case CHINESEBIG5_CHARSET:
- cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
- ordering = "CNS1";
- supplement = 4;
- pWidthArray->AddInteger(1);
- _InsertWidthArray(hDC, 0x20, 0x7e, pWidthArray);
- break;
- case GB2312_CHARSET:
- cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
- ordering = "GB1", supplement = 2;
- pWidthArray->AddInteger(7716);
- _InsertWidthArray(hDC, 0x20, 0x20, pWidthArray);
- pWidthArray->AddInteger(814);
- _InsertWidthArray(hDC, 0x21, 0x7e, pWidthArray);
- break;
- case HANGEUL_CHARSET:
- cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
- ordering = "Korea1";
- supplement = 2;
- pWidthArray->AddInteger(1);
- _InsertWidthArray(hDC, 0x20, 0x7e, pWidthArray);
- break;
- case SHIFTJIS_CHARSET:
- cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
- ordering = "Japan1";
- supplement = 5;
- pWidthArray->AddInteger(231);
- _InsertWidthArray(hDC, 0x20, 0x7d, pWidthArray);
- pWidthArray->AddInteger(326);
- _InsertWidthArray(hDC, 0xa0, 0xa0, pWidthArray);
- pWidthArray->AddInteger(327);
- _InsertWidthArray(hDC, 0xa1, 0xdf, pWidthArray);
- pWidthArray->AddInteger(631);
- _InsertWidthArray(hDC, 0x7e, 0x7e, pWidthArray);
- break;
- }
- pBaseDict->SetAtName("Subtype", "Type0");
- pBaseDict->SetAtName("BaseFont", basefont);
- pBaseDict->SetAtName("Encoding", cmap);
- pFontDict->SetAt("W", pWidthArray);
- pFontDict->SetAtName("Type", "Font");
- pFontDict->SetAtName("Subtype", "CIDFontType2");
- pFontDict->SetAtName("BaseFont", basefont);
- CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary;
- pCIDSysInfo->SetAtString("Registry", "Adobe");
- pCIDSysInfo->SetAtString("Ordering", ordering);
- pCIDSysInfo->SetAtInteger("Supplement", supplement);
- pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
- CPDF_Array* pArray = new CPDF_Array;
- pBaseDict->SetAt("DescendantFonts", pArray);
- AddIndirectObject(pFontDict);
- pArray->AddReference(this, pFontDict);
- }
- AddIndirectObject(pBaseDict);
- CPDF_Dictionary* pFontDesc = new CPDF_Dictionary;
- pFontDesc->SetAtName("Type", "FontDescriptor");
- pFontDesc->SetAtName("FontName", basefont);
- pFontDesc->SetAtInteger("Flags", flags);
- CPDF_Array* pBBox = new CPDF_Array;
- for (int i = 0; i < 4; i++) {
- pBBox->AddInteger(bbox[i]);
- }
- pFontDesc->SetAt("FontBBox", pBBox);
- pFontDesc->SetAtInteger("ItalicAngle", italicangle);
- pFontDesc->SetAtInteger("Ascent", ascend);
- pFontDesc->SetAtInteger("Descent", descend);
- pFontDesc->SetAtInteger("CapHeight", capheight);
- pFontDesc->SetAtInteger("StemV", pLogFont->lfWeight / 5);
- AddIndirectObject(pFontDesc);
- pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
- hFont = SelectObject(hDC, hFont);
- DeleteObject(hFont);
- DeleteDC(hDC);
- return LoadFont(pBaseDict);
-}
-#endif
-
-#if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_)
-uint32_t FX_GetLangHashCode(const FX_CHAR* pStr) {
- FXSYS_assert(pStr);
- int32_t iLength = FXSYS_strlen(pStr);
- const FX_CHAR* pStrEnd = pStr + iLength;
- uint32_t uHashCode = 0;
- while (pStr < pStrEnd) {
- uHashCode = 31 * uHashCode + tolower(*pStr++);
- }
- return uHashCode;
-}
-struct FX_LANG2CS {
- uint32_t uLang;
- int uCharset;
-} * FX_LPLANG2CS;
-static const FX_LANG2CS gs_FXLang2CharsetTable[] = {
- {3109, 0}, {3121, 178}, {3129, 162}, {3139, 204}, {3141, 204},
- {3166, 0}, {3184, 238}, {3197, 0}, {3201, 0}, {3239, 161},
- {3241, 0}, {3246, 0}, {3247, 186}, {3248, 0}, {3259, 178},
- {3267, 0}, {3273, 0}, {3276, 0}, {3301, 0}, {3310, 1},
- {3325, 177}, {3329, 1}, {3338, 238}, {3341, 238}, {3345, 1},
- {3355, 0}, {3370, 0}, {3371, 0}, {3383, 128}, {3424, 204},
- {3427, 1}, {3428, 129}, {3436, 178}, {3464, 186}, {3466, 186},
- {3486, 204}, {3487, 0}, {3493, 1}, {3494, 0}, {3508, 0},
- {3518, 0}, {3520, 0}, {3569, 1}, {3580, 238}, {3588, 0},
- {3645, 238}, {3651, 204}, {3672, 238}, {3673, 238}, {3678, 238},
- {3679, 238}, {3683, 0}, {3684, 0}, {3693, 1}, {3697, 1},
- {3700, 222}, {3710, 162}, {3734, 204}, {3741, 178}, {3749, 162},
- {3763, 163}, {3886, 134}, {105943, 0}, {106375, 1}, {3923451837, 134},
- {3923451838, 136},
-};
-static uint16_t FX_GetCsFromLangCode(uint32_t uCode) {
- int32_t iStart = 0;
- int32_t iEnd = sizeof(gs_FXLang2CharsetTable) / sizeof(FX_LANG2CS) - 1;
- while (iStart <= iEnd) {
- int32_t iMid = (iStart + iEnd) / 2;
- const FX_LANG2CS& charset = gs_FXLang2CharsetTable[iMid];
- if (uCode == charset.uLang) {
- return charset.uCharset;
- }
- if (uCode < charset.uLang) {
- iEnd = iMid - 1;
- } else {
- iStart = iMid + 1;
- }
- }
- return 0;
-}
-static uint16_t FX_GetCharsetFromLang(const FX_CHAR* pLang, int32_t iLength) {
- FXSYS_assert(pLang);
- if (iLength < 0) {
- iLength = FXSYS_strlen(pLang);
- }
- uint32_t uHash = FX_GetLangHashCode(pLang);
- return FX_GetCsFromLangCode(uHash);
-}
-static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString& dest) {
- SInt32 len = CFStringGetLength(src);
- CFRange range = CFRangeMake(0, len);
- CFIndex used = 0;
- UInt8* pBuffer = (UInt8*)calloc(len + 1, sizeof(UInt8));
- CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len,
- &used);
- dest = (FX_CHAR*)pBuffer;
- free(pBuffer);
-}
-FX_BOOL IsHasCharSet(CFArrayRef languages,
- const CFX_ArrayTemplate<uint32_t>& charSets) {
- int iCount = charSets.GetSize();
- for (int i = 0; i < CFArrayGetCount(languages); ++i) {
- CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i);
- uint32_t CharSet = FX_GetCharsetFromLang(
- CFStringGetCStringPtr(language, kCFStringEncodingMacRoman), -1);
- for (int j = 0; j < iCount; ++j) {
- if (CharSet == charSets[j]) {
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-void FX_GetCharWidth(CTFontRef font, UniChar start, UniChar end, int* width) {
- CGFloat size = CTFontGetSize(font);
- for (; start <= end; ++start) {
- CGGlyph pGlyph = 0;
- CFIndex count = 1;
- CTFontGetGlyphsForCharacters(font, &start, &pGlyph, count);
- CGSize advances;
- CTFontGetAdvancesForGlyphs(font, kCTFontDefaultOrientation, &pGlyph,
- &advances, 1);
- *width = (int)(advances.width / size * 1000);
- width++;
- }
-}
-static void _InsertWidthArray(CTFontRef font,
- int start,
- int end,
- CPDF_Array* pWidthArray) {
- int size = end - start + 1;
- int* widths = FX_Alloc(int, size);
- FX_GetCharWidth(font, start, end, widths);
- int i;
- for (i = 1; i < size; i++)
- if (widths[i] != *widths) {
- break;
- }
- if (i == size) {
- int first = pWidthArray->GetIntegerAt(pWidthArray->GetCount() - 1);
- pWidthArray->AddInteger(first + size - 1);
- pWidthArray->AddInteger(*widths);
- } else {
- CPDF_Array* pWidthArray1 = new CPDF_Array;
- pWidthArray->Add(pWidthArray1);
- for (i = 0; i < size; i++) {
- pWidthArray1->AddInteger(widths[i]);
- }
- }
- FX_Free(widths);
-}
-CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName) {
- CTFontRef font = (CTFontRef)pFont;
- CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font);
- if (!descriptor) {
- return NULL;
- }
- CFX_ByteString basefont;
- FX_BOOL bCJK = FALSE;
- int flags = 0, italicangle = 0, ascend = 0, descend = 0, capheight = 0,
- bbox[4];
- FXSYS_memset(bbox, 0, sizeof(int) * 4);
- CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(
- descriptor, kCTFontLanguagesAttribute);
- if (!languages) {
- CFRelease(descriptor);
- return NULL;
- }
- CFX_ArrayTemplate<uint32_t> charSets;
- charSets.Add(FXFONT_CHINESEBIG5_CHARSET);
- charSets.Add(FXFONT_GB2312_CHARSET);
- charSets.Add(FXFONT_HANGEUL_CHARSET);
- charSets.Add(FXFONT_SHIFTJIS_CHARSET);
- if (IsHasCharSet(languages, charSets)) {
- bCJK = TRUE;
- }
- CFRelease(descriptor);
- CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font);
- if (!traits) {
- CFRelease(languages);
- return NULL;
- }
- CFNumberRef sybolicTrait =
- (CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait);
- CTFontSymbolicTraits trait = 0;
- CFNumberGetValue(sybolicTrait, kCFNumberSInt32Type, &trait);
- if (trait & kCTFontItalicTrait) {
- flags |= PDFFONT_ITALIC;
- }
- if (trait & kCTFontMonoSpaceTrait) {
- flags |= PDFFONT_FIXEDPITCH;
- }
- if (trait & kCTFontModernSerifsClass) {
- flags |= PDFFONT_SERIF;
- }
- if (trait & kCTFontScriptsClass) {
- flags |= PDFFONT_SCRIPT;
- }
- CFNumberRef weightTrait =
- (CFNumberRef)CFDictionaryGetValue(traits, kCTFontWeightTrait);
- Float32 weight = 0;
- CFNumberGetValue(weightTrait, kCFNumberFloat32Type, &weight);
- italicangle = CTFontGetSlantAngle(font);
- ascend = CTFontGetAscent(font);
- descend = CTFontGetDescent(font);
- capheight = CTFontGetCapHeight(font);
- CGRect box = CTFontGetBoundingBox(font);
- bbox[0] = box.origin.x;
- bbox[1] = box.origin.y;
- bbox[2] = box.origin.x + box.size.width;
- bbox[3] = box.origin.y + box.size.height;
- if (bTranslateName && bCJK) {
- CFStringRef postName = CTFontCopyPostScriptName(font);
- _CFString2CFXByteString(postName, basefont);
- CFRelease(postName);
- }
- if (basefont.IsEmpty()) {
- CFStringRef fullName = CTFontCopyFullName(font);
- _CFString2CFXByteString(fullName, basefont);
- CFRelease(fullName);
- }
- basefont.Replace(" ", "");
- CPDF_Dictionary* pBaseDict = new CPDF_Dictionary;
- CPDF_Dictionary* pFontDict = pBaseDict;
- if (!bCJK) {
- charSets.RemoveAll();
- charSets.Add(FXFONT_ANSI_CHARSET);
- charSets.Add(FXFONT_DEFAULT_CHARSET);
- charSets.Add(FXFONT_SYMBOL_CHARSET);
- if (IsHasCharSet(languages, charSets)) {
- charSets.RemoveAll();
- charSets.Add(FXFONT_SYMBOL_CHARSET);
- if (IsHasCharSet(languages, charSets)) {
- flags |= PDFFONT_SYMBOLIC;
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- }
- pBaseDict->SetAtName("Encoding", "WinAnsiEncoding");
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- size_t i;
- for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes);
- i++) {
- charSets.RemoveAll();
- charSets.Add(g_FX_CharsetUnicodes[i].m_Charset);
- if (IsHasCharSet(languages, charSets)) {
- break;
- }
- }
- if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
- CPDF_Dictionary* pEncoding = new CPDF_Dictionary;
- pEncoding->SetAtName("BaseEncoding", "WinAnsiEncoding");
- CPDF_Array* pArray = new CPDF_Array;
- pArray->AddInteger(128);
- const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
- for (int j = 0; j < 128; j++) {
- CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
- if (name.IsEmpty()) {
- pArray->AddName(".notdef");
- } else {
- pArray->AddName(name);
- }
- }
- pEncoding->SetAt("Differences", pArray);
- AddIndirectObject(pEncoding);
- pBaseDict->SetAtReference("Encoding", this, pEncoding);
- }
- }
- if (weight > 0.0 && trait & kCTFontItalicTrait) {
- basefont += ",BoldItalic";
- } else if (weight > 0.0) {
- basefont += ",Bold";
- } else if (trait & kCTFontItalicTrait) {
- basefont += ",Italic";
- }
- pBaseDict->SetAtName("Subtype", "TrueType");
- pBaseDict->SetAtName("BaseFont", basefont);
- pBaseDict->SetAtNumber("FirstChar", 32);
- pBaseDict->SetAtNumber("LastChar", 255);
- int char_widths[224];
- FX_GetCharWidth(font, 32, 255, char_widths);
- CPDF_Array* pWidths = new CPDF_Array;
- for (int i = 0; i < 224; i++) {
- pWidths->AddInteger(char_widths[i]);
- }
- pBaseDict->SetAt("Widths", pWidths);
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- CPDF_Array* pArray = NULL;
- pFontDict = new CPDF_Dictionary;
- CFX_ByteString cmap;
- CFX_ByteString ordering;
- int supplement;
- FX_BOOL bFound = FALSE;
- CPDF_Array* pWidthArray = new CPDF_Array;
- charSets.RemoveAll();
- charSets.Add(FXFONT_CHINESEBIG5_CHARSET);
- if (IsHasCharSet(languages, charSets)) {
- cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
- ordering = "CNS1";
- supplement = 4;
- pWidthArray->AddInteger(1);
- _InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
- bFound = TRUE;
- }
- charSets.RemoveAll();
- charSets.Add(FXFONT_GB2312_CHARSET);
- if (!bFound && IsHasCharSet(languages, charSets)) {
- cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
- ordering = "GB1", supplement = 2;
- pWidthArray->AddInteger(7716);
- _InsertWidthArray(font, 0x20, 0x20, pWidthArray);
- pWidthArray->AddInteger(814);
- _InsertWidthArray(font, 0x21, 0x7e, pWidthArray);
- bFound = TRUE;
- }
- charSets.RemoveAll();
- charSets.Add(FXFONT_HANGEUL_CHARSET);
- if (!bFound && IsHasCharSet(languages, charSets)) {
- cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
- ordering = "Korea1";
- supplement = 2;
- pWidthArray->AddInteger(1);
- _InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
- bFound = TRUE;
- }
- charSets.RemoveAll();
- charSets.Add(FXFONT_SHIFTJIS_CHARSET);
- if (!bFound && IsHasCharSet(languages, charSets)) {
- cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
- ordering = "Japan1";
- supplement = 5;
- pWidthArray->AddInteger(231);
- _InsertWidthArray(font, 0x20, 0x7d, pWidthArray);
- pWidthArray->AddInteger(326);
- _InsertWidthArray(font, 0xa0, 0xa0, pWidthArray);
- pWidthArray->AddInteger(327);
- _InsertWidthArray(font, 0xa1, 0xdf, pWidthArray);
- pWidthArray->AddInteger(631);
- _InsertWidthArray(font, 0x7e, 0x7e, pWidthArray);
- }
- pBaseDict->SetAtName("Subtype", "Type0");
- pBaseDict->SetAtName("BaseFont", basefont);
- pBaseDict->SetAtName("Encoding", cmap);
- pFontDict->SetAt("W", pWidthArray);
- pFontDict->SetAtName("Type", "Font");
- pFontDict->SetAtName("Subtype", "CIDFontType2");
- pFontDict->SetAtName("BaseFont", basefont);
- CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary;
- pCIDSysInfo->SetAtString("Registry", "Adobe");
- pCIDSysInfo->SetAtString("Ordering", ordering);
- pCIDSysInfo->SetAtInteger("Supplement", supplement);
- pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
- pArray = new CPDF_Array;
- pBaseDict->SetAt("DescendantFonts", pArray);
- AddIndirectObject(pFontDict);
- pArray->AddReference(this, pFontDict);
- }
- AddIndirectObject(pBaseDict);
- CPDF_Dictionary* pFontDesc = new CPDF_Dictionary;
- pFontDesc->SetAtName("Type", "FontDescriptor");
- pFontDesc->SetAtName("FontName", basefont);
- pFontDesc->SetAtInteger("Flags", flags);
- CPDF_Array* pBBox = new CPDF_Array;
- for (int i = 0; i < 4; i++) {
- pBBox->AddInteger(bbox[i]);
- }
- pFontDesc->SetAt("FontBBox", pBBox);
- pFontDesc->SetAtInteger("ItalicAngle", italicangle);
- pFontDesc->SetAtInteger("Ascent", ascend);
- pFontDesc->SetAtInteger("Descent", descend);
- pFontDesc->SetAtInteger("CapHeight", capheight);
- CGFloat fStemV = 0;
- int16_t min_width = SHRT_MAX;
-
- static const UniChar stem_chars[] = {'i', 'I', '!', '1'};
- CGGlyph glyphs[FX_ArraySize(stem_chars)];
- CGRect boundingRects[FX_ArraySize(stem_chars)];
-
- const size_t count = FX_ArraySize(stem_chars);
- if (CTFontGetGlyphsForCharacters(font, stem_chars, glyphs, count)) {
- CTFontGetBoundingRectsForGlyphs(font, kCTFontHorizontalOrientation, glyphs,
- boundingRects, count);
- for (size_t i = 0; i < count; i++) {
- int16_t width = boundingRects[i].size.width;
- if (width > 0 && width < min_width) {
- min_width = width;
- fStemV = min_width;
- }
- }
- }
- pFontDesc->SetAtInteger("StemV", fStemV);
- AddIndirectObject(pFontDesc);
- pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
- CFRelease(traits);
- CFRelease(languages);
- return LoadFont(pBaseDict);
-}
-#endif // (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_)
-
-static void _InsertWidthArray1(CFX_Font* pFont,
- CFX_UnicodeEncoding* pEncoding,
- FX_WCHAR start,
- FX_WCHAR end,
- CPDF_Array* pWidthArray) {
- int size = end - start + 1;
- int* widths = FX_Alloc(int, size);
- int i;
- for (i = 0; i < size; i++) {
- int glyph_index = pEncoding->GlyphFromCharCode(start + i);
- widths[i] = pFont->GetGlyphWidth(glyph_index);
- }
- for (i = 1; i < size; i++)
- if (widths[i] != *widths) {
- break;
- }
- if (i == size) {
- int first = pWidthArray->GetIntegerAt(pWidthArray->GetCount() - 1);
- pWidthArray->AddInteger(first + size - 1);
- pWidthArray->AddInteger(*widths);
- } else {
- CPDF_Array* pWidthArray1 = new CPDF_Array;
- pWidthArray->Add(pWidthArray1);
- for (i = 0; i < size; i++) {
- pWidthArray1->AddInteger(widths[i]);
- }
- }
- FX_Free(widths);
-}
-
-CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
- if (!pFont) {
- return NULL;
- }
- bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET ||
- charset == FXFONT_GB2312_CHARSET ||
- charset == FXFONT_HANGEUL_CHARSET ||
- charset == FXFONT_SHIFTJIS_CHARSET;
- CFX_ByteString basefont = pFont->GetFamilyName();
- basefont.Replace(" ", "");
- int flags = 0;
- if (pFont->IsBold()) {
- flags |= PDFFONT_FORCEBOLD;
- }
- if (pFont->IsItalic()) {
- flags |= PDFFONT_ITALIC;
- }
- if (pFont->IsFixedWidth()) {
- flags |= PDFFONT_FIXEDPITCH;
- }
- CPDF_Dictionary* pBaseDict = new CPDF_Dictionary;
- pBaseDict->SetAtName("Type", "Font");
- std::unique_ptr<CFX_UnicodeEncoding> pEncoding(
- new CFX_UnicodeEncoding(pFont));
- CPDF_Dictionary* pFontDict = pBaseDict;
- if (!bCJK) {
- CPDF_Array* pWidths = new CPDF_Array;
- int charcode;
- for (charcode = 32; charcode < 128; charcode++) {
- int glyph_index = pEncoding->GlyphFromCharCode(charcode);
- int char_width = pFont->GetGlyphWidth(glyph_index);
- pWidths->AddInteger(char_width);
- }
- if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET ||
- charset == FXFONT_SYMBOL_CHARSET) {
- if (charset == FXFONT_SYMBOL_CHARSET) {
- flags |= PDFFONT_SYMBOLIC;
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- }
- pBaseDict->SetAtName("Encoding", "WinAnsiEncoding");
- for (charcode = 128; charcode <= 255; charcode++) {
- int glyph_index = pEncoding->GlyphFromCharCode(charcode);
- int char_width = pFont->GetGlyphWidth(glyph_index);
- pWidths->AddInteger(char_width);
- }
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- size_t i;
- for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes);
- i++)
- if (g_FX_CharsetUnicodes[i].m_Charset == charset) {
- break;
- }
- if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
- CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary;
- pEncodingDict->SetAtName("BaseEncoding", "WinAnsiEncoding");
- CPDF_Array* pArray = new CPDF_Array;
- pArray->AddInteger(128);
- const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
- for (int j = 0; j < 128; j++) {
- CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
- if (name.IsEmpty()) {
- pArray->AddName(".notdef");
- } else {
- pArray->AddName(name);
- }
- int glyph_index = pEncoding->GlyphFromCharCode(pUnicodes[j]);
- int char_width = pFont->GetGlyphWidth(glyph_index);
- pWidths->AddInteger(char_width);
- }
- pEncodingDict->SetAt("Differences", pArray);
- AddIndirectObject(pEncodingDict);
- pBaseDict->SetAtReference("Encoding", this, pEncodingDict);
- }
- }
- if (pFont->IsBold() && pFont->IsItalic()) {
- basefont += ",BoldItalic";
- } else if (pFont->IsBold()) {
- basefont += ",Bold";
- } else if (pFont->IsItalic()) {
- basefont += ",Italic";
- }
- pBaseDict->SetAtName("Subtype", "TrueType");
- pBaseDict->SetAtName("BaseFont", basefont);
- pBaseDict->SetAtNumber("FirstChar", 32);
- pBaseDict->SetAtNumber("LastChar", 255);
- pBaseDict->SetAt("Widths", pWidths);
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- pFontDict = new CPDF_Dictionary;
- CFX_ByteString cmap;
- CFX_ByteString ordering;
- int supplement = 0;
- CPDF_Array* pWidthArray = new CPDF_Array;
- switch (charset) {
- case FXFONT_CHINESEBIG5_CHARSET:
- cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
- ordering = "CNS1";
- supplement = 4;
- pWidthArray->AddInteger(1);
- _InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7e, pWidthArray);
- break;
- case FXFONT_GB2312_CHARSET:
- cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
- ordering = "GB1";
- supplement = 2;
- pWidthArray->AddInteger(7716);
- _InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x20, pWidthArray);
- pWidthArray->AddInteger(814);
- _InsertWidthArray1(pFont, pEncoding.get(), 0x21, 0x7e, pWidthArray);
- break;
- case FXFONT_HANGEUL_CHARSET:
- cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
- ordering = "Korea1";
- supplement = 2;
- pWidthArray->AddInteger(1);
- _InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7e, pWidthArray);
- break;
- case FXFONT_SHIFTJIS_CHARSET:
- cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
- ordering = "Japan1";
- supplement = 5;
- pWidthArray->AddInteger(231);
- _InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7d, pWidthArray);
- pWidthArray->AddInteger(326);
- _InsertWidthArray1(pFont, pEncoding.get(), 0xa0, 0xa0, pWidthArray);
- pWidthArray->AddInteger(327);
- _InsertWidthArray1(pFont, pEncoding.get(), 0xa1, 0xdf, pWidthArray);
- pWidthArray->AddInteger(631);
- _InsertWidthArray1(pFont, pEncoding.get(), 0x7e, 0x7e, pWidthArray);
- break;
- }
- pBaseDict->SetAtName("Subtype", "Type0");
- pBaseDict->SetAtName("BaseFont", basefont);
- pBaseDict->SetAtName("Encoding", cmap);
- pFontDict->SetAt("W", pWidthArray);
- pFontDict->SetAtName("Type", "Font");
- pFontDict->SetAtName("Subtype", "CIDFontType2");
- pFontDict->SetAtName("BaseFont", basefont);
- CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary;
- pCIDSysInfo->SetAtString("Registry", "Adobe");
- pCIDSysInfo->SetAtString("Ordering", ordering);
- pCIDSysInfo->SetAtInteger("Supplement", supplement);
- pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
- CPDF_Array* pArray = new CPDF_Array;
- pBaseDict->SetAt("DescendantFonts", pArray);
- AddIndirectObject(pFontDict);
- pArray->AddReference(this, pFontDict);
- }
- AddIndirectObject(pBaseDict);
- CPDF_Dictionary* pFontDesc = new CPDF_Dictionary;
- pFontDesc->SetAtName("Type", "FontDescriptor");
- pFontDesc->SetAtName("FontName", basefont);
- pFontDesc->SetAtInteger("Flags", flags);
- pFontDesc->SetAtInteger(
- "ItalicAngle",
- pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0);
- pFontDesc->SetAtInteger("Ascent", pFont->GetAscent());
- pFontDesc->SetAtInteger("Descent", pFont->GetDescent());
- FX_RECT bbox;
- pFont->GetBBox(bbox);
- CPDF_Array* pBBox = new CPDF_Array;
- pBBox->AddInteger(bbox.left);
- pBBox->AddInteger(bbox.bottom);
- pBBox->AddInteger(bbox.right);
- pBBox->AddInteger(bbox.top);
- pFontDesc->SetAt("FontBBox", pBBox);
- int32_t nStemV = 0;
- if (pFont->GetSubstFont()) {
- nStemV = pFont->GetSubstFont()->m_Weight / 5;
- } else {
- static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'};
- const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]);
- uint32_t glyph = pEncoding->GlyphFromCharCode(stem_chars[0]);
- nStemV = pFont->GetGlyphWidth(glyph);
- for (size_t i = 1; i < count; i++) {
- glyph = pEncoding->GlyphFromCharCode(stem_chars[i]);
- int width = pFont->GetGlyphWidth(glyph);
- if (width > 0 && width < nStemV) {
- nStemV = width;
- }
- }
- }
- pFontDesc->SetAtInteger("StemV", nStemV);
- AddIndirectObject(pFontDesc);
- pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
- return LoadFont(pBaseDict);
-}
-static int InsertDeletePDFPage(CPDF_Document* pDoc,
- CPDF_Dictionary* pPages,
- int nPagesToGo,
- CPDF_Dictionary* pPage,
- FX_BOOL bInsert,
- CFX_ArrayTemplate<CPDF_Dictionary*>& stackList) {
- CPDF_Array* pKidList = pPages->GetArrayBy("Kids");
- if (!pKidList) {
- return -1;
- }
- int nKids = pKidList->GetCount();
- for (int i = 0; i < nKids; i++) {
- CPDF_Dictionary* pKid = pKidList->GetDictAt(i);
- if (pKid->GetStringBy("Type") == "Page") {
- if (nPagesToGo == 0) {
- if (bInsert) {
- pKidList->InsertAt(i, new CPDF_Reference(pDoc, pPage->GetObjNum()));
- pPage->SetAtReference("Parent", pDoc, pPages->GetObjNum());
- } else {
- pKidList->RemoveAt(i);
- }
- pPages->SetAtInteger(
- "Count", pPages->GetIntegerBy("Count") + (bInsert ? 1 : -1));
- return 1;
- }
- nPagesToGo--;
- } else {
- int nPages = pKid->GetIntegerBy("Count");
- if (nPagesToGo < nPages) {
- int stackCount = stackList.GetSize();
- for (int j = 0; j < stackCount; ++j) {
- if (pKid == stackList[j]) {
- return -1;
- }
- }
- stackList.Add(pKid);
- if (InsertDeletePDFPage(pDoc, pKid, nPagesToGo, pPage, bInsert,
- stackList) < 0) {
- return -1;
- }
- stackList.RemoveAt(stackCount);
- pPages->SetAtInteger(
- "Count", pPages->GetIntegerBy("Count") + (bInsert ? 1 : -1));
- return 1;
- }
- nPagesToGo -= nPages;
- }
- }
- return 0;
-}
-static int InsertNewPage(CPDF_Document* pDoc,
- int iPage,
- CPDF_Dictionary* pPageDict,
- CFX_ArrayTemplate<uint32_t>& pageList) {
- CPDF_Dictionary* pRoot = pDoc->GetRoot();
- if (!pRoot) {
- return -1;
- }
- CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages");
- if (!pPages) {
- return -1;
- }
- int nPages = pDoc->GetPageCount();
- if (iPage < 0 || iPage > nPages) {
- return -1;
- }
- if (iPage == nPages) {
- CPDF_Array* pPagesList = pPages->GetArrayBy("Kids");
- if (!pPagesList) {
- pPagesList = new CPDF_Array;
- pPages->SetAt("Kids", pPagesList);
- }
- pPagesList->Add(pPageDict, pDoc);
- pPages->SetAtInteger("Count", nPages + 1);
- pPageDict->SetAtReference("Parent", pDoc, pPages->GetObjNum());
- } else {
- CFX_ArrayTemplate<CPDF_Dictionary*> stack;
- stack.Add(pPages);
- if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, stack) < 0) {
- return -1;
- }
- }
- pageList.InsertAt(iPage, pPageDict->GetObjNum());
- return iPage;
-}
-CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) {
- CPDF_Dictionary* pDict = new CPDF_Dictionary;
- pDict->SetAtName("Type", "Page");
- uint32_t dwObjNum = AddIndirectObject(pDict);
- if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) {
- ReleaseIndirectObject(dwObjNum);
- return NULL;
- }
- return pDict;
-}
-
-CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font,
- CPDF_FontEncoding* pEncoding) {
- CFX_ByteString name(font);
- if (PDF_GetStandardFontName(&name) < 0)
- return nullptr;
- return GetPageData()->GetStandardFont(name.AsByteStringC(), pEncoding);
-}
-
-void CPDF_Document::DeletePage(int iPage) {
- CPDF_Dictionary* pRoot = GetRoot();
- if (!pRoot) {
- return;
- }
- CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages");
- if (!pPages) {
- return;
- }
- int nPages = pPages->GetIntegerBy("Count");
- if (iPage < 0 || iPage >= nPages) {
- return;
- }
- CFX_ArrayTemplate<CPDF_Dictionary*> stack;
- stack.Add(pPages);
- if (InsertDeletePDFPage(this, pPages, iPage, NULL, FALSE, stack) < 0) {
- return;
- }
- m_PageList.RemoveAt(iPage);
-}
-
-void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict,
- const CFX_ByteStringC& name) {
- if (pPageDict->KeyExist(name)) {
- return;
- }
- CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name);
- if (pObj) {
- pPageDict->SetAt(name, pObj->Clone());
- }
-}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_creator.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_creator.h
index d6a1c1079aa..8782c54f861 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_creator.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_creator.h
@@ -7,15 +7,17 @@
#ifndef CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_
#define CORE_FPDFAPI_FPDF_EDIT_INCLUDE_CPDF_CREATOR_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_basic.h"
class CPDF_Array;
+class CPDF_CryptoHandler;
class CPDF_Dictionary;
class CPDF_Document;
class CPDF_Object;
class CPDF_Parser;
class CPDF_XRefStream;
-class IPDF_CryptoHandler;
#define FPDFCREATE_INCREMENTAL 1
#define FPDFCREATE_NO_ORIGINAL 2
@@ -26,7 +28,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj);
class CPDF_Creator {
public:
- CPDF_Creator(CPDF_Document* pDoc);
+ explicit CPDF_Creator(CPDF_Document* pDoc);
~CPDF_Creator();
void RemoveSecurity();
@@ -69,21 +71,19 @@ class CPDF_Creator {
int32_t WriteStream(const CPDF_Object* pStream,
uint32_t objnum,
- IPDF_CryptoHandler* pCrypto);
+ CPDF_CryptoHandler* pCrypto);
- CPDF_Document* m_pDocument;
- CPDF_Parser* m_pParser;
- FX_BOOL m_bCompress;
+ CPDF_Document* const m_pDocument;
+ CPDF_Parser* const m_pParser;
FX_BOOL m_bSecurityChanged;
CPDF_Dictionary* m_pEncryptDict;
- uint32_t m_dwEnryptObjNum;
+ uint32_t m_dwEncryptObjNum;
FX_BOOL m_bEncryptCloned;
- FX_BOOL m_bStandardSecurity;
- IPDF_CryptoHandler* m_pCryptoHandler;
- FX_BOOL m_bNewCrypto;
- FX_BOOL m_bEncryptMetadata;
+ CPDF_CryptoHandler* m_pCryptoHandler;
+ // Whether this owns the crypto handler |m_pCryptoHandler|.
+ FX_BOOL m_bLocalCryptoHandler;
CPDF_Object* m_pMetadata;
- CPDF_XRefStream* m_pXRefStream;
+ std::unique_ptr<CPDF_XRefStream> m_pXRefStream;
int32_t m_ObjectStreamSize;
uint32_t m_dwLastObjNum;
CFX_FileBufferArchive m_File;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h
index 564a9ff54c8..f60b083be12 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h
@@ -32,7 +32,7 @@ class CPDF_PageContentGenerator {
uint32_t size,
CFX_Matrix& matrix);
CFX_ByteString RealizeResource(CPDF_Object* pResourceObj,
- const FX_CHAR* szType);
+ const CFX_ByteString& bsType);
CPDF_Page* m_pPage;
CPDF_Document* m_pDocument;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
index 3329f5c5771..f5405b197f1 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/fpdf_font/font_int.h"
#include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
#include "core/fpdfapi/fpdf_font/ttgsubtable.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
@@ -401,7 +402,8 @@ FX_BOOL CPDF_CIDFont::Load() {
if (m_Charset == CIDSET_UNKNOWN) {
CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDictBy("CIDSystemInfo");
if (pCIDInfo) {
- m_Charset = CharsetFromOrdering(pCIDInfo->GetStringBy("Ordering"));
+ m_Charset =
+ CharsetFromOrdering(pCIDInfo->GetStringBy("Ordering").AsStringC());
}
}
if (m_Charset != CIDSET_UNKNOWN)
@@ -817,8 +819,7 @@ void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray,
int iCurElement = 0;
int first_code = 0;
int last_code = 0;
- uint32_t count = pArray->GetCount();
- for (uint32_t i = 0; i < count; i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
if (!pObj)
continue;
@@ -827,8 +828,7 @@ void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray,
if (width_status != 1)
return;
- uint32_t count = pArray->GetCount();
- for (uint32_t j = 0; j < count; j += nElements) {
+ for (size_t j = 0; j < pArray->GetCount(); j += nElements) {
result.Add(first_code);
result.Add(first_code);
for (int k = 0; k < nElements; k++) {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_font.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_font.cpp
index fd6a9c98145..9fb54a828be 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_font.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_font.cpp
@@ -6,11 +6,14 @@
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
+#include <memory>
+
#include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h"
#include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
#include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
#include "core/fpdfapi/fpdf_font/font_int.h"
#include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
@@ -18,7 +21,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_name.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_freetype.h"
namespace {
@@ -146,7 +149,7 @@ FX_BOOL CPDF_Font::IsVertWriting() const {
}
int CPDF_Font::AppendChar(FX_CHAR* buf, uint32_t charcode) const {
- *buf = (FX_CHAR)charcode;
+ *buf = static_cast<FX_CHAR>(charcode);
return 1;
}
@@ -337,54 +340,30 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc,
CPDF_Font* CPDF_Font::CreateFontF(CPDF_Document* pDoc,
CPDF_Dictionary* pFontDict) {
CFX_ByteString type = pFontDict->GetStringBy("Subtype");
- CPDF_Font* pFont;
+ std::unique_ptr<CPDF_Font> pFont;
if (type == "TrueType") {
- {
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- CFX_ByteString basefont = pFontDict->GetStringBy("BaseFont");
- CFX_ByteString tag = basefont.Left(4);
- int i;
- int count = sizeof(ChineseFontNames) / sizeof(ChineseFontNames[0]);
- for (i = 0; i < count; ++i) {
- if (tag == CFX_ByteString((const FX_CHAR*)ChineseFontNames[i])) {
- break;
- }
- }
- if (i < count) {
+ CFX_ByteString tag = pFontDict->GetStringBy("BaseFont").Left(4);
+ for (size_t i = 0; i < FX_ArraySize(ChineseFontNames); ++i) {
+ if (tag == CFX_ByteString(ChineseFontNames[i], 4)) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDictBy("FontDescriptor");
- if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) {
- pFont = new CPDF_CIDFont;
- pFont->m_pFontDict = pFontDict;
- pFont->m_pDocument = pDoc;
- pFont->m_BaseFont = pFontDict->GetStringBy("BaseFont");
- if (!pFont->Load()) {
- delete pFont;
- return NULL;
- }
- return pFont;
- }
+ if (!pFontDesc || !pFontDesc->KeyExist("FontFile2"))
+ pFont.reset(new CPDF_CIDFont);
+ break;
}
-#endif
}
- pFont = new CPDF_TrueTypeFont;
+ if (!pFont)
+ pFont.reset(new CPDF_TrueTypeFont);
} else if (type == "Type3") {
- pFont = new CPDF_Type3Font;
+ pFont.reset(new CPDF_Type3Font);
} else if (type == "Type0") {
- pFont = new CPDF_CIDFont;
+ pFont.reset(new CPDF_CIDFont);
} else {
- pFont = new CPDF_Type1Font;
+ pFont.reset(new CPDF_Type1Font);
}
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
pFont->m_BaseFont = pFontDict->GetStringBy("BaseFont");
- if (!pFont->Load()) {
- delete pFont;
- return NULL;
- }
- return pFont;
+ return pFont->Load() ? pFont.release() : nullptr;
}
uint32_t CPDF_Font::GetNextChar(const FX_CHAR* pString,
@@ -485,7 +464,7 @@ const FX_CHAR* CPDF_Font::GetAdobeCharName(int iBaseEncoding,
const FX_CHAR* name = nullptr;
if (pCharNames)
- name = pCharNames[charcode];
+ name = pCharNames[charcode].c_str();
if ((!name || name[0] == 0) && iBaseEncoding)
name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
return name && name[0] ? name : nullptr;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp
index 3fc16a2c439..8a280e6ba04 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_fontencoding.cpp
@@ -6,12 +6,12 @@
#include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_name.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_name.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
+#include "core/fxge/include/fx_freetype.h"
namespace {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp
index 53bbd93d6cc..b367184e2e5 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_simplefont.cpp
@@ -9,7 +9,7 @@
#include "core/fpdfapi/fpdf_font/font_int.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_freetype.h"
CPDF_SimpleFont::CPDF_SimpleFont()
: m_pCharNames(nullptr), m_BaseEncoding(PDFFONT_ENCODING_BUILTIN) {
@@ -111,7 +111,6 @@ FX_BOOL CPDF_SimpleFont::LoadCommon() {
LoadFontDescriptor(pFontDesc);
}
CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths");
- int width_start = 0, width_end = -1;
m_bUseFontWidth = TRUE;
if (pWidthArray) {
m_bUseFontWidth = FALSE;
@@ -121,19 +120,15 @@ FX_BOOL CPDF_SimpleFont::LoadCommon() {
m_CharWidth[i] = MissingWidth;
}
}
- width_start = m_pFontDict->GetIntegerBy("FirstChar", 0);
- width_end = m_pFontDict->GetIntegerBy("LastChar", 0);
- if (width_start >= 0 && width_start <= 255) {
- if (width_end <= 0 ||
- width_end >= width_start + (int)pWidthArray->GetCount()) {
+ size_t width_start = m_pFontDict->GetIntegerBy("FirstChar", 0);
+ size_t width_end = m_pFontDict->GetIntegerBy("LastChar", 0);
+ if (width_start <= 255) {
+ if (width_end == 0 || width_end >= width_start + pWidthArray->GetCount())
width_end = width_start + pWidthArray->GetCount() - 1;
- }
- if (width_end > 255) {
+ if (width_end > 255)
width_end = 255;
- }
- for (int i = width_start; i <= width_end; i++) {
+ for (size_t i = width_start; i <= width_end; i++)
m_CharWidth[i] = pWidthArray->GetIntegerAt(i - width_start);
- }
}
}
if (m_pFontFile) {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp
index 032fa00e96a..576b00550e8 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_truetypefont.cpp
@@ -8,7 +8,7 @@
#include "core/fpdfapi/fpdf_font/font_int.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
-#include "core/include/fxge/fx_font.h"
+#include "core/fxge/include/fx_font.h"
CPDF_TrueTypeFont::CPDF_TrueTypeFont() {}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type1font.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type1font.cpp
index 51196246116..5fbc520ae5e 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type1font.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type1font.cpp
@@ -8,7 +8,7 @@
#include "core/fpdfapi/fpdf_font/font_int.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_freetype.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
#include "core/fxge/apple/apple_int.h"
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.cpp
index c9d44435a3e..9bfda99fd17 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.cpp
@@ -10,34 +10,30 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_image.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm)
- : m_pForm(pForm), m_pBitmap(nullptr), m_bColored(FALSE) {}
+ : m_pForm(pForm), m_bColored(FALSE) {}
CPDF_Type3Char::~CPDF_Type3Char() {
- delete m_pForm;
- delete m_pBitmap;
}
FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) {
- if (m_pBitmap || !m_pForm) {
+ if (m_pBitmap || !m_pForm)
return TRUE;
- }
- if (m_pForm->GetPageObjectList()->size() == 1 && !m_bColored) {
- auto& pPageObj = m_pForm->GetPageObjectList()->front();
- if (pPageObj->IsImage()) {
- m_ImageMatrix = pPageObj->AsImage()->m_Matrix;
- const CFX_DIBSource* pSource =
- pPageObj->AsImage()->m_pImage->LoadDIBSource();
- if (pSource) {
- m_pBitmap = pSource->Clone();
- delete pSource;
- }
- delete m_pForm;
- m_pForm = NULL;
- return TRUE;
- }
- }
- return FALSE;
+
+ if (m_pForm->GetPageObjectList()->size() != 1 || m_bColored)
+ return FALSE;
+
+ auto& pPageObj = m_pForm->GetPageObjectList()->front();
+ if (!pPageObj->IsImage())
+ return FALSE;
+
+ m_ImageMatrix = pPageObj->AsImage()->m_Matrix;
+ std::unique_ptr<CFX_DIBSource> pSource(
+ pPageObj->AsImage()->m_pImage->LoadDIBSource());
+ if (pSource)
+ m_pBitmap.reset(pSource->Clone());
+ m_pForm.reset();
+ return TRUE;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.h
index c67620b5f69..7b101d31722 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3char.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_FPDF_FONT_CPDF_TYPE3CHAR_H_
#define CORE_FPDFAPI_FPDF_FONT_CPDF_TYPE3CHAR_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
@@ -22,8 +24,8 @@ class CPDF_Type3Char {
FX_BOOL LoadBitmap(CPDF_RenderContext* pContext);
- CPDF_Form* m_pForm;
- CFX_DIBitmap* m_pBitmap;
+ std::unique_ptr<CPDF_Form> m_pForm;
+ std::unique_ptr<CFX_DIBitmap> m_pBitmap;
FX_BOOL m_bColored;
int m_Width;
CFX_Matrix m_ImageMatrix;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3font.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
index 9f37d4adeec..6c339ea5a72 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/cpdf_type3font.cpp
@@ -57,14 +57,12 @@ FX_BOOL CPDF_Type3Font::Load() {
int StartChar = m_pFontDict->GetIntegerBy("FirstChar");
CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths");
if (pWidthArray && (StartChar >= 0 && StartChar < 256)) {
- uint32_t count = pWidthArray->GetCount();
- if (count > 256) {
+ size_t count = pWidthArray->GetCount();
+ if (count > 256)
count = 256;
- }
- if (StartChar + count > 256) {
+ if (StartChar + count > 256)
count = 256 - StartChar;
- }
- for (uint32_t i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
m_CharWidthL[StartChar + i] =
FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000);
}
@@ -75,7 +73,8 @@ FX_BOOL CPDF_Type3Font::Load() {
LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, FALSE, FALSE);
if (m_pCharNames) {
for (int i = 0; i < 256; i++) {
- m_Encoding.m_Unicodes[i] = PDF_UnicodeFromAdobeName(m_pCharNames[i]);
+ m_Encoding.m_Unicodes[i] =
+ PDF_UnicodeFromAdobeName(m_pCharNames[i].c_str());
if (m_Encoding.m_Unicodes[i] == 0) {
m_Encoding.m_Unicodes[i] = i;
}
@@ -114,8 +113,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) {
// This can trigger recursion into this method. The content of |m_CacheMap|
// can change as a result. Thus after it returns, check the cache again for
// a cache hit.
- pNewChar->m_pForm->ParseContent(nullptr, nullptr, pNewChar.get(), nullptr,
- level + 1);
+ pNewChar->m_pForm->ParseContent(nullptr, nullptr, pNewChar.get(), level + 1);
it = m_CacheMap.find(charcode);
if (it != m_CacheMap.end())
return it->second;
@@ -138,10 +136,8 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode, int level) {
ASSERT(!pdfium::ContainsKey(m_CacheMap, charcode));
CPDF_Type3Char* pCachedChar = pNewChar.release();
m_CacheMap[charcode] = pCachedChar;
- if (pCachedChar->m_pForm->GetPageObjectList()->empty()) {
- delete pCachedChar->m_pForm;
- pCachedChar->m_pForm = nullptr;
- }
+ if (pCachedChar->m_pForm->GetPageObjectList()->empty())
+ pCachedChar->m_pForm.reset();
return pCachedChar;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/font_int.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/font_int.h
index fc69b0cbd9b..792377ebf09 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/font_int.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/font_int.h
@@ -22,7 +22,7 @@ typedef void* FXFT_Library;
short TT2PDF(int m, FXFT_Face face);
FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id);
-CIDSet CharsetFromOrdering(const CFX_ByteString& ordering);
+CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering);
class CPDF_CMapManager {
public:
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font.cpp
index 9670aa8e7f8..9f7b127d60e 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -6,6 +6,7 @@
#include "core/fpdfapi/fpdf_font/font_int.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
@@ -17,7 +18,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_ext.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_freetype.h"
#include "third_party/base/stl_util.h"
FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) {
@@ -131,20 +132,19 @@ uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) {
// Static.
uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) {
- const FX_CHAR* buf = str.c_str();
int len = str.GetLength();
if (len == 0)
return 0;
int result = 0;
- if (buf[0] == '<') {
- for (int i = 1; i < len && std::isxdigit(buf[i]); ++i)
- result = result * 16 + FXSYS_toHexDigit(buf[i]);
+ if (str[0] == '<') {
+ for (int i = 1; i < len && std::isxdigit(str[i]); ++i)
+ result = result * 16 + FXSYS_toHexDigit(str.CharAt(i));
return result;
}
- for (int i = 0; i < len && std::isdigit(buf[i]); ++i)
- result = result * 10 + FXSYS_toDecimalDigit(buf[i]);
+ for (int i = 0; i < len && std::isdigit(str[i]); ++i)
+ result = result * 10 + FXSYS_toDecimalDigit(str.CharAt(i));
return result;
}
@@ -171,17 +171,16 @@ static CFX_WideString StringDataAdd(CFX_WideString str) {
// Static.
CFX_WideString CPDF_ToUnicodeMap::StringToWideString(
const CFX_ByteStringC& str) {
- const FX_CHAR* buf = str.c_str();
int len = str.GetLength();
if (len == 0)
return CFX_WideString();
CFX_WideString result;
- if (buf[0] == '<') {
+ if (str[0] == '<') {
int byte_pos = 0;
FX_WCHAR ch = 0;
- for (int i = 1; i < len && std::isxdigit(buf[i]); ++i) {
- ch = ch * 16 + FXSYS_toHexDigit(buf[i]);
+ for (int i = 1; i < len && std::isxdigit(str[i]); ++i) {
+ ch = ch * 16 + FXSYS_toHexDigit(str[i]);
byte_pos++;
if (byte_pos == 4) {
result += ch;
@@ -233,17 +232,17 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
break;
}
high = parser.GetWord();
- uint32_t lowcode = StringToCode(low.AsByteStringC());
- uint32_t highcode = (lowcode & 0xffffff00) |
- (StringToCode(high.AsByteStringC()) & 0xff);
+ uint32_t lowcode = StringToCode(low.AsStringC());
+ uint32_t highcode =
+ (lowcode & 0xffffff00) | (StringToCode(high.AsStringC()) & 0xff);
if (highcode == (uint32_t)-1) {
break;
}
- CFX_ByteString start = parser.GetWord();
+ CFX_ByteString start(parser.GetWord());
if (start == "[") {
for (uint32_t code = lowcode; code <= highcode; code++) {
- CFX_ByteString dest = parser.GetWord();
- CFX_WideString destcode = StringToWideString(dest.AsByteStringC());
+ CFX_ByteString dest(parser.GetWord());
+ CFX_WideString destcode = StringToWideString(dest.AsStringC());
int len = destcode.GetLength();
if (len == 0) {
continue;
@@ -258,11 +257,11 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
}
parser.GetWord();
} else {
- CFX_WideString destcode = StringToWideString(start.AsByteStringC());
+ CFX_WideString destcode = StringToWideString(start.AsStringC());
int len = destcode.GetLength();
uint32_t value = 0;
if (len == 1) {
- value = StringToCode(start.AsByteStringC());
+ value = StringToCode(start.AsStringC());
for (uint32_t code = lowcode; code <= highcode; code++) {
m_Map[code] = value++;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index fb3707f498b..01a0f6cbdd4 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -13,8 +13,8 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_ext.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge.h"
namespace {
@@ -190,8 +190,10 @@ CIDSet CIDSetFromSizeT(size_t index) {
return static_cast<CIDSet>(index);
}
-CFX_ByteString CMap_GetString(const CFX_ByteStringC& word) {
- return word.Mid(1, word.GetLength() - 2);
+CFX_ByteStringC CMap_GetString(const CFX_ByteStringC& word) {
+ if (word.GetLength() <= 2)
+ return CFX_ByteStringC();
+ return CFX_ByteStringC(&word[1], word.GetLength() - 2);
}
int CompareDWORD(const void* data1, const void* data2) {
@@ -304,7 +306,7 @@ CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name,
CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name,
FX_BOOL bPromptCJK) {
CPDF_CMap* pCMap = new CPDF_CMap;
- const FX_CHAR* pname = name;
+ const FX_CHAR* pname = name.c_str();
if (*pname == '/') {
pname++;
}
@@ -315,7 +317,7 @@ CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name,
void CPDF_CMapManager::ReloadAll() {
for (const auto& pair : m_CMaps) {
CPDF_CMap* pCMap = pair.second;
- pCMap->LoadPredefined(this, pair.first, FALSE);
+ pCMap->LoadPredefined(this, pair.first.c_str(), FALSE);
}
for (size_t i = 0; i < FX_ArraySize(m_CID2UnicodeMaps); ++i) {
if (CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i]) {
@@ -407,13 +409,11 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) {
}
m_CodeSeq = 0;
} else if (m_Status == 3) {
- CMap_GetString(word);
m_Status = 0;
} else if (m_Status == 4) {
m_pCMap->m_Charset = CharsetFromOrdering(CMap_GetString(word));
m_Status = 0;
} else if (m_Status == 5) {
- CMap_GetCode(word);
m_Status = 0;
} else if (m_Status == 6) {
m_pCMap->m_bVertical = CMap_GetCode(word);
@@ -440,7 +440,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) {
}
if (m_CodeSeq % 2) {
CMap_CodeRange range;
- if (CMap_GetCodeRange(range, m_LastWord.AsByteStringC(), word)) {
+ if (CMap_GetCodeRange(range, m_LastWord.AsStringC(), word)) {
m_CodeRanges.Add(range);
}
}
@@ -788,9 +788,9 @@ void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr,
FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount);
}
-CIDSet CharsetFromOrdering(const CFX_ByteString& ordering) {
+CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) {
for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) {
- if (ordering == CFX_ByteStringC(g_CharsetNames[charset]))
+ if (ordering == g_CharsetNames[charset])
return CIDSetFromSizeT(charset);
}
return CIDSET_UNKNOWN;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/include/cpdf_font.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/include/cpdf_font.h
index 79456aa7a5a..81518408e70 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/include/cpdf_font.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/include/cpdf_font.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_font.h"
+#include "core/fxge/include/fx_font.h"
#define PDFFONT_FIXEDPITCH 1
#define PDFFONT_SERIF 2
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.cpp
index bb1a6f9f22e..f6d6400f471 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.cpp
@@ -8,8 +8,8 @@
#include <memory>
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge.h"
#include "third_party/base/stl_util.h"
CFX_GlyphMap::CFX_GlyphMap() {}
@@ -382,34 +382,3 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw,
rec->Substitute[i] = GetUInt16(sp);
}
}
-FX_BOOL CFX_GSUBTable::GetVerticalGlyph(uint32_t glyphnum,
- uint32_t* vglyphnum) {
- return m_GsubImp.GetVerticalGlyph(glyphnum, vglyphnum);
-}
-// static
-IFX_GSUBTable* IFX_GSUBTable::Create(CFX_Font* pFont) {
- if (!pFont) {
- return NULL;
- }
- if (!pFont->GetSubData()) {
- unsigned long length = 0;
- int error = FXFT_Load_Sfnt_Table(
- pFont->GetFace(), FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, NULL, &length);
- if (!error) {
- pFont->SetSubData(FX_Alloc(uint8_t, length));
- }
- if (!pFont->GetSubData()) {
- return NULL;
- }
- }
- int error =
- FXFT_Load_Sfnt_Table(pFont->GetFace(), FT_MAKE_TAG('G', 'S', 'U', 'B'), 0,
- pFont->GetSubData(), NULL);
- if (!error && pFont->GetSubData()) {
- std::unique_ptr<CFX_GSUBTable> pGsubTable(new CFX_GSUBTable);
- if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->GetSubData())) {
- return pGsubTable.release();
- }
- }
- return NULL;
-}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.h
index 56f3fc01eab..0ef23513367 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_font/ttgsubtable.h
@@ -12,8 +12,8 @@
#include <map>
#include "core/fxcrt/include/fx_basic.h"
-#include "core/include/fxge/fx_font.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_font.h"
+#include "core/fxge/include/fx_freetype.h"
class CFX_GlyphMap {
public:
@@ -25,6 +25,7 @@ class CFX_GlyphMap {
protected:
CFX_BinaryBuf m_Buffer;
};
+
class CFX_CTTGSUBTable {
public:
CFX_CTTGSUBTable(void) : m_bFeautureMapLoad(FALSE), loaded(false) {}
@@ -352,12 +353,5 @@ class CFX_CTTGSUBTable {
struct TFeatureList FeatureList;
struct TLookupList LookupList;
};
-class CFX_GSUBTable final : public IFX_GSUBTable {
- public:
- ~CFX_GSUBTable() override {}
- FX_BOOL GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum) override;
-
- CFX_CTTGSUBTable m_GsubImp;
-};
#endif // CORE_FPDFAPI_FPDF_FONT_TTGSUBTABLE_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
index d81a488d207..4fe52832519 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
@@ -46,10 +46,9 @@ void CPDF_AllStates::SetLineDash(CPDF_Array* pArray,
FX_FLOAT scale) {
CFX_GraphStateData* pData = m_GraphState.GetModify();
pData->m_DashPhase = phase * scale;
- pData->SetDashCount(pArray->GetCount());
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
+ pData->SetDashCount(static_cast<int>(pArray->GetCount()));
+ for (size_t i = 0; i < pArray->GetCount(); i++)
pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale;
- }
}
void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
@@ -115,7 +114,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
CFX_ByteString mode =
pArray ? pArray->GetStringAt(0) : pObject->GetString();
- pGeneralState->SetBlendMode(mode.AsByteStringC());
+ pGeneralState->SetBlendMode(mode.AsStringC());
if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) {
pParser->GetPageObjectHolder()->SetBackgroundAlphaNeeded(TRUE);
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_color.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_color.cpp
index d174660d4a2..e6fe3e88e9a 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_color.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_color.cpp
@@ -11,24 +11,17 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fxcrt/include/fx_system.h"
-CPDF_Color::CPDF_Color(int family) {
- m_pCS = CPDF_ColorSpace::GetStockCS(family);
- int nComps = 3;
- if (family == PDFCS_DEVICEGRAY)
- nComps = 1;
- else if (family == PDFCS_DEVICECMYK)
- nComps = 4;
-
- m_pBuffer = FX_Alloc(FX_FLOAT, nComps);
- for (int i = 0; i < nComps; i++)
- m_pBuffer[i] = 0;
-}
+CPDF_Color::CPDF_Color() : m_pCS(nullptr), m_pBuffer(nullptr) {}
CPDF_Color::~CPDF_Color() {
ReleaseBuffer();
ReleaseColorSpace();
}
+bool CPDF_Color::IsPattern() const {
+ return m_pCS && m_pCS->GetFamily() == PDFCS_PATTERN;
+}
+
void CPDF_Color::ReleaseBuffer() {
if (!m_pBuffer)
return;
@@ -37,10 +30,10 @@ void CPDF_Color::ReleaseBuffer() {
PatternValue* pvalue = (PatternValue*)m_pBuffer;
CPDF_Pattern* pPattern =
pvalue->m_pCountedPattern ? pvalue->m_pCountedPattern->get() : nullptr;
- if (pPattern && pPattern->m_pDocument) {
- CPDF_DocPageData* pPageData = pPattern->m_pDocument->GetPageData();
+ if (pPattern && pPattern->document()) {
+ CPDF_DocPageData* pPageData = pPattern->document()->GetPageData();
if (pPageData)
- pPageData->ReleasePattern(pPattern->m_pPatternObj);
+ pPageData->ReleasePattern(pPattern->pattern_obj());
}
}
FX_Free(m_pBuffer);
@@ -84,7 +77,7 @@ void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) {
if (ncomps > MAX_PATTERN_COLORCOMPS)
return;
- if (!m_pCS || m_pCS->GetFamily() != PDFCS_PATTERN) {
+ if (!IsPattern()) {
FX_Free(m_pBuffer);
m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN);
m_pBuffer = m_pCS->CreateBuf();
@@ -92,10 +85,10 @@ void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) {
CPDF_DocPageData* pDocPageData = nullptr;
PatternValue* pvalue = (PatternValue*)m_pBuffer;
- if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) {
- pDocPageData = pvalue->m_pPattern->m_pDocument->GetPageData();
+ if (pvalue->m_pPattern && pvalue->m_pPattern->document()) {
+ pDocPageData = pvalue->m_pPattern->document()->GetPageData();
if (pDocPageData)
- pDocPageData->ReleasePattern(pvalue->m_pPattern->m_pPatternObj);
+ pDocPageData->ReleasePattern(pvalue->m_pPattern->pattern_obj());
}
pvalue->m_nComps = ncomps;
pvalue->m_pPattern = pPattern;
@@ -103,12 +96,12 @@ void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) {
FXSYS_memcpy(pvalue->m_Comps, comps, ncomps * sizeof(FX_FLOAT));
pvalue->m_pCountedPattern = nullptr;
- if (pPattern && pPattern->m_pDocument) {
+ if (pPattern && pPattern->document()) {
if (!pDocPageData)
- pDocPageData = pPattern->m_pDocument->GetPageData();
+ pDocPageData = pPattern->document()->GetPageData();
pvalue->m_pCountedPattern =
- pDocPageData->FindPatternPtr(pPattern->m_pPatternObj);
+ pDocPageData->FindPatternPtr(pPattern->pattern_obj());
}
}
@@ -127,14 +120,14 @@ void CPDF_Color::Copy(const CPDF_Color* pSrc) {
m_pBuffer = m_pCS->CreateBuf();
FXSYS_memcpy(m_pBuffer, pSrc->m_pBuffer, m_pCS->GetBufSize());
- if (m_pCS->GetFamily() == PDFCS_PATTERN) {
- PatternValue* pvalue = (PatternValue*)m_pBuffer;
- if (pvalue->m_pPattern && pvalue->m_pPattern->m_pDocument) {
- pvalue->m_pPattern =
- pvalue->m_pPattern->m_pDocument->GetPageData()->GetPattern(
- pvalue->m_pPattern->m_pPatternObj, FALSE,
- &pvalue->m_pPattern->m_ParentMatrix);
- }
+ if (m_pCS->GetFamily() != PDFCS_PATTERN)
+ return;
+
+ PatternValue* pValue = reinterpret_cast<PatternValue*>(m_pBuffer);
+ CPDF_Pattern* pPattern = pValue->m_pPattern;
+ if (pPattern && pPattern->document()) {
+ pValue->m_pPattern = pPattern->document()->GetPageData()->GetPattern(
+ pPattern->pattern_obj(), FALSE, pPattern->parent_matrix());
}
}
@@ -159,22 +152,3 @@ CPDF_Pattern* CPDF_Color::GetPattern() const {
PatternValue* pvalue = (PatternValue*)m_pBuffer;
return pvalue->m_pPattern;
}
-
-CPDF_ColorSpace* CPDF_Color::GetPatternCS() const {
- if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN)
- return nullptr;
- return m_pCS->GetBaseCS();
-}
-
-FX_FLOAT* CPDF_Color::GetPatternColor() const {
- if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN)
- return nullptr;
-
- PatternValue* pvalue = (PatternValue*)m_pBuffer;
- return pvalue->m_nComps ? pvalue->m_Comps : nullptr;
-}
-
-FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const {
- return m_pCS && m_pCS == other.m_pCS &&
- FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
-}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
index c5aa5e3905c..77e8c00d202 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
@@ -6,6 +6,7 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
@@ -15,7 +16,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fxcodec/include/fx_codec.h"
namespace {
@@ -472,14 +473,6 @@ void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const {
}
}
-int CPDF_ColorSpace::GetMaxIndex() const {
- if (m_Family != PDFCS_INDEXED) {
- return 0;
- }
- CPDF_IndexedCS* pCS = (CPDF_IndexedCS*)this;
- return pCS->m_MaxIndex;
-}
-
void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf,
const uint8_t* src_buf,
int pixels,
@@ -675,7 +668,7 @@ void CPDF_LabCS::GetDefaultValue(int iComponent,
FX_FLOAT& value,
FX_FLOAT& min,
FX_FLOAT& max) const {
- assert(iComponent < 3);
+ ASSERT(iComponent < 3);
value = 0;
if (iComponent == 0) {
min = 0;
@@ -863,12 +856,14 @@ FX_BOOL CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf,
B = pBuf[2];
return TRUE;
}
- ICodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule();
+ CCodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule();
if (!m_pProfile->m_pTransform || !pIccModule) {
- if (m_pAlterCS) {
+ if (m_pAlterCS)
return m_pAlterCS->GetRGB(pBuf, R, G, B);
- }
- R = G = B = 0.0f;
+
+ R = 0.0f;
+ G = 0.0f;
+ B = 0.0f;
return TRUE;
}
FX_FLOAT rgb[3];
@@ -1029,7 +1024,7 @@ FX_BOOL CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf,
}
CFX_FixedBufGrow<FX_FLOAT, 16> Comps(m_nBaseComponents);
FX_FLOAT* comps = Comps;
- const uint8_t* pTable = m_Table;
+ const uint8_t* pTable = m_Table.raw_str();
for (int i = 0; i < m_nBaseComponents; i++) {
comps[i] =
m_pCompMinMax[i * 2] +
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
index 5c73b28e674..1d422cb061a 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
@@ -8,7 +8,7 @@
#include "core/fpdfapi/fpdf_page/cpdf_pattern.h"
#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
@@ -34,9 +34,9 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
} else if (color.IsNull()) {
color.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
}
- if (color.m_pCS->CountComponents() > nValues) {
+ if (color.GetColorSpace()->CountComponents() > nValues)
return;
- }
+
color.SetValue(pValue);
int R, G, B;
rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
@@ -49,10 +49,11 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
pData->m_FillColor.SetValue(pPattern, pValue, nValues);
int R, G, B;
FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B);
- if (pPattern->m_PatternType == 1 &&
- ((CPDF_TilingPattern*)pPattern)->m_bColored && !ret) {
- pData->m_FillRGB = 0x00BFBFBF;
- return;
+ if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
+ if (!ret && pTilingPattern->colored()) {
+ pData->m_FillRGB = 0x00BFBFBF;
+ return;
+ }
}
pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
}
@@ -64,10 +65,11 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
pData->m_StrokeColor.SetValue(pPattern, pValue, nValues);
int R, G, B;
FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B);
- if (pPattern->m_PatternType == 1 &&
- ((CPDF_TilingPattern*)pPattern)->m_bColored && !ret) {
- pData->m_StrokeRGB = 0x00BFBFBF;
- return;
+ if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
+ if (!ret && pTilingPattern->colored()) {
+ pData->m_StrokeRGB = 0x00BFBFBF;
+ return;
+ }
}
pData->m_StrokeRGB =
pData->m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_countedobject.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_countedobject.h
index da840bec606..e7f4ab6af0e 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_countedobject.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_countedobject.h
@@ -25,7 +25,7 @@ class CPDF_CountedObject {
}
T* get() const { return m_pObj; }
T* AddRef() {
- FXSYS_assert(m_pObj);
+ ASSERT(m_pObj);
++m_nCount;
return m_pObj;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_form.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_form.cpp
index 403baa2482d..570419f58f4 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_form.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_form.cpp
@@ -18,15 +18,13 @@ CPDF_Form::CPDF_Form(CPDF_Document* pDoc,
CPDF_Dictionary* pParentResources) {
m_pDocument = pDoc;
m_pFormStream = pFormStream;
- m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL;
+ m_pFormDict = pFormStream ? pFormStream->GetDict() : nullptr;
m_pResources = m_pFormDict->GetDictBy("Resources");
m_pPageResources = pPageResources;
- if (!m_pResources) {
+ if (!m_pResources)
m_pResources = pParentResources;
- }
- if (!m_pResources) {
+ if (!m_pResources)
m_pResources = pPageResources;
- }
m_Transparency = 0;
LoadTransInfo();
}
@@ -34,26 +32,23 @@ CPDF_Form::CPDF_Form(CPDF_Document* pDoc,
CPDF_Form::~CPDF_Form() {}
void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates,
- CFX_Matrix* pParentMatrix,
+ const CFX_Matrix* pParentMatrix,
CPDF_Type3Char* pType3Char,
- CPDF_ParseOptions* pOptions,
int level) {
- if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) {
+ if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
- }
+
m_pParser.reset(new CPDF_ContentParser);
- m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions,
- level);
+ m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, level);
m_ParseState = CONTENT_PARSING;
}
void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates,
- CFX_Matrix* pParentMatrix,
+ const CFX_Matrix* pParentMatrix,
CPDF_Type3Char* pType3Char,
- CPDF_ParseOptions* pOptions,
int level) {
- StartParse(pGraphicStates, pParentMatrix, pType3Char, pOptions, level);
- ContinueParse(NULL);
+ StartParse(pGraphicStates, pParentMatrix, pType3Char, level);
+ ContinueParse(nullptr);
}
CPDF_Form* CPDF_Form::Clone() const {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_graphstate.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_graphstate.h
index d44d32d31ce..038ed155801 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_graphstate.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_graphstate.h
@@ -7,7 +7,7 @@
#ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_GRAPHSTATE_H_
#define CORE_FPDFAPI_FPDF_PAGE_CPDF_GRAPHSTATE_H_
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
class CPDF_GraphState : public CFX_CountRef<CFX_GraphStateData> {};
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_image.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_image.cpp
index d5c97807e9d..84f6853b580 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_image.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_image.cpp
@@ -6,17 +6,17 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_image.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
-#include "core/include/fxcodec/fx_codec.h"
#include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
-#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
#include "core/fpdfapi/fpdf_render/render_int.h"
+#include "core/fpdfapi/include/cpdf_modulemgr.h"
+#include "core/fxcodec/include/fx_codec.h"
+#include "core/fxge/include/fx_dib.h"
CPDF_Image::CPDF_Image(CPDF_Document* pDoc)
: m_pDIBSource(nullptr),
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_page.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_page.cpp
index dd298f382fa..6b0609ff001 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_page.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_page.cpp
@@ -6,95 +6,59 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
+#include <set>
+
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
-#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/fpdfapi/ipdf_rendermodule.h"
-
-CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict,
- const CFX_ByteStringC& name) {
- int level = 0;
- while (1) {
- CPDF_Object* pObj = pPageDict->GetDirectObjectBy(name);
- if (pObj) {
- return pObj;
- }
- CPDF_Dictionary* pParent = pPageDict->GetDictBy("Parent");
- if (!pParent || pParent == pPageDict) {
- return NULL;
- }
- pPageDict = pParent;
- level++;
- if (level == 1000) {
- return NULL;
- }
- }
-}
+#include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
+#include "third_party/base/stl_util.h"
-CPDF_Page::CPDF_Page() : m_pPageRender(nullptr) {}
-
-CPDF_Page::~CPDF_Page() {
- if (m_pPageRender) {
- IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule();
- pModule->DestroyPageCache(m_pPageRender);
- }
-}
-
-void CPDF_Page::Load(CPDF_Document* pDocument,
+CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
CPDF_Dictionary* pPageDict,
- FX_BOOL bPageCache) {
- m_pDocument = (CPDF_Document*)pDocument;
+ bool bPageCache)
+ : m_PageWidth(100),
+ m_PageHeight(100),
+ m_pPageRender(bPageCache ? new CPDF_PageRenderCache(this) : nullptr) {
m_pFormDict = pPageDict;
- if (bPageCache) {
- m_pPageRender =
- CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this);
- }
- if (!pPageDict) {
- m_PageWidth = m_PageHeight = 100 * 1.0f;
- m_pPageResources = m_pResources = NULL;
+ m_pDocument = pDocument;
+ if (!pPageDict)
return;
- }
+
CPDF_Object* pageAttr = GetPageAttr("Resources");
- m_pResources = pageAttr ? pageAttr->GetDict() : NULL;
+ m_pResources = pageAttr ? pageAttr->GetDict() : nullptr;
m_pPageResources = m_pResources;
CPDF_Object* pRotate = GetPageAttr("Rotate");
- int rotate = 0;
- if (pRotate) {
- rotate = pRotate->GetInteger() / 90 % 4;
- }
- if (rotate < 0) {
+ int rotate = pRotate ? pRotate->GetInteger() / 90 % 4 : 0;
+ if (rotate < 0)
rotate += 4;
- }
+
CPDF_Array* pMediaBox = ToArray(GetPageAttr("MediaBox"));
CFX_FloatRect mediabox;
if (pMediaBox) {
mediabox = pMediaBox->GetRect();
mediabox.Normalize();
}
- if (mediabox.IsEmpty()) {
+ if (mediabox.IsEmpty())
mediabox = CFX_FloatRect(0, 0, 612, 792);
- }
CPDF_Array* pCropBox = ToArray(GetPageAttr("CropBox"));
if (pCropBox) {
m_BBox = pCropBox->GetRect();
m_BBox.Normalize();
}
- if (m_BBox.IsEmpty()) {
+ if (m_BBox.IsEmpty())
m_BBox = mediabox;
- } else {
+ else
m_BBox.Intersect(mediabox);
- }
- if (rotate % 2) {
- m_PageHeight = m_BBox.right - m_BBox.left;
- m_PageWidth = m_BBox.top - m_BBox.bottom;
- } else {
- m_PageWidth = m_BBox.right - m_BBox.left;
- m_PageHeight = m_BBox.top - m_BBox.bottom;
- }
+
+ m_PageWidth = m_BBox.right - m_BBox.left;
+ m_PageHeight = m_BBox.top - m_BBox.bottom;
+ if (rotate % 2)
+ std::swap(m_PageWidth, m_PageHeight);
+
switch (rotate) {
case 0:
m_PageMatrix.Set(1.0f, 0, 0, 1.0f, -m_BBox.left, -m_BBox.bottom);
@@ -109,26 +73,40 @@ void CPDF_Page::Load(CPDF_Document* pDocument,
m_PageMatrix.Set(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left);
break;
}
+
m_Transparency = PDFTRANS_ISOLATED;
LoadTransInfo();
}
-void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions) {
- if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) {
+CPDF_Page::~CPDF_Page() {}
+
+void CPDF_Page::StartParse() {
+ if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
- }
+
m_pParser.reset(new CPDF_ContentParser);
- m_pParser->Start(this, pOptions);
+ m_pParser->Start(this);
m_ParseState = CONTENT_PARSING;
}
-void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions) {
- StartParse(pOptions);
+void CPDF_Page::ParseContent() {
+ StartParse();
ContinueParse(nullptr);
}
-CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteStringC& name) const {
- return FPDFAPI_GetPageAttr(m_pFormDict, name);
+CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const {
+ CPDF_Dictionary* pPageDict = m_pFormDict;
+ std::set<CPDF_Dictionary*> visited;
+ while (1) {
+ visited.insert(pPageDict);
+ if (CPDF_Object* pObj = pPageDict->GetDirectObjectBy(name))
+ return pObj;
+
+ pPageDict = pPageDict->GetDictBy("Parent");
+ if (!pPageDict || pdfium::ContainsKey(visited, pPageDict))
+ break;
+ }
+ return nullptr;
}
void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix,
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp
new file mode 100644
index 00000000000..0d2f5478358
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp
@@ -0,0 +1,19 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
+
+CPDF_ColorSpace* CPDF_PageModule::GetStockCS(int family) {
+ if (family == PDFCS_DEVICEGRAY)
+ return &m_StockGrayCS;
+ if (family == PDFCS_DEVICERGB)
+ return &m_StockRGBCS;
+ if (family == PDFCS_DEVICECMYK)
+ return &m_StockCMYKCS;
+ if (family == PDFCS_PATTERN)
+ return &m_StockPatternCS;
+ return nullptr;
+}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pagemodule.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pagemodule.h
new file mode 100644
index 00000000000..c609de9c583
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pagemodule.h
@@ -0,0 +1,37 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_PAGEMODULE_H_
+#define CORE_FPDFAPI_FPDF_PAGE_CPDF_PAGEMODULE_H_
+
+#include "core/fpdfapi/fpdf_font/font_int.h"
+#include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h"
+#include "core/fpdfapi/fpdf_page/pageint.h"
+
+class CPDF_Document;
+
+class CPDF_PageModule {
+ public:
+ CPDF_PageModule()
+ : m_StockGrayCS(nullptr, PDFCS_DEVICEGRAY),
+ m_StockRGBCS(nullptr, PDFCS_DEVICERGB),
+ m_StockCMYKCS(nullptr, PDFCS_DEVICECMYK),
+ m_StockPatternCS(nullptr) {}
+ ~CPDF_PageModule() {}
+
+ CPDF_FontGlobals* GetFontGlobals() { return &m_FontGlobals; }
+ CPDF_ColorSpace* GetStockCS(int family);
+ void ClearStockFont(CPDF_Document* pDoc) { m_FontGlobals.Clear(pDoc); }
+
+ private:
+ CPDF_FontGlobals m_FontGlobals;
+ CPDF_DeviceCS m_StockGrayCS;
+ CPDF_DeviceCS m_StockRGBCS;
+ CPDF_DeviceCS m_StockCMYKCS;
+ CPDF_PatternCS m_StockPatternCS;
+};
+
+#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PAGEMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_parseoptions.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_parseoptions.h
deleted file mode 100644
index 3d091ab7cf8..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_parseoptions.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_PARSEOPTIONS_H_
-#define CORE_FPDFAPI_FPDF_PAGE_CPDF_PARSEOPTIONS_H_
-
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_ParseOptions {
- public:
- CPDF_ParseOptions();
-
- FX_BOOL m_bTextOnly;
- FX_BOOL m_bMarkedContent;
- FX_BOOL m_bSeparateForm;
- FX_BOOL m_bDecodeInlineImage;
-};
-
-#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PARSEOPTIONS_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.cpp
index fc9d10e7ab9..f8bc9a555fe 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.cpp
@@ -9,13 +9,10 @@
CPDF_Pattern::CPDF_Pattern(PatternType type,
CPDF_Document* pDoc,
CPDF_Object* pObj,
- const CFX_Matrix* pParentMatrix)
+ const CFX_Matrix& parentMatrix)
: m_PatternType(type),
m_pDocument(pDoc),
m_pPatternObj(pObj),
- m_bForceClear(FALSE) {
- if (pParentMatrix)
- m_ParentMatrix = *pParentMatrix;
-}
+ m_ParentMatrix(parentMatrix) {}
CPDF_Pattern::~CPDF_Pattern() {}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.h
index 7f9a33bac9f..983c9eab3f6 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_pattern.h
@@ -12,6 +12,8 @@
class CPDF_Document;
class CPDF_Object;
+class CPDF_ShadingPattern;
+class CPDF_TilingPattern;
class CPDF_Pattern {
public:
@@ -19,21 +21,25 @@ class CPDF_Pattern {
virtual ~CPDF_Pattern();
- void SetForceClear(FX_BOOL bForceClear) { m_bForceClear = bForceClear; }
+ virtual CPDF_TilingPattern* AsTilingPattern() = 0;
+ virtual CPDF_ShadingPattern* AsShadingPattern() = 0;
- const PatternType m_PatternType;
- CPDF_Document* const m_pDocument;
- CPDF_Object* const m_pPatternObj;
- CFX_Matrix m_Pattern2Form;
- CFX_Matrix m_ParentMatrix;
+ CPDF_Document* document() { return m_pDocument; }
+ CPDF_Object* pattern_obj() { return m_pPatternObj; }
+ CFX_Matrix* pattern_to_form() { return &m_Pattern2Form; }
+ const CFX_Matrix& parent_matrix() const { return m_ParentMatrix; }
protected:
CPDF_Pattern(PatternType type,
CPDF_Document* pDoc,
CPDF_Object* pObj,
- const CFX_Matrix* pParentMatrix);
+ const CFX_Matrix& parentMatrix);
- FX_BOOL m_bForceClear;
+ const PatternType m_PatternType;
+ CPDF_Document* const m_pDocument;
+ CPDF_Object* const m_pPatternObj;
+ CFX_Matrix m_Pattern2Form;
+ const CFX_Matrix m_ParentMatrix;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PATTERN_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
index 56dd6d4af42..08581322916 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
@@ -19,12 +19,12 @@ CPDF_ShadingObject* CPDF_ShadingObject::Clone() const {
obj->CopyData(this);
obj->m_pShading = m_pShading;
- if (obj->m_pShading && obj->m_pShading->m_pDocument) {
- CPDF_DocPageData* pDocPageData =
- obj->m_pShading->m_pDocument->GetPageData();
- obj->m_pShading = (CPDF_ShadingPattern*)pDocPageData->GetPattern(
+ if (obj->m_pShading && obj->m_pShading->document()) {
+ CPDF_DocPageData* pDocPageData = obj->m_pShading->document()->GetPageData();
+ CPDF_Pattern* pattern = pDocPageData->GetPattern(
obj->m_pShading->m_pShadingObj, m_pShading->m_bShadingObj,
- &obj->m_pShading->m_ParentMatrix);
+ obj->m_pShading->parent_matrix());
+ obj->m_pShading = pattern ? pattern->AsShadingPattern() : nullptr;
}
obj->m_Matrix = m_Matrix;
return obj;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
index f637a4463c8..b7174b44511 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
@@ -25,7 +25,7 @@ ShadingType ToShadingType(int type) {
CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
FX_BOOL bShading,
- const CFX_Matrix* parentMatrix)
+ const CFX_Matrix& parentMatrix)
: CPDF_Pattern(SHADING,
pDoc,
bShading ? nullptr : pPatternObj,
@@ -40,15 +40,14 @@ CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
m_Pattern2Form = pDict->GetMatrixBy("Matrix");
m_pShadingObj = pDict->GetDirectObjectBy("Shading");
- if (parentMatrix)
- m_Pattern2Form.Concat(*parentMatrix);
+ m_Pattern2Form.Concat(parentMatrix);
}
for (size_t i = 0; i < FX_ArraySize(m_pFunctions); ++i)
m_pFunctions[i] = nullptr;
}
CPDF_ShadingPattern::~CPDF_ShadingPattern() {
- for (int i = 0; i < m_nFuncs; ++i)
+ for (size_t i = 0; i < m_nFuncs; ++i)
delete m_pFunctions[i];
CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->get() : nullptr;
@@ -66,16 +65,16 @@ FX_BOOL CPDF_ShadingPattern::Load() {
return FALSE;
if (m_nFuncs) {
- for (int i = 0; i < m_nFuncs; i++)
+ for (size_t i = 0; i < m_nFuncs; i++)
delete m_pFunctions[i];
m_nFuncs = 0;
}
CPDF_Object* pFunc = pShadingDict->GetDirectObjectBy("Function");
if (pFunc) {
if (CPDF_Array* pArray = pFunc->AsArray()) {
- m_nFuncs = std::min<int>(pArray->GetCount(), 4);
+ m_nFuncs = std::min<size_t>(pArray->GetCount(), 4);
- for (int i = 0; i < m_nFuncs; i++)
+ for (size_t i = 0; i < m_nFuncs; i++)
m_pFunctions[i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i));
} else {
m_pFunctions[0] = CPDF_Function::Load(pFunc);
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
index 55a249a1bcd..1872764a616 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
@@ -12,7 +12,7 @@
#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fxcrt/include/fx_system.h"
-typedef enum {
+enum ShadingType {
kInvalidShading = 0,
kFunctionBasedShading = 1,
kAxialShading = 2,
@@ -22,7 +22,7 @@ typedef enum {
kCoonsPatchMeshShading = 6,
kTensorProductPatchMeshShading = 7,
kMaxShading = 8
-} ShadingType;
+};
class CFX_Matrix;
class CPDF_ColorSpace;
@@ -34,10 +34,13 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
CPDF_ShadingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
FX_BOOL bShading,
- const CFX_Matrix* parentMatrix);
+ const CFX_Matrix& parentMatrix);
~CPDF_ShadingPattern() override;
+ CPDF_TilingPattern* AsTilingPattern() override { return nullptr; }
+ CPDF_ShadingPattern* AsShadingPattern() override { return this; }
+
bool IsMeshShading() const {
return m_ShadingType == kFreeFormGouraudTriangleMeshShading ||
m_ShadingType == kLatticeFormGouraudTriangleMeshShading ||
@@ -56,7 +59,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
CPDF_CountedColorSpace* m_pCountedCS;
CPDF_Function* m_pFunctions[4];
- int m_nFuncs;
+ size_t m_nFuncs;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_SHADINGPATTERN_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_textobject.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
index 444101fb9e0..a3fbbad8b00 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
@@ -142,7 +142,7 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
CPDF_Font* pFont = m_TextState.GetFont();
m_nChars = 0;
for (int i = 0; i < nsegs; ++i) {
- m_nChars += pFont->CountChar(pStrs[i], pStrs[i].GetLength());
+ m_nChars += pFont->CountChar(pStrs[i].c_str(), pStrs[i].GetLength());
}
m_nChars += nsegs - 1;
if (m_nChars > 1) {
@@ -150,8 +150,9 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
int index = 0;
for (int i = 0; i < nsegs; ++i) {
- const FX_CHAR* segment = pStrs[i];
- int offset = 0, len = pStrs[i].GetLength();
+ const FX_CHAR* segment = pStrs[i].c_str();
+ int len = pStrs[i].GetLength();
+ int offset = 0;
while (offset < len) {
m_pCharCodes[index++] = pFont->GetNextChar(segment, len, offset);
}
@@ -163,7 +164,7 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
} else {
int offset = 0;
m_pCharCodes = (uint32_t*)(uintptr_t)pFont->GetNextChar(
- pStrs[0], pStrs[0].GetLength(), offset);
+ pStrs[0].c_str(), pStrs[0].GetLength(), offset);
}
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
index f49ad2b8fbd..0b1eeab9f4c 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
@@ -13,19 +13,15 @@
CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
- const CFX_Matrix* parentMatrix)
+ const CFX_Matrix& parentMatrix)
: CPDF_Pattern(TILING, pDoc, pPatternObj, parentMatrix) {
CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
m_Pattern2Form = pDict->GetMatrixBy("Matrix");
m_bColored = pDict->GetIntegerBy("PaintType") == 1;
- if (parentMatrix)
- m_Pattern2Form.Concat(*parentMatrix);
-
- m_pForm = nullptr;
+ m_Pattern2Form.Concat(parentMatrix);
}
CPDF_TilingPattern::~CPDF_TilingPattern() {
- delete m_pForm;
}
FX_BOOL CPDF_TilingPattern::Load() {
@@ -44,8 +40,8 @@ FX_BOOL CPDF_TilingPattern::Load() {
if (!pStream)
return FALSE;
- m_pForm = new CPDF_Form(m_pDocument, NULL, pStream);
- m_pForm->ParseContent(NULL, &m_ParentMatrix, NULL, NULL);
+ m_pForm.reset(new CPDF_Form(m_pDocument, nullptr, pStream));
+ m_pForm->ParseContent(nullptr, &m_ParentMatrix, nullptr);
m_BBox = pDict->GetRectBy("BBox");
return TRUE;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
index 44446eac91d..3e628103636 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_TILINGPATTERN_H_
#define CORE_FPDFAPI_FPDF_PAGE_CPDF_TILINGPATTERN_H_
+#include <memory>
+
#include "core/fpdfapi/fpdf_page/cpdf_pattern.h"
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
@@ -19,16 +21,26 @@ class CPDF_TilingPattern : public CPDF_Pattern {
public:
CPDF_TilingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
- const CFX_Matrix* parentMatrix);
+ const CFX_Matrix& parentMatrix);
~CPDF_TilingPattern() override;
+ CPDF_TilingPattern* AsTilingPattern() override { return this; }
+ CPDF_ShadingPattern* AsShadingPattern() override { return nullptr; }
+
FX_BOOL Load();
- FX_BOOL m_bColored;
+ bool colored() const { return m_bColored; }
+ const CFX_FloatRect& bbox() const { return m_BBox; }
+ FX_FLOAT x_step() const { return m_XStep; }
+ FX_FLOAT y_step() const { return m_YStep; }
+ CPDF_Form* form() const { return m_pForm.get(); }
+
+ private:
+ bool m_bColored;
CFX_FloatRect m_BBox;
FX_FLOAT m_XStep;
FX_FLOAT m_YStep;
- CPDF_Form* m_pForm;
+ std::unique_ptr<CPDF_Form> m_pForm;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_TILINGPATTERN_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp
index 224602ebc7e..2256fda585e 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_colors.cpp
@@ -17,7 +17,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fxcodec/include/fx_codec.h"
namespace {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp
index 758ce940d29..f8729066747 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_doc.cpp
@@ -9,6 +9,7 @@
#include "core/fdrm/crypto/include/fx_crypt.h"
#include "core/fpdfapi/fpdf_font/cpdf_type1font.h"
#include "core/fpdfapi/fpdf_font/font_int.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
#include "core/fpdfapi/fpdf_page/cpdf_pattern.h"
#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
@@ -18,110 +19,11 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/fpdfapi/ipdf_pagemodule.h"
-
-namespace {
-
-class CPDF_PageModule : public IPDF_PageModule {
- public:
- CPDF_PageModule()
- : m_StockGrayCS(nullptr, PDFCS_DEVICEGRAY),
- m_StockRGBCS(nullptr, PDFCS_DEVICERGB),
- m_StockCMYKCS(nullptr, PDFCS_DEVICECMYK),
- m_StockPatternCS(nullptr) {}
-
- private:
- ~CPDF_PageModule() override {}
-
- CPDF_DocPageData* CreateDocData(CPDF_Document* pDoc) override {
- return new CPDF_DocPageData(pDoc);
- }
-
- void ReleaseDoc(CPDF_Document* pDoc) override;
- void ClearDoc(CPDF_Document* pDoc) override;
-
- CPDF_FontGlobals* GetFontGlobals() override { return &m_FontGlobals; }
-
- void ClearStockFont(CPDF_Document* pDoc) override {
- m_FontGlobals.Clear(pDoc);
- }
-
- CPDF_ColorSpace* GetStockCS(int family) override;
- void NotifyCJKAvailable() override;
-
- CPDF_FontGlobals m_FontGlobals;
- CPDF_DeviceCS m_StockGrayCS;
- CPDF_DeviceCS m_StockRGBCS;
- CPDF_DeviceCS m_StockCMYKCS;
- CPDF_PatternCS m_StockPatternCS;
-};
-
-} // namespace
-
-CPDF_ColorSpace* CPDF_PageModule::GetStockCS(int family) {
- if (family == PDFCS_DEVICEGRAY) {
- return &m_StockGrayCS;
- }
- if (family == PDFCS_DEVICERGB) {
- return &m_StockRGBCS;
- }
- if (family == PDFCS_DEVICECMYK) {
- return &m_StockCMYKCS;
- }
- if (family == PDFCS_PATTERN) {
- return &m_StockPatternCS;
- }
- return NULL;
-}
void CPDF_ModuleMgr::InitPageModule() {
m_pPageModule.reset(new CPDF_PageModule);
}
-void CPDF_PageModule::ReleaseDoc(CPDF_Document* pDoc) {
- delete pDoc->GetPageData();
-}
-void CPDF_PageModule::ClearDoc(CPDF_Document* pDoc) {
- pDoc->GetPageData()->Clear(FALSE);
-}
-void CPDF_PageModule::NotifyCJKAvailable() {
- m_FontGlobals.m_CMapManager.ReloadAll();
-}
-
-CPDF_Font* CPDF_Document::LoadFont(CPDF_Dictionary* pFontDict) {
- ASSERT(pFontDict);
- return GetValidatePageData()->GetFont(pFontDict, FALSE);
-}
-
-CPDF_StreamAcc* CPDF_Document::LoadFontFile(CPDF_Stream* pStream) {
- return GetValidatePageData()->GetFontFileStreamAcc(pStream);
-}
-
-CPDF_ColorSpace* CPDF_Document::LoadColorSpace(CPDF_Object* pCSObj,
- CPDF_Dictionary* pResources) {
- return GetValidatePageData()->GetColorSpace(pCSObj, pResources);
-}
-CPDF_Pattern* CPDF_Document::LoadPattern(CPDF_Object* pPatternObj,
- FX_BOOL bShading,
- const CFX_Matrix* matrix) {
- return GetValidatePageData()->GetPattern(pPatternObj, bShading, matrix);
-}
-CPDF_IccProfile* CPDF_Document::LoadIccProfile(CPDF_Stream* pStream) {
- return GetValidatePageData()->GetIccProfile(pStream);
-}
-CPDF_Image* CPDF_Document::LoadImageF(CPDF_Object* pObj) {
- if (!pObj) {
- return NULL;
- }
- FXSYS_assert(pObj->GetObjNum());
- return GetValidatePageData()->GetImage(pObj);
-}
-void CPDF_Document::RemoveColorSpaceFromPageData(CPDF_Object* pCSObj) {
- if (!pCSObj) {
- return;
- }
- GetPageData()->ReleaseColorSpace(pCSObj);
-}
CPDF_DocPageData::CPDF_DocPageData(CPDF_Document* pPDFDoc)
: m_pPDFDoc(pPDFDoc), m_bForceClear(FALSE) {}
@@ -150,10 +52,8 @@ void CPDF_DocPageData::Clear(FX_BOOL bForceRelease) {
if (!ptData->get())
continue;
- if (bForceRelease || ptData->use_count() < 2) {
- ptData->get()->SetForceClear(bForceRelease);
+ if (bForceRelease || ptData->use_count() < 2)
ptData->clear();
- }
}
for (auto& it : m_FontMap) {
@@ -259,7 +159,7 @@ CPDF_Font* CPDF_DocPageData::GetFont(CPDF_Dictionary* pFontDict,
return fontData->AddRef();
}
-CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteStringC& fontName,
+CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteString& fontName,
CPDF_FontEncoding* pEncoding) {
if (fontName.IsEmpty())
return nullptr;
@@ -326,12 +226,12 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpace(
return nullptr;
if (pCSObj->IsName()) {
- CFX_ByteString name = pCSObj->GetConstString();
+ CFX_ByteString name = pCSObj->GetString();
CPDF_ColorSpace* pCS = CPDF_ColorSpace::ColorspaceFromName(name);
if (!pCS && pResources) {
CPDF_Dictionary* pList = pResources->GetDictBy("ColorSpace");
if (pList) {
- pCSObj = pList->GetDirectObjectBy(name.AsByteStringC());
+ pCSObj = pList->GetDirectObjectBy(name);
return GetColorSpace(pCSObj, nullptr);
}
}
@@ -416,7 +316,7 @@ void CPDF_DocPageData::ReleaseColorSpace(CPDF_Object* pColorSpace) {
CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj,
FX_BOOL bShading,
- const CFX_Matrix* matrix) {
+ const CFX_Matrix& matrix) {
if (!pPatternObj)
return nullptr;
@@ -436,9 +336,9 @@ CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj,
CPDF_Dictionary* pDict = pPatternObj ? pPatternObj->GetDict() : nullptr;
if (pDict) {
int type = pDict->GetIntegerBy("PatternType");
- if (type == 1) {
+ if (type == CPDF_Pattern::TILING) {
pPattern = new CPDF_TilingPattern(m_pPDFDoc, pPatternObj, matrix);
- } else if (type == 2) {
+ } else if (type == CPDF_Pattern::SHADING) {
pPattern =
new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, FALSE, matrix);
}
@@ -525,7 +425,8 @@ CPDF_IccProfile* CPDF_DocPageData::GetIccProfile(
stream.LoadAllData(pIccProfileStream, FALSE);
uint8_t digest[20];
CRYPT_SHA1Generate(stream.GetData(), stream.GetSize(), digest);
- auto hash_it = m_HashProfileMap.find(CFX_ByteStringC(digest, 20));
+ CFX_ByteString bsDigest(digest, 20);
+ auto hash_it = m_HashProfileMap.find(bsDigest);
if (hash_it != m_HashProfileMap.end()) {
auto it_copied_stream = m_IccProfileMap.find(hash_it->second);
return it_copied_stream->second->AddRef();
@@ -534,7 +435,7 @@ CPDF_IccProfile* CPDF_DocPageData::GetIccProfile(
new CPDF_IccProfile(stream.GetData(), stream.GetSize());
CPDF_CountedIccProfile* ipData = new CPDF_CountedIccProfile(pProfile);
m_IccProfileMap[pIccProfileStream] = ipData;
- m_HashProfileMap[CFX_ByteStringC(digest, 20)] = pIccProfileStream;
+ m_HashProfileMap[bsDigest] = pIccProfileStream;
return ipData->AddRef();
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_func.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_func.cpp
index ebd6811da83..31faf6a2d7d 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_func.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_func.cpp
@@ -491,28 +491,40 @@ static uint32_t _GetBits32(const uint8_t* pData, int bitpos, int nbits) {
}
return result;
}
-typedef struct {
- FX_FLOAT encode_max, encode_min;
- int sizes;
-} SampleEncodeInfo;
-typedef struct { FX_FLOAT decode_max, decode_min; } SampleDecodeInfo;
-class CPDF_SampledFunc : public CPDF_Function {
+class CPDF_PSFunc : public CPDF_Function {
public:
- CPDF_SampledFunc();
- ~CPDF_SampledFunc() override;
-
+ CPDF_PSFunc() : CPDF_Function(Type::kType4PostScript) {}
// CPDF_Function
FX_BOOL v_Init(CPDF_Object* pObj) override;
FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
- SampleEncodeInfo* m_pEncodeInfo;
- SampleDecodeInfo* m_pDecodeInfo;
- uint32_t m_nBitsPerSample;
- uint32_t m_SampleMax;
- CPDF_StreamAcc* m_pSampleStream;
+ private:
+ CPDF_PSEngine m_PS;
};
+FX_BOOL CPDF_PSFunc::v_Init(CPDF_Object* pObj) {
+ CPDF_StreamAcc acc;
+ acc.LoadAllData(pObj->AsStream(), FALSE);
+ return m_PS.Parse(reinterpret_cast<const FX_CHAR*>(acc.GetData()),
+ acc.GetSize());
+}
+
+FX_BOOL CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const {
+ CPDF_PSEngine& PS = const_cast<CPDF_PSEngine&>(m_PS);
+ PS.Reset();
+ for (uint32_t i = 0; i < m_nInputs; i++)
+ PS.Push(inputs[i]);
+ PS.Execute();
+ if (PS.GetStackSize() < m_nOutputs)
+ return FALSE;
+ for (uint32_t i = 0; i < m_nOutputs; i++)
+ results[m_nOutputs - i - 1] = PS.Pop();
+ return TRUE;
+}
+
+} // namespace
+
CPDF_SampledFunc::CPDF_SampledFunc() : CPDF_Function(Type::kType0Sampled) {
m_pSampleStream = NULL;
m_pEncodeInfo = NULL;
@@ -524,6 +536,7 @@ CPDF_SampledFunc::~CPDF_SampledFunc() {
FX_Free(m_pEncodeInfo);
FX_Free(m_pDecodeInfo);
}
+
FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
CPDF_Stream* pStream = pObj->AsStream();
if (!pStream)
@@ -541,7 +554,7 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
m_pSampleStream = new CPDF_StreamAcc;
m_pSampleStream->LoadAllData(pStream, FALSE);
m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs);
- FX_SAFE_DWORD nTotalSampleBits = 1;
+ FX_SAFE_UINT32 nTotalSampleBits = 1;
for (uint32_t i = 0; i < m_nInputs; i++) {
m_pEncodeInfo[i].sizes = pSize ? pSize->GetIntegerAt(i) : 0;
if (!pSize && i == 0)
@@ -560,7 +573,7 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
}
nTotalSampleBits *= m_nBitsPerSample;
nTotalSampleBits *= m_nOutputs;
- FX_SAFE_DWORD nTotalSampleBytes = nTotalSampleBits;
+ FX_SAFE_UINT32 nTotalSampleBytes = nTotalSampleBits;
nTotalSampleBytes += 7;
nTotalSampleBytes /= 8;
if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 ||
@@ -579,13 +592,14 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
}
return TRUE;
}
+
FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const {
int pos = 0;
CFX_FixedBufGrow<FX_FLOAT, 16> encoded_input_buf(m_nInputs);
FX_FLOAT* encoded_input = encoded_input_buf;
- CFX_FixedBufGrow<int, 32> int_buf(m_nInputs * 2);
- int* index = int_buf;
- int* blocksize = index + m_nInputs;
+ CFX_FixedBufGrow<uint32_t, 32> int_buf(m_nInputs * 2);
+ uint32_t* index = int_buf;
+ uint32_t* blocksize = index + m_nInputs;
for (uint32_t i = 0; i < m_nInputs; i++) {
if (i == 0)
blocksize[i] = 1;
@@ -594,11 +608,8 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const {
encoded_input[i] = PDF_Interpolate(
inputs[i], m_pDomains[i * 2], m_pDomains[i * 2 + 1],
m_pEncodeInfo[i].encode_min, m_pEncodeInfo[i].encode_max);
- index[i] = (int)encoded_input[i];
- if (index[i] < 0)
- index[i] = 0;
- else if (index[i] > m_pEncodeInfo[i].sizes - 1)
- index[i] = m_pEncodeInfo[i].sizes - 1;
+ index[i] = std::min((uint32_t)std::max(0.f, encoded_input[i]),
+ m_pEncodeInfo[i].sizes - 1);
pos += index[i] * blocksize[i];
}
FX_SAFE_INT32 bits_to_output = m_nOutputs;
@@ -650,37 +661,6 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const {
return TRUE;
}
-class CPDF_PSFunc : public CPDF_Function {
- public:
- // CPDF_Function
- CPDF_PSFunc() : CPDF_Function(Type::kType4PostScript) {}
- FX_BOOL v_Init(CPDF_Object* pObj) override;
- FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
-
- CPDF_PSEngine m_PS;
-};
-
-FX_BOOL CPDF_PSFunc::v_Init(CPDF_Object* pObj) {
- CPDF_Stream* pStream = pObj->AsStream();
- CPDF_StreamAcc acc;
- acc.LoadAllData(pStream, FALSE);
- return m_PS.Parse((const FX_CHAR*)acc.GetData(), acc.GetSize());
-}
-FX_BOOL CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const {
- CPDF_PSEngine& PS = (CPDF_PSEngine&)m_PS;
- PS.Reset();
- for (uint32_t i = 0; i < m_nInputs; i++)
- PS.Push(inputs[i]);
- PS.Execute();
- if (PS.GetStackSize() < m_nOutputs)
- return FALSE;
- for (uint32_t i = 0; i < m_nOutputs; i++)
- results[m_nOutputs - i - 1] = PS.Pop();
- return TRUE;
-}
-
-} // namespace
-
CPDF_ExpIntFunc::CPDF_ExpIntFunc()
: CPDF_Function(Type::kType2ExpotentialInterpolation) {
m_pBeginValues = NULL;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 4f304a3b3b9..8c16d8c41f1 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
#include "core/fpdfapi/fpdf_page/cpdf_allstates.h"
+#include "core/fpdfapi/fpdf_page/cpdf_meshstream.h"
#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_formobject.h"
@@ -33,6 +34,12 @@
namespace {
+const int kSingleCoordinatePair = 1;
+const int kTensorCoordinatePairs = 16;
+const int kCoonsCoordinatePairs = 12;
+const int kSingleColorPerPatch = 1;
+const int kQuadColorsPerPatch = 4;
+
const char kPathOperatorSubpath = 'm';
const char kPathOperatorLine = 'l';
const char kPathOperatorCubicBezier1 = 'c';
@@ -90,6 +97,64 @@ CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPair* table,
: CFX_ByteStringC();
}
+CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
+ ShadingType type,
+ const CFX_Matrix& matrix,
+ CPDF_Function** pFuncs,
+ int nFuncs,
+ CPDF_ColorSpace* pCS) {
+ if (!pStream || !pFuncs || !pCS)
+ return CFX_FloatRect(0, 0, 0, 0);
+
+ CPDF_MeshStream stream;
+ if (!stream.Load(pStream, pFuncs, nFuncs, pCS))
+ return CFX_FloatRect(0, 0, 0, 0);
+
+ CFX_FloatRect rect;
+ bool bStarted = false;
+ bool bGouraud = type == kFreeFormGouraudTriangleMeshShading ||
+ type == kLatticeFormGouraudTriangleMeshShading;
+
+ int point_count = kSingleCoordinatePair;
+ if (type == kTensorProductPatchMeshShading)
+ point_count = kTensorCoordinatePairs;
+ else if (type == kCoonsPatchMeshShading)
+ point_count = kCoonsCoordinatePairs;
+
+ int color_count = kSingleColorPerPatch;
+ if (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading)
+ color_count = kQuadColorsPerPatch;
+
+ while (!stream.m_BitStream.IsEOF()) {
+ uint32_t flag = 0;
+ if (type != kLatticeFormGouraudTriangleMeshShading)
+ flag = stream.GetFlag();
+
+ if (!bGouraud && flag) {
+ point_count -= 4;
+ color_count -= 2;
+ }
+
+ for (int i = 0; i < point_count; i++) {
+ FX_FLOAT x;
+ FX_FLOAT y;
+ stream.GetCoords(x, y);
+ if (bStarted) {
+ rect.UpdateRect(x, y);
+ } else {
+ rect.InitRect(x, y);
+ bStarted = true;
+ }
+ }
+ stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits *
+ color_count);
+ if (bGouraud)
+ stream.m_BitStream.ByteAlign();
+ }
+ rect.Transform(&matrix);
+ return rect;
+}
+
} // namespace
CFX_ByteStringC PDF_FindKeyAbbreviationForTesting(const CFX_ByteStringC& abbr) {
@@ -124,11 +189,10 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
CPDF_Document* pDocument,
CPDF_Dictionary* pPageResources,
CPDF_Dictionary* pParentResources,
- CFX_Matrix* pmtContentToUser,
+ const CFX_Matrix* pmtContentToUser,
CPDF_PageObjectHolder* pObjHolder,
CPDF_Dictionary* pResources,
CFX_FloatRect* pBBox,
- CPDF_ParseOptions* pOptions,
CPDF_AllStates* pStates,
int level)
: m_pDocument(pDocument),
@@ -154,21 +218,14 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
m_bReleaseLastDict(TRUE),
m_bColored(FALSE),
m_bResourceMissing(FALSE) {
- if (pmtContentToUser) {
+ if (pmtContentToUser)
m_mtContentToUser = *pmtContentToUser;
- }
- if (pOptions) {
- m_Options = *pOptions;
- }
- if (!m_pResources) {
+ if (!m_pResources)
m_pResources = m_pParentResources;
- }
- if (!m_pResources) {
+ if (!m_pResources)
m_pResources = m_pPageResources;
- }
- if (pBBox) {
+ if (pBBox)
m_BBox = *pBBox;
- }
if (pStates) {
m_pCurStates->Copy(*pStates);
} else {
@@ -214,18 +271,18 @@ int CPDF_StreamContentParser::GetNextParamPos() {
}
void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) {
+ CFX_ByteStringC bsName(name, len);
int index = GetNextParamPos();
if (len > 32) {
m_ParamBuf[index].m_Type = ContentParam::OBJECT;
- m_ParamBuf[index].m_pObject =
- new CPDF_Name(PDF_NameDecode(CFX_ByteStringC(name, len)));
+ m_ParamBuf[index].m_pObject = new CPDF_Name(PDF_NameDecode(bsName));
} else {
m_ParamBuf[index].m_Type = ContentParam::NAME;
- if (!FXSYS_memchr(name, '#', len)) {
+ if (bsName.Find('#') == -1) {
FXSYS_memcpy(m_ParamBuf[index].m_Name.m_Buffer, name, len);
m_ParamBuf[index].m_Name.m_Len = len;
} else {
- CFX_ByteString str = PDF_NameDecode(CFX_ByteStringC(name, len));
+ CFX_ByteString str = PDF_NameDecode(bsName);
FXSYS_memcpy(m_ParamBuf[index].m_Name.m_Buffer, str.c_str(),
str.GetLength());
m_ParamBuf[index].m_Name.m_Len = str.GetLength();
@@ -329,10 +386,6 @@ FX_FLOAT CPDF_StreamContentParser::GetNumber(uint32_t index) {
return 0;
}
-FX_FLOAT CPDF_StreamContentParser::GetNumber16(uint32_t index) {
- return GetNumber(index);
-}
-
void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj,
FX_BOOL bColor,
FX_BOOL bText,
@@ -492,39 +545,24 @@ void CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) {
}
void CPDF_StreamContentParser::Handle_CloseFillStrokePath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
Handle_ClosePath();
AddPathObject(FXFILL_WINDING, TRUE);
}
void CPDF_StreamContentParser::Handle_FillStrokePath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathObject(FXFILL_WINDING, TRUE);
}
void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE);
AddPathObject(FXFILL_ALTERNATE, TRUE);
}
void CPDF_StreamContentParser::Handle_EOFillStrokePath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathObject(FXFILL_ALTERNATE, TRUE);
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
- if (!m_Options.m_bMarkedContent) {
- return;
- }
CFX_ByteString tag = GetString(1);
CPDF_Object* pProperty = GetObject(0);
if (!pProperty) {
@@ -562,13 +600,13 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1,
m_pSyntax->GetWordSize() - 1);
std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
- m_pSyntax->ReadNextObject());
+ m_pSyntax->ReadNextObject(false, 0));
if (!key.IsEmpty()) {
uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
if (dwObjNum)
- pDict->SetAtReference(key.AsByteStringC(), m_pDocument, dwObjNum);
+ pDict->SetAtReference(key, m_pDocument, dwObjNum);
else
- pDict->SetAt(key.AsByteStringC(), pObj.release());
+ pDict->SetAt(key, pObj.release());
}
}
PDF_ReplaceAbbr(pDict);
@@ -586,8 +624,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
}
}
- CPDF_Stream* pStream = m_pSyntax->ReadInlineStream(
- m_pDocument, pDict, pCSObj, m_Options.m_bDecodeInlineImage);
+ CPDF_Stream* pStream =
+ m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj);
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::EndOfData) {
@@ -601,14 +639,6 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
break;
}
}
- if (m_Options.m_bTextOnly) {
- if (pStream) {
- pStream->Release();
- } else {
- pDict->Release();
- }
- return;
- }
pDict->SetAtName("Subtype", "Image");
CPDF_ImageObject* pImgObj = AddImage(pStream, NULL, TRUE);
if (!pImgObj) {
@@ -621,9 +651,6 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
- if (!m_Options.m_bMarkedContent) {
- return;
- }
CFX_ByteString tag = GetString(0);
m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE);
}
@@ -638,28 +665,20 @@ void CPDF_StreamContentParser::Handle_BeginText() {
}
void CPDF_StreamContentParser::Handle_CurveTo_123() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathPoint(GetNumber(5), GetNumber(4), FXPT_BEZIERTO);
AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO);
AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
}
void CPDF_StreamContentParser::Handle_ConcatMatrix() {
- FX_FLOAT a2 = GetNumber16(5), b2 = GetNumber16(4), c2 = GetNumber16(3),
- d2 = GetNumber16(2);
- FX_FLOAT e2 = GetNumber(1), f2 = GetNumber(0);
- CFX_Matrix new_matrix(a2, b2, c2, d2, e2, f2);
+ CFX_Matrix new_matrix(GetNumber(5), GetNumber(4), GetNumber(3), GetNumber(2),
+ GetNumber(1), GetNumber(0));
new_matrix.Concat(m_pCurStates->m_CTM);
m_pCurStates->m_CTM = new_matrix;
OnChangeTextMatrix();
}
void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
- if (m_Options.m_bTextOnly) {
- return;
- }
CFX_ByteString csname = GetString(0);
CPDF_ColorSpace* pCS = FindColorSpace(csname);
if (!pCS) {
@@ -669,9 +688,6 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
}
void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
- if (m_Options.m_bTextOnly) {
- return;
- }
CFX_ByteString csname = GetString(0);
CPDF_ColorSpace* pCS = FindColorSpace(csname);
if (!pCS) {
@@ -681,13 +697,10 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
}
void CPDF_StreamContentParser::Handle_SetDash() {
- if (m_Options.m_bTextOnly) {
+ CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : nullptr;
+ if (!pArray)
return;
- }
- CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL;
- if (!pArray) {
- return;
- }
+
m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f);
}
@@ -712,38 +725,17 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
return;
}
- if (m_Options.m_bTextOnly) {
- if (!m_pResources)
- return;
-
- CPDF_Dictionary* pList = m_pResources->GetDictBy("XObject");
- if (!pList && m_pPageResources && m_pResources != m_pPageResources)
- pList = m_pPageResources->GetDictBy("XObject");
- if (!pList)
- return;
- CPDF_Reference* pRes =
- ToReference(pList->GetObjectBy(name.AsByteStringC()));
- if (!pRes)
- return;
-
- FX_BOOL bForm;
- if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm)
- return;
- }
-
CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name));
if (!pXObject) {
m_bResourceMissing = TRUE;
return;
}
- CFX_ByteStringC type = pXObject->GetDict()
- ? pXObject->GetDict()->GetConstStringBy("Subtype")
- : CFX_ByteStringC();
+ CFX_ByteString type;
+ if (pXObject->GetDict())
+ type = pXObject->GetDict()->GetStringBy("Subtype");
+
if (type == "Image") {
- if (m_Options.m_bTextOnly) {
- return;
- }
CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE);
m_LastImageName = name;
m_pLastImage = pObj->m_pImage;
@@ -751,44 +743,10 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
m_pObjectHolder->SetHasImageMask(m_pLastImage->IsMask());
} else if (type == "Form") {
AddForm(pXObject);
- } else {
- return;
}
}
void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
- if (!m_Options.m_bSeparateForm) {
- CPDF_Dictionary* pResources = pStream->GetDict()->GetDictBy("Resources");
- CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixBy("Matrix");
- form_matrix.Concat(m_pCurStates->m_CTM);
- CPDF_Array* pBBox = pStream->GetDict()->GetArrayBy("BBox");
- CFX_FloatRect form_bbox;
- CPDF_Path ClipPath;
- if (pBBox) {
- form_bbox = pStream->GetDict()->GetRectBy("BBox");
- ClipPath.New();
- ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right,
- form_bbox.top);
- ClipPath.Transform(&form_matrix);
- form_bbox.Transform(&form_matrix);
- }
- CPDF_StreamContentParser parser(m_pDocument, m_pPageResources, m_pResources,
- &m_mtContentToUser, m_pObjectHolder,
- pResources, &form_bbox, &m_Options,
- m_pCurStates.get(), m_Level + 1);
- parser.m_pCurStates->m_CTM = form_matrix;
- if (ClipPath.NotNull()) {
- parser.m_pCurStates->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING,
- TRUE);
- }
- CPDF_StreamAcc stream;
- stream.LoadAllData(pStream, FALSE);
- if (stream.GetSize() == 0) {
- return;
- }
- parser.Parse(stream.GetData(), stream.GetSize(), 0);
- return;
- }
std::unique_ptr<CPDF_FormObject> pFormObj(new CPDF_FormObject);
pFormObj->m_pForm =
new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_pResources);
@@ -799,7 +757,7 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
status.m_GraphState = m_pCurStates->m_GraphState;
status.m_ColorState = m_pCurStates->m_ColorState;
status.m_TextState = m_pCurStates->m_TextState;
- pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1);
+ pFormObj->m_pForm->ParseContent(&status, nullptr, nullptr, m_Level + 1);
if (!m_pObjectHolder->BackgroundAlphaNeeded() &&
pFormObj->m_pForm->BackgroundAlphaNeeded()) {
m_pObjectHolder->SetBackgroundAlphaNeeded(TRUE);
@@ -843,12 +801,9 @@ void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() {}
void CPDF_StreamContentParser::Handle_EndImage() {}
void CPDF_StreamContentParser::Handle_EndMarkedContent() {
- if (!m_Options.m_bMarkedContent) {
- return;
- }
- if (m_CurContentMark.IsNull()) {
+ if (m_CurContentMark.IsNull())
return;
- }
+
int count = m_CurContentMark.GetObject()->CountItems();
if (count == 1) {
m_CurContentMark.SetNull();
@@ -873,23 +828,14 @@ void CPDF_StreamContentParser::Handle_EndText() {
}
void CPDF_StreamContentParser::Handle_FillPath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathObject(FXFILL_WINDING, FALSE);
}
void CPDF_StreamContentParser::Handle_FillPathOld() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathObject(FXFILL_WINDING, FALSE);
}
void CPDF_StreamContentParser::Handle_EOFillPath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathObject(FXFILL_ALTERNATE, FALSE);
}
@@ -916,9 +862,6 @@ void CPDF_StreamContentParser::Handle_SetExtendGraphState() {
}
void CPDF_StreamContentParser::Handle_ClosePath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
if (m_PathPointCount == 0) {
return;
}
@@ -973,9 +916,6 @@ void CPDF_StreamContentParser::Handle_LineTo() {
if (m_ParamCount != 2)
return;
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathPoint(GetNumber(1), GetNumber(0), FXPT_LINETO);
}
@@ -983,10 +923,6 @@ void CPDF_StreamContentParser::Handle_MoveTo() {
if (m_ParamCount != 2)
return;
- if (m_Options.m_bTextOnly) {
- m_pSyntax->SkipPathObject();
- return;
- }
AddPathPoint(GetNumber(1), GetNumber(0), FXPT_MOVETO);
ParsePathObject();
}
@@ -998,9 +934,6 @@ void CPDF_StreamContentParser::Handle_SetMiterLimit() {
void CPDF_StreamContentParser::Handle_MarkPlace() {}
void CPDF_StreamContentParser::Handle_EndPath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathObject(0, FALSE);
}
@@ -1019,9 +952,6 @@ void CPDF_StreamContentParser::Handle_RestoreGraphState() {
}
void CPDF_StreamContentParser::Handle_Rectangle() {
- if (m_Options.m_bTextOnly) {
- return;
- }
FX_FLOAT x = GetNumber(3), y = GetNumber(2);
FX_FLOAT w = GetNumber(1), h = GetNumber(0);
AddPathRect(x, y, w, h);
@@ -1065,24 +995,15 @@ void CPDF_StreamContentParser::Handle_SetRGBColor_Stroke() {
void CPDF_StreamContentParser::Handle_SetRenderIntent() {}
void CPDF_StreamContentParser::Handle_CloseStrokePath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
Handle_ClosePath();
AddPathObject(0, TRUE);
}
void CPDF_StreamContentParser::Handle_StrokePath() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathObject(0, TRUE);
}
void CPDF_StreamContentParser::Handle_SetColor_Fill() {
- if (m_Options.m_bTextOnly) {
- return;
- }
FX_FLOAT values[4];
int nargs = m_ParamCount;
if (nargs > 4) {
@@ -1095,9 +1016,6 @@ void CPDF_StreamContentParser::Handle_SetColor_Fill() {
}
void CPDF_StreamContentParser::Handle_SetColor_Stroke() {
- if (m_Options.m_bTextOnly) {
- return;
- }
FX_FLOAT values[4];
int nargs = m_ParamCount;
if (nargs > 4) {
@@ -1110,9 +1028,6 @@ void CPDF_StreamContentParser::Handle_SetColor_Stroke() {
}
void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
- if (m_Options.m_bTextOnly) {
- return;
- }
CPDF_Object* pLastParam = GetObject(0);
if (!pLastParam) {
return;
@@ -1129,7 +1044,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
}
}
if (nvalues != nargs) {
- CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE);
+ CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
if (pPattern) {
m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues);
}
@@ -1140,9 +1055,6 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
}
void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
- if (m_Options.m_bTextOnly) {
- return;
- }
CPDF_Object* pLastParam = GetObject(0);
if (!pLastParam) {
return;
@@ -1160,7 +1072,7 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
}
}
if (nvalues != nargs) {
- CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE);
+ CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
if (pPattern) {
m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues);
}
@@ -1170,45 +1082,28 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
FX_Free(values);
}
-CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
- ShadingType type,
- const CFX_Matrix* pMatrix,
- CPDF_Function** pFuncs,
- int nFuncs,
- CPDF_ColorSpace* pCS);
-
void CPDF_StreamContentParser::Handle_ShadeFill() {
- if (m_Options.m_bTextOnly) {
- return;
- }
- CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE);
- if (!pPattern) {
+ CPDF_Pattern* pPattern = FindPattern(GetString(0), true);
+ if (!pPattern)
return;
- }
- if (pPattern->m_PatternType != CPDF_Pattern::SHADING) {
- return;
- }
- CPDF_ShadingPattern* pShading = static_cast<CPDF_ShadingPattern*>(pPattern);
- if (!pShading->m_bShadingObj) {
+
+ CPDF_ShadingPattern* pShading = pPattern->AsShadingPattern();
+ if (!pShading)
return;
- }
- if (!pShading->Load()) {
+
+ if (!pShading->m_bShadingObj || !pShading->Load())
return;
- }
+
std::unique_ptr<CPDF_ShadingObject> pObj(new CPDF_ShadingObject);
pObj->m_pShading = pShading;
SetGraphicStates(pObj.get(), FALSE, FALSE, FALSE);
pObj->m_Matrix = m_pCurStates->m_CTM;
pObj->m_Matrix.Concat(m_mtContentToUser);
- CFX_FloatRect bbox;
- if (!pObj->m_ClipPath.IsNull()) {
- bbox = pObj->m_ClipPath.GetClipBox();
- } else {
- bbox = m_BBox;
- }
+ CFX_FloatRect bbox =
+ pObj->m_ClipPath.IsNull() ? m_BBox : pObj->m_ClipPath.GetClipBox();
if (pShading->IsMeshShading()) {
bbox.Intersect(GetShadingBBox(ToStream(pShading->m_pShadingObj),
- pShading->m_ShadingType, &pObj->m_Matrix,
+ pShading->m_ShadingType, pObj->m_Matrix,
pShading->m_pFunctions, pShading->m_nFuncs,
pShading->m_pCS));
}
@@ -1248,7 +1143,7 @@ void CPDF_StreamContentParser::Handle_SetFont() {
}
CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
- const CFX_ByteStringC& type,
+ const CFX_ByteString& type,
const CFX_ByteString& name) {
if (!m_pResources) {
return NULL;
@@ -1258,7 +1153,7 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
if (!pList) {
return NULL;
}
- CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC());
+ CPDF_Object* pRes = pList->GetDirectObjectBy(name);
return pRes;
}
CPDF_Dictionary* pList = m_pResources->GetDictBy(type);
@@ -1270,10 +1165,10 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
if (!pList) {
return NULL;
}
- CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC());
+ CPDF_Object* pRes = pList->GetDirectObjectBy(name);
return pRes;
}
- CPDF_Object* pRes = pList->GetDirectObjectBy(name.AsByteStringC());
+ CPDF_Object* pRes = pList->GetDirectObjectBy(name);
return pRes;
}
@@ -1321,15 +1216,15 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
}
CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
- FX_BOOL bShading) {
+ bool bShading) {
CPDF_Object* pPattern =
FindResourceObj(bShading ? "Shading" : "Pattern", name);
if (!pPattern || (!pPattern->IsDictionary() && !pPattern->IsStream())) {
m_bResourceMissing = TRUE;
- return NULL;
+ return nullptr;
}
return m_pDocument->LoadPattern(pPattern, bShading,
- &m_pCurStates->m_ParentMatrix);
+ m_pCurStates->m_ParentMatrix);
}
void CPDF_StreamContentParser::ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y) {
@@ -1419,14 +1314,14 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
if (!pArray) {
return;
}
- int n = pArray->GetCount();
- int nsegs = 0;
- for (int i = 0; i < n; i++) {
+ size_t n = pArray->GetCount();
+ size_t nsegs = 0;
+ for (size_t i = 0; i < n; i++) {
if (pArray->GetDirectObjectAt(i)->IsString())
nsegs++;
}
if (nsegs == 0) {
- for (int i = 0; i < n; i++) {
+ for (size_t i = 0; i < n; i++) {
m_pCurStates->m_TextX -=
(pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) /
1000;
@@ -1435,9 +1330,9 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
}
CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
- int iSegment = 0;
+ size_t iSegment = 0;
FX_FLOAT fInitKerning = 0;
- for (int i = 0; i < n; i++) {
+ for (size_t i = 0; i < n; i++) {
CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
if (pObj->IsString()) {
CFX_ByteString str = pObj->GetString();
@@ -1465,8 +1360,8 @@ void CPDF_StreamContentParser::Handle_SetTextLeading() {
}
void CPDF_StreamContentParser::Handle_SetTextMatrix() {
- m_pCurStates->m_TextMatrix.Set(GetNumber16(5), GetNumber16(4), GetNumber16(3),
- GetNumber16(2), GetNumber(1), GetNumber(0));
+ m_pCurStates->m_TextMatrix.Set(GetNumber(5), GetNumber(4), GetNumber(3),
+ GetNumber(2), GetNumber(1), GetNumber(0));
OnChangeTextMatrix();
m_pCurStates->m_TextX = 0;
m_pCurStates->m_TextY = 0;
@@ -1518,9 +1413,6 @@ void CPDF_StreamContentParser::Handle_MoveToNextLine() {
}
void CPDF_StreamContentParser::Handle_CurveTo_23() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_BEZIERTO);
AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO);
AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
@@ -1540,9 +1432,6 @@ void CPDF_StreamContentParser::Handle_EOClip() {
}
void CPDF_StreamContentParser::Handle_CurveTo_13() {
- if (m_Options.m_bTextOnly) {
- return;
- }
AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO);
AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
@@ -1766,7 +1655,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
CPDF_Object* value = it.second;
CFX_ByteStringC fullname =
PDF_FindFullName(PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr),
- key.AsByteStringC());
+ key.AsStringC());
if (!fullname.IsEmpty()) {
AbbrReplacementOp op;
op.is_replace_key = true;
@@ -1780,7 +1669,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
CFX_ByteString name = value->GetString();
fullname = PDF_FindFullName(PDF_InlineValueAbbr,
FX_ArraySize(PDF_InlineValueAbbr),
- name.AsByteStringC());
+ name.AsStringC());
if (!fullname.IsEmpty()) {
AbbrReplacementOp op;
op.is_replace_key = false;
@@ -1794,23 +1683,23 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
}
for (const auto& op : replacements) {
if (op.is_replace_key)
- pDict->ReplaceKey(op.key.AsByteStringC(), op.replacement);
+ pDict->ReplaceKey(op.key, CFX_ByteString(op.replacement));
else
- pDict->SetAtName(op.key.AsByteStringC(), op.replacement);
+ pDict->SetAtName(op.key, CFX_ByteString(op.replacement));
}
break;
}
case CPDF_Object::ARRAY: {
CPDF_Array* pArray = pObj->AsArray();
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pElement = pArray->GetObjectAt(i);
if (pElement->IsName()) {
CFX_ByteString name = pElement->GetString();
CFX_ByteStringC fullname = PDF_FindFullName(
PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr),
- name.AsByteStringC());
+ name.AsStringC());
if (!fullname.IsEmpty()) {
- pArray->SetAt(i, new CPDF_Name(fullname));
+ pArray->SetAt(i, new CPDF_Name(CFX_ByteString(fullname)));
}
} else {
PDF_ReplaceAbbr(pElement);
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index a3c88c00df8..5bac23e1379 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -27,9 +27,17 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcrt/include/fx_ext.h"
#include "core/fxcrt/include/fx_safe_types.h"
-#include "core/include/fxcodec/fx_codec.h"
+
+namespace {
+
+const uint32_t kMaxNestedArrayLevel = 512;
+const uint32_t kMaxWordBuffer = 256;
+const FX_STRSIZE kMaxStringLength = 32767;
+
+} // namespace
CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize) {
m_pBuf = pData;
@@ -44,7 +52,7 @@ CPDF_StreamParser::~CPDF_StreamParser() {
}
}
-uint32_t DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder,
+uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder,
uint8_t*& dest_buf,
uint32_t& dest_size) {
if (!pDecoder) {
@@ -73,7 +81,7 @@ uint32_t DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder,
return srcoff;
}
-ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
+CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
@@ -89,7 +97,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf,
uint8_t*& dest_buf,
uint32_t& dest_size) {
if (decoder == "CCITTFaxDecode" || decoder == "CCF") {
- ICodec_ScanlineDecoder* pDecoder =
+ CCodec_ScanlineDecoder* pDecoder =
FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam);
return DecodeAllScanlines(pDecoder, dest_buf, dest_size);
}
@@ -108,7 +116,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf,
dest_size);
}
if (decoder == "DCTDecode" || decoder == "DCT") {
- ICodec_ScanlineDecoder* pDecoder =
+ CCodec_ScanlineDecoder* pDecoder =
CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(
src_buf, limit, width, height, 0,
pParam ? pParam->GetIntegerBy("ColorTransform", 1) : 1);
@@ -124,8 +132,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf,
CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
CPDF_Dictionary* pDict,
- CPDF_Object* pCSObj,
- FX_BOOL bDecode) {
+ CPDF_Object* pCSObj) {
if (m_Pos == m_Size)
return nullptr;
@@ -199,56 +206,38 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
dwStreamSize =
PDF_DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height,
Decoder, pParam, pData, dwDestSize);
- if ((int)dwStreamSize < 0) {
- FX_Free(pData);
+ FX_Free(pData);
+ if ((int)dwStreamSize < 0)
return NULL;
- }
- if (bDecode) {
- m_Pos += dwStreamSize;
- dwStreamSize = dwDestSize;
- if (CPDF_Array* pArray = pFilter->AsArray()) {
- pArray->RemoveAt(0);
- CPDF_Array* pParams = pDict->GetArrayBy("DecodeParms");
- if (pParams)
- pParams->RemoveAt(0);
- } else {
- pDict->RemoveAt("Filter");
- pDict->RemoveAt("DecodeParms");
- }
- } else {
- FX_Free(pData);
- uint32_t dwSavePos = m_Pos;
- m_Pos += dwStreamSize;
- while (1) {
- uint32_t dwPrevPos = m_Pos;
- CPDF_StreamParser::SyntaxType type = ParseNextElement();
- if (type == CPDF_StreamParser::EndOfData) {
- break;
- }
- if (type != CPDF_StreamParser::Keyword) {
- dwStreamSize += m_Pos - dwPrevPos;
- continue;
- }
- if (GetWordSize() == 2 && GetWordBuf()[0] == 'E' &&
- GetWordBuf()[1] == 'I') {
- m_Pos = dwPrevPos;
- break;
- }
+
+ uint32_t dwSavePos = m_Pos;
+ m_Pos += dwStreamSize;
+ while (1) {
+ uint32_t dwPrevPos = m_Pos;
+ CPDF_StreamParser::SyntaxType type = ParseNextElement();
+ if (type == CPDF_StreamParser::EndOfData)
+ break;
+
+ if (type != CPDF_StreamParser::Keyword) {
dwStreamSize += m_Pos - dwPrevPos;
+ continue;
+ }
+ if (GetWordSize() == 2 && GetWordBuf()[0] == 'E' &&
+ GetWordBuf()[1] == 'I') {
+ m_Pos = dwPrevPos;
+ break;
}
- m_Pos = dwSavePos;
- pData = FX_Alloc(uint8_t, dwStreamSize);
- FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize);
- m_Pos += dwStreamSize;
+ dwStreamSize += m_Pos - dwPrevPos;
}
+ m_Pos = dwSavePos;
+ pData = FX_Alloc(uint8_t, dwStreamSize);
+ FXSYS_memcpy(pData, m_pBuf + m_Pos, dwStreamSize);
+ m_Pos += dwStreamSize;
}
pDict->SetAtInteger("Length", (int)dwStreamSize);
return new CPDF_Stream(pData, dwStreamSize, pDict);
}
-#define MAX_WORD_BUFFER 256
-#define MAX_STRING_LENGTH 32767
-
CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
if (m_pLastObj) {
m_pLastObj->Release();
@@ -284,12 +273,12 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
if (PDFCharIsDelimiter(ch) && ch != '/') {
m_Pos--;
- m_pLastObj = ReadNextObject();
+ m_pLastObj = ReadNextObject(false, 0);
return Others;
}
while (1) {
- if (m_WordSize < MAX_WORD_BUFFER)
+ if (m_WordSize < kMaxWordBuffer)
m_WordBuffer[m_WordSize++] = ch;
if (!PDFCharIsNumeric(ch))
@@ -331,139 +320,90 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
return Keyword;
}
-void CPDF_StreamParser::SkipPathObject() {
- uint32_t command_startpos = m_Pos;
- if (!PositionIsInBounds())
- return;
-
- int ch = m_pBuf[m_Pos++];
- while (1) {
- while (PDFCharIsWhitespace(ch)) {
- if (!PositionIsInBounds())
- return;
- ch = m_pBuf[m_Pos++];
- }
-
- if (!PDFCharIsNumeric(ch)) {
- m_Pos = command_startpos;
- return;
- }
-
- while (1) {
- while (!PDFCharIsWhitespace(ch)) {
- if (!PositionIsInBounds())
- return;
- ch = m_pBuf[m_Pos++];
- }
-
- while (PDFCharIsWhitespace(ch)) {
- if (!PositionIsInBounds())
- return;
- ch = m_pBuf[m_Pos++];
- }
-
- if (PDFCharIsNumeric(ch))
- continue;
-
- uint32_t op_startpos = m_Pos - 1;
- while (!PDFCharIsWhitespace(ch) && !PDFCharIsDelimiter(ch)) {
- if (!PositionIsInBounds())
- return;
- ch = m_pBuf[m_Pos++];
- }
-
- if (IsPathOperator(&m_pBuf[op_startpos], m_Pos - 1 - op_startpos)) {
- command_startpos = m_Pos;
- break;
- }
- m_Pos = command_startpos;
- return;
- }
- }
-}
-
-CPDF_Object* CPDF_StreamParser::ReadNextObject(FX_BOOL bAllowNestedArray,
- FX_BOOL bInArray) {
+CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray,
+ uint32_t dwInArrayLevel) {
FX_BOOL bIsNumber;
GetNextWord(bIsNumber);
- if (m_WordSize == 0) {
- return NULL;
- }
+ if (!m_WordSize)
+ return nullptr;
+
if (bIsNumber) {
m_WordBuffer[m_WordSize] = 0;
return new CPDF_Number(CFX_ByteStringC(m_WordBuffer, m_WordSize));
}
+
int first_char = m_WordBuffer[0];
if (first_char == '/') {
return new CPDF_Name(
PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1)));
}
- if (first_char == '(') {
+
+ if (first_char == '(')
return new CPDF_String(ReadString(), FALSE);
- }
+
if (first_char == '<') {
- if (m_WordSize == 1) {
+ if (m_WordSize == 1)
return new CPDF_String(ReadHexString(), TRUE);
- }
+
CPDF_Dictionary* pDict = new CPDF_Dictionary;
while (1) {
GetNextWord(bIsNumber);
- if (m_WordSize == 0) {
- pDict->Release();
- return nullptr;
- }
- if (m_WordSize == 2 && m_WordBuffer[0] == '>') {
+ if (m_WordSize == 2 && m_WordBuffer[0] == '>')
break;
- }
- if (m_WordBuffer[0] != '/') {
+
+ if (!m_WordSize || m_WordBuffer[0] != '/') {
pDict->Release();
return nullptr;
}
+
CFX_ByteString key =
PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
- CPDF_Object* pObj = ReadNextObject(TRUE);
+ CPDF_Object* pObj = ReadNextObject(true, 0);
if (!pObj) {
pDict->Release();
return nullptr;
}
- if (!key.IsEmpty()) {
- pDict->SetAt(key.AsByteStringC(), pObj);
- } else {
+
+ if (key.IsEmpty())
pObj->Release();
- }
+ else
+ pDict->SetAt(key, pObj);
}
return pDict;
}
+
if (first_char == '[') {
- if (!bAllowNestedArray && bInArray) {
- return NULL;
+ if ((!bAllowNestedArray && dwInArrayLevel) ||
+ dwInArrayLevel > kMaxNestedArrayLevel) {
+ return nullptr;
}
+
CPDF_Array* pArray = new CPDF_Array;
while (1) {
- CPDF_Object* pObj = ReadNextObject(bAllowNestedArray, TRUE);
+ CPDF_Object* pObj = ReadNextObject(bAllowNestedArray, dwInArrayLevel + 1);
if (pObj) {
pArray->Add(pObj);
continue;
}
- if (m_WordSize == 0 || m_WordBuffer[0] == ']')
+ if (!m_WordSize || m_WordBuffer[0] == ']')
break;
}
return pArray;
}
+
+ if (m_WordSize == 5 && !memcmp(m_WordBuffer, "false", 5))
+ return new CPDF_Boolean(FALSE);
+
if (m_WordSize == 4) {
- if (memcmp(m_WordBuffer, "true", 4) == 0) {
+ if (memcmp(m_WordBuffer, "true", 4) == 0)
return new CPDF_Boolean(TRUE);
- }
- if (memcmp(m_WordBuffer, "null", 4) == 0) {
+
+ if (memcmp(m_WordBuffer, "null", 4) == 0)
return new CPDF_Null;
- }
- } else if (m_WordSize == 5) {
- if (memcmp(m_WordBuffer, "false", 5) == 0) {
- return new CPDF_Boolean(FALSE);
- }
}
- return NULL;
+
+ return nullptr;
}
void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) {
@@ -506,7 +446,7 @@ void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) {
return;
}
- if (m_WordSize < MAX_WORD_BUFFER)
+ if (m_WordSize < kMaxWordBuffer)
m_WordBuffer[m_WordSize++] = ch;
}
} else if (ch == '<') {
@@ -530,7 +470,7 @@ void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) {
}
while (1) {
- if (m_WordSize < MAX_WORD_BUFFER)
+ if (m_WordSize < kMaxWordBuffer)
m_WordBuffer[m_WordSize++] = ch;
if (!PDFCharIsNumeric(ch))
bIsNumber = FALSE;
@@ -559,10 +499,10 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
case 0:
if (ch == ')') {
if (parlevel == 0) {
- if (buf.GetLength() > MAX_STRING_LENGTH) {
- return CFX_ByteString(buf.GetBuffer(), MAX_STRING_LENGTH);
+ if (buf.GetLength() > kMaxStringLength) {
+ return CFX_ByteString(buf.GetBuffer(), kMaxStringLength);
}
- return buf.GetByteString();
+ return buf.MakeString();
}
parlevel--;
buf.AppendChar(')');
@@ -638,10 +578,10 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
if (PositionIsInBounds())
++m_Pos;
- if (buf.GetLength() > MAX_STRING_LENGTH) {
- return CFX_ByteString(buf.GetBuffer(), MAX_STRING_LENGTH);
+ if (buf.GetLength() > kMaxStringLength) {
+ return CFX_ByteString(buf.GetBuffer(), kMaxStringLength);
}
- return buf.GetByteString();
+ return buf.MakeString();
}
CFX_ByteString CPDF_StreamParser::ReadHexString() {
@@ -672,10 +612,10 @@ CFX_ByteString CPDF_StreamParser::ReadHexString() {
if (!bFirst)
buf.AppendChar((char)code);
- if (buf.GetLength() > MAX_STRING_LENGTH)
- return CFX_ByteString(buf.GetBuffer(), MAX_STRING_LENGTH);
+ if (buf.GetLength() > kMaxStringLength)
+ return CFX_ByteString(buf.GetBuffer(), kMaxStringLength);
- return buf.GetByteString();
+ return buf.MakeString();
}
bool CPDF_StreamParser::PositionIsInBounds() const {
@@ -697,7 +637,7 @@ CPDF_ContentParser::~CPDF_ContentParser() {
FX_Free(m_pData);
}
-void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) {
+void CPDF_ContentParser::Start(CPDF_Page* pPage) {
if (m_Status != Ready || !pPage || !pPage->m_pDocument ||
!pPage->m_pFormDict) {
m_Status = Done;
@@ -705,9 +645,6 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) {
}
m_pObjectHolder = pPage;
m_bForm = FALSE;
- if (pOptions) {
- m_Options = *pOptions;
- }
m_Status = ToBeContinued;
m_InternalStage = STAGE_GETCONTENT;
m_CurrentOffset = 0;
@@ -734,9 +671,8 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) {
void CPDF_ContentParser::Start(CPDF_Form* pForm,
CPDF_AllStates* pGraphicStates,
- CFX_Matrix* pParentMatrix,
+ const CFX_Matrix* pParentMatrix,
CPDF_Type3Char* pType3Char,
- CPDF_ParseOptions* pOptions,
int level) {
m_pType3Char = pType3Char;
m_pObjectHolder = pForm;
@@ -765,8 +701,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictBy("Resources");
m_pParser.reset(new CPDF_StreamContentParser(
pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources,
- pParentMatrix, pForm, pResources, &form_bbox, pOptions, pGraphicStates,
- level));
+ pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level));
m_pParser->GetCurStates()->m_CTM = form_matrix;
m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
if (ClipPath.NotNull()) {
@@ -797,7 +732,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
if (m_InternalStage == STAGE_GETCONTENT) {
if (m_CurrentOffset == m_nStreams) {
if (!m_StreamArray.empty()) {
- FX_SAFE_DWORD safeSize = 0;
+ FX_SAFE_UINT32 safeSize = 0;
for (const auto& stream : m_StreamArray) {
safeSize += stream->GetSize();
safeSize += 1;
@@ -836,7 +771,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
m_pParser.reset(new CPDF_StreamContentParser(
m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources,
nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
- &m_pObjectHolder->m_BBox, &m_Options, nullptr, 0));
+ &m_pObjectHolder->m_BBox, nullptr, 0));
m_pParser->GetCurStates()->m_ColorState.GetModify()->Default();
}
if (m_CurrentOffset >= m_Size) {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
deleted file mode 100644
index 68ac8c849d7..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fpdfapi/fpdf_page/pageint.h"
-
-#include <algorithm>
-
-#include "core/fpdfapi/fpdf_page/cpdf_meshstream.h"
-#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
-#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
-
-namespace {
-
-const int kSingleCoordinatePair = 1;
-const int kTensorCoordinatePairs = 16;
-const int kCoonsCoordinatePairs = 12;
-
-const int kSingleColorPerPatch = 1;
-const int kQuadColorsPerPatch = 4;
-
-} // namespace
-
-
-
-CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
- ShadingType type,
- const CFX_Matrix* pMatrix,
- CPDF_Function** pFuncs,
- int nFuncs,
- CPDF_ColorSpace* pCS) {
- if (!pStream || !pStream->IsStream() || !pFuncs || !pCS)
- return CFX_FloatRect(0, 0, 0, 0);
-
- CPDF_MeshStream stream;
- if (!stream.Load(pStream, pFuncs, nFuncs, pCS))
- return CFX_FloatRect(0, 0, 0, 0);
-
- CFX_FloatRect rect;
- bool bStarted = false;
- bool bGouraud = type == kFreeFormGouraudTriangleMeshShading ||
- type == kLatticeFormGouraudTriangleMeshShading;
-
- int point_count = kSingleCoordinatePair;
- if (type == kTensorProductPatchMeshShading)
- point_count = kTensorCoordinatePairs;
- else if (type == kCoonsPatchMeshShading)
- point_count = kCoonsCoordinatePairs;
-
- int color_count = kSingleColorPerPatch;
- if (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading)
- color_count = kQuadColorsPerPatch;
-
- while (!stream.m_BitStream.IsEOF()) {
- uint32_t flag = 0;
- if (type != kLatticeFormGouraudTriangleMeshShading)
- flag = stream.GetFlag();
-
- if (!bGouraud && flag) {
- point_count -= 4;
- color_count -= 2;
- }
-
- for (int i = 0; i < point_count; i++) {
- FX_FLOAT x, y;
- stream.GetCoords(x, y);
- if (bStarted) {
- rect.UpdateRect(x, y);
- } else {
- rect.InitRect(x, y);
- bStarted = TRUE;
- }
- }
- stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits *
- color_count);
- if (bGouraud)
- stream.m_BitStream.ByteAlign();
- }
- rect.Transform(pMatrix);
- return rect;
-}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_color.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_color.h
index 9e20684d839..89c0eac7307 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_color.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_color.h
@@ -14,15 +14,11 @@ class CPDF_Pattern;
class CPDF_Color {
public:
- CPDF_Color() : m_pCS(nullptr), m_pBuffer(nullptr) {}
- explicit CPDF_Color(int family);
+ CPDF_Color();
~CPDF_Color();
- FX_BOOL IsNull() const { return !m_pBuffer; }
- FX_BOOL IsEqual(const CPDF_Color& other) const;
- FX_BOOL IsPattern() const {
- return m_pCS && m_pCS->GetFamily() == PDFCS_PATTERN;
- }
+ bool IsNull() const { return !m_pBuffer; }
+ bool IsPattern() const;
void Copy(const CPDF_Color* pSrc);
@@ -32,15 +28,13 @@ class CPDF_Color {
FX_BOOL GetRGB(int& R, int& G, int& B) const;
CPDF_Pattern* GetPattern() const;
- CPDF_ColorSpace* GetPatternCS() const;
- FX_FLOAT* GetPatternColor() const;
-
- CPDF_ColorSpace* m_pCS;
+ const CPDF_ColorSpace* GetColorSpace() const { return m_pCS; }
protected:
void ReleaseBuffer();
void ReleaseColorSpace();
+ CPDF_ColorSpace* m_pCS;
FX_FLOAT* m_pBuffer;
};
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
index 6be55f47b9f..48ace368350 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
@@ -79,7 +79,6 @@ class CPDF_ColorSpace {
FX_BOOL bTransMask = FALSE) const;
CPDF_Array*& GetArray() { return m_pArray; }
- int GetMaxIndex() const;
virtual CPDF_ColorSpace* GetBaseCS() const { return NULL; }
virtual void EnableStdConversion(FX_BOOL bEnabled);
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_form.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_form.h
index 3b9f1cc7fb6..d36a976176b 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_form.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_form.h
@@ -15,7 +15,6 @@ class CPDF_Stream;
class CPDF_AllStates;
class CFX_Matrix;
class CPDF_Type3Char;
-class CPDF_ParseOptions;
class CPDF_Form : public CPDF_PageObjectHolder {
public:
@@ -26,19 +25,18 @@ class CPDF_Form : public CPDF_PageObjectHolder {
~CPDF_Form();
- void StartParse(CPDF_AllStates* pGraphicStates,
- CFX_Matrix* pParentMatrix,
- CPDF_Type3Char* pType3Char,
- CPDF_ParseOptions* pOptions,
- int level = 0);
-
void ParseContent(CPDF_AllStates* pGraphicStates,
- CFX_Matrix* pParentMatrix,
+ const CFX_Matrix* pParentMatrix,
CPDF_Type3Char* pType3Char,
- CPDF_ParseOptions* pOptions,
int level = 0);
CPDF_Form* Clone() const;
+
+ private:
+ void StartParse(CPDF_AllStates* pGraphicStates,
+ const CFX_Matrix* pParentMatrix,
+ CPDF_Type3Char* pType3Char,
+ int level = 0);
};
#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_FORM_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_generalstatedata.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_generalstatedata.h
index df7560289c3..a4577a6cb02 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_generalstatedata.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_generalstatedata.h
@@ -10,7 +10,7 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
class CPDF_TransferFunc;
class CPDF_Object;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_page.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_page.h
index 3ede3c94040..7f4430187ab 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_page.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_page.h
@@ -7,30 +7,26 @@
#ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_
#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_
+#include <memory>
+
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h"
#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-class CPDF_Document;
class CPDF_Dictionary;
+class CPDF_Document;
class CPDF_Object;
class CPDF_PageRenderCache;
-class CPDF_ParseOptions;
-
-CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict,
- const CFX_ByteStringC& name);
class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData {
public:
- CPDF_Page();
- ~CPDF_Page();
-
- void Load(CPDF_Document* pDocument,
+ CPDF_Page(CPDF_Document* pDocument,
CPDF_Dictionary* pPageDict,
- FX_BOOL bPageCache = TRUE);
+ bool bPageCache);
+ ~CPDF_Page();
- void ParseContent(CPDF_ParseOptions* pOptions);
+ void ParseContent();
void GetDisplayMatrix(CFX_Matrix& matrix,
int xPos,
@@ -43,18 +39,18 @@ class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData {
FX_FLOAT GetPageHeight() const { return m_PageHeight; }
CFX_FloatRect GetPageBBox() const { return m_BBox; }
const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; }
- CPDF_Object* GetPageAttr(const CFX_ByteStringC& name) const;
- CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender; }
+ CPDF_Object* GetPageAttr(const CFX_ByteString& name) const;
+ CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender.get(); }
protected:
friend class CPDF_ContentParser;
- void StartParse(CPDF_ParseOptions* pOptions);
+ void StartParse();
FX_FLOAT m_PageWidth;
FX_FLOAT m_PageHeight;
CFX_Matrix m_PageMatrix;
- CPDF_PageRenderCache* m_pPageRender;
+ std::unique_ptr<CPDF_PageRenderCache> m_pPageRender;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_path.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_path.h
index f13b2719b9e..d9f3ead88cf 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_path.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/include/cpdf_path.h
@@ -8,7 +8,7 @@
#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PATH_H_
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
class CPDF_Path : public CFX_CountRef<CFX_PathData> {
public:
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/pageint.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/pageint.h
index 0909125ab04..6534186dc8c 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/pageint.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/pageint.h
@@ -14,9 +14,8 @@
#include "core/fpdfapi/fpdf_page/cpdf_contentmark.h"
#include "core/fpdfapi/fpdf_page/cpdf_countedobject.h"
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
class CPDF_AllStates;
class CPDF_ColorSpace;
@@ -27,7 +26,6 @@ class CPDF_IccProfile;
class CPDF_Image;
class CPDF_ImageObject;
class CPDF_Page;
-class CPDF_ParseOptions;
class CPDF_Pattern;
class CPDF_StreamAcc;
class CPDF_TextObject;
@@ -44,8 +42,7 @@ class CPDF_StreamParser {
CPDF_Stream* ReadInlineStream(CPDF_Document* pDoc,
CPDF_Dictionary* pDict,
- CPDF_Object* pCSObj,
- FX_BOOL bDecode);
+ CPDF_Object* pCSObj);
SyntaxType ParseNextElement();
uint8_t* GetWordBuf() { return m_WordBuffer; }
uint32_t GetWordSize() const { return m_WordSize; }
@@ -56,9 +53,7 @@ class CPDF_StreamParser {
}
uint32_t GetPos() const { return m_Pos; }
void SetPos(uint32_t pos) { m_Pos = pos; }
- CPDF_Object* ReadNextObject(FX_BOOL bAllowNestedArray = FALSE,
- FX_BOOL bInArray = FALSE);
- void SkipPathObject();
+ CPDF_Object* ReadNextObject(bool bAllowNestedArray, uint32_t dwInArrayLevel);
protected:
friend class fpdf_page_parser_old_ReadHexString_Test;
@@ -103,17 +98,15 @@ struct ContentParam {
};
#define _FPDF_MAX_FORM_LEVEL_ 30
#define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4
-#define _FPDF_MAX_OBJECT_STACK_SIZE_ 512
class CPDF_StreamContentParser {
public:
CPDF_StreamContentParser(CPDF_Document* pDoc,
CPDF_Dictionary* pPageResources,
CPDF_Dictionary* pParentResources,
- CFX_Matrix* pmtContentToUser,
+ const CFX_Matrix* pmtContentToUser,
CPDF_PageObjectHolder* pObjectHolder,
CPDF_Dictionary* pResources,
CFX_FloatRect* pBBox,
- CPDF_ParseOptions* pOptions,
CPDF_AllStates* pAllStates,
int level);
~CPDF_StreamContentParser();
@@ -131,7 +124,6 @@ class CPDF_StreamContentParser {
CPDF_Object* GetObject(uint32_t index);
CFX_ByteString GetString(uint32_t index);
FX_FLOAT GetNumber(uint32_t index);
- FX_FLOAT GetNumber16(uint32_t index);
int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); }
void OnOperator(const FX_CHAR* op);
void BigCaseCaller(int index);
@@ -162,8 +154,8 @@ class CPDF_StreamContentParser {
void RestoreStates(CPDF_AllStates* pState);
CPDF_Font* FindFont(const CFX_ByteString& name);
CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name);
- CPDF_Pattern* FindPattern(const CFX_ByteString& name, FX_BOOL bShading);
- CPDF_Object* FindResourceObj(const CFX_ByteStringC& type,
+ CPDF_Pattern* FindPattern(const CFX_ByteString& name, bool bShading);
+ CPDF_Object* FindResourceObj(const CFX_ByteString& type,
const CFX_ByteString& name);
protected:
@@ -252,7 +244,6 @@ class CPDF_StreamContentParser {
int m_Level;
CFX_Matrix m_mtContentToUser;
CFX_FloatRect m_BBox;
- CPDF_ParseOptions m_Options;
ContentParam m_ParamBuf[PARAM_BUF_SIZE];
uint32_t m_ParamStartPos;
uint32_t m_ParamCount;
@@ -291,12 +282,11 @@ class CPDF_ContentParser {
~CPDF_ContentParser();
ParseStatus GetStatus() const { return m_Status; }
- void Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions);
+ void Start(CPDF_Page* pPage);
void Start(CPDF_Form* pForm,
CPDF_AllStates* pGraphicStates,
- CFX_Matrix* pParentMatrix,
+ const CFX_Matrix* pParentMatrix,
CPDF_Type3Char* pType3Char,
- CPDF_ParseOptions* pOptions,
int level);
void Continue(IFX_Pause* pPause);
@@ -311,7 +301,6 @@ class CPDF_ContentParser {
InternalStage m_InternalStage;
CPDF_PageObjectHolder* m_pObjectHolder;
FX_BOOL m_bForm;
- CPDF_ParseOptions m_Options;
CPDF_Type3Char* m_pType3Char;
uint32_t m_nStreams;
std::unique_ptr<CPDF_StreamAcc> m_pSingleStream;
@@ -329,7 +318,7 @@ class CPDF_DocPageData {
void Clear(FX_BOOL bRelease = FALSE);
CPDF_Font* GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly);
- CPDF_Font* GetStandardFont(const CFX_ByteStringC& fontName,
+ CPDF_Font* GetStandardFont(const CFX_ByteString& fontName,
CPDF_FontEncoding* pEncoding);
void ReleaseFont(CPDF_Dictionary* pFontDict);
CPDF_ColorSpace* GetColorSpace(CPDF_Object* pCSObj,
@@ -338,7 +327,7 @@ class CPDF_DocPageData {
void ReleaseColorSpace(CPDF_Object* pColorSpace);
CPDF_Pattern* GetPattern(CPDF_Object* pPatternObj,
FX_BOOL bShading,
- const CFX_Matrix* matrix);
+ const CFX_Matrix& matrix);
void ReleasePattern(CPDF_Object* pPatternObj);
CPDF_Image* GetImage(CPDF_Object* pImageStream);
void ReleaseImage(CPDF_Object* pImageStream);
@@ -393,6 +382,7 @@ class CPDF_Function {
uint32_t CountInputs() const { return m_nInputs; }
uint32_t CountOutputs() const { return m_nOutputs; }
FX_FLOAT GetDomain(int i) const { return m_pDomains[i]; }
+ FX_FLOAT GetRange(int i) const { return m_pRanges[i]; }
Type GetType() const { return m_Type; }
protected:
@@ -423,6 +413,33 @@ class CPDF_ExpIntFunc : public CPDF_Function {
FX_FLOAT* m_pEndValues;
};
+class CPDF_SampledFunc : public CPDF_Function {
+ public:
+ struct SampleEncodeInfo {
+ FX_FLOAT encode_max;
+ FX_FLOAT encode_min;
+ uint32_t sizes;
+ };
+
+ struct SampleDecodeInfo {
+ FX_FLOAT decode_max;
+ FX_FLOAT decode_min;
+ };
+
+ CPDF_SampledFunc();
+ ~CPDF_SampledFunc() override;
+
+ // CPDF_Function
+ FX_BOOL v_Init(CPDF_Object* pObj) override;
+ FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override;
+
+ SampleEncodeInfo* m_pEncodeInfo;
+ SampleDecodeInfo* m_pDecodeInfo;
+ uint32_t m_nBitsPerSample;
+ uint32_t m_SampleMax;
+ CPDF_StreamAcc* m_pSampleStream;
+};
+
class CPDF_StitchFunc : public CPDF_Function {
public:
CPDF_StitchFunc();
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cfdf_document.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cfdf_document.cpp
index 9cbf9997028..3039c329386 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cfdf_document.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cfdf_document.cpp
@@ -53,7 +53,7 @@ void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
bool bNumber;
CFX_ByteString word = parser.GetNextWord(&bNumber);
if (bNumber) {
- uint32_t objnum = FXSYS_atoui(word);
+ uint32_t objnum = FXSYS_atoui(word.c_str());
word = parser.GetNextWord(&bNumber);
if (!bNumber) {
break;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array.cpp
index 964ba642367..d588f339a7b 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array.cpp
@@ -15,11 +15,9 @@
CPDF_Array::CPDF_Array() {}
CPDF_Array::~CPDF_Array() {
- int size = m_Objects.GetSize();
- CPDF_Object** pList = m_Objects.GetData();
- for (int i = 0; i < size; i++) {
- if (pList[i])
- pList[i]->Release();
+ for (auto& it : m_Objects) {
+ if (it)
+ it->Release();
}
}
@@ -48,15 +46,15 @@ const CPDF_Array* CPDF_Array::AsArray() const {
CPDF_Object* CPDF_Array::Clone(FX_BOOL bDirect) const {
CPDF_Array* pCopy = new CPDF_Array();
for (size_t i = 0; i < GetCount(); i++) {
- CPDF_Object* value = m_Objects.GetAt(i);
- pCopy->m_Objects.Add(value->Clone(bDirect));
+ CPDF_Object* value = m_Objects.at(i);
+ pCopy->m_Objects.push_back(value->Clone(bDirect));
}
return pCopy;
}
CFX_FloatRect CPDF_Array::GetRect() {
CFX_FloatRect rect;
- if (!IsArray() || m_Objects.GetSize() != 4)
+ if (!IsArray() || m_Objects.size() != 4)
return rect;
rect.left = GetNumberAt(0);
@@ -68,7 +66,7 @@ CFX_FloatRect CPDF_Array::GetRect() {
CFX_Matrix CPDF_Array::GetMatrix() {
CFX_Matrix matrix;
- if (!IsArray() || m_Objects.GetSize() != 6)
+ if (!IsArray() || m_Objects.size() != 6)
return matrix;
matrix.Set(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2), GetNumberAt(3),
@@ -76,43 +74,37 @@ CFX_Matrix CPDF_Array::GetMatrix() {
return matrix;
}
-CPDF_Object* CPDF_Array::GetObjectAt(uint32_t i) const {
- if (i >= (uint32_t)m_Objects.GetSize())
+CPDF_Object* CPDF_Array::GetObjectAt(size_t i) const {
+ if (i >= m_Objects.size())
return nullptr;
- return m_Objects.GetAt(i);
+ return m_Objects.at(i);
}
-CPDF_Object* CPDF_Array::GetDirectObjectAt(uint32_t i) const {
- if (i >= (uint32_t)m_Objects.GetSize())
+CPDF_Object* CPDF_Array::GetDirectObjectAt(size_t i) const {
+ if (i >= m_Objects.size())
return nullptr;
- return m_Objects.GetAt(i)->GetDirect();
+ return m_Objects.at(i)->GetDirect();
}
-CFX_ByteString CPDF_Array::GetStringAt(uint32_t i) const {
- if (i >= (uint32_t)m_Objects.GetSize())
+CFX_ByteString CPDF_Array::GetStringAt(size_t i) const {
+ if (i >= m_Objects.size())
return CFX_ByteString();
- return m_Objects.GetAt(i)->GetString();
+ return m_Objects.at(i)->GetString();
}
-CFX_ByteStringC CPDF_Array::GetConstStringAt(uint32_t i) const {
- if (i >= (uint32_t)m_Objects.GetSize())
- return CFX_ByteStringC();
- return m_Objects.GetAt(i)->GetConstString();
-}
-
-int CPDF_Array::GetIntegerAt(uint32_t i) const {
- if (i >= (uint32_t)m_Objects.GetSize())
+int CPDF_Array::GetIntegerAt(size_t i) const {
+ if (i >= m_Objects.size())
return 0;
- return m_Objects.GetAt(i)->GetInteger();
+ return m_Objects.at(i)->GetInteger();
}
-FX_FLOAT CPDF_Array::GetNumberAt(uint32_t i) const {
- if (i >= (uint32_t)m_Objects.GetSize())
+FX_FLOAT CPDF_Array::GetNumberAt(size_t i) const {
+ if (i >= m_Objects.size())
return 0;
- return m_Objects.GetAt(i)->GetNumber();
+ return m_Objects.at(i)->GetNumber();
}
-CPDF_Dictionary* CPDF_Array::GetDictAt(uint32_t i) const {
+CPDF_Dictionary* CPDF_Array::GetDictAt(size_t i) const {
CPDF_Object* p = GetDirectObjectAt(i);
if (!p)
return NULL;
@@ -123,52 +115,59 @@ CPDF_Dictionary* CPDF_Array::GetDictAt(uint32_t i) const {
return NULL;
}
-CPDF_Stream* CPDF_Array::GetStreamAt(uint32_t i) const {
+CPDF_Stream* CPDF_Array::GetStreamAt(size_t i) const {
return ToStream(GetDirectObjectAt(i));
}
-CPDF_Array* CPDF_Array::GetArrayAt(uint32_t i) const {
+CPDF_Array* CPDF_Array::GetArrayAt(size_t i) const {
return ToArray(GetDirectObjectAt(i));
}
-void CPDF_Array::RemoveAt(uint32_t i, uint32_t nCount) {
- if (i >= (uint32_t)m_Objects.GetSize())
+void CPDF_Array::RemoveAt(size_t i, size_t nCount) {
+ if (i >= m_Objects.size())
return;
- if (nCount <= 0 || nCount > m_Objects.GetSize() - i)
+ if (nCount <= 0 || nCount > m_Objects.size() - i)
return;
- for (uint32_t j = 0; j < nCount; ++j) {
- if (CPDF_Object* p = m_Objects.GetAt(i + j))
+ for (size_t j = 0; j < nCount; ++j) {
+ if (CPDF_Object* p = m_Objects.at(i + j))
p->Release();
}
- m_Objects.RemoveAt(i, nCount);
+ m_Objects.erase(m_Objects.begin() + i, m_Objects.begin() + i + nCount);
}
-void CPDF_Array::SetAt(uint32_t i,
+void CPDF_Array::SetAt(size_t i,
CPDF_Object* pObj,
CPDF_IndirectObjectHolder* pObjs) {
ASSERT(IsArray());
- ASSERT(i < (uint32_t)m_Objects.GetSize());
- if (i >= (uint32_t)m_Objects.GetSize())
+ ASSERT(i < m_Objects.size());
+ if (i >= m_Objects.size())
return;
- if (CPDF_Object* pOld = m_Objects.GetAt(i))
+ if (CPDF_Object* pOld = m_Objects.at(i))
pOld->Release();
if (pObj->GetObjNum()) {
ASSERT(pObjs);
pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
}
- m_Objects.SetAt(i, pObj);
+ m_Objects[i] = pObj;
}
-void CPDF_Array::InsertAt(uint32_t index,
+void CPDF_Array::InsertAt(size_t index,
CPDF_Object* pObj,
CPDF_IndirectObjectHolder* pObjs) {
if (pObj->GetObjNum()) {
ASSERT(pObjs);
pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
}
- m_Objects.InsertAt(index, pObj);
+ if (index >= m_Objects.size()) {
+ // Allocate space first.
+ m_Objects.resize(index + 1, nullptr);
+ m_Objects[index] = pObj;
+ } else {
+ // Directly insert.
+ m_Objects.insert(m_Objects.begin() + index, pObj);
+ }
}
void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs) {
@@ -176,7 +175,7 @@ void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs) {
ASSERT(pObjs);
pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
}
- m_Objects.Add(pObj);
+ m_Objects.push_back(pObj);
}
void CPDF_Array::AddName(const CFX_ByteString& str) {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp
new file mode 100644
index 00000000000..12a36d921a8
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp
@@ -0,0 +1,181 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
+
+#include <memory>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+using ScopedArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>>;
+
+} // namespace
+
+TEST(cpdf_array, RemoveAt) {
+ {
+ int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ ScopedArray arr(new CPDF_Array);
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ arr->AddInteger(elems[i]);
+ arr->RemoveAt(3, 3);
+ int expected[] = {1, 2, 3, 7, 8, 9, 10};
+ EXPECT_EQ(FX_ArraySize(expected), arr->GetCount());
+ for (size_t i = 0; i < FX_ArraySize(expected); ++i)
+ EXPECT_EQ(expected[i], arr->GetIntegerAt(i));
+ arr->RemoveAt(4, 2);
+ int expected2[] = {1, 2, 3, 7, 10};
+ EXPECT_EQ(FX_ArraySize(expected2), arr->GetCount());
+ for (size_t i = 0; i < FX_ArraySize(expected2); ++i)
+ EXPECT_EQ(expected2[i], arr->GetIntegerAt(i));
+ }
+ {
+ // When the range is out of bound, RemoveAt has no effect.
+ int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ ScopedArray arr(new CPDF_Array);
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ arr->AddInteger(elems[i]);
+ arr->RemoveAt(8, 5);
+ EXPECT_EQ(FX_ArraySize(elems), arr->GetCount());
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ EXPECT_EQ(elems[i], arr->GetIntegerAt(i));
+ arr->RemoveAt(0, 12);
+ EXPECT_EQ(FX_ArraySize(elems), arr->GetCount());
+ arr->RemoveAt(11, 1);
+ EXPECT_EQ(FX_ArraySize(elems), arr->GetCount());
+ }
+}
+
+TEST(cpdf_array, InsertAt) {
+ {
+ int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ ScopedArray arr(new CPDF_Array);
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ arr->InsertAt(i, new CPDF_Number(elems[i]));
+ EXPECT_EQ(FX_ArraySize(elems), arr->GetCount());
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ EXPECT_EQ(elems[i], arr->GetIntegerAt(i));
+ arr->InsertAt(3, new CPDF_Number(33));
+ arr->InsertAt(6, new CPDF_Number(55));
+ arr->InsertAt(12, new CPDF_Number(12));
+ int expected[] = {1, 2, 3, 33, 4, 5, 55, 6, 7, 8, 9, 10, 12};
+ EXPECT_EQ(FX_ArraySize(expected), arr->GetCount());
+ for (size_t i = 0; i < FX_ArraySize(expected); ++i)
+ EXPECT_EQ(expected[i], arr->GetIntegerAt(i));
+ }
+ {
+ // When the position to insert is beyond the upper bound,
+ // an element is inserted at that position while other unfilled
+ // positions have nullptr.
+ int elems[] = {1, 2};
+ ScopedArray arr(new CPDF_Array);
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ arr->InsertAt(i, new CPDF_Number(elems[i]));
+ arr->InsertAt(10, new CPDF_Number(10));
+ EXPECT_EQ(11u, arr->GetCount());
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ EXPECT_EQ(elems[i], arr->GetIntegerAt(i));
+ for (size_t i = FX_ArraySize(elems); i < 10; ++i)
+ EXPECT_EQ(nullptr, arr->GetObjectAt(i));
+ EXPECT_EQ(10, arr->GetIntegerAt(10));
+ }
+}
+
+TEST(cpdf_array, Clone) {
+ {
+ // Basic case.
+ int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ ScopedArray arr(new CPDF_Array);
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ arr->InsertAt(i, new CPDF_Number(elems[i]));
+ ScopedArray arr2(arr->Clone()->AsArray());
+ EXPECT_EQ(arr->GetCount(), arr2->GetCount());
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i) {
+ // Clone() always create new objects.
+ EXPECT_NE(arr->GetObjectAt(i), arr2->GetObjectAt(i));
+ EXPECT_EQ(arr->GetIntegerAt(i), arr2->GetIntegerAt(i));
+ }
+ }
+ {
+ // Clone() with and without dereferencing reference objects.
+ static const size_t kNumOfRows = 3;
+ static const size_t kNumOfRowElems = 5;
+ int elems[kNumOfRows][kNumOfRowElems] = {
+ {1, 2, 3, 4, 5}, {10, 9, 8, 7, 6}, {11, 12, 13, 14, 15}};
+ ScopedArray arr(new CPDF_Array);
+ // Indirect references to indirect objects.
+ std::unique_ptr<CPDF_IndirectObjectHolder> obj_holder(
+ new CPDF_IndirectObjectHolder(nullptr));
+ for (size_t i = 0; i < kNumOfRows; ++i) {
+ CPDF_Array* arr_elem = new CPDF_Array;
+ for (size_t j = 0; j < kNumOfRowElems; ++j) {
+ CPDF_Number* obj = new CPDF_Number(elems[i][j]);
+ // Starts object number from 1.
+ int obj_num = i * kNumOfRowElems + j + 1;
+ obj_holder->InsertIndirectObject(obj_num, obj);
+ arr_elem->InsertAt(j, new CPDF_Reference(obj_holder.get(), obj_num),
+ obj_holder.get());
+ }
+ arr->InsertAt(i, arr_elem);
+ }
+ ASSERT_EQ(kNumOfRows, arr->GetCount());
+ // Not dereferencing reference objects means just creating new references
+ // instead of new copies of direct objects.
+ ScopedArray arr1(arr->Clone(FALSE)->AsArray());
+ EXPECT_EQ(arr->GetCount(), arr1->GetCount());
+ // Dereferencing reference objects creates new copies of direct objects.
+ ScopedArray arr2(arr->Clone(TRUE)->AsArray());
+ EXPECT_EQ(arr->GetCount(), arr2->GetCount());
+ for (size_t i = 0; i < kNumOfRows; ++i) {
+ CPDF_Array* arr_elem = arr->GetObjectAt(i)->AsArray();
+ CPDF_Array* arr1_elem = arr1->GetObjectAt(i)->AsArray();
+ CPDF_Array* arr2_elem = arr2->GetObjectAt(i)->AsArray();
+ EXPECT_NE(arr_elem, arr1_elem);
+ EXPECT_NE(arr_elem, arr2_elem);
+ for (size_t j = 0; j < kNumOfRowElems; ++j) {
+ auto elem_obj = arr_elem->GetObjectAt(j);
+ auto elem_obj1 = arr1_elem->GetObjectAt(j);
+ auto elem_obj2 = arr2_elem->GetObjectAt(j);
+ // Results from not deferencing reference objects.
+ EXPECT_NE(elem_obj, elem_obj1);
+ EXPECT_TRUE(elem_obj1->IsReference());
+ EXPECT_EQ(elem_obj->GetDirect(), elem_obj1->GetDirect());
+ EXPECT_EQ(elem_obj->GetInteger(), elem_obj1->GetInteger());
+ // Results from deferencing reference objects.
+ EXPECT_NE(elem_obj, elem_obj2);
+ EXPECT_TRUE(elem_obj2->IsNumber());
+ EXPECT_NE(elem_obj->GetDirect(), elem_obj2);
+ EXPECT_EQ(elem_obj->GetObjNum(), elem_obj2->GetObjNum());
+ EXPECT_EQ(elem_obj->GetInteger(), elem_obj2->GetInteger());
+ }
+ }
+ arr.reset();
+ ASSERT_EQ(kNumOfRows, arr1->GetCount());
+ for (size_t i = 0; i < kNumOfRows; ++i) {
+ for (size_t j = 0; j < kNumOfRowElems; ++j) {
+ // Results from not deferencing reference objects.
+ auto elem_obj1 = arr1->GetObjectAt(i)->AsArray()->GetObjectAt(j);
+ EXPECT_TRUE(elem_obj1->IsReference());
+ EXPECT_EQ(elems[i][j], elem_obj1->GetInteger());
+ // Results from deferencing reference objects.
+ EXPECT_EQ(elems[i][j],
+ arr2->GetObjectAt(i)->AsArray()->GetIntegerAt(j));
+ }
+ }
+ }
+}
+
+TEST(cpdf_array, Iterator) {
+ int elems[] = {-23, -11, 3, 455, 2345877,
+ 0, 7895330, -12564334, 10000, -100000};
+ ScopedArray arr(new CPDF_Array);
+ for (size_t i = 0; i < FX_ArraySize(elems); ++i)
+ arr->InsertAt(i, new CPDF_Number(elems[i]));
+ size_t index = 0;
+ for (const auto& it : *arr)
+ EXPECT_EQ(elems[index++], it->AsNumber()->GetInteger());
+}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp
index 46384244e81..2d845d856ad 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp
@@ -4,34 +4,22 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
#include <time.h>
#include "core/fdrm/crypto/include/fx_crypt.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_security_handler.h"
-IPDF_CryptoHandler::~IPDF_CryptoHandler() {}
-
-void IPDF_CryptoHandler::Decrypt(uint32_t objnum,
- uint32_t gennum,
- CFX_ByteString& str) {
- CFX_BinaryBuf dest_buf;
- void* context = DecryptStart(objnum, gennum);
- DecryptStream(context, (const uint8_t*)str, str.GetLength(), dest_buf);
- DecryptFinish(context, dest_buf);
- str = dest_buf;
-}
-
-void CPDF_StandardCryptoHandler::CryptBlock(FX_BOOL bEncrypt,
- uint32_t objnum,
- uint32_t gennum,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) {
+void CPDF_CryptoHandler::CryptBlock(FX_BOOL bEncrypt,
+ uint32_t objnum,
+ uint32_t gennum,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size) {
if (m_Cipher == FXCIPHER_NONE) {
FXSYS_memcpy(dest_buf, src_buf, src_size);
return;
@@ -99,9 +87,9 @@ struct AESCryptContext {
uint32_t m_BlockOffset;
};
-void* CPDF_StandardCryptoHandler::CryptStart(uint32_t objnum,
- uint32_t gennum,
- FX_BOOL bEncrypt) {
+void* CPDF_CryptoHandler::CryptStart(uint32_t objnum,
+ uint32_t gennum,
+ FX_BOOL bEncrypt) {
if (m_Cipher == FXCIPHER_NONE) {
return this;
}
@@ -149,11 +137,11 @@ void* CPDF_StandardCryptoHandler::CryptStart(uint32_t objnum,
CRYPT_ArcFourSetup(pContext, realkey, realkeylen);
return pContext;
}
-FX_BOOL CPDF_StandardCryptoHandler::CryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt) {
+FX_BOOL CPDF_CryptoHandler::CryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf,
+ FX_BOOL bEncrypt) {
if (!context) {
return FALSE;
}
@@ -208,9 +196,9 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptStream(void* context,
}
return TRUE;
}
-FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(void* context,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt) {
+FX_BOOL CPDF_CryptoHandler::CryptFinish(void* context,
+ CFX_BinaryBuf& dest_buf,
+ FX_BOOL bEncrypt) {
if (!context) {
return FALSE;
}
@@ -244,17 +232,26 @@ FX_BOOL CPDF_StandardCryptoHandler::CryptFinish(void* context,
FX_Free(pContext);
return TRUE;
}
-void* CPDF_StandardCryptoHandler::DecryptStart(uint32_t objnum,
- uint32_t gennum) {
+
+void CPDF_CryptoHandler::Decrypt(uint32_t objnum,
+ uint32_t gennum,
+ CFX_ByteString& str) {
+ CFX_BinaryBuf dest_buf;
+ void* context = DecryptStart(objnum, gennum);
+ DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf);
+ DecryptFinish(context, dest_buf);
+ str = CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize());
+}
+
+void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) {
return CryptStart(objnum, gennum, FALSE);
}
-uint32_t CPDF_StandardCryptoHandler::DecryptGetSize(uint32_t src_size) {
+uint32_t CPDF_CryptoHandler::DecryptGetSize(uint32_t src_size) {
return m_Cipher == FXCIPHER_AES ? src_size - 16 : src_size;
}
-FX_BOOL CPDF_StandardCryptoHandler::Init(
- CPDF_Dictionary* pEncryptDict,
- IPDF_SecurityHandler* pSecurityHandler) {
+FX_BOOL CPDF_CryptoHandler::Init(CPDF_Dictionary* pEncryptDict,
+ CPDF_SecurityHandler* pSecurityHandler) {
const uint8_t* key;
if (!pSecurityHandler->GetCryptInfo(m_Cipher, key, m_KeyLen)) {
return FALSE;
@@ -271,9 +268,7 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(
return TRUE;
}
-FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher,
- const uint8_t* key,
- int keylen) {
+FX_BOOL CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) {
if (cipher == FXCIPHER_AES) {
switch (keylen) {
case 16:
@@ -304,39 +299,39 @@ FX_BOOL CPDF_StandardCryptoHandler::Init(int cipher,
}
return TRUE;
}
-FX_BOOL CPDF_StandardCryptoHandler::DecryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf) {
+FX_BOOL CPDF_CryptoHandler::DecryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf) {
return CryptStream(context, src_buf, src_size, dest_buf, FALSE);
}
-FX_BOOL CPDF_StandardCryptoHandler::DecryptFinish(void* context,
- CFX_BinaryBuf& dest_buf) {
+FX_BOOL CPDF_CryptoHandler::DecryptFinish(void* context,
+ CFX_BinaryBuf& dest_buf) {
return CryptFinish(context, dest_buf, FALSE);
}
-uint32_t CPDF_StandardCryptoHandler::EncryptGetSize(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size) {
+uint32_t CPDF_CryptoHandler::EncryptGetSize(uint32_t objnum,
+ uint32_t version,
+ const uint8_t* src_buf,
+ uint32_t src_size) {
if (m_Cipher == FXCIPHER_AES) {
return src_size + 32;
}
return src_size;
}
-FX_BOOL CPDF_StandardCryptoHandler::EncryptContent(uint32_t objnum,
- uint32_t gennum,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) {
+FX_BOOL CPDF_CryptoHandler::EncryptContent(uint32_t objnum,
+ uint32_t gennum,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size) {
CryptBlock(TRUE, objnum, gennum, src_buf, src_size, dest_buf, dest_size);
return TRUE;
}
-CPDF_StandardCryptoHandler::CPDF_StandardCryptoHandler() {
+CPDF_CryptoHandler::CPDF_CryptoHandler() {
m_pAESContext = NULL;
m_Cipher = FXCIPHER_NONE;
m_KeyLen = 0;
}
-CPDF_StandardCryptoHandler::~CPDF_StandardCryptoHandler() {
+CPDF_CryptoHandler::~CPDF_CryptoHandler() {
FX_Free(m_pAESContext);
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h
new file mode 100644
index 00000000000..3edc47b7b01
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h
@@ -0,0 +1,67 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_CRYPTO_HANDLER_H_
+#define CORE_FPDFAPI_FPDF_PARSER_CPDF_CRYPTO_HANDLER_H_
+
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_Dictionary;
+class CPDF_SecurityHandler;
+
+class CPDF_CryptoHandler {
+ public:
+ CPDF_CryptoHandler();
+ ~CPDF_CryptoHandler();
+
+ FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
+ CPDF_SecurityHandler* pSecurityHandler);
+ uint32_t DecryptGetSize(uint32_t src_size);
+ void* DecryptStart(uint32_t objnum, uint32_t gennum);
+ void Decrypt(uint32_t objnum, uint32_t gennum, CFX_ByteString& str);
+ FX_BOOL DecryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf);
+ FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf);
+ uint32_t EncryptGetSize(uint32_t objnum,
+ uint32_t version,
+ const uint8_t* src_buf,
+ uint32_t src_size);
+ FX_BOOL EncryptContent(uint32_t objnum,
+ uint32_t version,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size);
+
+ FX_BOOL Init(int cipher, const uint8_t* key, int keylen);
+
+ protected:
+ void CryptBlock(FX_BOOL bEncrypt,
+ uint32_t objnum,
+ uint32_t gennum,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t* dest_buf,
+ uint32_t& dest_size);
+ void* CryptStart(uint32_t objnum, uint32_t gennum, FX_BOOL bEncrypt);
+ FX_BOOL CryptStream(void* context,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_BinaryBuf& dest_buf,
+ FX_BOOL bEncrypt);
+ FX_BOOL CryptFinish(void* context, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt);
+
+ uint8_t m_EncryptKey[32];
+ int m_KeyLen;
+ int m_Cipher;
+ uint8_t* m_pAESContext;
+};
+
+#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_CRYPTO_HANDLER_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
index 504e921d4ec..e47d4244ac8 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
@@ -143,8 +143,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(
uint32_t count = 0;
CFX_ArrayTemplate<CPDF_Object*> new_obj_array;
- int32_t i = 0;
- for (i = 0; i < obj_array.GetSize(); i++) {
+ for (int i = 0; i < obj_array.GetSize(); i++) {
CPDF_Object* pObj = obj_array[i];
if (!pObj)
continue;
@@ -153,7 +152,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(
switch (type) {
case CPDF_Object::ARRAY: {
CPDF_Array* pArray = pObj->GetArray();
- for (uint32_t k = 0; k < pArray->GetCount(); ++k)
+ for (size_t k = 0; k < pArray->GetCount(); ++k)
new_obj_array.Add(pArray->GetObjectAt(k));
} break;
case CPDF_Object::STREAM:
@@ -194,8 +193,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(
}
if (count > 0) {
- int32_t iSize = new_obj_array.GetSize();
- for (i = 0; i < iSize; ++i) {
+ for (int i = 0; i < new_obj_array.GetSize(); ++i) {
CPDF_Object* pObj = new_obj_array[i];
if (CPDF_Reference* pRef = pObj->AsReference()) {
uint32_t dwNum = pRef->GetRefObjNum();
@@ -514,8 +512,7 @@ FX_BOOL CPDF_DataAvail::CheckPage(IPDF_DataAvail::DownloadHints* pHints) {
if (pObj->IsArray()) {
CPDF_Array* pArray = pObj->GetArray();
if (pArray) {
- int32_t iSize = pArray->GetCount();
- for (int32_t j = 0; j < iSize; ++j) {
+ for (size_t j = 0; j < pArray->GetCount(); ++j) {
if (CPDF_Reference* pRef = ToReference(pArray->GetObjectAt(j)))
UnavailObjList.Add(pRef->GetRefObjNum());
}
@@ -584,7 +581,7 @@ FX_BOOL CPDF_DataAvail::GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages) {
break;
case CPDF_Object::ARRAY: {
CPDF_Array* pKidsArray = pKids->AsArray();
- for (uint32_t i = 0; i < pKidsArray->GetCount(); ++i) {
+ for (size_t i = 0; i < pKidsArray->GetCount(); ++i) {
if (CPDF_Reference* pRef = ToReference(pKidsArray->GetObjectAt(i)))
m_PageObjList.Add(pRef->GetRefObjNum());
}
@@ -795,7 +792,7 @@ CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
if (!bIsNumber)
return nullptr;
- uint32_t parser_objnum = FXSYS_atoui(word);
+ uint32_t parser_objnum = FXSYS_atoui(word.c_str());
if (objnum && parser_objnum != objnum)
return nullptr;
@@ -803,7 +800,7 @@ CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
if (!bIsNumber)
return nullptr;
- uint32_t gennum = FXSYS_atoui(word);
+ uint32_t gennum = FXSYS_atoui(word.c_str());
if (m_syntaxParser.GetKeyword() != "obj") {
m_syntaxParser.RestorePos(SavedPos);
return nullptr;
@@ -856,7 +853,7 @@ FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) {
if (!bNumber)
return FALSE;
- uint32_t objnum = FXSYS_atoui(wordObjNum);
+ uint32_t objnum = FXSYS_atoui(wordObjNum.c_str());
m_pLinearized =
ParseIndirectObjectAt(m_syntaxParser.m_HeaderOffset + 9, objnum);
if (!m_pLinearized)
@@ -903,7 +900,7 @@ FX_BOOL CPDF_DataAvail::CheckEnd(IPDF_DataAvail::DownloadHints* pHints) {
return FALSE;
}
- m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str);
+ m_dwXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str.c_str());
if (!m_dwXRefOffset || m_dwXRefOffset > m_dwFileLen) {
m_docStatus = PDF_DATAAVAIL_LOADALLFILE;
return TRUE;
@@ -945,7 +942,7 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(
if (!bNumber)
return -1;
- uint32_t objNum = FXSYS_atoui(objnum);
+ uint32_t objNum = FXSYS_atoui(objnum.c_str());
CPDF_Object* pObj = m_parser.ParseIndirectObjectAt(nullptr, 0, objNum);
if (!pObj) {
m_Pos += m_parser.m_pSyntax->SavePos();
@@ -1284,7 +1281,7 @@ FX_BOOL CPDF_DataAvail::CheckArrayPageNode(
}
pPageNode->m_type = PDF_PAGENODE_PAGES;
- for (uint32_t i = 0; i < pArray->GetCount(); ++i) {
+ for (size_t i = 0; i < pArray->GetCount(); ++i) {
CPDF_Reference* pKid = ToReference(pArray->GetObjectAt(i));
if (!pKid)
continue;
@@ -1347,7 +1344,7 @@ FX_BOOL CPDF_DataAvail::CheckUnkownPageNode(
} break;
case CPDF_Object::ARRAY: {
CPDF_Array* pKidsArray = pKids->AsArray();
- for (uint32_t i = 0; i < pKidsArray->GetCount(); ++i) {
+ for (size_t i = 0; i < pKidsArray->GetCount(); ++i) {
CPDF_Reference* pKid = ToReference(pKidsArray->GetObjectAt(i));
if (!pKid)
continue;
@@ -1506,7 +1503,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData(
return DataAvailable;
if (!m_bMainXRefLoadTried) {
- FX_SAFE_DWORD data_size = m_dwFileLen;
+ FX_SAFE_UINT32 data_size = m_dwFileLen;
data_size -= m_dwLastXRefOffset;
if (!data_size.IsValid())
return DataError;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp
index 5f86a7bbc2a..27b866a65b5 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp
@@ -51,72 +51,58 @@ CPDF_Object* CPDF_Dictionary::Clone(FX_BOOL bDirect) const {
return pCopy;
}
-CPDF_Object* CPDF_Dictionary::GetObjectBy(const CFX_ByteStringC& key) const {
+CPDF_Object* CPDF_Dictionary::GetObjectBy(const CFX_ByteString& key) const {
auto it = m_Map.find(key);
- if (it == m_Map.end())
- return nullptr;
- return it->second;
+ return it != m_Map.end() ? it->second : nullptr;
}
+
CPDF_Object* CPDF_Dictionary::GetDirectObjectBy(
- const CFX_ByteStringC& key) const {
+ const CFX_ByteString& key) const {
CPDF_Object* p = GetObjectBy(key);
return p ? p->GetDirect() : nullptr;
}
-CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key) const {
+CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteString& key) const {
CPDF_Object* p = GetObjectBy(key);
return p ? p->GetString() : CFX_ByteString();
}
-CFX_ByteStringC CPDF_Dictionary::GetConstStringBy(
- const CFX_ByteStringC& key) const {
- CPDF_Object* p = GetObjectBy(key);
- return p ? p->GetConstString() : CFX_ByteStringC();
-}
-
CFX_WideString CPDF_Dictionary::GetUnicodeTextBy(
- const CFX_ByteStringC& key) const {
+ const CFX_ByteString& key) const {
CPDF_Object* p = GetObjectBy(key);
if (CPDF_Reference* pRef = ToReference(p))
p = pRef->GetDirect();
return p ? p->GetUnicodeText() : CFX_WideString();
}
-CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteStringC& key,
- const CFX_ByteStringC& def) const {
+CFX_ByteString CPDF_Dictionary::GetStringBy(const CFX_ByteString& key,
+ const CFX_ByteString& def) const {
CPDF_Object* p = GetObjectBy(key);
return p ? p->GetString() : CFX_ByteString(def);
}
-CFX_ByteStringC CPDF_Dictionary::GetConstStringBy(
- const CFX_ByteStringC& key,
- const CFX_ByteStringC& def) const {
- CPDF_Object* p = GetObjectBy(key);
- return p ? p->GetConstString() : CFX_ByteStringC(def);
-}
-
-int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key) const {
+int CPDF_Dictionary::GetIntegerBy(const CFX_ByteString& key) const {
CPDF_Object* p = GetObjectBy(key);
return p ? p->GetInteger() : 0;
}
-int CPDF_Dictionary::GetIntegerBy(const CFX_ByteStringC& key, int def) const {
+int CPDF_Dictionary::GetIntegerBy(const CFX_ByteString& key, int def) const {
CPDF_Object* p = GetObjectBy(key);
return p ? p->GetInteger() : def;
}
-FX_FLOAT CPDF_Dictionary::GetNumberBy(const CFX_ByteStringC& key) const {
+FX_FLOAT CPDF_Dictionary::GetNumberBy(const CFX_ByteString& key) const {
CPDF_Object* p = GetObjectBy(key);
return p ? p->GetNumber() : 0;
}
-FX_BOOL CPDF_Dictionary::GetBooleanBy(const CFX_ByteStringC& key,
+FX_BOOL CPDF_Dictionary::GetBooleanBy(const CFX_ByteString& key,
FX_BOOL bDefault) const {
CPDF_Object* p = GetObjectBy(key);
return ToBoolean(p) ? p->GetInteger() : bDefault;
}
-CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteStringC& key) const {
+CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteString& key) const {
CPDF_Object* p = GetDirectObjectBy(key);
if (!p)
return nullptr;
@@ -127,15 +113,15 @@ CPDF_Dictionary* CPDF_Dictionary::GetDictBy(const CFX_ByteStringC& key) const {
return nullptr;
}
-CPDF_Array* CPDF_Dictionary::GetArrayBy(const CFX_ByteStringC& key) const {
+CPDF_Array* CPDF_Dictionary::GetArrayBy(const CFX_ByteString& key) const {
return ToArray(GetDirectObjectBy(key));
}
-CPDF_Stream* CPDF_Dictionary::GetStreamBy(const CFX_ByteStringC& key) const {
+CPDF_Stream* CPDF_Dictionary::GetStreamBy(const CFX_ByteString& key) const {
return ToStream(GetDirectObjectBy(key));
}
-CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteStringC& key) const {
+CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteString& key) const {
CFX_FloatRect rect;
CPDF_Array* pArray = GetArrayBy(key);
if (pArray)
@@ -143,7 +129,7 @@ CFX_FloatRect CPDF_Dictionary::GetRectBy(const CFX_ByteStringC& key) const {
return rect;
}
-CFX_Matrix CPDF_Dictionary::GetMatrixBy(const CFX_ByteStringC& key) const {
+CFX_Matrix CPDF_Dictionary::GetMatrixBy(const CFX_ByteString& key) const {
CFX_Matrix matrix;
CPDF_Array* pArray = GetArrayBy(key);
if (pArray)
@@ -151,7 +137,7 @@ CFX_Matrix CPDF_Dictionary::GetMatrixBy(const CFX_ByteStringC& key) const {
return matrix;
}
-FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteStringC& key) const {
+FX_BOOL CPDF_Dictionary::KeyExist(const CFX_ByteString& key) const {
return pdfium::ContainsKey(m_Map, key);
}
@@ -162,14 +148,11 @@ bool CPDF_Dictionary::IsSignatureDict() const {
return pType && pType->GetString() == "Sig";
}
-void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) {
- ASSERT(IsDictionary());
- // Avoid 2 constructions of CFX_ByteString.
- CFX_ByteString key_bytestring = key;
- auto it = m_Map.find(key_bytestring);
+void CPDF_Dictionary::SetAt(const CFX_ByteString& key, CPDF_Object* pObj) {
+ auto it = m_Map.find(key);
if (it == m_Map.end()) {
if (pObj)
- m_Map.insert(std::make_pair(key_bytestring, pObj));
+ m_Map.insert(std::make_pair(key, pObj));
return;
}
@@ -183,7 +166,7 @@ void CPDF_Dictionary::SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj) {
m_Map.erase(it);
}
-void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) {
+void CPDF_Dictionary::RemoveAt(const CFX_ByteString& key) {
auto it = m_Map.find(key);
if (it == m_Map.end())
return;
@@ -192,15 +175,13 @@ void CPDF_Dictionary::RemoveAt(const CFX_ByteStringC& key) {
m_Map.erase(it);
}
-void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey,
- const CFX_ByteStringC& newkey) {
+void CPDF_Dictionary::ReplaceKey(const CFX_ByteString& oldkey,
+ const CFX_ByteString& newkey) {
auto old_it = m_Map.find(oldkey);
if (old_it == m_Map.end())
return;
- // Avoid 2 constructions of CFX_ByteString.
- CFX_ByteString newkey_bytestring = newkey;
- auto new_it = m_Map.find(newkey_bytestring);
+ auto new_it = m_Map.find(newkey);
if (new_it == old_it)
return;
@@ -208,47 +189,46 @@ void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey,
new_it->second->Release();
new_it->second = old_it->second;
} else {
- m_Map.insert(std::make_pair(newkey_bytestring, old_it->second));
+ m_Map.insert(std::make_pair(newkey, old_it->second));
}
m_Map.erase(old_it);
}
-void CPDF_Dictionary::SetAtInteger(const CFX_ByteStringC& key, int i) {
+void CPDF_Dictionary::SetAtInteger(const CFX_ByteString& key, int i) {
SetAt(key, new CPDF_Number(i));
}
-void CPDF_Dictionary::SetAtName(const CFX_ByteStringC& key,
+void CPDF_Dictionary::SetAtName(const CFX_ByteString& key,
const CFX_ByteString& name) {
SetAt(key, new CPDF_Name(name));
}
-void CPDF_Dictionary::SetAtString(const CFX_ByteStringC& key,
+void CPDF_Dictionary::SetAtString(const CFX_ByteString& key,
const CFX_ByteString& str) {
SetAt(key, new CPDF_String(str, FALSE));
}
-void CPDF_Dictionary::SetAtReference(const CFX_ByteStringC& key,
+void CPDF_Dictionary::SetAtReference(const CFX_ByteString& key,
CPDF_IndirectObjectHolder* pDoc,
uint32_t objnum) {
SetAt(key, new CPDF_Reference(pDoc, objnum));
}
-void CPDF_Dictionary::AddReference(const CFX_ByteStringC& key,
+void CPDF_Dictionary::AddReference(const CFX_ByteString& key,
CPDF_IndirectObjectHolder* pDoc,
uint32_t objnum) {
SetAt(key, new CPDF_Reference(pDoc, objnum));
}
-void CPDF_Dictionary::SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f) {
- CPDF_Number* pNumber = new CPDF_Number(f);
- SetAt(key, pNumber);
+void CPDF_Dictionary::SetAtNumber(const CFX_ByteString& key, FX_FLOAT f) {
+ SetAt(key, new CPDF_Number(f));
}
-void CPDF_Dictionary::SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue) {
+void CPDF_Dictionary::SetAtBoolean(const CFX_ByteString& key, FX_BOOL bValue) {
SetAt(key, new CPDF_Boolean(bValue));
}
-void CPDF_Dictionary::SetAtRect(const CFX_ByteStringC& key,
+void CPDF_Dictionary::SetAtRect(const CFX_ByteString& key,
const CFX_FloatRect& rect) {
CPDF_Array* pArray = new CPDF_Array;
pArray->AddNumber(rect.left);
@@ -258,7 +238,7 @@ void CPDF_Dictionary::SetAtRect(const CFX_ByteStringC& key,
SetAt(key, pArray);
}
-void CPDF_Dictionary::SetAtMatrix(const CFX_ByteStringC& key,
+void CPDF_Dictionary::SetAtMatrix(const CFX_ByteString& key,
const CFX_Matrix& matrix) {
CPDF_Array* pArray = new CPDF_Array;
pArray->AddNumber(matrix.a);
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_document.cpp
index 9058ed67679..13d9737b5b1 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_document.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_document.cpp
@@ -8,6 +8,9 @@
#include <set>
+#include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
+#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
+#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
@@ -15,12 +18,433 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_render/render_int.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/fpdfapi/ipdf_rendermodule.h"
-#include "core/include/fxge/fx_font.h"
+#include "core/fxge/include/fx_font.h"
#include "third_party/base/stl_util.h"
namespace {
+const int FX_MAX_PAGE_LEVEL = 1024;
+
+const uint16_t g_FX_CP874Unicodes[128] = {
+ 0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018,
+ 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A0, 0x0E01, 0x0E02, 0x0E03,
+ 0x0E04, 0x0E05, 0x0E06, 0x0E07, 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C,
+ 0x0E0D, 0x0E0E, 0x0E0F, 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15,
+ 0x0E16, 0x0E17, 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E,
+ 0x0E1F, 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+ 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, 0x0E30,
+ 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, 0x0E38, 0x0E39,
+ 0x0E3A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0E3F, 0x0E40, 0x0E41, 0x0E42,
+ 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, 0x0E48, 0x0E49, 0x0E4A, 0x0E4B,
+ 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54,
+ 0x0E55, 0x0E56, 0x0E57, 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0000, 0x0000,
+ 0x0000, 0x0000,
+};
+const uint16_t g_FX_CP1250Unicodes[128] = {
+ 0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021, 0x0000,
+ 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179, 0x0000, 0x2018,
+ 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0161,
+ 0x203A, 0x015B, 0x0165, 0x017E, 0x017A, 0x00A0, 0x02C7, 0x02D8, 0x0141,
+ 0x00A4, 0x0104, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC,
+ 0x00AD, 0x00AE, 0x017B, 0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5,
+ 0x00B6, 0x00B7, 0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E,
+ 0x017C, 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, 0x0110,
+ 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158, 0x016E,
+ 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, 0x0155, 0x00E1, 0x00E2,
+ 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D, 0x00E9, 0x0119, 0x00EB,
+ 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4,
+ 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD,
+ 0x0163, 0x02D9,
+};
+const uint16_t g_FX_CP1251Unicodes[128] = {
+ 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, 0x20AC,
+ 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, 0x0452, 0x2018,
+ 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0459,
+ 0x203A, 0x045A, 0x045C, 0x045B, 0x045F, 0x00A0, 0x040E, 0x045E, 0x0408,
+ 0x00A4, 0x0490, 0x00A6, 0x00A7, 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC,
+ 0x00AD, 0x00AE, 0x0407, 0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5,
+ 0x00B6, 0x00B7, 0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455,
+ 0x0457, 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420,
+ 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429,
+ 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, 0x0430, 0x0431, 0x0432,
+ 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B,
+ 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444,
+ 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D,
+ 0x044E, 0x044F,
+};
+const uint16_t g_FX_CP1253Unicodes[128] = {
+ 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x0000,
+ 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018,
+ 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0000,
+ 0x203A, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A0, 0x0385, 0x0386, 0x00A3,
+ 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x0000, 0x00AB, 0x00AC,
+ 0x00AD, 0x00AE, 0x2015, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5,
+ 0x00B6, 0x00B7, 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E,
+ 0x038F, 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
+ 0x03A1, 0x0000, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
+ 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, 0x03B0, 0x03B1, 0x03B2,
+ 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB,
+ 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4,
+ 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD,
+ 0x03CE, 0x0000,
+};
+const uint16_t g_FX_CP1254Unicodes[128] = {
+ 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6,
+ 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018,
+ 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0161,
+ 0x203A, 0x0153, 0x0000, 0x0000, 0x0178, 0x00A0, 0x00A1, 0x00A2, 0x00A3,
+ 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC,
+ 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5,
+ 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE,
+ 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x011E,
+ 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9,
+ 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, 0x00E0, 0x00E1, 0x00E2,
+ 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB,
+ 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4,
+ 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131,
+ 0x015F, 0x00FF,
+};
+const uint16_t g_FX_CP1255Unicodes[128] = {
+ 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6,
+ 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2018,
+ 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0000,
+ 0x203A, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A0, 0x00A1, 0x00A2, 0x00A3,
+ 0x20AA, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC,
+ 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5,
+ 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE,
+ 0x00BF, 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
+ 0x05B8, 0x05B9, 0x0000, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF, 0x05C0,
+ 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x05D0, 0x05D1, 0x05D2,
+ 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB,
+ 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4,
+ 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x0000, 0x0000, 0x200E,
+ 0x200F, 0x0000,
+};
+const uint16_t g_FX_CP1256Unicodes[128] = {
+ 0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6,
+ 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688, 0x06AF, 0x2018,
+ 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x06A9, 0x2122, 0x0691,
+ 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA, 0x00A0, 0x060C, 0x00A2, 0x00A3,
+ 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC,
+ 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5,
+ 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE,
+ 0x061F, 0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
+ 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630,
+ 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7, 0x0637, 0x0638,
+ 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643, 0x00E0, 0x0644, 0x00E2,
+ 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB,
+ 0x0649, 0x064A, 0x00EE, 0x00EF, 0x064B, 0x064C, 0x064D, 0x064E, 0x00F4,
+ 0x064F, 0x0650, 0x00F7, 0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E,
+ 0x200F, 0x06D2,
+};
+const uint16_t g_FX_CP1257Unicodes[128] = {
+ 0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021, 0x0000,
+ 0x2030, 0x0000, 0x2039, 0x0000, 0x00A8, 0x02C7, 0x00B8, 0x0000, 0x2018,
+ 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0000, 0x2122, 0x0000,
+ 0x203A, 0x0000, 0x00AF, 0x02DB, 0x0000, 0x00A0, 0x0000, 0x00A2, 0x00A3,
+ 0x00A4, 0x0000, 0x00A6, 0x00A7, 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC,
+ 0x00AD, 0x00AE, 0x00C6, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5,
+ 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE,
+ 0x00E6, 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
+ 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, 0x0160,
+ 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141,
+ 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, 0x0105, 0x012F, 0x0101,
+ 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117,
+ 0x0123, 0x0137, 0x012B, 0x013C, 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D,
+ 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C,
+ 0x017E, 0x02D9,
+};
+
+struct FX_CharsetUnicodes {
+ uint8_t m_Charset;
+ const uint16_t* m_pUnicodes;
+};
+
+const FX_CharsetUnicodes g_FX_CharsetUnicodes[] = {
+ {FXFONT_THAI_CHARSET, g_FX_CP874Unicodes},
+ {FXFONT_EASTEUROPE_CHARSET, g_FX_CP1250Unicodes},
+ {FXFONT_RUSSIAN_CHARSET, g_FX_CP1251Unicodes},
+ {FXFONT_GREEK_CHARSET, g_FX_CP1253Unicodes},
+ {FXFONT_TURKISH_CHARSET, g_FX_CP1254Unicodes},
+ {FXFONT_HEBREW_CHARSET, g_FX_CP1255Unicodes},
+ {FXFONT_ARABIC_CHARSET, g_FX_CP1256Unicodes},
+ {FXFONT_BALTIC_CHARSET, g_FX_CP1257Unicodes},
+};
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+void InsertWidthArray(HDC hDC, int start, int end, CPDF_Array* pWidthArray) {
+ int size = end - start + 1;
+ int* widths = FX_Alloc(int, size);
+ GetCharWidth(hDC, start, end, widths);
+ int i;
+ for (i = 1; i < size; i++) {
+ if (widths[i] != *widths)
+ break;
+ }
+ if (i == size) {
+ int first = pWidthArray->GetIntegerAt(pWidthArray->GetCount() - 1);
+ pWidthArray->AddInteger(first + size - 1);
+ pWidthArray->AddInteger(*widths);
+ } else {
+ CPDF_Array* pWidthArray1 = new CPDF_Array;
+ pWidthArray->Add(pWidthArray1);
+ for (i = 0; i < size; i++) {
+ pWidthArray1->AddInteger(widths[i]);
+ }
+ }
+ FX_Free(widths);
+}
+
+CFX_ByteString FPDF_GetPSNameFromTT(HDC hDC) {
+ CFX_ByteString result;
+ DWORD size = ::GetFontData(hDC, 'eman', 0, nullptr, 0);
+ if (size != GDI_ERROR) {
+ LPBYTE buffer = FX_Alloc(BYTE, size);
+ ::GetFontData(hDC, 'eman', 0, buffer, size);
+ result = GetNameFromTT(buffer, size, 6);
+ FX_Free(buffer);
+ }
+ return result;
+}
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
+struct FX_LANG2CS {
+ uint32_t uLang;
+ uint8_t uCharset;
+};
+const FX_LANG2CS gs_FXLang2CharsetTable[] = {
+ {3109, 0}, {3121, 178}, {3129, 162}, {3139, 204}, {3141, 204},
+ {3166, 0}, {3184, 238}, {3197, 0}, {3201, 0}, {3239, 161},
+ {3241, 0}, {3246, 0}, {3247, 186}, {3248, 0}, {3259, 178},
+ {3267, 0}, {3273, 0}, {3276, 0}, {3301, 0}, {3310, 1},
+ {3325, 177}, {3329, 1}, {3338, 238}, {3341, 238}, {3345, 1},
+ {3355, 0}, {3370, 0}, {3371, 0}, {3383, 128}, {3424, 204},
+ {3427, 1}, {3428, 129}, {3436, 178}, {3464, 186}, {3466, 186},
+ {3486, 204}, {3487, 0}, {3493, 1}, {3494, 0}, {3508, 0},
+ {3518, 0}, {3520, 0}, {3569, 1}, {3580, 238}, {3588, 0},
+ {3645, 238}, {3651, 204}, {3672, 238}, {3673, 238}, {3678, 238},
+ {3679, 238}, {3683, 0}, {3684, 0}, {3693, 1}, {3697, 1},
+ {3700, 222}, {3710, 162}, {3734, 204}, {3741, 178}, {3749, 162},
+ {3763, 163}, {3886, 134}, {105943, 0}, {106375, 1}, {3923451837, 134},
+ {3923451838, 136},
+};
+
+uint32_t FX_GetLangHashCode(const FX_CHAR* pStr) {
+ ASSERT(pStr);
+ int32_t iLength = FXSYS_strlen(pStr);
+ const FX_CHAR* pStrEnd = pStr + iLength;
+ uint32_t uHashCode = 0;
+ while (pStr < pStrEnd)
+ uHashCode = 31 * uHashCode + tolower(*pStr++);
+ return uHashCode;
+}
+
+uint8_t FX_GetCsFromLangCode(uint32_t uCode) {
+ int32_t iStart = 0;
+ int32_t iEnd = FX_ArraySize(gs_FXLang2CharsetTable) - 1;
+ while (iStart <= iEnd) {
+ int32_t iMid = (iStart + iEnd) / 2;
+ const FX_LANG2CS& charset = gs_FXLang2CharsetTable[iMid];
+ if (uCode == charset.uLang)
+ return charset.uCharset;
+
+ if (uCode < charset.uLang)
+ iEnd = iMid - 1;
+ else
+ iStart = iMid + 1;
+ }
+ return 0;
+}
+
+uint8_t FX_GetCharsetFromLang(const FX_CHAR* pLang, int32_t iLength) {
+ ASSERT(pLang);
+ if (iLength < 0)
+ iLength = FXSYS_strlen(pLang);
+
+ uint32_t uHash = FX_GetLangHashCode(pLang);
+ return FX_GetCsFromLangCode(uHash);
+}
+
+void CFString2CFXByteString(CFStringRef src, CFX_ByteString& dest) {
+ SInt32 len = CFStringGetLength(src);
+ CFRange range = CFRangeMake(0, len);
+ CFIndex used = 0;
+ UInt8* pBuffer = (UInt8*)calloc(len + 1, sizeof(UInt8));
+ CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len,
+ &used);
+ dest = (FX_CHAR*)pBuffer;
+ free(pBuffer);
+}
+
+bool HasCharSet(CFArrayRef languages, const std::vector<uint8_t>& charsets) {
+ for (int i = 0; i < CFArrayGetCount(languages); ++i) {
+ CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i);
+ uint8_t charset = FX_GetCharsetFromLang(
+ CFStringGetCStringPtr(language, kCFStringEncodingMacRoman), -1);
+ if (pdfium::ContainsValue(charsets, charset))
+ return true;
+ }
+ return false;
+}
+
+void FX_GetCharWidth(CTFontRef font, UniChar start, UniChar end, int* width) {
+ CGFloat size = CTFontGetSize(font);
+ for (; start <= end; ++start) {
+ CGGlyph pGlyph = 0;
+ CFIndex count = 1;
+ CTFontGetGlyphsForCharacters(font, &start, &pGlyph, count);
+ CGSize advances;
+ CTFontGetAdvancesForGlyphs(font, kCTFontDefaultOrientation, &pGlyph,
+ &advances, 1);
+ *width = (int)(advances.width / size * 1000);
+ width++;
+ }
+}
+
+void InsertWidthArray(CTFontRef font,
+ int start,
+ int end,
+ CPDF_Array* pWidthArray) {
+ int size = end - start + 1;
+ int* widths = FX_Alloc(int, size);
+ FX_GetCharWidth(font, start, end, widths);
+ int i;
+ for (i = 1; i < size; i++) {
+ if (widths[i] != *widths)
+ break;
+ }
+ if (i == size) {
+ int first = pWidthArray->GetIntegerAt(pWidthArray->GetCount() - 1);
+ pWidthArray->AddInteger(first + size - 1);
+ pWidthArray->AddInteger(*widths);
+ } else {
+ CPDF_Array* pWidthArray1 = new CPDF_Array;
+ pWidthArray->Add(pWidthArray1);
+ for (i = 0; i < size; i++) {
+ pWidthArray1->AddInteger(widths[i]);
+ }
+ }
+ FX_Free(widths);
+}
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
+
+void InsertWidthArray1(CFX_Font* pFont,
+ CFX_UnicodeEncoding* pEncoding,
+ FX_WCHAR start,
+ FX_WCHAR end,
+ CPDF_Array* pWidthArray) {
+ int size = end - start + 1;
+ int* widths = FX_Alloc(int, size);
+ int i;
+ for (i = 0; i < size; i++) {
+ int glyph_index = pEncoding->GlyphFromCharCode(start + i);
+ widths[i] = pFont->GetGlyphWidth(glyph_index);
+ }
+ for (i = 1; i < size; i++) {
+ if (widths[i] != *widths)
+ break;
+ }
+ if (i == size) {
+ int first = pWidthArray->GetIntegerAt(pWidthArray->GetCount() - 1);
+ pWidthArray->AddInteger(first + size - 1);
+ pWidthArray->AddInteger(*widths);
+ } else {
+ CPDF_Array* pWidthArray1 = new CPDF_Array;
+ pWidthArray->Add(pWidthArray1);
+ for (i = 0; i < size; i++) {
+ pWidthArray1->AddInteger(widths[i]);
+ }
+ }
+ FX_Free(widths);
+}
+
+int InsertDeletePDFPage(CPDF_Document* pDoc,
+ CPDF_Dictionary* pPages,
+ int nPagesToGo,
+ CPDF_Dictionary* pPage,
+ FX_BOOL bInsert,
+ std::set<CPDF_Dictionary*>* pVisited) {
+ CPDF_Array* pKidList = pPages->GetArrayBy("Kids");
+ if (!pKidList)
+ return -1;
+
+ for (size_t i = 0; i < pKidList->GetCount(); i++) {
+ CPDF_Dictionary* pKid = pKidList->GetDictAt(i);
+ if (pKid->GetStringBy("Type") == "Page") {
+ if (nPagesToGo == 0) {
+ if (bInsert) {
+ pKidList->InsertAt(i, new CPDF_Reference(pDoc, pPage->GetObjNum()));
+ pPage->SetAtReference("Parent", pDoc, pPages->GetObjNum());
+ } else {
+ pKidList->RemoveAt(i);
+ }
+ pPages->SetAtInteger(
+ "Count", pPages->GetIntegerBy("Count") + (bInsert ? 1 : -1));
+ return 1;
+ }
+ nPagesToGo--;
+ } else {
+ int nPages = pKid->GetIntegerBy("Count");
+ if (nPagesToGo < nPages) {
+ if (pdfium::ContainsValue(*pVisited, pKid))
+ return -1;
+ pdfium::ScopedSetInsertion<CPDF_Dictionary*>(pVisited, pKid);
+ if (InsertDeletePDFPage(pDoc, pKid, nPagesToGo, pPage, bInsert,
+ pVisited) < 0) {
+ return -1;
+ }
+ pPages->SetAtInteger(
+ "Count", pPages->GetIntegerBy("Count") + (bInsert ? 1 : -1));
+ return 1;
+ }
+ nPagesToGo -= nPages;
+ }
+ }
+ return 0;
+}
+
+int InsertNewPage(CPDF_Document* pDoc,
+ int iPage,
+ CPDF_Dictionary* pPageDict,
+ CFX_ArrayTemplate<uint32_t>& pageList) {
+ CPDF_Dictionary* pRoot = pDoc->GetRoot();
+ if (!pRoot)
+ return -1;
+
+ CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages");
+ if (!pPages)
+ return -1;
+
+ int nPages = pDoc->GetPageCount();
+ if (iPage < 0 || iPage > nPages)
+ return -1;
+
+ if (iPage == nPages) {
+ CPDF_Array* pPagesList = pPages->GetArrayBy("Kids");
+ if (!pPagesList) {
+ pPagesList = new CPDF_Array;
+ pPages->SetAt("Kids", pPagesList);
+ }
+ pPagesList->Add(pPageDict, pDoc);
+ pPages->SetAtInteger("Count", nPages + 1);
+ pPageDict->SetAtReference("Parent", pDoc, pPages->GetObjNum());
+ } else {
+ std::set<CPDF_Dictionary*> stack = {pPages};
+ if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, &stack) < 0)
+ return -1;
+ }
+ pageList.InsertAt(iPage, pPageDict->GetObjNum());
+ return iPage;
+}
+
int CountPages(CPDF_Dictionary* pPages,
std::set<CPDF_Dictionary*>* visited_pages) {
int count = pPages->GetIntegerBy("Count");
@@ -32,7 +456,7 @@ int CountPages(CPDF_Dictionary* pPages,
return 0;
}
count = 0;
- for (uint32_t i = 0; i < pKidList->GetCount(); i++) {
+ for (size_t i = 0; i < pKidList->GetCount(); i++) {
CPDF_Dictionary* pKid = pKidList->GetDictAt(i);
if (!pKid || pdfium::ContainsKey(*visited_pages, pKid)) {
continue;
@@ -54,30 +478,20 @@ int CountPages(CPDF_Dictionary* pPages,
} // namespace
CPDF_Document::CPDF_Document(CPDF_Parser* pParser)
- : CPDF_IndirectObjectHolder(pParser) {
- ASSERT(pParser);
- m_pRootDict = NULL;
- m_pInfoDict = NULL;
- m_bLinearized = FALSE;
- m_dwFirstPageNo = 0;
- m_dwFirstPageObjNum = 0;
- m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this);
- m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this);
-}
-CPDF_DocPageData* CPDF_Document::GetValidatePageData() {
- if (m_pDocPage) {
- return m_pDocPage;
- }
- m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this);
- return m_pDocPage;
-}
-CPDF_DocRenderData* CPDF_Document::GetValidateRenderData() {
- if (m_pDocRender) {
- return m_pDocRender;
- }
- m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this);
- return m_pDocRender;
+ : CPDF_IndirectObjectHolder(pParser),
+ m_pRootDict(nullptr),
+ m_pInfoDict(nullptr),
+ m_bLinearized(false),
+ m_iFirstPageNo(0),
+ m_dwFirstPageObjNum(0),
+ m_pDocPage(new CPDF_DocPageData(this)),
+ m_pDocRender(new CPDF_DocRenderData(this)) {}
+
+CPDF_Document::~CPDF_Document() {
+ delete m_pDocPage;
+ CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this);
}
+
void CPDF_Document::LoadDoc() {
m_LastObjNum = m_pParser->GetLastObjNum();
CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum());
@@ -99,8 +513,9 @@ void CPDF_Document::LoadDoc() {
}
m_PageList.SetSize(RetrievePageCount());
}
+
void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) {
- m_bLinearized = TRUE;
+ m_bLinearized = true;
m_LastObjNum = m_pParser->GetLastObjNum();
CPDF_Object* pIndirectObj = GetIndirectObject(m_pParser->GetRootObjNum());
m_pRootDict = pIndirectObj ? pIndirectObj->GetDict() : nullptr;
@@ -122,41 +537,29 @@ void CPDF_Document::LoadAsynDoc(CPDF_Dictionary* pLinearized) {
m_PageList.SetSize(dwPageCount);
CPDF_Object* pNo = pLinearized->GetObjectBy("P");
if (ToNumber(pNo))
- m_dwFirstPageNo = pNo->GetInteger();
+ m_iFirstPageNo = pNo->GetInteger();
CPDF_Object* pObjNum = pLinearized->GetObjectBy("O");
if (ToNumber(pObjNum))
m_dwFirstPageObjNum = pObjNum->GetInteger();
}
+
void CPDF_Document::LoadPages() {
m_PageList.SetSize(RetrievePageCount());
}
-CPDF_Document::~CPDF_Document() {
- if (m_pDocPage) {
- CPDF_ModuleMgr::Get()->GetPageModule()->ReleaseDoc(this);
- CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this);
- }
- if (m_pDocRender) {
- CPDF_ModuleMgr::Get()->GetRenderModule()->DestroyDocData(m_pDocRender);
- }
-}
-#define FX_MAX_PAGE_LEVEL 1024
-CPDF_Dictionary* CPDF_Document::_FindPDFPage(CPDF_Dictionary* pPages,
- int iPage,
- int nPagesToGo,
- int level) {
+
+CPDF_Dictionary* CPDF_Document::FindPDFPage(CPDF_Dictionary* pPages,
+ int iPage,
+ int nPagesToGo,
+ int level) {
CPDF_Array* pKidList = pPages->GetArrayBy("Kids");
- if (!pKidList) {
- if (nPagesToGo == 0) {
- return pPages;
- }
- return NULL;
- }
- if (level >= FX_MAX_PAGE_LEVEL) {
- return NULL;
- }
- int nKids = pKidList->GetCount();
- for (int i = 0; i < nKids; i++) {
+ if (!pKidList)
+ return nPagesToGo == 0 ? pPages : nullptr;
+
+ if (level >= FX_MAX_PAGE_LEVEL)
+ return nullptr;
+
+ for (size_t i = 0; i < pKidList->GetCount(); i++) {
CPDF_Dictionary* pKid = pKidList->GetDictAt(i);
if (!pKid) {
nPagesToGo--;
@@ -174,19 +577,19 @@ CPDF_Dictionary* CPDF_Document::_FindPDFPage(CPDF_Dictionary* pPages,
} else {
int nPages = pKid->GetIntegerBy("Count");
if (nPagesToGo < nPages) {
- return _FindPDFPage(pKid, iPage, nPagesToGo, level + 1);
+ return FindPDFPage(pKid, iPage, nPagesToGo, level + 1);
}
nPagesToGo -= nPages;
}
}
- return NULL;
+ return nullptr;
}
CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
if (iPage < 0 || iPage >= m_PageList.GetSize())
return nullptr;
- if (m_bLinearized && (iPage == (int)m_dwFirstPageNo)) {
+ if (m_bLinearized && (iPage == m_iFirstPageNo)) {
if (CPDF_Dictionary* pDict =
ToDictionary(GetIndirectObject(m_dwFirstPageObjNum))) {
return pDict;
@@ -207,7 +610,7 @@ CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
if (!pPages)
return nullptr;
- CPDF_Dictionary* pPage = _FindPDFPage(pPages, iPage, iPage, 0);
+ CPDF_Dictionary* pPage = FindPDFPage(pPages, iPage, iPage, 0);
if (!pPage)
return nullptr;
@@ -215,111 +618,109 @@ CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
return pPage;
}
-int CPDF_Document::_FindPageIndex(CPDF_Dictionary* pNode,
- uint32_t& skip_count,
- uint32_t objnum,
- int& index,
- int level) {
- if (pNode->KeyExist("Kids")) {
- CPDF_Array* pKidList = pNode->GetArrayBy("Kids");
- if (!pKidList) {
- return -1;
- }
- if (level >= FX_MAX_PAGE_LEVEL) {
- return -1;
- }
- uint32_t count = pNode->GetIntegerBy("Count");
- if (count <= skip_count) {
- skip_count -= count;
- index += count;
- return -1;
- }
- if (count && count == pKidList->GetCount()) {
- for (uint32_t i = 0; i < count; i++) {
- if (CPDF_Reference* pKid = ToReference(pKidList->GetObjectAt(i))) {
- if (pKid->GetRefObjNum() == objnum) {
- m_PageList.SetAt(index + i, objnum);
- return index + i;
- }
- }
- }
- }
- for (uint32_t i = 0; i < pKidList->GetCount(); i++) {
- CPDF_Dictionary* pKid = pKidList->GetDictAt(i);
- if (!pKid) {
- continue;
- }
- if (pKid == pNode) {
- continue;
- }
- int found_index =
- _FindPageIndex(pKid, skip_count, objnum, index, level + 1);
- if (found_index >= 0) {
- return found_index;
- }
- }
- } else {
- if (objnum == pNode->GetObjNum()) {
+int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode,
+ uint32_t& skip_count,
+ uint32_t objnum,
+ int& index,
+ int level) {
+ if (!pNode->KeyExist("Kids")) {
+ if (objnum == pNode->GetObjNum())
return index;
- }
- if (skip_count) {
+
+ if (skip_count)
skip_count--;
- }
+
index++;
+ return -1;
+ }
+
+ CPDF_Array* pKidList = pNode->GetArrayBy("Kids");
+ if (!pKidList)
+ return -1;
+
+ if (level >= FX_MAX_PAGE_LEVEL)
+ return -1;
+
+ size_t count = pNode->GetIntegerBy("Count");
+ if (count <= skip_count) {
+ skip_count -= count;
+ index += count;
+ return -1;
+ }
+
+ if (count && count == pKidList->GetCount()) {
+ for (size_t i = 0; i < count; i++) {
+ if (CPDF_Reference* pKid = ToReference(pKidList->GetObjectAt(i))) {
+ if (pKid->GetRefObjNum() == objnum) {
+ m_PageList.SetAt(index + i, objnum);
+ return static_cast<int>(index + i);
+ }
+ }
+ }
+ }
+
+ for (size_t i = 0; i < pKidList->GetCount(); i++) {
+ CPDF_Dictionary* pKid = pKidList->GetDictAt(i);
+ if (!pKid || pKid == pNode)
+ continue;
+
+ int found_index = FindPageIndex(pKid, skip_count, objnum, index, level + 1);
+ if (found_index >= 0)
+ return found_index;
}
return -1;
}
+
int CPDF_Document::GetPageIndex(uint32_t objnum) {
uint32_t nPages = m_PageList.GetSize();
uint32_t skip_count = 0;
- FX_BOOL bSkipped = FALSE;
+ bool bSkipped = false;
for (uint32_t i = 0; i < nPages; i++) {
uint32_t objnum1 = m_PageList.GetAt(i);
- if (objnum1 == objnum) {
+ if (objnum1 == objnum)
return i;
- }
+
if (!bSkipped && objnum1 == 0) {
skip_count = i;
- bSkipped = TRUE;
+ bSkipped = true;
}
}
CPDF_Dictionary* pRoot = GetRoot();
- if (!pRoot) {
+ if (!pRoot)
return -1;
- }
+
CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages");
- if (!pPages) {
+ if (!pPages)
return -1;
- }
+
int index = 0;
- return _FindPageIndex(pPages, skip_count, objnum, index);
+ return FindPageIndex(pPages, skip_count, objnum, index);
}
+
int CPDF_Document::GetPageCount() const {
return m_PageList.GetSize();
}
int CPDF_Document::RetrievePageCount() const {
CPDF_Dictionary* pRoot = GetRoot();
- if (!pRoot) {
+ if (!pRoot)
return 0;
- }
+
CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages");
- if (!pPages) {
+ if (!pPages)
return 0;
- }
- if (!pPages->KeyExist("Kids")) {
+
+ if (!pPages->KeyExist("Kids"))
return 1;
- }
+
std::set<CPDF_Dictionary*> visited_pages;
visited_pages.insert(pPages);
return CountPages(pPages, &visited_pages);
}
uint32_t CPDF_Document::GetUserPermissions(FX_BOOL bCheckRevision) const {
- if (!m_pParser) {
- return (uint32_t)-1;
- }
- return m_pParser->GetPermissions(bCheckRevision);
+ return m_pParser ? m_pParser->GetPermissions(bCheckRevision)
+ : static_cast<uint32_t>(-1);
}
FX_BOOL CPDF_Document::IsFormStream(uint32_t objnum, FX_BOOL& bForm) const {
@@ -336,21 +737,712 @@ FX_BOOL CPDF_Document::IsFormStream(uint32_t objnum, FX_BOOL& bForm) const {
return m_pParser->IsFormStream(objnum, bForm);
}
+CPDF_Font* CPDF_Document::LoadFont(CPDF_Dictionary* pFontDict) {
+ ASSERT(pFontDict);
+ return m_pDocPage->GetFont(pFontDict, FALSE);
+}
+
+CPDF_StreamAcc* CPDF_Document::LoadFontFile(CPDF_Stream* pStream) {
+ return m_pDocPage->GetFontFileStreamAcc(pStream);
+}
+
+CPDF_ColorSpace* CPDF_Document::LoadColorSpace(CPDF_Object* pCSObj,
+ CPDF_Dictionary* pResources) {
+ return m_pDocPage->GetColorSpace(pCSObj, pResources);
+}
+
+CPDF_Pattern* CPDF_Document::LoadPattern(CPDF_Object* pPatternObj,
+ FX_BOOL bShading,
+ const CFX_Matrix& matrix) {
+ return m_pDocPage->GetPattern(pPatternObj, bShading, matrix);
+}
+
+CPDF_IccProfile* CPDF_Document::LoadIccProfile(CPDF_Stream* pStream) {
+ return m_pDocPage->GetIccProfile(pStream);
+}
+
+CPDF_Image* CPDF_Document::LoadImageF(CPDF_Object* pObj) {
+ if (!pObj)
+ return nullptr;
+
+ ASSERT(pObj->GetObjNum());
+ return m_pDocPage->GetImage(pObj);
+}
+
+void CPDF_Document::RemoveColorSpaceFromPageData(CPDF_Object* pCSObj) {
+ if (pCSObj)
+ GetPageData()->ReleaseColorSpace(pCSObj);
+}
+
void CPDF_Document::ClearPageData() {
- if (m_pDocPage)
- CPDF_ModuleMgr::Get()->GetPageModule()->ClearDoc(this);
+ GetPageData()->Clear(FALSE);
}
void CPDF_Document::ClearRenderData() {
- if (m_pDocRender)
- CPDF_ModuleMgr::Get()->GetRenderModule()->ClearDocData(m_pDocRender);
+ m_pDocRender->Clear(FALSE);
}
void CPDF_Document::ClearRenderFont() {
- if (!m_pDocRender)
- return;
-
CFX_FontCache* pCache = m_pDocRender->GetFontCache();
if (pCache)
pCache->FreeCache(FALSE);
}
+
+void CPDF_Document::CreateNewDoc() {
+ ASSERT(!m_pRootDict && !m_pInfoDict);
+ m_pRootDict = new CPDF_Dictionary;
+ m_pRootDict->SetAtName("Type", "Catalog");
+ int objnum = AddIndirectObject(m_pRootDict);
+ CPDF_Dictionary* pPages = new CPDF_Dictionary;
+ pPages->SetAtName("Type", "Pages");
+ pPages->SetAtNumber("Count", 0);
+ pPages->SetAt("Kids", new CPDF_Array);
+ objnum = AddIndirectObject(pPages);
+ m_pRootDict->SetAtReference("Pages", this, objnum);
+ m_pInfoDict = new CPDF_Dictionary;
+ AddIndirectObject(m_pInfoDict);
+}
+
+CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) {
+ CPDF_Dictionary* pDict = new CPDF_Dictionary;
+ pDict->SetAtName("Type", "Page");
+ uint32_t dwObjNum = AddIndirectObject(pDict);
+ if (InsertNewPage(this, iPage, pDict, m_PageList) < 0) {
+ ReleaseIndirectObject(dwObjNum);
+ return nullptr;
+ }
+ return pDict;
+}
+
+void CPDF_Document::DeletePage(int iPage) {
+ CPDF_Dictionary* pRoot = GetRoot();
+ if (!pRoot)
+ return;
+
+ CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages");
+ if (!pPages)
+ return;
+
+ int nPages = pPages->GetIntegerBy("Count");
+ if (iPage < 0 || iPage >= nPages)
+ return;
+
+ std::set<CPDF_Dictionary*> stack = {pPages};
+ if (InsertDeletePDFPage(this, pPages, iPage, nullptr, FALSE, &stack) < 0)
+ return;
+
+ m_PageList.RemoveAt(iPage);
+}
+
+CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font,
+ CPDF_FontEncoding* pEncoding) {
+ CFX_ByteString name(font);
+ if (PDF_GetStandardFontName(&name) < 0)
+ return nullptr;
+ return GetPageData()->GetStandardFont(name, pEncoding);
+}
+
+CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
+ if (!pFont)
+ return nullptr;
+
+ bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET ||
+ charset == FXFONT_GB2312_CHARSET ||
+ charset == FXFONT_HANGEUL_CHARSET ||
+ charset == FXFONT_SHIFTJIS_CHARSET;
+ CFX_ByteString basefont = pFont->GetFamilyName();
+ basefont.Replace(" ", "");
+ int flags = 0;
+ if (pFont->IsBold())
+ flags |= PDFFONT_FORCEBOLD;
+ if (pFont->IsItalic())
+ flags |= PDFFONT_ITALIC;
+ if (pFont->IsFixedWidth())
+ flags |= PDFFONT_FIXEDPITCH;
+
+ CPDF_Dictionary* pBaseDict = new CPDF_Dictionary;
+ pBaseDict->SetAtName("Type", "Font");
+ std::unique_ptr<CFX_UnicodeEncoding> pEncoding(
+ new CFX_UnicodeEncoding(pFont));
+ CPDF_Dictionary* pFontDict = pBaseDict;
+ if (!bCJK) {
+ CPDF_Array* pWidths = new CPDF_Array;
+ for (int charcode = 32; charcode < 128; charcode++) {
+ int glyph_index = pEncoding->GlyphFromCharCode(charcode);
+ int char_width = pFont->GetGlyphWidth(glyph_index);
+ pWidths->AddInteger(char_width);
+ }
+ if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET ||
+ charset == FXFONT_SYMBOL_CHARSET) {
+ if (charset == FXFONT_SYMBOL_CHARSET) {
+ flags |= PDFFONT_SYMBOLIC;
+ } else {
+ flags |= PDFFONT_NONSYMBOLIC;
+ }
+ pBaseDict->SetAtName("Encoding", "WinAnsiEncoding");
+ for (int charcode = 128; charcode <= 255; charcode++) {
+ int glyph_index = pEncoding->GlyphFromCharCode(charcode);
+ int char_width = pFont->GetGlyphWidth(glyph_index);
+ pWidths->AddInteger(char_width);
+ }
+ } else {
+ flags |= PDFFONT_NONSYMBOLIC;
+ size_t i;
+ for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) {
+ if (g_FX_CharsetUnicodes[i].m_Charset == charset)
+ break;
+ }
+ if (i < FX_ArraySize(g_FX_CharsetUnicodes)) {
+ CPDF_Dictionary* pEncodingDict = new CPDF_Dictionary;
+ pEncodingDict->SetAtName("BaseEncoding", "WinAnsiEncoding");
+ CPDF_Array* pArray = new CPDF_Array;
+ pArray->AddInteger(128);
+ const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
+ for (int j = 0; j < 128; j++) {
+ CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
+ pArray->AddName(name.IsEmpty() ? ".notdef" : name);
+ int glyph_index = pEncoding->GlyphFromCharCode(pUnicodes[j]);
+ int char_width = pFont->GetGlyphWidth(glyph_index);
+ pWidths->AddInteger(char_width);
+ }
+ pEncodingDict->SetAt("Differences", pArray);
+ AddIndirectObject(pEncodingDict);
+ pBaseDict->SetAtReference("Encoding", this, pEncodingDict);
+ }
+ }
+ if (pFont->IsBold() && pFont->IsItalic())
+ basefont += ",BoldItalic";
+ else if (pFont->IsBold())
+ basefont += ",Bold";
+ else if (pFont->IsItalic())
+ basefont += ",Italic";
+
+ pBaseDict->SetAtName("Subtype", "TrueType");
+ pBaseDict->SetAtName("BaseFont", basefont);
+ pBaseDict->SetAtNumber("FirstChar", 32);
+ pBaseDict->SetAtNumber("LastChar", 255);
+ pBaseDict->SetAt("Widths", pWidths);
+ } else {
+ flags |= PDFFONT_NONSYMBOLIC;
+ pFontDict = new CPDF_Dictionary;
+ CFX_ByteString cmap;
+ CFX_ByteString ordering;
+ int supplement = 0;
+ CPDF_Array* pWidthArray = new CPDF_Array;
+ switch (charset) {
+ case FXFONT_CHINESEBIG5_CHARSET:
+ cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
+ ordering = "CNS1";
+ supplement = 4;
+ pWidthArray->AddInteger(1);
+ InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7e, pWidthArray);
+ break;
+ case FXFONT_GB2312_CHARSET:
+ cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
+ ordering = "GB1";
+ supplement = 2;
+ pWidthArray->AddInteger(7716);
+ InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x20, pWidthArray);
+ pWidthArray->AddInteger(814);
+ InsertWidthArray1(pFont, pEncoding.get(), 0x21, 0x7e, pWidthArray);
+ break;
+ case FXFONT_HANGEUL_CHARSET:
+ cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
+ ordering = "Korea1";
+ supplement = 2;
+ pWidthArray->AddInteger(1);
+ InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7e, pWidthArray);
+ break;
+ case FXFONT_SHIFTJIS_CHARSET:
+ cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
+ ordering = "Japan1";
+ supplement = 5;
+ pWidthArray->AddInteger(231);
+ InsertWidthArray1(pFont, pEncoding.get(), 0x20, 0x7d, pWidthArray);
+ pWidthArray->AddInteger(326);
+ InsertWidthArray1(pFont, pEncoding.get(), 0xa0, 0xa0, pWidthArray);
+ pWidthArray->AddInteger(327);
+ InsertWidthArray1(pFont, pEncoding.get(), 0xa1, 0xdf, pWidthArray);
+ pWidthArray->AddInteger(631);
+ InsertWidthArray1(pFont, pEncoding.get(), 0x7e, 0x7e, pWidthArray);
+ break;
+ }
+ pBaseDict->SetAtName("Subtype", "Type0");
+ pBaseDict->SetAtName("BaseFont", basefont);
+ pBaseDict->SetAtName("Encoding", cmap);
+ pFontDict->SetAt("W", pWidthArray);
+ pFontDict->SetAtName("Type", "Font");
+ pFontDict->SetAtName("Subtype", "CIDFontType2");
+ pFontDict->SetAtName("BaseFont", basefont);
+ CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary;
+ pCIDSysInfo->SetAtString("Registry", "Adobe");
+ pCIDSysInfo->SetAtString("Ordering", ordering);
+ pCIDSysInfo->SetAtInteger("Supplement", supplement);
+ pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
+ CPDF_Array* pArray = new CPDF_Array;
+ pBaseDict->SetAt("DescendantFonts", pArray);
+ AddIndirectObject(pFontDict);
+ pArray->AddReference(this, pFontDict);
+ }
+ AddIndirectObject(pBaseDict);
+ CPDF_Dictionary* pFontDesc = new CPDF_Dictionary;
+ pFontDesc->SetAtName("Type", "FontDescriptor");
+ pFontDesc->SetAtName("FontName", basefont);
+ pFontDesc->SetAtInteger("Flags", flags);
+ pFontDesc->SetAtInteger(
+ "ItalicAngle",
+ pFont->GetSubstFont() ? pFont->GetSubstFont()->m_ItalicAngle : 0);
+ pFontDesc->SetAtInteger("Ascent", pFont->GetAscent());
+ pFontDesc->SetAtInteger("Descent", pFont->GetDescent());
+ FX_RECT bbox;
+ pFont->GetBBox(bbox);
+ CPDF_Array* pBBox = new CPDF_Array;
+ pBBox->AddInteger(bbox.left);
+ pBBox->AddInteger(bbox.bottom);
+ pBBox->AddInteger(bbox.right);
+ pBBox->AddInteger(bbox.top);
+ pFontDesc->SetAt("FontBBox", pBBox);
+ int32_t nStemV = 0;
+ if (pFont->GetSubstFont()) {
+ nStemV = pFont->GetSubstFont()->m_Weight / 5;
+ } else {
+ static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'};
+ const size_t count = FX_ArraySize(stem_chars);
+ uint32_t glyph = pEncoding->GlyphFromCharCode(stem_chars[0]);
+ nStemV = pFont->GetGlyphWidth(glyph);
+ for (size_t i = 1; i < count; i++) {
+ glyph = pEncoding->GlyphFromCharCode(stem_chars[i]);
+ int width = pFont->GetGlyphWidth(glyph);
+ if (width > 0 && width < nStemV) {
+ nStemV = width;
+ }
+ }
+ }
+ pFontDesc->SetAtInteger("StemV", nStemV);
+ AddIndirectObject(pFontDesc);
+ pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
+ return LoadFont(pBaseDict);
+}
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont,
+ FX_BOOL bVert,
+ FX_BOOL bTranslateName) {
+ LOGFONTA lfa;
+ FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa);
+ CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName);
+ if (face.GetLength() >= LF_FACESIZE)
+ return nullptr;
+
+ FXSYS_strcpy(lfa.lfFaceName, face.c_str());
+ return AddWindowsFont(&lfa, bVert, bTranslateName);
+}
+
+CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
+ FX_BOOL bVert,
+ FX_BOOL bTranslateName) {
+ pLogFont->lfHeight = -1000;
+ pLogFont->lfWidth = 0;
+ HGDIOBJ hFont = CreateFontIndirectA(pLogFont);
+ HDC hDC = CreateCompatibleDC(nullptr);
+ hFont = SelectObject(hDC, hFont);
+ int tm_size = GetOutlineTextMetrics(hDC, 0, nullptr);
+ if (tm_size == 0) {
+ hFont = SelectObject(hDC, hFont);
+ DeleteObject(hFont);
+ DeleteDC(hDC);
+ return nullptr;
+ }
+
+ LPBYTE tm_buf = FX_Alloc(BYTE, tm_size);
+ OUTLINETEXTMETRIC* ptm = (OUTLINETEXTMETRIC*)tm_buf;
+ GetOutlineTextMetrics(hDC, tm_size, ptm);
+ int flags = 0, italicangle, ascend, descend, capheight, bbox[4];
+ if (pLogFont->lfItalic)
+ flags |= PDFFONT_ITALIC;
+ if ((pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH)
+ flags |= PDFFONT_FIXEDPITCH;
+ if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN)
+ flags |= PDFFONT_SERIF;
+ if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT)
+ flags |= PDFFONT_SCRIPT;
+
+ bool bCJK = pLogFont->lfCharSet == CHINESEBIG5_CHARSET ||
+ pLogFont->lfCharSet == GB2312_CHARSET ||
+ pLogFont->lfCharSet == HANGEUL_CHARSET ||
+ pLogFont->lfCharSet == SHIFTJIS_CHARSET;
+ CFX_ByteString basefont;
+ if (bTranslateName && bCJK)
+ basefont = FPDF_GetPSNameFromTT(hDC);
+
+ if (basefont.IsEmpty())
+ basefont = pLogFont->lfFaceName;
+
+ italicangle = ptm->otmItalicAngle / 10;
+ ascend = ptm->otmrcFontBox.top;
+ descend = ptm->otmrcFontBox.bottom;
+ capheight = ptm->otmsCapEmHeight;
+ bbox[0] = ptm->otmrcFontBox.left;
+ bbox[1] = ptm->otmrcFontBox.bottom;
+ bbox[2] = ptm->otmrcFontBox.right;
+ bbox[3] = ptm->otmrcFontBox.top;
+ FX_Free(tm_buf);
+ basefont.Replace(" ", "");
+ CPDF_Dictionary* pBaseDict = new CPDF_Dictionary;
+ pBaseDict->SetAtName("Type", "Font");
+ CPDF_Dictionary* pFontDict = pBaseDict;
+ if (!bCJK) {
+ if (pLogFont->lfCharSet == ANSI_CHARSET ||
+ pLogFont->lfCharSet == DEFAULT_CHARSET ||
+ pLogFont->lfCharSet == SYMBOL_CHARSET) {
+ if (pLogFont->lfCharSet == SYMBOL_CHARSET)
+ flags |= PDFFONT_SYMBOLIC;
+ else
+ flags |= PDFFONT_NONSYMBOLIC;
+ pBaseDict->SetAtName("Encoding", "WinAnsiEncoding");
+ } else {
+ flags |= PDFFONT_NONSYMBOLIC;
+ size_t i;
+ for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) {
+ if (g_FX_CharsetUnicodes[i].m_Charset == pLogFont->lfCharSet)
+ break;
+ }
+ if (i < FX_ArraySize(g_FX_CharsetUnicodes)) {
+ CPDF_Dictionary* pEncoding = new CPDF_Dictionary;
+ pEncoding->SetAtName("BaseEncoding", "WinAnsiEncoding");
+ CPDF_Array* pArray = new CPDF_Array;
+ pArray->AddInteger(128);
+ const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
+ for (int j = 0; j < 128; j++) {
+ CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
+ pArray->AddName(name.IsEmpty() ? ".notdef" : name);
+ }
+ pEncoding->SetAt("Differences", pArray);
+ AddIndirectObject(pEncoding);
+ pBaseDict->SetAtReference("Encoding", this, pEncoding);
+ }
+ }
+ if (pLogFont->lfWeight > FW_MEDIUM && pLogFont->lfItalic)
+ basefont += ",BoldItalic";
+ else if (pLogFont->lfWeight > FW_MEDIUM)
+ basefont += ",Bold";
+ else if (pLogFont->lfItalic)
+ basefont += ",Italic";
+
+ pBaseDict->SetAtName("Subtype", "TrueType");
+ pBaseDict->SetAtName("BaseFont", basefont);
+ pBaseDict->SetAtNumber("FirstChar", 32);
+ pBaseDict->SetAtNumber("LastChar", 255);
+ int char_widths[224];
+ GetCharWidth(hDC, 32, 255, char_widths);
+ CPDF_Array* pWidths = new CPDF_Array;
+ for (size_t i = 0; i < 224; i++)
+ pWidths->AddInteger(char_widths[i]);
+
+ pBaseDict->SetAt("Widths", pWidths);
+ } else {
+ flags |= PDFFONT_NONSYMBOLIC;
+ pFontDict = new CPDF_Dictionary;
+ CFX_ByteString cmap;
+ CFX_ByteString ordering;
+ int supplement = 0;
+ CPDF_Array* pWidthArray = new CPDF_Array;
+ switch (pLogFont->lfCharSet) {
+ case CHINESEBIG5_CHARSET:
+ cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
+ ordering = "CNS1";
+ supplement = 4;
+ pWidthArray->AddInteger(1);
+ InsertWidthArray(hDC, 0x20, 0x7e, pWidthArray);
+ break;
+ case GB2312_CHARSET:
+ cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
+ ordering = "GB1", supplement = 2;
+ pWidthArray->AddInteger(7716);
+ InsertWidthArray(hDC, 0x20, 0x20, pWidthArray);
+ pWidthArray->AddInteger(814);
+ InsertWidthArray(hDC, 0x21, 0x7e, pWidthArray);
+ break;
+ case HANGEUL_CHARSET:
+ cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
+ ordering = "Korea1";
+ supplement = 2;
+ pWidthArray->AddInteger(1);
+ InsertWidthArray(hDC, 0x20, 0x7e, pWidthArray);
+ break;
+ case SHIFTJIS_CHARSET:
+ cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
+ ordering = "Japan1";
+ supplement = 5;
+ pWidthArray->AddInteger(231);
+ InsertWidthArray(hDC, 0x20, 0x7d, pWidthArray);
+ pWidthArray->AddInteger(326);
+ InsertWidthArray(hDC, 0xa0, 0xa0, pWidthArray);
+ pWidthArray->AddInteger(327);
+ InsertWidthArray(hDC, 0xa1, 0xdf, pWidthArray);
+ pWidthArray->AddInteger(631);
+ InsertWidthArray(hDC, 0x7e, 0x7e, pWidthArray);
+ break;
+ }
+ pBaseDict->SetAtName("Subtype", "Type0");
+ pBaseDict->SetAtName("BaseFont", basefont);
+ pBaseDict->SetAtName("Encoding", cmap);
+ pFontDict->SetAt("W", pWidthArray);
+ pFontDict->SetAtName("Type", "Font");
+ pFontDict->SetAtName("Subtype", "CIDFontType2");
+ pFontDict->SetAtName("BaseFont", basefont);
+ CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary;
+ pCIDSysInfo->SetAtString("Registry", "Adobe");
+ pCIDSysInfo->SetAtString("Ordering", ordering);
+ pCIDSysInfo->SetAtInteger("Supplement", supplement);
+ pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
+ CPDF_Array* pArray = new CPDF_Array;
+ pBaseDict->SetAt("DescendantFonts", pArray);
+ AddIndirectObject(pFontDict);
+ pArray->AddReference(this, pFontDict);
+ }
+ AddIndirectObject(pBaseDict);
+ CPDF_Dictionary* pFontDesc = new CPDF_Dictionary;
+ pFontDesc->SetAtName("Type", "FontDescriptor");
+ pFontDesc->SetAtName("FontName", basefont);
+ pFontDesc->SetAtInteger("Flags", flags);
+ CPDF_Array* pBBox = new CPDF_Array;
+ for (int i = 0; i < 4; i++) {
+ pBBox->AddInteger(bbox[i]);
+ }
+ pFontDesc->SetAt("FontBBox", pBBox);
+ pFontDesc->SetAtInteger("ItalicAngle", italicangle);
+ pFontDesc->SetAtInteger("Ascent", ascend);
+ pFontDesc->SetAtInteger("Descent", descend);
+ pFontDesc->SetAtInteger("CapHeight", capheight);
+ pFontDesc->SetAtInteger("StemV", pLogFont->lfWeight / 5);
+ AddIndirectObject(pFontDesc);
+ pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
+ hFont = SelectObject(hDC, hFont);
+ DeleteObject(hFont);
+ DeleteDC(hDC);
+ return LoadFont(pBaseDict);
+}
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
+CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont,
+ FX_BOOL bVert,
+ FX_BOOL bTranslateName) {
+ CTFontRef font = (CTFontRef)pFont;
+ CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font);
+ if (!descriptor)
+ return nullptr;
+
+ CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(
+ descriptor, kCTFontLanguagesAttribute);
+ if (!languages) {
+ CFRelease(descriptor);
+ return nullptr;
+ }
+
+ bool bCJK =
+ HasCharSet(languages, {FXFONT_CHINESEBIG5_CHARSET, FXFONT_GB2312_CHARSET,
+ FXFONT_HANGEUL_CHARSET, FXFONT_SHIFTJIS_CHARSET});
+ CFRelease(descriptor);
+ CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font);
+ if (!traits) {
+ CFRelease(languages);
+ return nullptr;
+ }
+
+ CFNumberRef sybolicTrait =
+ (CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait);
+ CTFontSymbolicTraits trait = 0;
+ CFNumberGetValue(sybolicTrait, kCFNumberSInt32Type, &trait);
+ int flags = 0;
+ if (trait & kCTFontItalicTrait)
+ flags |= PDFFONT_ITALIC;
+ if (trait & kCTFontMonoSpaceTrait)
+ flags |= PDFFONT_FIXEDPITCH;
+ if (trait & kCTFontModernSerifsClass)
+ flags |= PDFFONT_SERIF;
+ if (trait & kCTFontScriptsClass)
+ flags |= PDFFONT_SCRIPT;
+
+ CFNumberRef weightTrait =
+ (CFNumberRef)CFDictionaryGetValue(traits, kCTFontWeightTrait);
+ Float32 weight = 0;
+ CFNumberGetValue(weightTrait, kCFNumberFloat32Type, &weight);
+ int italicangle = CTFontGetSlantAngle(font);
+ int ascend = CTFontGetAscent(font);
+ int descend = CTFontGetDescent(font);
+ int capheight = CTFontGetCapHeight(font);
+ CGRect box = CTFontGetBoundingBox(font);
+ int bbox[4];
+ bbox[0] = box.origin.x;
+ bbox[1] = box.origin.y;
+ bbox[2] = box.origin.x + box.size.width;
+ bbox[3] = box.origin.y + box.size.height;
+ CFX_ByteString basefont;
+ if (bTranslateName && bCJK) {
+ CFStringRef postName = CTFontCopyPostScriptName(font);
+ CFString2CFXByteString(postName, basefont);
+ CFRelease(postName);
+ }
+ if (basefont.IsEmpty()) {
+ CFStringRef fullName = CTFontCopyFullName(font);
+ CFString2CFXByteString(fullName, basefont);
+ CFRelease(fullName);
+ }
+ basefont.Replace(" ", "");
+ CPDF_Dictionary* pBaseDict = new CPDF_Dictionary;
+ CPDF_Dictionary* pFontDict = pBaseDict;
+ if (!bCJK) {
+ if (HasCharSet(languages, {FXFONT_ANSI_CHARSET, FXFONT_DEFAULT_CHARSET,
+ FXFONT_SYMBOL_CHARSET})) {
+ if (HasCharSet(languages, {FXFONT_SYMBOL_CHARSET})) {
+ flags |= PDFFONT_SYMBOLIC;
+ } else {
+ flags |= PDFFONT_NONSYMBOLIC;
+ }
+ pBaseDict->SetAtName("Encoding", "WinAnsiEncoding");
+ } else {
+ flags |= PDFFONT_NONSYMBOLIC;
+ size_t i;
+ for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) {
+ if (HasCharSet(languages, {g_FX_CharsetUnicodes[i].m_Charset}))
+ break;
+ }
+ if (i < FX_ArraySize(g_FX_CharsetUnicodes)) {
+ CPDF_Dictionary* pEncoding = new CPDF_Dictionary;
+ pEncoding->SetAtName("BaseEncoding", "WinAnsiEncoding");
+ CPDF_Array* pArray = new CPDF_Array;
+ pArray->AddInteger(128);
+ const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
+ for (int j = 0; j < 128; j++) {
+ CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
+ pArray->AddName(name.IsEmpty() ? ".notdef" : name);
+ }
+ pEncoding->SetAt("Differences", pArray);
+ AddIndirectObject(pEncoding);
+ pBaseDict->SetAtReference("Encoding", this, pEncoding);
+ }
+ }
+ if (weight > 0.0 && trait & kCTFontItalicTrait)
+ basefont += ",BoldItalic";
+ else if (weight > 0.0)
+ basefont += ",Bold";
+ else if (trait & kCTFontItalicTrait)
+ basefont += ",Italic";
+
+ pBaseDict->SetAtName("Subtype", "TrueType");
+ pBaseDict->SetAtName("BaseFont", basefont);
+ pBaseDict->SetAtNumber("FirstChar", 32);
+ pBaseDict->SetAtNumber("LastChar", 255);
+ int char_widths[224];
+ FX_GetCharWidth(font, 32, 255, char_widths);
+ CPDF_Array* pWidths = new CPDF_Array;
+ for (int i = 0; i < 224; i++)
+ pWidths->AddInteger(char_widths[i]);
+ pBaseDict->SetAt("Widths", pWidths);
+ } else {
+ flags |= PDFFONT_NONSYMBOLIC;
+ CFX_ByteString cmap;
+ CFX_ByteString ordering;
+ int supplement;
+ bool bFound = false;
+ CPDF_Array* pWidthArray = new CPDF_Array;
+ if (HasCharSet(languages, {FXFONT_CHINESEBIG5_CHARSET})) {
+ cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
+ ordering = "CNS1";
+ supplement = 4;
+ pWidthArray->AddInteger(1);
+ InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
+ bFound = true;
+ }
+ if (!bFound && HasCharSet(languages, {FXFONT_GB2312_CHARSET})) {
+ cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
+ ordering = "GB1", supplement = 2;
+ pWidthArray->AddInteger(7716);
+ InsertWidthArray(font, 0x20, 0x20, pWidthArray);
+ pWidthArray->AddInteger(814);
+ InsertWidthArray(font, 0x21, 0x7e, pWidthArray);
+ bFound = true;
+ }
+ if (!bFound && HasCharSet(languages, {FXFONT_HANGEUL_CHARSET})) {
+ cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
+ ordering = "Korea1";
+ supplement = 2;
+ pWidthArray->AddInteger(1);
+ InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
+ bFound = true;
+ }
+ if (!bFound && HasCharSet(languages, {FXFONT_SHIFTJIS_CHARSET})) {
+ cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
+ ordering = "Japan1";
+ supplement = 5;
+ pWidthArray->AddInteger(231);
+ InsertWidthArray(font, 0x20, 0x7d, pWidthArray);
+ pWidthArray->AddInteger(326);
+ InsertWidthArray(font, 0xa0, 0xa0, pWidthArray);
+ pWidthArray->AddInteger(327);
+ InsertWidthArray(font, 0xa1, 0xdf, pWidthArray);
+ pWidthArray->AddInteger(631);
+ InsertWidthArray(font, 0x7e, 0x7e, pWidthArray);
+ }
+ pBaseDict->SetAtName("Subtype", "Type0");
+ pBaseDict->SetAtName("BaseFont", basefont);
+ pBaseDict->SetAtName("Encoding", cmap);
+
+ pFontDict = new CPDF_Dictionary;
+ pFontDict->SetAt("W", pWidthArray);
+ pFontDict->SetAtName("Type", "Font");
+ pFontDict->SetAtName("Subtype", "CIDFontType2");
+ pFontDict->SetAtName("BaseFont", basefont);
+ CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary;
+ pCIDSysInfo->SetAtString("Registry", "Adobe");
+ pCIDSysInfo->SetAtString("Ordering", ordering);
+ pCIDSysInfo->SetAtInteger("Supplement", supplement);
+ pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
+ CPDF_Array* pArray = new CPDF_Array;
+ pBaseDict->SetAt("DescendantFonts", pArray);
+ AddIndirectObject(pFontDict);
+ pArray->AddReference(this, pFontDict);
+ }
+ AddIndirectObject(pBaseDict);
+ CPDF_Dictionary* pFontDesc = new CPDF_Dictionary;
+ pFontDesc->SetAtName("Type", "FontDescriptor");
+ pFontDesc->SetAtName("FontName", basefont);
+ pFontDesc->SetAtInteger("Flags", flags);
+ CPDF_Array* pBBox = new CPDF_Array;
+ for (int i = 0; i < 4; i++)
+ pBBox->AddInteger(bbox[i]);
+
+ pFontDesc->SetAt("FontBBox", pBBox);
+ pFontDesc->SetAtInteger("ItalicAngle", italicangle);
+ pFontDesc->SetAtInteger("Ascent", ascend);
+ pFontDesc->SetAtInteger("Descent", descend);
+ pFontDesc->SetAtInteger("CapHeight", capheight);
+ CGFloat fStemV = 0;
+ int16_t min_width = SHRT_MAX;
+
+ static const UniChar stem_chars[] = {'i', 'I', '!', '1'};
+ CGGlyph glyphs[FX_ArraySize(stem_chars)];
+ CGRect boundingRects[FX_ArraySize(stem_chars)];
+
+ const size_t count = FX_ArraySize(stem_chars);
+ if (CTFontGetGlyphsForCharacters(font, stem_chars, glyphs, count)) {
+ CTFontGetBoundingRectsForGlyphs(font, kCTFontHorizontalOrientation, glyphs,
+ boundingRects, count);
+ for (size_t i = 0; i < count; i++) {
+ int16_t width = boundingRects[i].size.width;
+ if (width > 0 && width < min_width) {
+ min_width = width;
+ fStemV = min_width;
+ }
+ }
+ }
+ pFontDesc->SetAtInteger("StemV", fStemV);
+ AddIndirectObject(pFontDesc);
+ pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
+ CFRelease(traits);
+ CFRelease(languages);
+ return LoadFont(pBaseDict);
+}
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
index 18687e5fb7d..3e08ead9ff5 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
@@ -16,7 +16,7 @@
namespace {
bool CanReadFromBitStream(const CFX_BitStream* hStream,
- const FX_SAFE_DWORD& num_bits) {
+ const FX_SAFE_UINT32& num_bits) {
return num_bits.IsValid() &&
hStream->BitsRemaining() >= num_bits.ValueOrDie();
}
@@ -60,7 +60,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
// Item 2: The location of the first page's page object.
uint32_t dwFirstObjLoc = hStream->GetBits(32);
if (dwFirstObjLoc > static_cast<uint32_t>(nStreamOffset)) {
- FX_SAFE_DWORD safeLoc = pdfium::base::checked_cast<uint32_t>(nStreamLen);
+ FX_SAFE_UINT32 safeLoc = pdfium::base::checked_cast<uint32_t>(nStreamLen);
safeLoc += dwFirstObjLoc;
if (!safeLoc.IsValid())
return FALSE;
@@ -107,13 +107,13 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
if (nPages < 1)
return FALSE;
- FX_SAFE_DWORD required_bits = dwDeltaObjectsBits;
+ FX_SAFE_UINT32 required_bits = dwDeltaObjectsBits;
required_bits *= pdfium::base::checked_cast<uint32_t>(nPages);
if (!CanReadFromBitStream(hStream, required_bits))
return FALSE;
for (int i = 0; i < nPages; ++i) {
- FX_SAFE_DWORD safeDeltaObj = hStream->GetBits(dwDeltaObjectsBits);
+ FX_SAFE_UINT32 safeDeltaObj = hStream->GetBits(dwDeltaObjectsBits);
safeDeltaObj += dwObjLeastNum;
if (!safeDeltaObj.IsValid())
return FALSE;
@@ -128,7 +128,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
CFX_ArrayTemplate<uint32_t> dwPageLenArray;
for (int i = 0; i < nPages; ++i) {
- FX_SAFE_DWORD safePageLen = hStream->GetBits(dwDeltaPageLenBits);
+ FX_SAFE_UINT32 safePageLen = hStream->GetBits(dwDeltaPageLenBits);
safePageLen += dwPageLeastLen;
if (!safePageLen.IsValid())
return FALSE;
@@ -191,7 +191,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
hStream->ByteAlign();
for (int i = 0; i < nPages; i++) {
- FX_SAFE_DWORD safeSize = m_dwNSharedObjsArray[i];
+ FX_SAFE_UINT32 safeSize = m_dwNSharedObjsArray[i];
safeSize *= dwSharedNumeratorBits;
if (!CanReadFromBitStream(hStream, safeSize))
return FALSE;
@@ -200,7 +200,8 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
}
hStream->ByteAlign();
- FX_SAFE_DWORD safeTotalPageLen = pdfium::base::checked_cast<uint32_t>(nPages);
+ FX_SAFE_UINT32 safeTotalPageLen =
+ pdfium::base::checked_cast<uint32_t>(nPages);
safeTotalPageLen *= dwDeltaPageLenBits;
if (!CanReadFromBitStream(hStream, safeTotalPageLen))
return FALSE;
@@ -220,7 +221,7 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream,
if (nStreamOffset < 0 || nStreamLen < 1)
return FALSE;
- FX_SAFE_DWORD bit_offset = offset;
+ FX_SAFE_UINT32 bit_offset = offset;
bit_offset *= 8;
if (!bit_offset.IsValid() || hStream->GetPos() > bit_offset.ValueOrDie())
return FALSE;
@@ -263,14 +264,14 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream,
uint32_t dwPrevObjLen = 0;
uint32_t dwCurObjLen = 0;
- FX_SAFE_DWORD required_bits = dwSharedObjTotal;
+ FX_SAFE_UINT32 required_bits = dwSharedObjTotal;
required_bits *= dwDeltaGroupLen;
if (!CanReadFromBitStream(hStream, required_bits))
return FALSE;
for (uint32_t i = 0; i < dwSharedObjTotal; ++i) {
dwPrevObjLen = dwCurObjLen;
- FX_SAFE_DWORD safeObjLen = hStream->GetBits(dwDeltaGroupLen);
+ FX_SAFE_UINT32 safeObjLen = hStream->GetBits(dwDeltaGroupLen);
safeObjLen += dwGroupLeastLen;
if (!safeObjLen.IsValid())
return FALSE;
@@ -281,7 +282,7 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream,
if (i == 0)
m_szSharedObjOffsetArray.push_back(m_szFirstPageObjOffset);
} else {
- FX_SAFE_DWORD safeObjNum = dwFirstSharedObjNum;
+ FX_SAFE_UINT32 safeObjNum = dwFirstSharedObjNum;
safeObjNum += i - m_nFirstPageSharedObjs;
if (!safeObjNum.IsValid())
return FALSE;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_name.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_name.cpp
index a7adf1b3d6e..7d67b51d7c9 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_name.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_name.cpp
@@ -10,10 +10,6 @@
CPDF_Name::CPDF_Name(const CFX_ByteString& str) : m_Name(str) {}
-CPDF_Name::CPDF_Name(const CFX_ByteStringC& str) : m_Name(str) {}
-
-CPDF_Name::CPDF_Name(const FX_CHAR* str) : m_Name(str) {}
-
CPDF_Name::~CPDF_Name() {}
CPDF_Object::Type CPDF_Name::GetType() const {
@@ -28,10 +24,6 @@ CFX_ByteString CPDF_Name::GetString() const {
return m_Name;
}
-CFX_ByteStringC CPDF_Name::GetConstString() const {
- return m_Name.AsByteStringC();
-}
-
void CPDF_Name::SetString(const CFX_ByteString& str) {
m_Name = str;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_number.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_number.cpp
index dbc17d5dd62..a6bace57c94 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_number.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_number.cpp
@@ -47,7 +47,7 @@ const CPDF_Number* CPDF_Number::AsNumber() const {
}
void CPDF_Number::SetString(const CFX_ByteString& str) {
- FX_atonum(str.AsByteStringC(), m_bInteger, &m_Integer);
+ FX_atonum(str.AsStringC(), m_bInteger, &m_Integer);
}
CFX_ByteString CPDF_Number::GetString() const {
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object.cpp
index 9a190a73082..86b9449cf8b 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object.cpp
@@ -33,10 +33,6 @@ CFX_ByteString CPDF_Object::GetString() const {
return CFX_ByteString();
}
-CFX_ByteStringC CPDF_Object::GetConstString() const {
- return CFX_ByteStringC();
-}
-
CFX_WideString CPDF_Object::GetUnicodeText() const {
return CFX_WideString();
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp
index 17fd891d1b7..d3dc5257a37 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp
@@ -34,7 +34,6 @@ void TestArrayAccessors(const CPDF_Array* arr,
CPDF_Dictionary* dict_val,
CPDF_Stream* stream_val) {
EXPECT_STREQ(str_val, arr->GetStringAt(index).c_str());
- EXPECT_STREQ(const_str_val, arr->GetConstStringAt(index).c_str());
EXPECT_EQ(int_val, arr->GetIntegerAt(index));
EXPECT_EQ(float_val, arr->GetNumberAt(index));
EXPECT_EQ(float_val, arr->GetFloatAt(index));
@@ -135,7 +134,7 @@ class PDFObjectsTest : public testing::Test {
return false;
for (CPDF_Dictionary::const_iterator it = dict1->begin();
it != dict1->end(); ++it) {
- if (!Equal(it->second, dict2->GetObjectBy(it->first.AsByteStringC())))
+ if (!Equal(it->second, dict2->GetObjectBy(it->first)))
return false;
}
return true;
@@ -199,42 +198,16 @@ TEST_F(PDFObjectsTest, GetString) {
}
}
-TEST_F(PDFObjectsTest, GetConstString) {
- const char* direct_obj_results[] = {
- nullptr, nullptr, nullptr, nullptr, "A simple test", "\t\n",
- "space", nullptr, nullptr, nullptr, nullptr};
- // Check for direct objects.
- for (size_t i = 0; i < m_DirectObjs.size(); ++i) {
- if (!direct_obj_results[i]) {
- EXPECT_EQ(direct_obj_results[i],
- m_DirectObjs[i]->GetConstString().c_str());
- } else {
- EXPECT_STREQ(direct_obj_results[i],
- m_DirectObjs[i]->GetConstString().c_str());
- }
- }
- // Check indirect references.
- const char* indirect_obj_results[] = {nullptr, nullptr, "\t\n", "space",
- nullptr, nullptr, nullptr};
- for (size_t i = 0; i < m_RefObjs.size(); ++i) {
- if (!indirect_obj_results[i]) {
- EXPECT_EQ(nullptr, m_RefObjs[i]->GetConstString().c_str());
- } else {
- EXPECT_STREQ(indirect_obj_results[i],
- m_RefObjs[i]->GetConstString().c_str());
- }
- }
-}
-
TEST_F(PDFObjectsTest, GetUnicodeText) {
const wchar_t* direct_obj_results[] = {
L"", L"", L"", L"", L"A simple test",
L"\t\n", L"space", L"", L"", L"abcdefghijklmnopqrstuvwxyz",
L""};
// Check for direct objects.
- for (size_t i = 0; i < m_DirectObjs.size(); ++i)
+ for (size_t i = 0; i < m_DirectObjs.size(); ++i) {
EXPECT_STREQ(direct_obj_results[i],
m_DirectObjs[i]->GetUnicodeText().c_str());
+ }
// Check indirect references.
for (const auto& it : m_RefObjs)
@@ -584,7 +557,7 @@ TEST(PDFArrayTest, GetTypeAt) {
char buf[33];
key.append(FXSYS_itoa(j, buf, 10));
int value = j + 200;
- vals[i]->SetAt(CFX_ByteStringC(key.c_str()), new CPDF_Number(value));
+ vals[i]->SetAt(key.c_str(), new CPDF_Number(value));
}
arr->InsertAt(i, vals[i]);
}
@@ -611,7 +584,7 @@ TEST(PDFArrayTest, GetTypeAt) {
char buf[33];
key.append(FXSYS_itoa(j, buf, 10));
int value = j + 200;
- vals[i]->SetAt(CFX_ByteStringC(key.c_str()), new CPDF_Number(value));
+ vals[i]->SetAt(key.c_str(), new CPDF_Number(value));
}
uint8_t content[] = "content: this is a stream";
size_t data_size = FX_ArraySize(content);
@@ -668,16 +641,12 @@ TEST(PDFArrayTest, GetTypeAt) {
const char* const expected_str[] = {
"true", "false", "0", "-1234", "2345", "0.05", "",
"It is a test!", "NAME", "test", "", "", "", ""};
- const char* const expected_cstr[] = {
- nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
- "It is a test!", "NAME", "test", nullptr, nullptr, nullptr, nullptr};
const int expected_int[] = {1, 0, 0, -1234, 2345, 0, 0,
0, 0, 0, 0, 0, 0, 0};
const float expected_float[] = {0, 0, 0, -1234, 2345, 0.05f, 0,
0, 0, 0, 0, 0, 0, 0};
for (size_t i = 0; i < arr->GetCount(); ++i) {
EXPECT_STREQ(expected_str[i], arr->GetStringAt(i).c_str());
- EXPECT_STREQ(expected_cstr[i], arr->GetConstStringAt(i).c_str());
EXPECT_EQ(expected_int[i], arr->GetIntegerAt(i));
EXPECT_EQ(expected_float[i], arr->GetNumberAt(i));
EXPECT_EQ(expected_float[i], arr->GetFloatAt(i));
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
index 73ca71ef1a0..acf51de1eaf 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser.cpp
@@ -8,7 +8,8 @@
#include <vector>
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
#include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h"
#include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
@@ -18,7 +19,6 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
#include "core/fxcrt/include/fx_ext.h"
#include "core/fxcrt/include/fx_safe_types.h"
#include "third_party/base/stl_util.h"
@@ -101,7 +101,7 @@ void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) {
m_pEncryptDict = pDict;
}
-IPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() {
+CPDF_CryptoHandler* CPDF_Parser::GetCryptoHandler() {
return m_pSyntax->m_pCryptoHandler.get();
}
@@ -202,7 +202,7 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_FileRead* pFileAccess) {
if (!bNumber)
return FORMAT_ERROR;
- m_LastXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str);
+ m_LastXRefOffset = (FX_FILESIZE)FXSYS_atoi64(xrefpos_str.c_str());
if (!LoadAllCrossRefV4(m_LastXRefOffset) &&
!LoadAllCrossRefV5(m_LastXRefOffset)) {
if (!RebuildCrossRef())
@@ -275,10 +275,10 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() {
if (m_pEncryptDict) {
CFX_ByteString filter = m_pEncryptDict->GetStringBy("Filter");
- std::unique_ptr<IPDF_SecurityHandler> pSecurityHandler;
+ std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler;
Error err = HANDLER_ERROR;
if (filter == "Standard") {
- pSecurityHandler.reset(new CPDF_StandardSecurityHandler);
+ pSecurityHandler.reset(new CPDF_SecurityHandler);
err = PASSWORD_ERROR;
}
if (!pSecurityHandler)
@@ -288,7 +288,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() {
return err;
m_pSecurityHandler = std::move(pSecurityHandler);
- std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler(
+ std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler(
m_pSecurityHandler->CreateCryptoHandler());
if (!pCryptoHandler->Init(m_pEncryptDict, m_pSecurityHandler.get()))
return HANDLER_ERROR;
@@ -316,6 +316,32 @@ FX_FILESIZE CPDF_Parser::GetObjectOffset(uint32_t objnum) const {
return 0;
}
+// Ideally, all the cross reference entries should be verified.
+// In reality, we rarely see well-formed cross references don't match
+// with the objects. crbug/602650 showed a case where object numbers
+// in the cross reference table are all off by one.
+bool CPDF_Parser::VerifyCrossRefV4() {
+ for (const auto& it : m_ObjectInfo) {
+ if (it.second.pos == 0)
+ continue;
+ // Find the first non-zero position.
+ FX_FILESIZE SavedPos = m_pSyntax->SavePos();
+ m_pSyntax->RestorePos(it.second.pos);
+ bool is_num = false;
+ CFX_ByteString num_str = m_pSyntax->GetNextWord(&is_num);
+ m_pSyntax->RestorePos(SavedPos);
+ if (!is_num || num_str.IsEmpty() ||
+ FXSYS_atoui(num_str.c_str()) != it.first) {
+ // If the object number read doesn't match the one stored,
+ // something is wrong with the cross reference table.
+ return false;
+ } else {
+ return true;
+ }
+ }
+ return true;
+}
+
FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
if (!LoadCrossRefV4(xrefpos, 0, TRUE))
return FALSE;
@@ -366,6 +392,8 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
for (size_t i = 0; i < CrossRefList.size(); ++i) {
if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
return FALSE;
+ if (i == 0 && !VerifyCrossRefV4())
+ return FALSE;
}
return TRUE;
}
@@ -505,7 +533,7 @@ bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
break;
}
- uint32_t start_objnum = FXSYS_atoui(word);
+ uint32_t start_objnum = FXSYS_atoui(word.c_str());
if (start_objnum >= kMaxObjectNumber)
return false;
@@ -822,11 +850,10 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
uint32_t dwObjNum =
pElement ? pElement->GetObjNum() : 0;
if (dwObjNum) {
- m_pTrailer->SetAtReference(key.AsByteStringC(),
- m_pDocument, dwObjNum);
+ m_pTrailer->SetAtReference(key, m_pDocument,
+ dwObjNum);
} else {
- m_pTrailer->SetAt(key.AsByteStringC(),
- pElement->Clone());
+ m_pTrailer->SetAt(key, pElement->Clone());
}
}
}
@@ -846,7 +873,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
CFX_ByteString bsOffset =
m_pSyntax->GetNextWord(&bNumber);
if (bNumber)
- m_LastXRefOffset = FXSYS_atoi(bsOffset);
+ m_LastXRefOffset = FXSYS_atoi(bsOffset.c_str());
}
m_pSyntax->RestorePos(dwSavePos);
}
@@ -931,9 +958,9 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
}
pos += size;
- // If the position has not changed at all in a loop iteration, then break
- // out to prevent infinite looping.
- if (pos == saved_pos)
+ // If the position has not changed at all or went backwards in a loop
+ // iteration, then break out to prevent infinite looping.
+ if (pos <= saved_pos)
break;
}
@@ -988,8 +1015,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
std::vector<std::pair<int32_t, int32_t>> arrIndex;
CPDF_Array* pArray = pStream->GetDict()->GetArrayBy("Index");
if (pArray) {
- uint32_t nPairSize = pArray->GetCount() / 2;
- for (uint32_t i = 0; i < nPairSize; i++) {
+ for (size_t i = 0; i < pArray->GetCount() / 2; i++) {
CPDF_Object* pStartNumObj = pArray->GetObjectAt(i * 2);
CPDF_Object* pCountObj = pArray->GetObjectAt(i * 2 + 1);
@@ -1012,8 +1038,8 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
}
CFX_ArrayTemplate<uint32_t> WidthArray;
- FX_SAFE_DWORD dwAccWidth = 0;
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
+ FX_SAFE_UINT32 dwAccWidth = 0;
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
WidthArray.Add(pArray->GetIntegerAt(i));
dwAccWidth += WidthArray[i];
}
@@ -1039,7 +1065,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
pdfium::base::checked_cast<uint32_t, int32_t>(startnum);
uint32_t count =
pdfium::base::checked_cast<uint32_t, int32_t>(arrIndex[i].second);
- FX_SAFE_DWORD dwCaculatedSize = segindex;
+ FX_SAFE_UINT32 dwCaculatedSize = segindex;
dwCaculatedSize += count;
dwCaculatedSize *= totalWidth;
if (!dwCaculatedSize.IsValid() ||
@@ -1048,7 +1074,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
}
const uint8_t* segstart = pData + segindex * totalWidth;
- FX_SAFE_DWORD dwMaxObjNum = startnum;
+ FX_SAFE_UINT32 dwMaxObjNum = startnum;
dwMaxObjNum += count;
uint32_t dwV5Size = m_ObjectInfo.empty() ? 0 : GetLastObjNum() + 1;
if (!dwMaxObjNum.IsValid() || dwMaxObjNum.ValueOrDie() > dwV5Size)
@@ -1294,7 +1320,7 @@ void CPDF_Parser::GetIndirectBinary(uint32_t objnum,
return;
}
- uint32_t parser_objnum = FXSYS_atoui(word);
+ uint32_t parser_objnum = FXSYS_atoui(word.c_str());
if (parser_objnum && parser_objnum != objnum) {
m_pSyntax->RestorePos(SavedPos);
return;
@@ -1366,7 +1392,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObjectAt(
FX_FILESIZE objOffset = m_pSyntax->SavePos();
objOffset -= word.GetLength();
- uint32_t parser_objnum = FXSYS_atoui(word);
+ uint32_t parser_objnum = FXSYS_atoui(word.c_str());
if (objnum && parser_objnum != objnum) {
m_pSyntax->RestorePos(SavedPos);
return nullptr;
@@ -1378,7 +1404,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObjectAt(
return nullptr;
}
- uint32_t parser_gennum = FXSYS_atoui(word);
+ uint32_t parser_gennum = FXSYS_atoui(word.c_str());
if (m_pSyntax->GetKeyword() != "obj") {
m_pSyntax->RestorePos(SavedPos);
return nullptr;
@@ -1416,7 +1442,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObjectAtByStrict(
return nullptr;
}
- uint32_t parser_objnum = FXSYS_atoui(word);
+ uint32_t parser_objnum = FXSYS_atoui(word.c_str());
if (objnum && parser_objnum != objnum) {
m_pSyntax->RestorePos(SavedPos);
return nullptr;
@@ -1428,7 +1454,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObjectAtByStrict(
return nullptr;
}
- uint32_t gennum = FXSYS_atoui(word);
+ uint32_t gennum = FXSYS_atoui(word.c_str());
if (m_pSyntax->GetKeyword() != "obj") {
m_pSyntax->RestorePos(SavedPos);
return nullptr;
@@ -1478,12 +1504,12 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_FileRead* pFileAccess,
if (!bIsNumber)
return FALSE;
- uint32_t objnum = FXSYS_atoui(word);
+ uint32_t objnum = FXSYS_atoui(word.c_str());
word = m_pSyntax->GetNextWord(&bIsNumber);
if (!bIsNumber)
return FALSE;
- uint32_t gennum = FXSYS_atoui(word);
+ uint32_t gennum = FXSYS_atoui(word.c_str());
if (m_pSyntax->GetKeyword() != "obj") {
m_pSyntax->RestorePos(SavedPos);
return FALSE;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp
index f427ec5d811..042b221554f 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_parser_embeddertest.cpp
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "public/fpdf_text.h"
#include "testing/embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -38,3 +39,18 @@ TEST_F(CPDFParserEmbeddertest, Bug_325) {
EXPECT_FALSE(OpenDocument("bug_325_a.pdf"));
EXPECT_FALSE(OpenDocument("bug_325_b.pdf"));
}
+
+TEST_F(CPDFParserEmbeddertest, Bug_602650) {
+ // Test the case that cross reference entries, which are well formed,
+ // but do not match with the objects.
+ EXPECT_TRUE(OpenDocument("bug_602650.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+ FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
+ EXPECT_NE(nullptr, text_page);
+ // The page should not be blank.
+ EXPECT_LT(0, FPDFText_CountChars(text_page));
+
+ FPDFText_ClosePage(text_page);
+ UnloadPage(page);
+}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_reference.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_reference.cpp
index 9053d08b368..007423e5fb2 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_reference.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_reference.cpp
@@ -22,11 +22,6 @@ CFX_ByteString CPDF_Reference::GetString() const {
return obj ? obj->GetString() : CFX_ByteString();
}
-CFX_ByteStringC CPDF_Reference::GetConstString() const {
- CPDF_Object* obj = SafeGetDirect();
- return obj ? obj->GetConstString() : CFX_ByteStringC();
-}
-
FX_FLOAT CPDF_Reference::GetNumber() const {
CPDF_Object* obj = SafeGetDirect();
return obj ? obj->GetNumber() : 0;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
index 9846c40d8f6..d6416fb0553 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
@@ -4,12 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_security_handler.h"
#include <time.h>
#include "core/fdrm/crypto/include/fx_crypt.h"
-#include "core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
@@ -67,9 +67,7 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt,
} // namespace
-IPDF_SecurityHandler::~IPDF_SecurityHandler() {}
-
-CPDF_StandardSecurityHandler::CPDF_StandardSecurityHandler() {
+CPDF_SecurityHandler::CPDF_SecurityHandler() {
m_Version = 0;
m_Revision = 0;
m_pParser = NULL;
@@ -79,14 +77,14 @@ CPDF_StandardSecurityHandler::CPDF_StandardSecurityHandler() {
m_KeyLen = 0;
}
-CPDF_StandardSecurityHandler::~CPDF_StandardSecurityHandler() {}
+CPDF_SecurityHandler::~CPDF_SecurityHandler() {}
-IPDF_CryptoHandler* CPDF_StandardSecurityHandler::CreateCryptoHandler() {
- return new CPDF_StandardCryptoHandler;
+CPDF_CryptoHandler* CPDF_SecurityHandler::CreateCryptoHandler() {
+ return new CPDF_CryptoHandler;
}
-FX_BOOL CPDF_StandardSecurityHandler::OnInit(CPDF_Parser* pParser,
- CPDF_Dictionary* pEncryptDict) {
+FX_BOOL CPDF_SecurityHandler::OnInit(CPDF_Parser* pParser,
+ CPDF_Dictionary* pEncryptDict) {
m_pParser = pParser;
if (!LoadDict(pEncryptDict)) {
return FALSE;
@@ -96,28 +94,29 @@ FX_BOOL CPDF_StandardSecurityHandler::OnInit(CPDF_Parser* pParser,
}
return CheckSecurity(m_KeyLen);
}
-FX_BOOL CPDF_StandardSecurityHandler::CheckSecurity(int32_t key_len) {
+FX_BOOL CPDF_SecurityHandler::CheckSecurity(int32_t key_len) {
CFX_ByteString password = m_pParser->GetPassword();
- if (CheckPassword(password, password.GetLength(), TRUE, m_EncryptKey,
- key_len)) {
+ if (CheckPassword(password.raw_str(), password.GetLength(), TRUE,
+ m_EncryptKey, key_len)) {
if (password.IsEmpty()) {
- if (!CheckPassword(password, password.GetLength(), FALSE, m_EncryptKey,
- key_len)) {
+ if (!CheckPassword(password.raw_str(), password.GetLength(), FALSE,
+ m_EncryptKey, key_len)) {
return FALSE;
}
}
return TRUE;
}
- return CheckPassword(password, password.GetLength(), FALSE, m_EncryptKey,
- key_len);
+ return CheckPassword(password.raw_str(), password.GetLength(), FALSE,
+ m_EncryptKey, key_len);
}
-uint32_t CPDF_StandardSecurityHandler::GetPermissions() {
+uint32_t CPDF_SecurityHandler::GetPermissions() {
return m_Permissions;
}
-static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
- const CFX_ByteStringC& name,
- int& cipher,
- int& keylen) {
+
+static FX_BOOL LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
+ const CFX_ByteString& name,
+ int& cipher,
+ int& keylen) {
int Version = pEncryptDict->GetIntegerBy("V");
cipher = FXCIPHER_RC4;
keylen = 0;
@@ -160,54 +159,50 @@ static FX_BOOL _LoadCryptInfo(CPDF_Dictionary* pEncryptDict,
return TRUE;
}
-FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
+FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict) {
m_pEncryptDict = pEncryptDict;
m_Version = pEncryptDict->GetIntegerBy("V");
m_Revision = pEncryptDict->GetIntegerBy("R");
m_Permissions = pEncryptDict->GetIntegerBy("P", -1);
- if (m_Version < 4) {
- return _LoadCryptInfo(pEncryptDict, CFX_ByteStringC(), m_Cipher, m_KeyLen);
- }
+ if (m_Version < 4)
+ return LoadCryptInfo(pEncryptDict, CFX_ByteString(), m_Cipher, m_KeyLen);
+
CFX_ByteString stmf_name = pEncryptDict->GetStringBy("StmF");
CFX_ByteString strf_name = pEncryptDict->GetStringBy("StrF");
- if (stmf_name != strf_name) {
+ if (stmf_name != strf_name)
return FALSE;
- }
- if (!_LoadCryptInfo(pEncryptDict, strf_name.AsByteStringC(), m_Cipher,
- m_KeyLen)) {
- return FALSE;
- }
- return TRUE;
+
+ return LoadCryptInfo(pEncryptDict, strf_name, m_Cipher, m_KeyLen);
}
-FX_BOOL CPDF_StandardSecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
- uint32_t type,
- int& cipher,
- int& key_len) {
+FX_BOOL CPDF_SecurityHandler::LoadDict(CPDF_Dictionary* pEncryptDict,
+ uint32_t type,
+ int& cipher,
+ int& key_len) {
m_pEncryptDict = pEncryptDict;
m_Version = pEncryptDict->GetIntegerBy("V");
m_Revision = pEncryptDict->GetIntegerBy("R");
m_Permissions = pEncryptDict->GetIntegerBy("P", -1);
- CFX_ByteString strf_name, stmf_name;
+
+ CFX_ByteString strf_name;
+ CFX_ByteString stmf_name;
if (m_Version >= 4) {
stmf_name = pEncryptDict->GetStringBy("StmF");
strf_name = pEncryptDict->GetStringBy("StrF");
- if (stmf_name != strf_name) {
+ if (stmf_name != strf_name)
return FALSE;
- }
}
- if (!_LoadCryptInfo(pEncryptDict, strf_name.AsByteStringC(), cipher,
- key_len)) {
+ if (!LoadCryptInfo(pEncryptDict, strf_name, cipher, key_len))
return FALSE;
- }
+
m_Cipher = cipher;
m_KeyLen = key_len;
return TRUE;
}
-FX_BOOL CPDF_StandardSecurityHandler::GetCryptInfo(int& cipher,
- const uint8_t*& buffer,
- int& keylen) {
+FX_BOOL CPDF_SecurityHandler::GetCryptInfo(int& cipher,
+ const uint8_t*& buffer,
+ int& keylen) {
cipher = m_Cipher;
buffer = m_EncryptKey;
keylen = m_KeyLen;
@@ -306,11 +301,10 @@ void Revision6_Hash(const uint8_t* password,
FXSYS_memcpy(hash, input, 32);
}
}
-FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
- const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- uint8_t* key) {
+FX_BOOL CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password,
+ uint32_t size,
+ FX_BOOL bOwner,
+ uint8_t* key) {
CFX_ByteString okey =
m_pEncryptDict ? m_pEncryptDict->GetStringBy("O") : CFX_ByteString();
if (okey.GetLength() < 48) {
@@ -321,18 +315,18 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
if (ukey.GetLength() < 48) {
return FALSE;
}
- const uint8_t* pkey = bOwner ? (const uint8_t*)okey : (const uint8_t*)ukey;
+ const uint8_t* pkey = (bOwner ? okey : ukey).raw_str();
uint8_t sha[128];
uint8_t digest[32];
if (m_Revision >= 6) {
Revision6_Hash(password, size, (const uint8_t*)pkey + 32,
- (bOwner ? (const uint8_t*)ukey : NULL), digest);
+ bOwner ? ukey.raw_str() : nullptr, digest);
} else {
CRYPT_SHA256Start(sha);
CRYPT_SHA256Update(sha, password, size);
CRYPT_SHA256Update(sha, pkey + 32, 8);
if (bOwner) {
- CRYPT_SHA256Update(sha, ukey, 48);
+ CRYPT_SHA256Update(sha, ukey.raw_str(), 48);
}
CRYPT_SHA256Finish(sha, digest);
}
@@ -344,13 +338,13 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
}
if (m_Revision >= 6) {
Revision6_Hash(password, size, (const uint8_t*)pkey + 40,
- (bOwner ? (const uint8_t*)ukey : NULL), digest);
+ bOwner ? ukey.raw_str() : nullptr, digest);
} else {
CRYPT_SHA256Start(sha);
CRYPT_SHA256Update(sha, password, size);
CRYPT_SHA256Update(sha, pkey + 40, 8);
if (bOwner) {
- CRYPT_SHA256Update(sha, ukey, 48);
+ CRYPT_SHA256Update(sha, ukey.raw_str(), 48);
}
CRYPT_SHA256Finish(sha, digest);
}
@@ -365,7 +359,7 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
uint8_t iv[16];
FXSYS_memset(iv, 0, 16);
CRYPT_AESSetIV(aes, iv);
- CRYPT_AESDecrypt(aes, key, ekey, 32);
+ CRYPT_AESDecrypt(aes, key, ekey.raw_str(), 32);
CRYPT_AESSetKey(aes, 16, key, 32, FALSE);
CRYPT_AESSetIV(aes, iv);
CFX_ByteString perms = m_pEncryptDict->GetStringBy("Perms");
@@ -378,7 +372,7 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
if (copy_len > (uint32_t)perms.GetLength()) {
copy_len = perms.GetLength();
}
- FXSYS_memcpy(perms_buf, (const uint8_t*)perms, copy_len);
+ FXSYS_memcpy(perms_buf, perms.raw_str(), copy_len);
uint8_t buf[16];
CRYPT_AESDecrypt(aes, buf, perms_buf, 16);
FX_Free(aes);
@@ -395,11 +389,11 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword(
return TRUE;
}
-int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- uint8_t* key,
- int32_t key_len) {
+int CPDF_SecurityHandler::CheckPassword(const uint8_t* password,
+ uint32_t size,
+ FX_BOOL bOwner,
+ uint8_t* key,
+ int32_t key_len) {
if (m_Revision >= 5) {
return AES256_CheckPassword(password, size, bOwner, key);
}
@@ -413,12 +407,11 @@ int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password,
return CheckUserPassword(password, size, FALSE, key, key_len) ||
CheckUserPassword(password, size, TRUE, key, key_len);
}
-FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(
- const uint8_t* password,
- uint32_t pass_size,
- FX_BOOL bIgnoreEncryptMeta,
- uint8_t* key,
- int32_t key_len) {
+FX_BOOL CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password,
+ uint32_t pass_size,
+ FX_BOOL bIgnoreEncryptMeta,
+ uint8_t* key,
+ int32_t key_len) {
CalcEncryptKey(m_pEncryptDict, password, pass_size, key, key_len,
bIgnoreEncryptMeta, m_pParser->GetIDArray());
CFX_ByteString ukey =
@@ -461,10 +454,9 @@ FX_BOOL CPDF_StandardSecurityHandler::CheckUserPassword(
}
return FALSE;
}
-CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(
- const uint8_t* owner_pass,
- uint32_t pass_size,
- int32_t key_len) {
+CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass,
+ uint32_t pass_size,
+ int32_t key_len) {
CFX_ByteString okey = m_pEncryptDict->GetStringBy("O");
uint8_t passcode[32];
uint32_t i;
@@ -510,31 +502,30 @@ CFX_ByteString CPDF_StandardSecurityHandler::GetUserPassword(
}
return CFX_ByteString(okeybuf, len);
}
-FX_BOOL CPDF_StandardSecurityHandler::CheckOwnerPassword(
- const uint8_t* password,
- uint32_t pass_size,
- uint8_t* key,
- int32_t key_len) {
+FX_BOOL CPDF_SecurityHandler::CheckOwnerPassword(const uint8_t* password,
+ uint32_t pass_size,
+ uint8_t* key,
+ int32_t key_len) {
CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len);
- if (CheckUserPassword(user_pass, user_pass.GetLength(), FALSE, key,
+ if (CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), FALSE, key,
key_len)) {
return TRUE;
}
- return CheckUserPassword(user_pass, user_pass.GetLength(), TRUE, key,
- key_len);
+ return CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), TRUE,
+ key, key_len);
}
-FX_BOOL CPDF_StandardSecurityHandler::IsMetadataEncrypted() {
+FX_BOOL CPDF_SecurityHandler::IsMetadataEncrypted() {
return m_pEncryptDict->GetBooleanBy("EncryptMetadata", TRUE);
}
-void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
- CPDF_Array* pIdArray,
- const uint8_t* user_pass,
- uint32_t user_size,
- const uint8_t* owner_pass,
- uint32_t owner_size,
- FX_BOOL bDefault,
- uint32_t type) {
+void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
+ CPDF_Array* pIdArray,
+ const uint8_t* user_pass,
+ uint32_t user_size,
+ const uint8_t* owner_pass,
+ uint32_t owner_size,
+ FX_BOOL bDefault,
+ uint32_t type) {
int cipher = 0, key_len = 0;
if (!LoadDict(pEncryptDict, type, cipher, key_len)) {
return;
@@ -621,29 +612,28 @@ void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
pEncryptDict->SetAtString("U", CFX_ByteString(digest, 32));
}
}
-void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
- CPDF_Array* pIdArray,
- const uint8_t* user_pass,
- uint32_t user_size,
- const uint8_t* owner_pass,
- uint32_t owner_size,
- uint32_t type) {
+void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
+ CPDF_Array* pIdArray,
+ const uint8_t* user_pass,
+ uint32_t user_size,
+ const uint8_t* owner_pass,
+ uint32_t owner_size,
+ uint32_t type) {
OnCreate(pEncryptDict, pIdArray, user_pass, user_size, owner_pass, owner_size,
TRUE, type);
}
-void CPDF_StandardSecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
- CPDF_Array* pIdArray,
- const uint8_t* user_pass,
- uint32_t user_size,
- uint32_t type) {
+void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
+ CPDF_Array* pIdArray,
+ const uint8_t* user_pass,
+ uint32_t user_size,
+ uint32_t type) {
OnCreate(pEncryptDict, pIdArray, user_pass, user_size, NULL, 0, FALSE, type);
}
-void CPDF_StandardSecurityHandler::AES256_SetPassword(
- CPDF_Dictionary* pEncryptDict,
- const uint8_t* password,
- uint32_t size,
- FX_BOOL bOwner,
- const uint8_t* key) {
+void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
+ const uint8_t* password,
+ uint32_t size,
+ FX_BOOL bOwner,
+ const uint8_t* key) {
uint8_t sha[128];
CRYPT_SHA1Start(sha);
CRYPT_SHA1Update(sha, key, 32);
@@ -653,14 +643,14 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(
CFX_ByteString ukey = pEncryptDict->GetStringBy("U");
uint8_t digest1[48];
if (m_Revision >= 6) {
- Revision6_Hash(password, size, digest,
- (bOwner ? (const uint8_t*)ukey : NULL), digest1);
+ Revision6_Hash(password, size, digest, bOwner ? ukey.raw_str() : nullptr,
+ digest1);
} else {
CRYPT_SHA256Start(sha);
CRYPT_SHA256Update(sha, password, size);
CRYPT_SHA256Update(sha, digest, 8);
if (bOwner) {
- CRYPT_SHA256Update(sha, ukey, ukey.GetLength());
+ CRYPT_SHA256Update(sha, ukey.raw_str(), ukey.GetLength());
}
CRYPT_SHA256Finish(sha, digest1);
}
@@ -668,13 +658,13 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(
pEncryptDict->SetAtString(bOwner ? "O" : "U", CFX_ByteString(digest1, 48));
if (m_Revision >= 6) {
Revision6_Hash(password, size, digest + 8,
- (bOwner ? (const uint8_t*)ukey : NULL), digest1);
+ bOwner ? ukey.raw_str() : nullptr, digest1);
} else {
CRYPT_SHA256Start(sha);
CRYPT_SHA256Update(sha, password, size);
CRYPT_SHA256Update(sha, digest + 8, 8);
if (bOwner) {
- CRYPT_SHA256Update(sha, ukey, ukey.GetLength());
+ CRYPT_SHA256Update(sha, ukey.raw_str(), ukey.GetLength());
}
CRYPT_SHA256Finish(sha, digest1);
}
@@ -687,11 +677,10 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword(
FX_Free(aes);
pEncryptDict->SetAtString(bOwner ? "OE" : "UE", CFX_ByteString(digest1, 32));
}
-void CPDF_StandardSecurityHandler::AES256_SetPerms(
- CPDF_Dictionary* pEncryptDict,
- uint32_t permissions,
- FX_BOOL bEncryptMetadata,
- const uint8_t* key) {
+void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict,
+ uint32_t permissions,
+ FX_BOOL bEncryptMetadata,
+ const uint8_t* key) {
uint8_t buf[16];
buf[0] = (uint8_t)permissions;
buf[1] = (uint8_t)(permissions >> 8);
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_security_handler.h
index dfbf6a34f98..645c97698a8 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_security_handler.h
@@ -4,30 +4,34 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_SECURITY_HANDLER_H_
-#define CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_SECURITY_HANDLER_H_
+#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_SECURITY_HANDLER_H_
+#define CORE_FPDFAPI_FPDF_PARSER_CPDF_SECURITY_HANDLER_H_
-#include "core/fpdfapi/fpdf_parser/ipdf_security_handler.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-class CPDF_Array;
+#define FXCIPHER_NONE 0
+#define FXCIPHER_RC4 1
+#define FXCIPHER_AES 2
+#define FXCIPHER_AES2 3
#define PDF_ENCRYPT_CONTENT 0
-class CPDF_StandardSecurityHandler : public IPDF_SecurityHandler {
+class CPDF_Array;
+class CPDF_CryptoHandler;
+class CPDF_Dictionary;
+class CPDF_Parser;
+
+class CPDF_SecurityHandler {
public:
- CPDF_StandardSecurityHandler();
- ~CPDF_StandardSecurityHandler() override;
-
- // IPDF_SecurityHandler:
- FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) override;
- uint32_t GetPermissions() override;
- FX_BOOL GetCryptInfo(int& cipher,
- const uint8_t*& buffer,
- int& keylen) override;
- FX_BOOL IsMetadataEncrypted() override;
- IPDF_CryptoHandler* CreateCryptoHandler() override;
+ CPDF_SecurityHandler();
+ ~CPDF_SecurityHandler();
+
+ FX_BOOL OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict);
+ uint32_t GetPermissions();
+ FX_BOOL GetCryptInfo(int& cipher, const uint8_t*& buffer, int& keylen);
+ FX_BOOL IsMetadataEncrypted();
+ CPDF_CryptoHandler* CreateCryptoHandler();
void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray,
@@ -102,4 +106,4 @@ class CPDF_StandardSecurityHandler : public IPDF_SecurityHandler {
int m_KeyLen;
};
-#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_SECURITY_HANDLER_H_
+#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_SECURITY_HANDLER_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h
deleted file mode 100644
index 689d44b81b0..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_CRYPTO_HANDLER_H_
-#define CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_CRYPTO_HANDLER_H_
-
-#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
-
-class CPDF_StandardCryptoHandler : public IPDF_CryptoHandler {
- public:
- CPDF_StandardCryptoHandler();
- ~CPDF_StandardCryptoHandler() override;
-
- // IPDF_CryptoHandler
- FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
- IPDF_SecurityHandler* pSecurityHandler) override;
- uint32_t DecryptGetSize(uint32_t src_size) override;
- void* DecryptStart(uint32_t objnum, uint32_t gennum) override;
- FX_BOOL DecryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf) override;
- FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) override;
- uint32_t EncryptGetSize(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size) override;
- FX_BOOL EncryptContent(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) override;
-
- FX_BOOL Init(int cipher, const uint8_t* key, int keylen);
-
- protected:
- virtual void CryptBlock(FX_BOOL bEncrypt,
- uint32_t objnum,
- uint32_t gennum,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size);
- virtual void* CryptStart(uint32_t objnum, uint32_t gennum, FX_BOOL bEncrypt);
- virtual FX_BOOL CryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt);
- virtual FX_BOOL CryptFinish(void* context,
- CFX_BinaryBuf& dest_buf,
- FX_BOOL bEncrypt);
-
- uint8_t m_EncryptKey[32];
- int m_KeyLen;
- int m_Cipher;
- uint8_t* m_pAESContext;
-};
-
-#endif // CORE_FPDFAPI_FPDF_PARSER_CPDF_STANDARD_CRYPTO_HANDLER_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_string.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_string.cpp
index 3f04d125a26..4b925962424 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_string.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_string.cpp
@@ -31,10 +31,6 @@ CFX_ByteString CPDF_String::GetString() const {
return m_String;
}
-CFX_ByteStringC CPDF_String::GetConstString() const {
- return m_String.AsByteStringC();
-}
-
void CPDF_String::SetString(const CFX_ByteString& str) {
m_String = str;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp
index 3deecf54ff2..13a99724254 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp
@@ -9,6 +9,7 @@
#include <vector>
#include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
+#include "core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h"
#include "core/fpdfapi/fpdf_parser/cpdf_null.h"
#include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
@@ -19,7 +20,6 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
#include "core/fxcrt/include/fx_ext.h"
#include "third_party/base/numerics/safe_math.h"
@@ -27,9 +27,8 @@
namespace {
struct SearchTagRecord {
- const char* m_pTag;
- uint32_t m_Len;
- uint32_t m_Offset;
+ CFX_ByteStringC m_bsTag;
+ FX_STRSIZE m_Offset;
};
} // namespace
@@ -218,7 +217,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() {
case 0:
if (ch == ')') {
if (parlevel == 0) {
- return buf.GetByteString();
+ return buf.MakeString();
}
parlevel--;
buf.AppendChar(')');
@@ -291,7 +290,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() {
}
GetNextChar(ch);
- return buf.GetByteString();
+ return buf.MakeString();
}
CFX_ByteString CPDF_SyntaxParser::ReadHexString() {
@@ -323,7 +322,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString() {
if (!bFirst)
buf.AppendByte(code);
- return buf.GetByteString();
+ return buf.MakeString();
}
void CPDF_SyntaxParser::ToNextLine() {
@@ -394,12 +393,12 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
if (bIsNumber) {
CFX_ByteString nextword2 = GetNextWord(nullptr);
if (nextword2 == "R") {
- uint32_t objnum = FXSYS_atoui(word);
+ uint32_t objnum = FXSYS_atoui(word.c_str());
return new CPDF_Reference(pObjList, objnum);
}
}
m_Pos = SavedPos;
- return new CPDF_Number(word.AsByteStringC());
+ return new CPDF_Number(word.AsStringC());
}
if (word == "true" || word == "false")
@@ -471,7 +470,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
if (!pObj)
continue;
- CFX_ByteStringC keyNoSlash(key.raw_str() + 1, key.GetLength() - 1);
+ CFX_ByteString keyNoSlash(key.raw_str() + 1, key.GetLength() - 1);
pDict->SetAt(keyNoSlash, pObj);
}
@@ -518,10 +517,10 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
if (bIsNumber) {
CFX_ByteString nextword2 = GetNextWord(nullptr);
if (nextword2 == "R")
- return new CPDF_Reference(pObjList, FXSYS_atoui(word));
+ return new CPDF_Reference(pObjList, FXSYS_atoui(word.c_str()));
}
m_Pos = SavedPos;
- return new CPDF_Number(word.AsByteStringC());
+ return new CPDF_Number(word.AsStringC());
}
if (word == "true" || word == "false")
@@ -590,7 +589,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
}
if (key.GetLength() > 1) {
- pDict->SetAt(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1),
+ pDict->SetAt(CFX_ByteString(key.c_str() + 1, key.GetLength() - 1),
obj.release());
}
}
@@ -646,7 +645,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
const CFX_ByteStringC kEndStreamStr("endstream");
const CFX_ByteStringC kEndObjStr("endobj");
- IPDF_CryptoHandler* pCryptoHandler =
+ CPDF_CryptoHandler* pCryptoHandler =
objnum == (uint32_t)m_MetadataObjnum ? nullptr : m_pCryptoHandler.get();
if (!pCryptoHandler) {
FX_BOOL bSearchForKeyword = TRUE;
@@ -913,6 +912,10 @@ int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags,
++ntags;
}
+ // Ensure that the input byte string happens to be nul-terminated. This
+ // need not be the case, but the loop below uses this guarantee to put
+ // the last pattern into the vector.
+ ASSERT(tags[tags.GetLength()] == 0);
std::vector<SearchTagRecord> patterns(ntags);
uint32_t start = 0;
uint32_t itag = 0;
@@ -921,8 +924,7 @@ int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags,
if (tags[i] == 0) {
uint32_t len = i - start;
max_len = std::max(len, max_len);
- patterns[itag].m_pTag = tags.c_str() + start;
- patterns[itag].m_Len = len;
+ patterns[itag].m_bsTag = tags.Mid(start, len);
patterns[itag].m_Offset = 0;
start = i + 1;
++itag;
@@ -937,22 +939,21 @@ int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags,
for (int i = 0; i < ntags; ++i) {
SearchTagRecord& pat = patterns[i];
- if (pat.m_pTag[pat.m_Offset] != byte) {
- pat.m_Offset = (pat.m_pTag[0] == byte) ? 1 : 0;
+ if (pat.m_bsTag[pat.m_Offset] != byte) {
+ pat.m_Offset = (pat.m_bsTag[0] == byte) ? 1 : 0;
continue;
}
++pat.m_Offset;
- if (pat.m_Offset != pat.m_Len)
+ if (pat.m_Offset != pat.m_bsTag.GetLength())
continue;
- if (!bWholeWord ||
- IsWholeWord(pos - pat.m_Len, limit,
- CFX_ByteStringC(pat.m_pTag, pat.m_Len), FALSE)) {
+ if (!bWholeWord || IsWholeWord(pos - pat.m_bsTag.GetLength(), limit,
+ pat.m_bsTag, FALSE)) {
return i;
}
- pat.m_Offset = (pat.m_pTag[0] == byte) ? 1 : 0;
+ pat.m_Offset = (pat.m_bsTag[0] == byte) ? 1 : 0;
}
}
return -1;
@@ -985,6 +986,6 @@ FX_FILESIZE CPDF_SyntaxParser::FindTag(const CFX_ByteStringC& tag,
}
void CPDF_SyntaxParser::SetEncrypt(
- std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler) {
+ std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) {
m_pCryptoHandler = std::move(pCryptoHandler);
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h
index 04fe6f4fec4..63992a85abf 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h
@@ -11,12 +11,12 @@
#include "core/fxcrt/include/fx_basic.h"
+class CPDF_CryptoHandler;
class CPDF_Dictionary;
class CPDF_IndirectObjectHolder;
class CPDF_Object;
class CPDF_Stream;
class IFX_FileRead;
-class IPDF_CryptoHandler;
class CPDF_SyntaxParser {
public:
@@ -49,7 +49,7 @@ class CPDF_SyntaxParser {
FX_FILESIZE limit);
FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE limit);
- void SetEncrypt(std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler);
+ void SetEncrypt(std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler);
FX_BOOL ReadBlock(uint8_t* pBuf, uint32_t size);
FX_BOOL GetCharAt(FX_FILESIZE pos, uint8_t& ch);
@@ -88,7 +88,7 @@ class CPDF_SyntaxParser {
uint8_t* m_pFileBuf;
uint32_t m_BufSize;
FX_FILESIZE m_BufOffset;
- std::unique_ptr<IPDF_CryptoHandler> m_pCryptoHandler;
+ std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler;
uint8_t m_WordBuffer[257];
uint32_t m_WordSize;
};
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index 5d9254901ad..e9f5a6d468e 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -7,14 +7,15 @@
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
#include <limits.h>
+#include <utility>
#include <vector>
#include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcrt/include/fx_ext.h"
-#include "core/include/fxcodec/fx_codec.h"
#include "third_party/base/stl_util.h"
#define _STREAM_MAX_SIZE_ 20 * 1024 * 1024
@@ -225,7 +226,7 @@ uint32_t RunLengthDecode(const uint8_t* src_buf,
return ret;
}
-ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
+CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
@@ -278,7 +279,7 @@ static FX_BOOL CheckFlateDecodeParams(int Colors,
return TRUE;
}
-ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
+CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
@@ -342,29 +343,26 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
CPDF_Object* pParams =
pDict ? pDict->GetDirectObjectBy("DecodeParms") : nullptr;
- std::vector<CFX_ByteString> DecoderList;
- CFX_ArrayTemplate<CPDF_Object*> ParamList;
+
+ std::vector<std::pair<CFX_ByteString, CPDF_Object*>> DecoderArray;
if (CPDF_Array* pDecoders = pDecoder->AsArray()) {
CPDF_Array* pParamsArray = ToArray(pParams);
- if (!pParamsArray)
- pParams = nullptr;
-
- for (uint32_t i = 0; i < pDecoders->GetCount(); i++) {
- DecoderList.push_back(pDecoders->GetConstStringAt(i));
- ParamList.Add(pParams ? pParamsArray->GetDictAt(i) : nullptr);
+ for (size_t i = 0; i < pDecoders->GetCount(); i++) {
+ DecoderArray.push_back(
+ {pDecoders->GetStringAt(i),
+ pParamsArray ? pParamsArray->GetDictAt(i) : nullptr});
}
} else {
- DecoderList.push_back(pDecoder->GetConstString());
- ParamList.Add(pParams ? pParams->GetDict() : nullptr);
+ DecoderArray.push_back(
+ {pDecoder->GetString(), pParams ? pParams->GetDict() : nullptr});
}
- uint8_t* last_buf = (uint8_t*)src_buf;
+ uint8_t* last_buf = const_cast<uint8_t*>(src_buf);
uint32_t last_size = src_size;
- int nSize = pdfium::CollectionSize<int>(DecoderList);
+ int nSize = pdfium::CollectionSize<int>(DecoderArray);
for (int i = 0; i < nSize; i++) {
int estimated_size = i == nSize - 1 ? last_estimated_size : 0;
- CFX_ByteString decoder = DecoderList[i];
- // Use ToDictionary here because we can push nullptr into the ParamList.
- CPDF_Dictionary* pParam = ToDictionary(ParamList[i]);
+ CFX_ByteString decoder = DecoderArray[i].first;
+ CPDF_Dictionary* pParam = ToDictionary(DecoderArray[i].second);
uint8_t* new_buf = nullptr;
uint32_t new_size = (uint32_t)-1;
int offset = -1;
@@ -530,7 +528,7 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) {
result.AppendChar("0123456789ABCDEF"[src[i] % 16]);
}
result.AppendChar('>');
- return result.GetByteString();
+ return result.MakeString();
}
result.AppendChar('(');
for (int i = 0; i < srclen; i++) {
@@ -547,7 +545,7 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) {
result.AppendChar(ch);
}
result.AppendChar(')');
- return result.GetByteString();
+ return result.MakeString();
}
void FlateEncode(const uint8_t* src_buf,
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index 31e7388bd73..a738356e438 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -81,27 +81,26 @@ int32_t GetHeaderOffset(IFX_FileRead* pFile) {
return -1;
}
-int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) {
+int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key) {
CPDF_Number* pObj = ToNumber(pDict->GetObjectBy(key));
return pObj ? pObj->GetInteger() : 0;
}
CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
+ if (bstr.Find('#') == -1)
+ return CFX_ByteString(bstr);
+
int size = bstr.GetLength();
- const FX_CHAR* pSrc = bstr.c_str();
- if (!FXSYS_memchr(pSrc, '#', size)) {
- return bstr;
- }
CFX_ByteString result;
FX_CHAR* pDestStart = result.GetBuffer(size);
FX_CHAR* pDest = pDestStart;
for (int i = 0; i < size; i++) {
- if (pSrc[i] == '#' && i < size - 2) {
+ if (bstr[i] == '#' && i < size - 2) {
*pDest++ =
- FXSYS_toHexDigit(pSrc[i + 1]) * 16 + FXSYS_toHexDigit(pSrc[i + 2]);
+ FXSYS_toHexDigit(bstr[i + 1]) * 16 + FXSYS_toHexDigit(bstr[i + 2]);
i += 2;
} else {
- *pDest++ = pSrc[i];
+ *pDest++ = bstr[i];
}
}
result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart));
@@ -109,10 +108,9 @@ CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
}
CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) {
- if (!FXSYS_memchr(orig.c_str(), '#', orig.GetLength())) {
+ if (orig.Find('#') == -1)
return orig;
- }
- return PDF_NameDecode(CFX_ByteStringC(orig));
+ return PDF_NameDecode(orig.AsStringC());
}
CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) {
@@ -179,7 +177,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
case CPDF_Object::ARRAY: {
const CPDF_Array* p = pObj->AsArray();
buf << "[";
- for (uint32_t i = 0; i < p->GetCount(); i++) {
+ for (size_t i = 0; i < p->GetCount(); i++) {
CPDF_Object* pElement = p->GetObjectAt(i);
if (pElement->GetObjNum()) {
buf << " " << pElement->GetObjNum() << " 0 R";
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h
index d072fbc1912..0b27a1fe9a9 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/fpdf_parser_utility.h
@@ -34,6 +34,6 @@ inline bool PDFCharIsLineEnding(uint8_t c) {
}
int32_t GetHeaderOffset(IFX_FileRead* pFile);
-int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key);
+int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key);
#endif // CORE_FPDFAPI_FPDF_PARSER_FPDF_PARSER_UTILITY_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_array.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_array.h
index b964f4955b6..dfe03b9d70e 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_array.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_array.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_ARRAY_H_
#define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_ARRAY_H_
+#include <vector>
+
#include "core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
#include "core/fxcrt/include/fx_basic.h"
@@ -14,6 +16,9 @@
class CPDF_Array : public CPDF_Object {
public:
+ using iterator = std::vector<CPDF_Object*>::iterator;
+ using const_iterator = std::vector<CPDF_Object*>::const_iterator;
+
CPDF_Array();
// CPDF_Object.
@@ -24,27 +29,26 @@ class CPDF_Array : public CPDF_Object {
CPDF_Array* AsArray() override;
const CPDF_Array* AsArray() const override;
- uint32_t GetCount() const { return m_Objects.GetSize(); }
- CPDF_Object* GetObjectAt(uint32_t index) const;
- CPDF_Object* GetDirectObjectAt(uint32_t index) const;
- CFX_ByteString GetStringAt(uint32_t index) const;
- CFX_ByteStringC GetConstStringAt(uint32_t index) const;
- int GetIntegerAt(uint32_t index) const;
- FX_FLOAT GetNumberAt(uint32_t index) const;
- CPDF_Dictionary* GetDictAt(uint32_t index) const;
- CPDF_Stream* GetStreamAt(uint32_t index) const;
- CPDF_Array* GetArrayAt(uint32_t index) const;
- FX_FLOAT GetFloatAt(uint32_t index) const { return GetNumberAt(index); }
+ size_t GetCount() const { return m_Objects.size(); }
+ CPDF_Object* GetObjectAt(size_t index) const;
+ CPDF_Object* GetDirectObjectAt(size_t index) const;
+ CFX_ByteString GetStringAt(size_t index) const;
+ int GetIntegerAt(size_t index) const;
+ FX_FLOAT GetNumberAt(size_t index) const;
+ CPDF_Dictionary* GetDictAt(size_t index) const;
+ CPDF_Stream* GetStreamAt(size_t index) const;
+ CPDF_Array* GetArrayAt(size_t index) const;
+ FX_FLOAT GetFloatAt(size_t index) const { return GetNumberAt(index); }
CFX_Matrix GetMatrix();
CFX_FloatRect GetRect();
- void SetAt(uint32_t index,
+ void SetAt(size_t index,
CPDF_Object* pObj,
CPDF_IndirectObjectHolder* pObjs = nullptr);
- void InsertAt(uint32_t index,
+ void InsertAt(size_t index,
CPDF_Object* pObj,
CPDF_IndirectObjectHolder* pObjs = nullptr);
- void RemoveAt(uint32_t index, uint32_t nCount = 1);
+ void RemoveAt(size_t index, size_t nCount = 1);
void Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs = nullptr);
void AddNumber(FX_FLOAT f);
@@ -56,10 +60,15 @@ class CPDF_Array : public CPDF_Object {
AddReference(pDoc, obj->GetObjNum());
}
+ iterator begin() { return m_Objects.begin(); }
+ iterator end() { return m_Objects.end(); }
+ const_iterator begin() const { return m_Objects.begin(); }
+ const_iterator end() const { return m_Objects.end(); }
+
protected:
~CPDF_Array() override;
- CFX_ArrayTemplate<CPDF_Object*> m_Objects;
+ std::vector<CPDF_Object*> m_Objects;
};
#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_ARRAY_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h
index 82abc35c024..e3b7496da7a 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h
@@ -31,59 +31,56 @@ class CPDF_Dictionary : public CPDF_Object {
const CPDF_Dictionary* AsDictionary() const override;
size_t GetCount() const { return m_Map.size(); }
- CPDF_Object* GetObjectBy(const CFX_ByteStringC& key) const;
- CPDF_Object* GetDirectObjectBy(const CFX_ByteStringC& key) const;
- CFX_ByteString GetStringBy(const CFX_ByteStringC& key) const;
- CFX_ByteStringC GetConstStringBy(const CFX_ByteStringC& key) const;
- CFX_ByteString GetStringBy(const CFX_ByteStringC& key,
- const CFX_ByteStringC& default_str) const;
- CFX_ByteStringC GetConstStringBy(const CFX_ByteStringC& key,
- const CFX_ByteStringC& default_str) const;
- CFX_WideString GetUnicodeTextBy(const CFX_ByteStringC& key) const;
- int GetIntegerBy(const CFX_ByteStringC& key) const;
- int GetIntegerBy(const CFX_ByteStringC& key, int default_int) const;
- FX_BOOL GetBooleanBy(const CFX_ByteStringC& key,
+ CPDF_Object* GetObjectBy(const CFX_ByteString& key) const;
+ CPDF_Object* GetDirectObjectBy(const CFX_ByteString& key) const;
+ CFX_ByteString GetStringBy(const CFX_ByteString& key) const;
+ CFX_ByteString GetStringBy(const CFX_ByteString& key,
+ const CFX_ByteString& default_str) const;
+ CFX_WideString GetUnicodeTextBy(const CFX_ByteString& key) const;
+ int GetIntegerBy(const CFX_ByteString& key) const;
+ int GetIntegerBy(const CFX_ByteString& key, int default_int) const;
+ FX_BOOL GetBooleanBy(const CFX_ByteString& key,
FX_BOOL bDefault = FALSE) const;
- FX_FLOAT GetNumberBy(const CFX_ByteStringC& key) const;
- CPDF_Dictionary* GetDictBy(const CFX_ByteStringC& key) const;
- CPDF_Stream* GetStreamBy(const CFX_ByteStringC& key) const;
- CPDF_Array* GetArrayBy(const CFX_ByteStringC& key) const;
- CFX_FloatRect GetRectBy(const CFX_ByteStringC& key) const;
- CFX_Matrix GetMatrixBy(const CFX_ByteStringC& key) const;
- FX_FLOAT GetFloatBy(const CFX_ByteStringC& key) const {
+ FX_FLOAT GetNumberBy(const CFX_ByteString& key) const;
+ CPDF_Dictionary* GetDictBy(const CFX_ByteString& key) const;
+ CPDF_Stream* GetStreamBy(const CFX_ByteString& key) const;
+ CPDF_Array* GetArrayBy(const CFX_ByteString& key) const;
+ CFX_FloatRect GetRectBy(const CFX_ByteString& key) const;
+ CFX_Matrix GetMatrixBy(const CFX_ByteString& key) const;
+ FX_FLOAT GetFloatBy(const CFX_ByteString& key) const {
return GetNumberBy(key);
}
- FX_BOOL KeyExist(const CFX_ByteStringC& key) const;
+ FX_BOOL KeyExist(const CFX_ByteString& key) const;
bool IsSignatureDict() const;
// Set* functions invalidate iterators for the element with the key |key|.
- void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj);
- void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name);
- void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& str);
- void SetAtInteger(const CFX_ByteStringC& key, int i);
- void SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f);
- void SetAtReference(const CFX_ByteStringC& key,
+ void SetAt(const CFX_ByteString& key, CPDF_Object* pObj);
+ void SetAtName(const CFX_ByteString& key, const CFX_ByteString& name);
+ void SetAtString(const CFX_ByteString& key, const CFX_ByteString& str);
+ void SetAtInteger(const CFX_ByteString& key, int i);
+ void SetAtNumber(const CFX_ByteString& key, FX_FLOAT f);
+ void SetAtReference(const CFX_ByteString& key,
CPDF_IndirectObjectHolder* pDoc,
uint32_t objnum);
- void SetAtReference(const CFX_ByteStringC& key,
+ void SetAtReference(const CFX_ByteString& key,
CPDF_IndirectObjectHolder* pDoc,
CPDF_Object* obj) {
SetAtReference(key, pDoc, obj->GetObjNum());
}
- void SetAtRect(const CFX_ByteStringC& key, const CFX_FloatRect& rect);
- void SetAtMatrix(const CFX_ByteStringC& key, const CFX_Matrix& matrix);
- void SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue);
+ void SetAtRect(const CFX_ByteString& key, const CFX_FloatRect& rect);
+ void SetAtMatrix(const CFX_ByteString& key, const CFX_Matrix& matrix);
+ void SetAtBoolean(const CFX_ByteString& key, FX_BOOL bValue);
- void AddReference(const CFX_ByteStringC& key,
+ void AddReference(const CFX_ByteString& key,
CPDF_IndirectObjectHolder* pDoc,
uint32_t objnum);
// Invalidates iterators for the element with the key |key|.
- void RemoveAt(const CFX_ByteStringC& key);
+ void RemoveAt(const CFX_ByteString& key);
// Invalidates iterators for the element with the key |oldkey|.
- void ReplaceKey(const CFX_ByteStringC& oldkey, const CFX_ByteStringC& newkey);
+ void ReplaceKey(const CFX_ByteString& oldkey, const CFX_ByteString& newkey);
iterator begin() { return m_Map.begin(); }
iterator end() { return m_Map.end(); }
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_document.h
index bbccf593610..687619b763b 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_document.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_document.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_
#define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_
+#include <memory>
+
#include "core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
#include "core/fxcrt/include/fx_basic.h"
@@ -35,7 +37,6 @@ class CPDF_StreamAcc;
class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
public:
- CPDF_Document();
explicit CPDF_Document(CPDF_Parser* pParser);
~CPDF_Document();
@@ -52,11 +53,11 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
CPDF_Dictionary* GetPage(int iPage);
int GetPageIndex(uint32_t objnum);
uint32_t GetUserPermissions(FX_BOOL bCheckRevision = FALSE) const;
- CPDF_DocPageData* GetPageData() { return GetValidatePageData(); }
+ CPDF_DocPageData* GetPageData() const { return m_pDocPage; }
void ClearPageData();
void RemoveColorSpaceFromPageData(CPDF_Object* pObject);
- CPDF_DocRenderData* GetRenderData() { return GetValidateRenderData(); }
+ CPDF_DocRenderData* GetRenderData() const { return m_pDocRender.get(); }
void ClearRenderData();
void ClearRenderFont();
@@ -69,14 +70,23 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
CPDF_Pattern* LoadPattern(CPDF_Object* pObj,
FX_BOOL bShading,
- const CFX_Matrix* matrix = NULL);
+ const CFX_Matrix& matrix);
CPDF_Image* LoadImageF(CPDF_Object* pObj);
CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream);
CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream);
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+ void LoadDoc();
+ void LoadAsynDoc(CPDF_Dictionary* pLinearized);
+ void LoadPages();
+ // Editing methods.
+ void CreateNewDoc();
+ CPDF_Dictionary* CreateNewPage(int iPage);
+ void DeletePage(int iPage);
+ CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding);
+ CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert);
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
CPDF_Font* AddWindowsFont(LOGFONTA* pLogFont,
FX_BOOL bVert,
FX_BOOL bTranslateName = FALSE);
@@ -90,48 +100,37 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
FX_BOOL bTranslateName = FALSE);
#endif
- CPDF_Font* AddStandardFont(const FX_CHAR* font, CPDF_FontEncoding* pEncoding);
- CPDF_Font* AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert);
- void CreateNewDoc();
-
- CPDF_Dictionary* CreateNewPage(int iPage);
- void DeletePage(int iPage);
-
- void LoadDoc();
- void LoadAsynDoc(CPDF_Dictionary* pLinearized);
- void LoadPages();
-
protected:
- // Retrieve page count information by getting count value from the tree nodes
- // or walking through the tree nodes to calculate it.
- int RetrievePageCount() const;
- CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages,
- int iPage,
- int nPagesToGo,
- int level);
- int _FindPageIndex(CPDF_Dictionary* pNode,
- uint32_t& skip_count,
- uint32_t objnum,
- int& index,
- int level = 0);
- FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting);
- CPDF_DocPageData* GetValidatePageData();
- CPDF_DocRenderData* GetValidateRenderData();
friend class CPDF_Creator;
friend class CPDF_Parser;
friend class CPDF_DataAvail;
friend class CPDF_OCContext;
+ // Retrieve page count information by getting count value from the tree nodes
+ // or walking through the tree nodes to calculate it.
+ int RetrievePageCount() const;
+ CPDF_Dictionary* FindPDFPage(CPDF_Dictionary* pPages,
+ int iPage,
+ int nPagesToGo,
+ int level);
+ int FindPageIndex(CPDF_Dictionary* pNode,
+ uint32_t& skip_count,
+ uint32_t objnum,
+ int& index,
+ int level = 0);
+ FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting);
+
CPDF_Dictionary* m_pRootDict;
CPDF_Dictionary* m_pInfoDict;
CFX_ByteString m_ID1;
CFX_ByteString m_ID2;
- FX_BOOL m_bLinearized;
- uint32_t m_dwFirstPageNo;
+ bool m_bLinearized;
+ int m_iFirstPageNo;
uint32_t m_dwFirstPageObjNum;
CFX_ArrayTemplate<uint32_t> m_PageList;
+ // TODO(thestig): Figure out why this cannot be a std::unique_ptr.
CPDF_DocPageData* m_pDocPage;
- CPDF_DocRenderData* m_pDocRender;
+ std::unique_ptr<CPDF_DocRenderData> m_pDocRender;
};
#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_name.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_name.h
index 62fd5c14a88..523238c8920 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_name.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_name.h
@@ -12,14 +12,11 @@
class CPDF_Name : public CPDF_Object {
public:
explicit CPDF_Name(const CFX_ByteString& str);
- explicit CPDF_Name(const CFX_ByteStringC& str);
- explicit CPDF_Name(const FX_CHAR* str);
// CPDF_Object.
Type GetType() const override;
CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const override;
CFX_ByteString GetString() const override;
- CFX_ByteStringC GetConstString() const override;
CFX_WideString GetUnicodeText() const override;
void SetString(const CFX_ByteString& str) override;
bool IsName() const override;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_object.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_object.h
index 6cdaaf58fd8..c0c442157ff 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_object.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_object.h
@@ -46,9 +46,6 @@ class CPDF_Object {
void Release();
virtual CFX_ByteString GetString() const;
-
- // Note: |this| must outlive the use of |GetConstString|'s result.
- virtual CFX_ByteStringC GetConstString() const;
virtual CFX_WideString GetUnicodeText() const;
virtual FX_FLOAT GetNumber() const;
virtual int GetInteger() const;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_parser.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
index 45aca8f21a1..48511e92632 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_parser.h
@@ -14,15 +14,15 @@
#include "core/fxcrt/include/fx_basic.h"
class CPDF_Array;
+class CPDF_CryptoHandler;
class CPDF_Dictionary;
class CPDF_Document;
class CPDF_IndirectObjectHolder;
class CPDF_Object;
+class CPDF_SecurityHandler;
class CPDF_StreamAcc;
class CPDF_SyntaxParser;
class IFX_FileRead;
-class IPDF_CryptoHandler;
-class IPDF_SecurityHandler;
class CPDF_Parser {
public:
@@ -63,7 +63,7 @@ class CPDF_Parser {
bool IsVersionUpdated() const { return m_bVersionUpdated; }
bool IsObjectFreeOrNull(uint32_t objnum) const;
FX_BOOL IsFormStream(uint32_t objnum, FX_BOOL& bForm);
- IPDF_CryptoHandler* GetCryptoHandler();
+ CPDF_CryptoHandler* GetCryptoHandler();
IFX_FileRead* GetFileAccess() const;
FX_FILESIZE GetObjectOffset(uint32_t objnum) const;
@@ -114,6 +114,9 @@ class CPDF_Parser {
FX_BOOL IsLinearizedFile(IFX_FileRead* pFileAccess, uint32_t offset);
void SetEncryptDictionary(CPDF_Dictionary* pDict);
void ShrinkObjectMap(uint32_t size);
+ // A simple check whether the cross reference table matches with
+ // the objects.
+ bool VerifyCrossRefV4();
CPDF_Document* m_pDocument;
std::unique_ptr<CPDF_SyntaxParser> m_pSyntax;
@@ -123,7 +126,7 @@ class CPDF_Parser {
CPDF_Dictionary* m_pEncryptDict;
FX_FILESIZE m_LastXRefOffset;
FX_BOOL m_bXRefStream;
- std::unique_ptr<IPDF_SecurityHandler> m_pSecurityHandler;
+ std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler;
CFX_ByteString m_bsRecipient;
CFX_ByteString m_FilePath;
CFX_ByteString m_Password;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_reference.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_reference.h
index b7d826902bd..49b698eacb1 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_reference.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_reference.h
@@ -20,7 +20,6 @@ class CPDF_Reference : public CPDF_Object {
CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const override;
CPDF_Object* GetDirect() const override;
CFX_ByteString GetString() const override;
- CFX_ByteStringC GetConstString() const override;
FX_FLOAT GetNumber() const override;
int GetInteger() const override;
CPDF_Dictionary* GetDict() const override;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_string.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_string.h
index 77e41ecd6a1..c17cc182f7f 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_string.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/include/cpdf_string.h
@@ -21,7 +21,6 @@ class CPDF_String : public CPDF_Object {
Type GetType() const override;
CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const override;
CFX_ByteString GetString() const override;
- CFX_ByteStringC GetConstString() const override;
CFX_WideString GetUnicodeText() const override;
void SetString(const CFX_ByteString& str) override;
bool IsString() const override;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h
deleted file mode 100644
index ea45a6b9cc8..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PARSER_IPDF_CRYPTO_HANDLER_H_
-#define CORE_FPDFAPI_FPDF_PARSER_IPDF_CRYPTO_HANDLER_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CPDF_Dictionary;
-class IPDF_SecurityHandler;
-
-class IPDF_CryptoHandler {
- public:
- virtual ~IPDF_CryptoHandler();
-
- virtual FX_BOOL Init(CPDF_Dictionary* pEncryptDict,
- IPDF_SecurityHandler* pSecurityHandler) = 0;
-
- virtual uint32_t DecryptGetSize(uint32_t src_size) = 0;
- virtual void* DecryptStart(uint32_t objnum, uint32_t gennum) = 0;
- virtual FX_BOOL DecryptStream(void* context,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_BinaryBuf& dest_buf) = 0;
-
- virtual FX_BOOL DecryptFinish(void* context, CFX_BinaryBuf& dest_buf) = 0;
- virtual uint32_t EncryptGetSize(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size) = 0;
-
- virtual FX_BOOL EncryptContent(uint32_t objnum,
- uint32_t version,
- const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t* dest_buf,
- uint32_t& dest_size) = 0;
-
- void Decrypt(uint32_t objnum, uint32_t version, CFX_ByteString& str);
-};
-
-#endif // CORE_FPDFAPI_FPDF_PARSER_IPDF_CRYPTO_HANDLER_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_occontext.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_occontext.cpp
deleted file mode 100644
index 0b98b9889e4..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_occontext.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fpdfapi/fpdf_parser/ipdf_occontext.h"
-
-#include "core/fpdfapi/fpdf_page/cpdf_contentmarkitem.h"
-#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"
-
-IPDF_OCContext::~IPDF_OCContext() {}
-
-FX_BOOL IPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) {
- const CPDF_ContentMarkData* pData = pObj->m_ContentMark;
- int nItems = pData->CountItems();
- for (int i = 0; i < nItems; i++) {
- const CPDF_ContentMarkItem& item = pData->GetItem(i);
- if (item.GetName() == "OC" &&
- item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict &&
- !CheckOCGVisible(item.GetParam())) {
- return FALSE;
- }
- }
- return TRUE;
-}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_occontext.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_occontext.h
deleted file mode 100644
index 01087873429..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_occontext.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PARSER_IPDF_OCCONTEXT_H_
-#define CORE_FPDFAPI_FPDF_PARSER_IPDF_OCCONTEXT_H_
-
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_Dictionary;
-class CPDF_PageObject;
-
-class IPDF_OCContext {
- public:
- virtual ~IPDF_OCContext();
-
- virtual FX_BOOL CheckOCGVisible(const CPDF_Dictionary* pOCG) = 0;
- FX_BOOL CheckObjectVisible(const CPDF_PageObject* pObj);
-};
-
-#endif // CORE_FPDFAPI_FPDF_PARSER_IPDF_OCCONTEXT_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_security_handler.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_security_handler.h
deleted file mode 100644
index e7eb822a837..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_parser/ipdf_security_handler.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_FPDF_PARSER_IPDF_SECURITY_HANDLER_H_
-#define CORE_FPDFAPI_FPDF_PARSER_IPDF_SECURITY_HANDLER_H_
-
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_Parser;
-class CPDF_Dictionary;
-class IPDF_CryptoHandler;
-
-#define FXCIPHER_NONE 0
-#define FXCIPHER_RC4 1
-#define FXCIPHER_AES 2
-#define FXCIPHER_AES2 3
-
-class IPDF_SecurityHandler {
- public:
- virtual ~IPDF_SecurityHandler();
- virtual FX_BOOL OnInit(CPDF_Parser* pParser,
- CPDF_Dictionary* pEncryptDict) = 0;
-
- virtual uint32_t GetPermissions() = 0;
- virtual FX_BOOL GetCryptInfo(int& cipher,
- const uint8_t*& buffer,
- int& keylen) = 0;
-
- virtual FX_BOOL IsMetadataEncrypted() = 0;
- virtual IPDF_CryptoHandler* CreateCryptoHandler() = 0;
-};
-
-#endif // CORE_FPDFAPI_FPDF_PARSER_IPDF_SECURITY_HANDLER_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h
index 4e47e019b40..4f9ea1fe468 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h
@@ -28,7 +28,6 @@ class CPDF_PageRenderCache {
m_nCacheSize(0),
m_bCurFindCache(FALSE) {}
~CPDF_PageRenderCache();
- void ClearImageData();
uint32_t EstimateSize();
void CacheOptimization(int32_t dwLimitCacheSize);
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render.cpp
index 52f29477a9b..4ca8a53f72f 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -22,14 +22,13 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_occontext.h"
#include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/fpdfapi/ipdf_rendermodule.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
+#include "core/fxge/include/fx_ge.h"
CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc)
: m_pPDFDoc(pPDFDoc), m_pFontCache(new CFX_FontCache) {}
@@ -88,47 +87,6 @@ void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont) {
it->second->RemoveRef();
}
-class CPDF_RenderModule : public IPDF_RenderModule {
- public:
- CPDF_RenderModule() {}
-
- private:
- ~CPDF_RenderModule() override {}
-
- CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc) override;
- void DestroyDocData(CPDF_DocRenderData* p) override;
- void ClearDocData(CPDF_DocRenderData* p) override;
-
- CPDF_DocRenderData* GetRenderData() override { return &m_RenderData; }
-
- CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage) override {
- return new CPDF_PageRenderCache(pPage);
- }
-
- void DestroyPageCache(CPDF_PageRenderCache* pCache) override;
-
- CPDF_DocRenderData m_RenderData;
-};
-
-CPDF_DocRenderData* CPDF_RenderModule::CreateDocData(CPDF_Document* pDoc) {
- return new CPDF_DocRenderData(pDoc);
-}
-void CPDF_RenderModule::DestroyDocData(CPDF_DocRenderData* pDocData) {
- delete pDocData;
-}
-void CPDF_RenderModule::ClearDocData(CPDF_DocRenderData* p) {
- if (p) {
- p->Clear(FALSE);
- }
-}
-void CPDF_RenderModule::DestroyPageCache(CPDF_PageRenderCache* pCache) {
- delete pCache;
-}
-
-void CPDF_ModuleMgr::InitRenderModule() {
- m_pRenderModule.reset(new CPDF_RenderModule);
-}
-
CPDF_RenderOptions::CPDF_RenderOptions()
: m_ColorMode(RENDER_COLOR_NORMAL),
m_Flags(RENDER_CLEARTYPE),
@@ -252,7 +210,7 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext,
} else {
m_InitialStates.DefaultStates();
}
- m_pObjectRenderer.reset();
+ m_pImageRenderer.reset();
m_Transparency = transparency;
return TRUE;
}
@@ -305,13 +263,13 @@ void CPDF_RenderStatus::RenderSingleObject(const CPDF_PageObject* pObj,
FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device,
IFX_Pause* pPause) {
- if (m_pObjectRenderer) {
- if (m_pObjectRenderer->Continue(pPause))
+ if (m_pImageRenderer) {
+ if (m_pImageRenderer->Continue(pPause))
return TRUE;
- if (!m_pObjectRenderer->m_Result)
+ if (!m_pImageRenderer->m_Result)
DrawObjWithBackground(pObj, pObj2Device);
- m_pObjectRenderer.reset();
+ m_pImageRenderer.reset();
return FALSE;
}
@@ -326,11 +284,11 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj,
return FALSE;
if (pObj->IsImage()) {
- m_pObjectRenderer.reset(IPDF_ObjectRenderer::Create());
- if (!m_pObjectRenderer->Start(this, pObj, pObj2Device, FALSE)) {
- if (!m_pObjectRenderer->m_Result)
+ m_pImageRenderer.reset(new CPDF_ImageRenderer);
+ if (!m_pImageRenderer->Start(this, pObj, pObj2Device, FALSE)) {
+ if (!m_pImageRenderer->m_Result)
DrawObjWithBackground(pObj, pObj2Device);
- m_pObjectRenderer.reset();
+ m_pImageRenderer.reset();
return FALSE;
}
return ContinueSingleObject(pObj, pObj2Device, pPause);
@@ -340,10 +298,6 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj,
return FALSE;
}
-IPDF_ObjectRenderer* IPDF_ObjectRenderer::Create() {
- return new CPDF_ImageRenderer;
-}
-
FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device,
FX_BOOL bLogical,
@@ -796,7 +750,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
!bTextClip && !bGroupTransparent) {
return FALSE;
}
- FX_BOOL isolated = Transparency & PDFTRANS_ISOLATED;
+ bool isolated = !!(Transparency & PDFTRANS_ISOLATED);
if (m_bPrint) {
FX_BOOL bRet = FALSE;
int rendCaps = m_pDevice->GetRenderCaps();
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
index f5bc584348f..b0539a20147 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
@@ -6,13 +6,12 @@
#include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h"
#include "core/fpdfapi/fpdf_render/render_int.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
struct CACHEINFO {
uint32_t time;
@@ -188,15 +187,7 @@ void CPDF_ImageCacheEntry::Reset(const CFX_DIBitmap* pBitmap) {
}
CalcSize();
}
-void CPDF_PageRenderCache::ClearImageData() {
- for (const auto& it : m_ImageCache)
- it.second->ClearImageData();
-}
-void CPDF_ImageCacheEntry::ClearImageData() {
- if (m_pCachedBitmap && !m_pCachedBitmap->GetBuffer()) {
- ((CPDF_DIBSource*)m_pCachedBitmap)->ClearImageData();
- }
-}
+
static uint32_t FPDF_ImageCache_EstimateImageSize(const CFX_DIBSource* pDIB) {
return pDIB && pDIB->GetBuffer()
? (uint32_t)pDIB->GetHeight() * pDIB->GetPitch() +
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index ef2109a02f4..53c40b66eec 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -9,7 +9,6 @@
#include <utility>
#include <vector>
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
@@ -20,13 +19,13 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_occontext.h"
#include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcrt/include/fx_safe_types.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
FX_BOOL CPDF_RenderStatus::ProcessImage(const CPDF_ImageObject* pImageObj,
const CFX_Matrix* pObj2Device) {
@@ -46,8 +45,6 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
if (!pDIBitmap) {
return;
}
- FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED;
- FX_BOOL bGroup = Transparency & PDFTRANS_GROUP;
if (blend_mode == FXDIB_BLEND_NORMAL) {
if (!pDIBitmap->IsAlphaMask()) {
if (bitmap_alpha < 255) {
@@ -67,8 +64,10 @@ void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
}
}
}
- FX_BOOL bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects;
- FX_BOOL bGetBackGround =
+ bool bIsolated = !!(Transparency & PDFTRANS_ISOLATED);
+ bool bGroup = !!(Transparency & PDFTRANS_GROUP);
+ bool bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects;
+ bool bGetBackGround =
((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) ||
(!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) &&
(m_pDevice->GetRenderCaps() & FXRC_GET_BITS) && !bBackAlphaRequired);
@@ -412,13 +411,13 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
"Filter");
if (pFilters) {
if (pFilters->IsName()) {
- CFX_ByteStringC bsDecodeType = pFilters->GetConstString();
+ CFX_ByteString bsDecodeType = pFilters->GetString();
if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") {
m_Flags |= FXRENDER_IMAGE_LOSSY;
}
} else if (CPDF_Array* pArray = pFilters->AsArray()) {
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
- CFX_ByteStringC bsDecodeType = pArray->GetConstStringAt(i);
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
+ CFX_ByteString bsDecodeType = pArray->GetStringAt(i);
if (bsDecodeType == "DCTDecode" || bsDecodeType == "JPXDecode") {
m_Flags |= FXRENDER_IMAGE_LOSSY;
break;
@@ -534,14 +533,13 @@ FX_BOOL CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) {
m_pRenderStatus->m_bDropObjects, NULL, TRUE);
CFX_Matrix patternDevice = *pObj2Device;
patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top);
- if (m_pPattern->m_PatternType == CPDF_Pattern::TILING) {
- bitmap_render.DrawTilingPattern(
- static_cast<CPDF_TilingPattern*>(m_pPattern), m_pImageObject,
- &patternDevice, FALSE);
- } else {
- bitmap_render.DrawShadingPattern(
- static_cast<CPDF_ShadingPattern*>(m_pPattern), m_pImageObject,
- &patternDevice, FALSE);
+ if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) {
+ bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject,
+ &patternDevice, FALSE);
+ } else if (CPDF_ShadingPattern* pShadingPattern =
+ m_pPattern->AsShadingPattern()) {
+ bitmap_render.DrawShadingPattern(pShadingPattern, m_pImageObject,
+ &patternDevice, FALSE);
}
}
{
@@ -701,6 +699,7 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() {
rect.top, m_BlendType);
return FALSE;
}
+
FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) {
int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() *
@@ -712,7 +711,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
}
if (m_pRenderStatus->m_pDevice->StartDIBits(
m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags,
- m_DeviceHandle, 0, NULL, m_BlendType)) {
+ m_DeviceHandle, 0, nullptr, m_BlendType)) {
if (m_DeviceHandle) {
m_Status = 3;
return TRUE;
@@ -733,30 +732,29 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox();
clip_box.Intersect(image_rect);
m_Status = 2;
- m_pTransformer = new CFX_ImageTransformer;
- m_pTransformer->Start(m_pDIBSource, &m_ImageMatrix, m_Flags, &clip_box);
+ m_pTransformer = new CFX_ImageTransformer(m_pDIBSource, &m_ImageMatrix,
+ m_Flags, &clip_box);
+ m_pTransformer->Start();
return TRUE;
}
- if (m_ImageMatrix.a < 0) {
+ if (m_ImageMatrix.a < 0)
dest_width = -dest_width;
- }
- if (m_ImageMatrix.d > 0) {
+
+ if (m_ImageMatrix.d > 0)
dest_height = -dest_height;
- }
- int dest_left, dest_top;
- dest_left = dest_width > 0 ? image_rect.left : image_rect.right;
- dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
+
+ int dest_left = dest_width > 0 ? image_rect.left : image_rect.right;
+ int dest_top = dest_height > 0 ? image_rect.top : image_rect.bottom;
if (m_pDIBSource->IsOpaqueImage() && m_BitmapAlpha == 255) {
if (m_pRenderStatus->m_pDevice->StretchDIBits(
m_pDIBSource, dest_left, dest_top, dest_width, dest_height, m_Flags,
- NULL, m_BlendType)) {
+ nullptr, m_BlendType)) {
return FALSE;
}
}
if (m_pDIBSource->IsAlphaMask()) {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
- }
if (m_pRenderStatus->m_pDevice->StretchBitMask(
m_pDIBSource, dest_left, dest_top, dest_width, dest_height,
m_FillArgb, m_Flags)) {
@@ -768,6 +766,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
m_Result = FALSE;
return TRUE;
}
+
FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox();
FX_RECT dest_rect = clip_box;
dest_rect.Intersect(image_rect);
@@ -783,6 +782,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() {
}
return FALSE;
}
+
FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() {
if (m_pDIBSource->IsOpaqueImage()) {
CFX_PathData path;
@@ -826,47 +826,45 @@ FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() {
}
return FALSE;
}
+
FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) {
if (m_Status == 2) {
- if (m_pTransformer->Continue(pPause)) {
+ if (m_pTransformer->Continue(pPause))
return TRUE;
- }
- CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (!pBitmap) {
+
+ std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap());
+ if (!pBitmap)
return FALSE;
- }
+
if (pBitmap->IsAlphaMask()) {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
- }
m_Result = m_pRenderStatus->m_pDevice->SetBitMask(
- pBitmap, m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop,
- m_FillArgb);
+ pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_FillArgb);
} else {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
- }
m_Result = m_pRenderStatus->m_pDevice->SetDIBits(
- pBitmap, m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop,
- m_BlendType);
+ pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_BlendType);
}
- delete pBitmap;
return FALSE;
}
- if (m_Status == 3) {
+ if (m_Status == 3)
return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
- }
+
if (m_Status == 4) {
- if (m_Loader.Continue(m_LoadHandle, pPause)) {
+ if (m_Loader.Continue(m_LoadHandle, pPause))
return TRUE;
- }
- if (StartRenderDIBSource()) {
+
+ if (StartRenderDIBSource())
return Continue(pPause);
- }
}
return FALSE;
}
-ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
+
+CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
@@ -880,10 +878,6 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
if (!pSMaskDict) {
return NULL;
}
- int width = pClipRect->right - pClipRect->left;
- int height = pClipRect->bottom - pClipRect->top;
- FX_BOOL bLuminosity = FALSE;
- bLuminosity = pSMaskDict->GetConstStringBy("S") != "Alpha";
CPDF_Stream* pGroup = pSMaskDict->GetStreamBy("G");
if (!pGroup) {
return NULL;
@@ -895,10 +889,15 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
CFX_Matrix matrix = *pMatrix;
matrix.TranslateI(-pClipRect->left, -pClipRect->top);
+
CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(),
pGroup);
- form.ParseContent(NULL, NULL, NULL, NULL);
+ form.ParseContent(nullptr, nullptr, nullptr);
+
CFX_FxgeDevice bitmap_device;
+ FX_BOOL bLuminosity = pSMaskDict->GetStringBy("S") != "Alpha";
+ int width = pClipRect->right - pClipRect->left;
+ int height = pClipRect->bottom - pClipRect->top;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
if (!bitmap_device.Create(width, height,
bLuminosity ? FXDIB_Rgb32 : FXDIB_8bppMask)) {
@@ -931,14 +930,14 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
}
CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps);
FX_FLOAT* pFloats = float_array;
- FX_SAFE_DWORD num_floats = comps;
+ FX_SAFE_UINT32 num_floats = comps;
num_floats *= sizeof(FX_FLOAT);
if (!num_floats.IsValid()) {
return NULL;
}
FXSYS_memset(pFloats, 0, num_floats.ValueOrDie());
- int count = pBC->GetCount() > 8 ? 8 : pBC->GetCount();
- for (int i = 0; i < count; i++) {
+ size_t count = pBC->GetCount() > 8 ? 8 : pBC->GetCount();
+ for (size_t i = 0; i < count; i++) {
pFloats[i] = pBC->GetNumberAt(i);
}
pCS->GetRGB(pFloats, R, G, B);
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index 74e102db325..19aeb71e9ad 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -10,7 +10,6 @@
#include <memory>
#include <vector>
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_image.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
@@ -19,9 +18,9 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcrt/include/fx_safe_types.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
namespace {
@@ -38,8 +37,8 @@ unsigned int GetBits8(const uint8_t* pData, uint64_t bitpos, size_t nbits) {
return (byte >> (8 - nbits - (bitpos % 8))) & ((1 << nbits) - 1);
}
-FX_SAFE_DWORD CalculatePitch8(uint32_t bpc, uint32_t components, int width) {
- FX_SAFE_DWORD pitch = bpc;
+FX_SAFE_UINT32 CalculatePitch8(uint32_t bpc, uint32_t components, int width) {
+ FX_SAFE_UINT32 pitch = bpc;
pitch *= components;
pitch *= width;
pitch += 7;
@@ -47,8 +46,8 @@ FX_SAFE_DWORD CalculatePitch8(uint32_t bpc, uint32_t components, int width) {
return pitch;
}
-FX_SAFE_DWORD CalculatePitch32(int bpp, int width) {
- FX_SAFE_DWORD pitch = bpp;
+FX_SAFE_UINT32 CalculatePitch32(int bpp, int width) {
+ FX_SAFE_UINT32 pitch = bpp;
pitch *= width;
pitch += 31;
pitch /= 32; // quantized to number of 32-bit words.
@@ -70,7 +69,7 @@ T ClampValue(T value, T max_value) {
// Wrapper class to use with std::unique_ptr for CJPX_Decoder.
class JpxBitMapContext {
public:
- explicit JpxBitMapContext(ICodec_JpxModule* jpx_module)
+ explicit JpxBitMapContext(CCodec_JpxModule* jpx_module)
: jpx_module_(jpx_module), decoder_(nullptr) {}
~JpxBitMapContext() { jpx_module_->DestroyDecoder(decoder_); }
@@ -81,7 +80,7 @@ class JpxBitMapContext {
CJPX_Decoder* decoder() { return decoder_; }
private:
- ICodec_JpxModule* const jpx_module_; // Weak pointer.
+ CCodec_JpxModule* const jpx_module_; // Weak pointer.
CJPX_Decoder* decoder_; // Decoder, owned.
// Disallow evil constructors
@@ -129,7 +128,7 @@ CPDF_DIBSource::~CPDF_DIBSource() {
m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
}
if (m_pJbig2Context) {
- ICodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
+ CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
pJbig2Module->DestroyJbig2Context(m_pJbig2Context);
}
}
@@ -177,7 +176,7 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc,
if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) {
return FALSE;
}
- FX_SAFE_DWORD src_size =
+ FX_SAFE_UINT32 src_size =
CalculatePitch8(m_bpc, m_nComponents, m_Width) * m_Height;
if (!src_size.IsValid()) {
return FALSE;
@@ -202,7 +201,7 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc,
} else {
m_bpp = 24;
}
- FX_SAFE_DWORD pitch = CalculatePitch32(m_bpp, m_Width);
+ FX_SAFE_UINT32 pitch = CalculatePitch32(m_bpp, m_Width);
if (!pitch.IsValid()) {
return FALSE;
}
@@ -246,7 +245,7 @@ int CPDF_DIBSource::ContinueToLoadMask() {
if (!m_bpc || !m_nComponents) {
return 0;
}
- FX_SAFE_DWORD pitch = CalculatePitch32(m_bpp, m_Width);
+ FX_SAFE_UINT32 pitch = CalculatePitch32(m_bpp, m_Width);
if (!pitch.IsValid()) {
return 0;
}
@@ -299,7 +298,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc,
if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) {
return 0;
}
- FX_SAFE_DWORD src_size =
+ FX_SAFE_UINT32 src_size =
CalculatePitch8(m_bpc, m_nComponents, m_Width) * m_Height;
if (!src_size.IsValid()) {
return 0;
@@ -344,7 +343,7 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) {
if (decoder == "JPXDecode") {
return 0;
}
- ICodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
+ CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
if (!m_pJbig2Context) {
m_pJbig2Context = pJbig2Module->CreateJbig2Context();
if (m_pStreamAcc->GetImageParam()) {
@@ -527,14 +526,14 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode,
return pCompData;
}
-ICodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
+CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
int height,
const CPDF_Dictionary* pParams);
-ICodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
+CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
@@ -565,7 +564,7 @@ int CPDF_DIBSource::CreateDecoder() {
FX_BOOL bTransform = FALSE;
int comps;
int bpc;
- ICodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule();
+ CCodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule();
if (pJpegModule->LoadInfo(src_data, src_size, m_Width, m_Height, comps,
bpc, bTransform)) {
if (m_nComponents != static_cast<uint32_t>(comps)) {
@@ -612,12 +611,12 @@ int CPDF_DIBSource::CreateDecoder() {
if (!m_pDecoder)
return 0;
- FX_SAFE_DWORD requested_pitch =
+ FX_SAFE_UINT32 requested_pitch =
CalculatePitch8(m_bpc, m_nComponents, m_Width);
if (!requested_pitch.IsValid()) {
return 0;
}
- FX_SAFE_DWORD provided_pitch = CalculatePitch8(
+ FX_SAFE_UINT32 provided_pitch = CalculatePitch8(
m_pDecoder->GetBPC(), m_pDecoder->CountComps(), m_pDecoder->GetWidth());
if (!provided_pitch.IsValid()) {
return 0;
@@ -629,7 +628,7 @@ int CPDF_DIBSource::CreateDecoder() {
}
void CPDF_DIBSource::LoadJpxBitmap() {
- ICodec_JpxModule* pJpxModule = CPDF_ModuleMgr::Get()->GetJpxModule();
+ CCodec_JpxModule* pJpxModule = CPDF_ModuleMgr::Get()->GetJpxModule();
if (!pJpxModule)
return;
@@ -1034,7 +1033,7 @@ const uint8_t* CPDF_DIBSource::GetScanline(int line) const {
if (m_bpc == 0) {
return nullptr;
}
- FX_SAFE_DWORD src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width);
+ FX_SAFE_UINT32 src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width);
if (!src_pitch.IsValid())
return nullptr;
uint32_t src_pitch_value = src_pitch.ValueOrDie();
@@ -1180,7 +1179,7 @@ void CPDF_DIBSource::DownSampleScanline(int line,
}
uint32_t src_width = m_Width;
- FX_SAFE_DWORD pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width);
+ FX_SAFE_UINT32 pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width);
if (!pitch.IsValid())
return;
@@ -1478,20 +1477,6 @@ FX_BOOL CPDF_DIBSource::TransMask() const {
m_Family == PDFCS_DEVICECMYK;
}
-void CPDF_DIBSource::SetDownSampleSize(int dest_width, int dest_height) {
- if (m_pDecoder) {
- m_pDecoder->DownScale(dest_width, dest_height);
- m_Width = m_pDecoder->GetWidth();
- m_Height = m_pDecoder->GetHeight();
- }
-}
-
-void CPDF_DIBSource::ClearImageData() {
- if (m_pDecoder) {
- m_pDecoder->ClearImageData();
- }
-}
-
CPDF_ImageLoaderHandle::CPDF_ImageLoaderHandle() {
m_pImageLoader = nullptr;
m_pCache = nullptr;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index d3081da26fc..ef604ec70f5 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -8,7 +8,6 @@
#include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h"
#include "core/fpdfapi/fpdf_page/cpdf_meshstream.h"
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
@@ -20,7 +19,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#define SHADING_STEPS 256
static void DrawAxialShading(CFX_DIBitmap* pBitmap,
@@ -653,7 +652,10 @@ struct CPDF_PatchDrawer {
FX_BOOL bSmall = C1.Distance() < 2 && C2.Distance() < 2 &&
D1.Distance() < 2 && D2.Distance() < 2;
Coon_Color div_colors[4];
- int d_bottom, d_left, d_top, d_right;
+ int d_bottom = 0;
+ int d_left = 0;
+ int d_top = 0;
+ int d_right = 0;
div_colors[0].BiInterpol(patch_colors, left, bottom, x_scale, y_scale);
if (!bSmall) {
div_colors[1].BiInterpol(patch_colors, left, bottom + 1, x_scale,
@@ -855,8 +857,8 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
clip_rect.Intersect(rect.GetOutterRect());
}
if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SHADING &&
- m_pDevice->GetDeviceDriver()->DrawShading(pPattern, pMatrix, alpha,
- bAlphaMode)) {
+ m_pDevice->GetDeviceDriver()->DrawShading(pPattern, pMatrix, clip_rect,
+ alpha, bAlphaMode)) {
return;
}
CPDF_DeviceBuffer buffer;
@@ -886,21 +888,31 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
pColorSpace, alpha);
break;
case kFreeFormGouraudTriangleMeshShading: {
- DrawFreeGouraudShading(pBitmap, &FinalMatrix,
- ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs,
- pColorSpace, alpha);
+ // The shading object can be a stream or a dictionary. We do not handle
+ // the case of dictionary at the moment.
+ if (CPDF_Stream* pStream = ToStream(pPattern->m_pShadingObj)) {
+ DrawFreeGouraudShading(pBitmap, &FinalMatrix, pStream, pFuncs, nFuncs,
+ pColorSpace, alpha);
+ }
} break;
case kLatticeFormGouraudTriangleMeshShading: {
- DrawLatticeGouraudShading(pBitmap, &FinalMatrix,
- ToStream(pPattern->m_pShadingObj), pFuncs,
- nFuncs, pColorSpace, alpha);
+ // The shading object can be a stream or a dictionary. We do not handle
+ // the case of dictionary at the moment.
+ if (CPDF_Stream* pStream = ToStream(pPattern->m_pShadingObj)) {
+ DrawLatticeGouraudShading(pBitmap, &FinalMatrix, pStream, pFuncs,
+ nFuncs, pColorSpace, alpha);
+ }
} break;
case kCoonsPatchMeshShading:
case kTensorProductPatchMeshShading: {
- DrawCoonPatchMeshes(
- pPattern->m_ShadingType == kTensorProductPatchMeshShading, pBitmap,
- &FinalMatrix, ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs,
- pColorSpace, fill_mode, alpha);
+ // The shading object can be a stream or a dictionary. We do not handle
+ // the case of dictionary at the moment.
+ if (CPDF_Stream* pStream = ToStream(pPattern->m_pShadingObj)) {
+ DrawCoonPatchMeshes(
+ pPattern->m_ShadingType == kTensorProductPatchMeshShading, pBitmap,
+ &FinalMatrix, pStream, pFuncs, nFuncs, pColorSpace, fill_mode,
+ alpha);
+ }
} break;
}
if (bAlphaMode) {
@@ -934,7 +946,7 @@ void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
m_pDevice->RestoreState();
return;
}
- CFX_Matrix matrix = pattern->m_Pattern2Form;
+ CFX_Matrix matrix = *pattern->pattern_to_form();
matrix.Concat(*pObj2Device);
GetScaledMatrix(matrix);
int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke);
@@ -966,15 +978,15 @@ static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc,
int flags) {
CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
if (!pBitmap->Create(width, height,
- pPattern->m_bColored ? FXDIB_Argb : FXDIB_8bppMask)) {
+ pPattern->colored() ? FXDIB_Argb : FXDIB_8bppMask)) {
delete pBitmap;
return NULL;
}
CFX_FxgeDevice bitmap_device;
bitmap_device.Attach(pBitmap);
pBitmap->Clear(0);
- CFX_FloatRect cell_bbox = pPattern->m_BBox;
- pPattern->m_Pattern2Form.TransformRect(cell_bbox);
+ CFX_FloatRect cell_bbox = pPattern->bbox();
+ pPattern->pattern_to_form()->TransformRect(cell_bbox);
pObject2Device->TransformRect(cell_bbox);
CFX_FloatRect bitmap_rect(0.0f, 0.0f, (FX_FLOAT)width, (FX_FLOAT)height);
CFX_Matrix mtAdjust;
@@ -982,13 +994,13 @@ static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc,
CFX_Matrix mtPattern2Bitmap = *pObject2Device;
mtPattern2Bitmap.Concat(mtAdjust);
CPDF_RenderOptions options;
- if (!pPattern->m_bColored) {
+ if (!pPattern->colored())
options.m_ColorMode = RENDER_COLOR_ALPHA;
- }
+
flags |= RENDER_FORCE_HALFTONE;
options.m_Flags = flags;
CPDF_RenderContext context(pDoc, pCache);
- context.AppendLayer(pPattern->m_pForm, &mtPattern2Bitmap);
+ context.AppendLayer(pPattern->form(), &mtPattern2Bitmap);
context.Render(&bitmap_device, &options, nullptr);
return pBitmap;
}
@@ -1020,17 +1032,17 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
FX_FLOAT sd = FXSYS_fabs(dCTM.d);
clip_box.right = clip_box.left + (int32_t)FXSYS_ceil(clip_box.Width() * sa);
clip_box.bottom = clip_box.top + (int32_t)FXSYS_ceil(clip_box.Height() * sd);
- CFX_Matrix mtPattern2Device = pPattern->m_Pattern2Form;
+ CFX_Matrix mtPattern2Device = *pPattern->pattern_to_form();
mtPattern2Device.Concat(*pObj2Device);
GetScaledMatrix(mtPattern2Device);
FX_BOOL bAligned = FALSE;
- if (pPattern->m_BBox.left == 0 && pPattern->m_BBox.bottom == 0 &&
- pPattern->m_BBox.right == pPattern->m_XStep &&
- pPattern->m_BBox.top == pPattern->m_YStep &&
+ if (pPattern->bbox().left == 0 && pPattern->bbox().bottom == 0 &&
+ pPattern->bbox().right == pPattern->x_step() &&
+ pPattern->bbox().top == pPattern->y_step() &&
(mtPattern2Device.IsScaled() || mtPattern2Device.Is90Rotated())) {
bAligned = TRUE;
}
- CFX_FloatRect cell_bbox = pPattern->m_BBox;
+ CFX_FloatRect cell_bbox = pPattern->bbox();
mtPattern2Device.TransformRect(cell_bbox);
int width = (int)FXSYS_ceil(cell_bbox.Width());
int height = (int)FXSYS_ceil(cell_bbox.Height());
@@ -1046,40 +1058,40 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
CFX_FloatRect clip_box_p(clip_box);
clip_box_p.Transform(&mtDevice2Pattern);
- min_col = (int)FXSYS_ceil((clip_box_p.left - pPattern->m_BBox.right) /
- pPattern->m_XStep);
- max_col = (int)FXSYS_floor((clip_box_p.right - pPattern->m_BBox.left) /
- pPattern->m_XStep);
- min_row = (int)FXSYS_ceil((clip_box_p.bottom - pPattern->m_BBox.top) /
- pPattern->m_YStep);
- max_row = (int)FXSYS_floor((clip_box_p.top - pPattern->m_BBox.bottom) /
- pPattern->m_YStep);
+ min_col = (int)FXSYS_ceil((clip_box_p.left - pPattern->bbox().right) /
+ pPattern->x_step());
+ max_col = (int)FXSYS_floor((clip_box_p.right - pPattern->bbox().left) /
+ pPattern->x_step());
+ min_row = (int)FXSYS_ceil((clip_box_p.bottom - pPattern->bbox().top) /
+ pPattern->y_step());
+ max_row = (int)FXSYS_floor((clip_box_p.top - pPattern->bbox().bottom) /
+ pPattern->y_step());
if (width > clip_box.Width() || height > clip_box.Height() ||
width * height > clip_box.Width() * clip_box.Height()) {
CPDF_GraphicStates* pStates = NULL;
- if (!pPattern->m_bColored) {
+ if (!pPattern->colored())
pStates = CloneObjStates(pPageObj, bStroke);
- }
- CPDF_Dictionary* pFormResource = NULL;
- if (pPattern->m_pForm->m_pFormDict) {
- pFormResource = pPattern->m_pForm->m_pFormDict->GetDictBy("Resources");
- }
+
+ CPDF_Dictionary* pFormResource = nullptr;
+ if (pPattern->form()->m_pFormDict)
+ pFormResource = pPattern->form()->m_pFormDict->GetDictBy("Resources");
+
for (int col = min_col; col <= max_col; col++)
for (int row = min_row; row <= max_row; row++) {
FX_FLOAT orig_x, orig_y;
- orig_x = col * pPattern->m_XStep;
- orig_y = row * pPattern->m_YStep;
+ orig_x = col * pPattern->x_step();
+ orig_y = row * pPattern->y_step();
mtPattern2Device.Transform(orig_x, orig_y);
CFX_Matrix matrix = *pObj2Device;
matrix.Translate(orig_x - mtPattern2Device.e,
orig_y - mtPattern2Device.f);
m_pDevice->SaveState();
CPDF_RenderStatus status;
- status.Initialize(m_pContext, m_pDevice, NULL, NULL, this, pStates,
- &m_Options, pPattern->m_pForm->m_Transparency,
+ status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this,
+ pStates, &m_Options, pPattern->form()->m_Transparency,
m_bDropObjects, pFormResource);
- status.RenderObjectList(pPattern->m_pForm, &matrix);
+ status.RenderObjectList(pPattern->form(), &matrix);
m_pDevice->RestoreState();
}
m_pDevice->RestoreState();
@@ -1144,8 +1156,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
start_x = FXSYS_round(mtPattern2Device.e) + col * width - clip_box.left;
start_y = FXSYS_round(mtPattern2Device.f) + row * height - clip_box.top;
} else {
- FX_FLOAT orig_x = col * pPattern->m_XStep;
- FX_FLOAT orig_y = row * pPattern->m_YStep;
+ FX_FLOAT orig_x = col * pPattern->x_step();
+ FX_FLOAT orig_y = row * pPattern->y_step();
mtPattern2Device.Transform(orig_x, orig_y);
start_x = FXSYS_round(orig_x + left_offset) - clip_box.left;
start_y = FXSYS_round(orig_y + top_offset) - clip_box.top;
@@ -1158,13 +1170,12 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
uint32_t* dest_buf =
(uint32_t*)(screen.GetBuffer() + screen.GetPitch() * start_y +
start_x * 4);
- if (pPattern->m_bColored) {
+ if (pPattern->colored())
*dest_buf = *src_buf;
- } else {
+ else
*dest_buf = (*(uint8_t*)src_buf << 24) | (fill_argb & 0xffffff);
- }
} else {
- if (pPattern->m_bColored) {
+ if (pPattern->colored()) {
screen.CompositeBitmap(start_x, start_y, width, height,
pPatternBitmap, 0, 0);
} else {
@@ -1179,36 +1190,35 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
m_pDevice->RestoreState();
delete pPatternBitmap;
}
+
void CPDF_RenderStatus::DrawPathWithPattern(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device,
CPDF_Color* pColor,
FX_BOOL bStroke) {
CPDF_Pattern* pattern = pColor->GetPattern();
- if (!pattern) {
+ if (!pattern)
return;
- }
- if (pattern->m_PatternType == CPDF_Pattern::TILING) {
- DrawTilingPattern(static_cast<CPDF_TilingPattern*>(pattern), pPathObj,
- pObj2Device, bStroke);
- } else {
- DrawShadingPattern(static_cast<CPDF_ShadingPattern*>(pattern), pPathObj,
- pObj2Device, bStroke);
- }
+
+ if (CPDF_TilingPattern* pTilingPattern = pattern->AsTilingPattern())
+ DrawTilingPattern(pTilingPattern, pPathObj, pObj2Device, bStroke);
+ else if (CPDF_ShadingPattern* pShadingPattern = pattern->AsShadingPattern())
+ DrawShadingPattern(pShadingPattern, pPathObj, pObj2Device, bStroke);
}
+
void CPDF_RenderStatus::ProcessPathPattern(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device,
int& filltype,
FX_BOOL& bStroke) {
if (filltype) {
CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor();
- if (FillColor.m_pCS && FillColor.m_pCS->GetFamily() == PDFCS_PATTERN) {
+ if (FillColor.IsPattern()) {
DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, FALSE);
filltype = 0;
}
}
if (bStroke) {
CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor();
- if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) {
+ if (StrokeColor.IsPattern()) {
DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE);
bStroke = FALSE;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 0165e8a7d70..225b6726e2d 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -10,7 +10,6 @@
#include "core/fpdfapi/fpdf_font/cpdf_type3char.h"
#include "core/fpdfapi/fpdf_font/cpdf_type3font.h"
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"
@@ -21,7 +20,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
namespace {
@@ -58,7 +57,7 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode,
keygen.Generate(
4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000),
FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000));
- CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
+ CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
CPDF_Type3Glyphs* pSizeCache;
auto it = m_SizeMap.find(FaceGlyphsKey);
if (it == m_SizeMap.end()) {
@@ -150,6 +149,7 @@ static int _DetectFirstLastScan(const CFX_DIBitmap* pBitmap, FX_BOOL bFirst) {
}
return -1;
}
+
CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
uint32_t charcode,
const CFX_Matrix* pMatrix,
@@ -159,12 +159,12 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
if (!pChar || !pChar->m_pBitmap)
return nullptr;
- CFX_DIBitmap* pBitmap = pChar->m_pBitmap;
+ CFX_DIBitmap* pBitmap = pChar->m_pBitmap.get();
CFX_Matrix image_matrix, text_matrix;
image_matrix = pChar->m_ImageMatrix;
text_matrix.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0);
image_matrix.Concat(text_matrix);
- CFX_DIBitmap* pResBitmap = NULL;
+ std::unique_ptr<CFX_DIBitmap> pResBitmap;
int left = 0;
int top = 0;
if (FXSYS_fabs(image_matrix.b) < FXSYS_fabs(image_matrix.a) / 100 &&
@@ -181,10 +181,10 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
bottom_y = temp;
}
pSize->AdjustBlue(top_y, bottom_y, top_line, bottom_line);
- pResBitmap = pBitmap->StretchTo(
+ pResBitmap.reset(pBitmap->StretchTo(
(int)(FXSYS_round(image_matrix.a) * retinaScaleX),
(int)((bFlipped ? top_line - bottom_line : bottom_line - top_line) *
- retinaScaleY));
+ retinaScaleY)));
top = top_line;
if (image_matrix.a < 0) {
image_matrix.Scale(retinaScaleX, retinaScaleY);
@@ -196,16 +196,15 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
}
if (!pResBitmap) {
image_matrix.Scale(retinaScaleX, retinaScaleY);
- pResBitmap = pBitmap->TransformTo(&image_matrix, left, top);
- }
- if (!pResBitmap) {
- return NULL;
+ pResBitmap.reset(pBitmap->TransformTo(&image_matrix, left, top));
}
+ if (!pResBitmap)
+ return nullptr;
+
CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap;
pGlyph->m_Left = left;
pGlyph->m_Top = -top;
- pGlyph->m_Bitmap.TakeOver(pResBitmap);
- delete pResBitmap;
+ pGlyph->m_Bitmap.TakeOver(pResBitmap.get());
return pGlyph;
}
@@ -424,7 +423,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
status.m_Type3FontCache.Append(m_Type3FontCache);
status.m_Type3FontCache.Add(pType3Font);
m_pDevice->SaveState();
- status.RenderObjectList(pType3Char->m_pForm, &matrix);
+ status.RenderObjectList(pType3Char->m_pForm.get(), &matrix);
m_pDevice->RestoreState();
} else {
CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox();
@@ -445,7 +444,7 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
status.m_Type3FontCache.Add(pType3Font);
matrix.TranslateI(-rect.left, -rect.top);
matrix.Scale(sa, sd);
- status.RenderObjectList(pType3Char->m_pForm, &matrix);
+ status.RenderObjectList(pType3Char->m_pForm.get(), &matrix);
m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top);
}
delete pStates;
@@ -471,13 +470,12 @@ FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj,
CFX_Matrix image_matrix = pType3Char->m_ImageMatrix;
image_matrix.Concat(matrix);
CPDF_ImageRenderer renderer;
- if (renderer.Start(this, pType3Char->m_pBitmap, fill_argb, 255,
+ if (renderer.Start(this, pType3Char->m_pBitmap.get(), fill_argb, 255,
&image_matrix, 0, FALSE)) {
- renderer.Continue(NULL);
+ renderer.Continue(nullptr);
}
- if (!renderer.m_Result) {
+ if (!renderer.m_Result)
return FALSE;
- }
}
}
}
@@ -637,7 +635,7 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
FX_ARGB stroke_argb,
const CFX_GraphStateData* pGraphState,
const CPDF_RenderOptions* pOptions) {
- int nChars = pFont->CountChar(str, str.GetLength());
+ int nChars = pFont->CountChar(str.c_str(), str.GetLength());
if (nChars == 0) {
return;
}
@@ -646,7 +644,7 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
uint32_t* pCharCodes;
FX_FLOAT* pCharPos;
if (nChars == 1) {
- charcode = pFont->GetNextChar(str, str.GetLength(), offset);
+ charcode = pFont->GetNextChar(str.c_str(), str.GetLength(), offset);
pCharCodes = (uint32_t*)(uintptr_t)charcode;
pCharPos = NULL;
} else {
@@ -654,7 +652,7 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
pCharPos = FX_Alloc(FX_FLOAT, nChars - 1);
FX_FLOAT cur_pos = 0;
for (int i = 0; i < nChars; i++) {
- pCharCodes[i] = pFont->GetNextChar(str, str.GetLength(), offset);
+ pCharCodes[i] = pFont->GetNextChar(str.c_str(), str.GetLength(), offset);
if (i) {
pCharPos[i - 1] = cur_pos;
}
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h
index a78838ac58d..2590dbbd2da 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h
@@ -8,9 +8,9 @@
#define CORE_FPDFAPI_FPDF_RENDER_INCLUDE_CPDF_RENDEROPTIONS_H_
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
-class IPDF_OCContext;
+class CPDF_OCContext;
#define RENDER_COLOR_NORMAL 0
#define RENDER_COLOR_GRAY 1
@@ -44,7 +44,7 @@ class CPDF_RenderOptions {
uint32_t m_Flags;
int m_Interpolation;
uint32_t m_AddFlags;
- IPDF_OCContext* m_pOCContext;
+ CPDF_OCContext* m_pOCContext;
uint32_t m_dwLimitCacheSize;
int m_HalftoneLimit;
};
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h
index 2d3ce44e46e..d532196675b 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h
@@ -10,7 +10,7 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
class CFX_RenderDevice;
class CFX_GraphStateData;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/render_int.h b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/render_int.h
index b22b9fc39b5..464ca387848 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/render_int.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/fpdf_render/render_int.h
@@ -16,32 +16,33 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
-class CPDF_PageObjectHolder;
-class CPDF_PageRenderCache;
-class CPDF_RenderStatus;
+class CCodec_ScanlineDecoder;
+class CFX_FontCache;
class CFX_GlyphBitmap;
class CFX_ImageTransformer;
+class CPDF_Color;
+class CPDF_Dictionary;
+class CPDF_Document;
+class CPDF_Font;
+class CPDF_FormObject;
class CPDF_ImageCacheEntry;
class CPDF_ImageLoaderHandle;
-class ICodec_ScanlineDecoder;
-class CPDF_Type3Font;
-class CPDF_Type3Cache;
-class CPDF_Type3Char;
-class CPDF_TransferFunc;
-class CPDF_Document;
+class CPDF_ImageObject;
+class CPDF_ImageRenderer;
class CPDF_Object;
-class CFX_FontCache;
-class CPDF_Font;
class CPDF_PageObject;
+class CPDF_PageObjectHolder;
+class CPDF_PageRenderCache;
class CPDF_PathObject;
+class CPDF_RenderStatus;
class CPDF_ShadingObject;
-class CPDF_FormObject;
class CPDF_ShadingPattern;
-class CPDF_TilingPattern;
-class CPDF_Color;
-class CPDF_Dictionary;
-class CPDF_ImageObject;
class CPDF_Stream;
+class CPDF_TilingPattern;
+class CPDF_TransferFunc;
+class CPDF_Type3Cache;
+class CPDF_Type3Char;
+class CPDF_Type3Font;
#define TYPE3_MAX_BLUES 16
@@ -118,19 +119,6 @@ class CPDF_DocRenderData {
CPDF_TransferFuncMap m_TransferFuncMap;
};
-class IPDF_ObjectRenderer {
- public:
- static IPDF_ObjectRenderer* Create();
- virtual ~IPDF_ObjectRenderer() {}
- virtual FX_BOOL Start(CPDF_RenderStatus* pRenderStatus,
- const CPDF_PageObject* pObj,
- const CFX_Matrix* pObj2Device,
- FX_BOOL bStdCS,
- int blendType = FXDIB_BLEND_NORMAL) = 0;
- virtual FX_BOOL Continue(IFX_Pause* pPause) = 0;
- FX_BOOL m_Result;
-};
-
class CPDF_RenderStatus {
public:
CPDF_RenderStatus();
@@ -275,7 +263,7 @@ class CPDF_RenderStatus {
const CPDF_PageObject* m_pStopObj;
CPDF_GraphicStates m_InitialStates;
int m_HalftoneLimit;
- std::unique_ptr<IPDF_ObjectRenderer> m_pObjectRenderer;
+ std::unique_ptr<CPDF_ImageRenderer> m_pImageRenderer;
FX_BOOL m_bPrint;
int m_Transparency;
int m_DitherBits;
@@ -342,18 +330,17 @@ class CPDF_ImageLoaderHandle {
int32_t m_nDownsampleHeight;
};
-class CPDF_ImageRenderer : public IPDF_ObjectRenderer {
+class CPDF_ImageRenderer {
public:
CPDF_ImageRenderer();
- ~CPDF_ImageRenderer() override;
+ ~CPDF_ImageRenderer();
- // IPDF_ObjectRenderer
FX_BOOL Start(CPDF_RenderStatus* pStatus,
const CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device,
FX_BOOL bStdCS,
- int blendType = FXDIB_BLEND_NORMAL) override;
- FX_BOOL Continue(IFX_Pause* pPause) override;
+ int blendType = FXDIB_BLEND_NORMAL);
+ FX_BOOL Continue(IFX_Pause* pPause);
FX_BOOL Start(CPDF_RenderStatus* pStatus,
const CFX_DIBSource* pDIBSource,
@@ -364,7 +351,16 @@ class CPDF_ImageRenderer : public IPDF_ObjectRenderer {
FX_BOOL bStdCS,
int blendType = FXDIB_BLEND_NORMAL);
+ FX_BOOL m_Result;
+
protected:
+ FX_BOOL StartBitmapAlpha();
+ FX_BOOL StartDIBSource();
+ FX_BOOL StartRenderDIBSource();
+ FX_BOOL StartLoadDIBSource();
+ FX_BOOL DrawMaskedImage();
+ FX_BOOL DrawPatternImage(const CFX_Matrix* pObj2Device);
+
CPDF_RenderStatus* m_pRenderStatus;
const CPDF_ImageObject* m_pImageObject;
int m_Status;
@@ -383,12 +379,6 @@ class CPDF_ImageRenderer : public IPDF_ObjectRenderer {
CPDF_ImageLoaderHandle* m_LoadHandle;
FX_BOOL m_bStdCS;
int m_BlendType;
- FX_BOOL StartBitmapAlpha();
- FX_BOOL StartDIBSource();
- FX_BOOL StartRenderDIBSource();
- FX_BOOL StartLoadDIBSource();
- FX_BOOL DrawMaskedImage();
- FX_BOOL DrawPatternImage(const CFX_Matrix* pObj2Device);
};
class CPDF_ScaledRenderBuffer {
@@ -443,7 +433,7 @@ class CPDF_ImageCacheEntry {
public:
CPDF_ImageCacheEntry(CPDF_Document* pDoc, CPDF_Stream* pStream);
~CPDF_ImageCacheEntry();
- void ClearImageData();
+
void Reset(const CFX_DIBitmap* pBitmap);
FX_BOOL GetCachedBitmap(CFX_DIBSource*& pBitmap,
CFX_DIBSource*& pMask,
@@ -521,11 +511,9 @@ class CPDF_DIBSource : public CFX_DIBSource {
FX_BOOL bFlipX,
int clip_left,
int clip_width) const override;
- void SetDownSampleSize(int dest_width, int dest_height) override;
CFX_DIBitmap* GetBitmap() const;
void ReleaseBitmap(CFX_DIBitmap* pBitmap) const;
- void ClearImageData();
uint32_t GetMatteColor() const { return m_MatteColor; }
int StartLoadDIBSource(CPDF_Document* pDoc,
@@ -607,7 +595,7 @@ class CPDF_DIBSource : public CFX_DIBSource {
uint8_t* m_pLineBuf;
uint8_t* m_pMaskedLine;
std::unique_ptr<CFX_DIBitmap> m_pCachedBitmap;
- std::unique_ptr<ICodec_ScanlineDecoder> m_pDecoder;
+ std::unique_ptr<CCodec_ScanlineDecoder> m_pDecoder;
void* m_pJbig2Context;
CPDF_DIBSource* m_pMask;
std::unique_ptr<CPDF_StreamAcc> m_pGlobalStream;
diff --git a/chromium/third_party/pdfium/core/fpdfapi/include/cpdf_modulemgr.h b/chromium/third_party/pdfium/core/fpdfapi/include/cpdf_modulemgr.h
index a8be5af7dd6..e54bd07a907 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/include/cpdf_modulemgr.h
+++ b/chromium/third_party/pdfium/core/fpdfapi/include/cpdf_modulemgr.h
@@ -9,19 +9,17 @@
#include <memory>
-#include "core/fpdfapi/ipdf_pagemodule.h"
#include "core/fxcrt/include/fx_basic.h"
class CCodec_ModuleMgr;
-class ICodec_FaxModule;
-class ICodec_FlateModule;
-class ICodec_IccModule;
-class ICodec_Jbig2Module;
-class ICodec_JpegModule;
-class ICodec_JpxModule;
+class CCodec_FaxModule;
+class CCodec_FlateModule;
+class CCodec_IccModule;
+class CCodec_Jbig2Module;
+class CCodec_JpegModule;
+class CCodec_JpxModule;
-class IPDF_PageModule;
-class IPDF_RenderModule;
+class CPDF_PageModule;
class CPDF_ModuleMgr {
public:
@@ -34,22 +32,20 @@ class CPDF_ModuleMgr {
CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; }
void InitPageModule();
- void InitRenderModule();
- IPDF_RenderModule* GetRenderModule() const { return m_pRenderModule.get(); }
- IPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); }
+ CPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); }
void LoadEmbeddedGB1CMaps();
void LoadEmbeddedCNS1CMaps();
void LoadEmbeddedJapan1CMaps();
void LoadEmbeddedKorea1CMaps();
- ICodec_FaxModule* GetFaxModule();
- ICodec_JpegModule* GetJpegModule();
- ICodec_JpxModule* GetJpxModule();
- ICodec_Jbig2Module* GetJbig2Module();
- ICodec_IccModule* GetIccModule();
- ICodec_FlateModule* GetFlateModule();
+ CCodec_FaxModule* GetFaxModule();
+ CCodec_JpegModule* GetJpegModule();
+ CCodec_JpxModule* GetJpxModule();
+ CCodec_Jbig2Module* GetJbig2Module();
+ CCodec_IccModule* GetIccModule();
+ CCodec_FlateModule* GetFlateModule();
void SetPrivateData(void* module_id,
void* pData,
@@ -62,8 +58,7 @@ class CPDF_ModuleMgr {
~CPDF_ModuleMgr();
CCodec_ModuleMgr* m_pCodecModule;
- std::unique_ptr<IPDF_RenderModule> m_pRenderModule;
- std::unique_ptr<IPDF_PageModule> m_pPageModule;
+ std::unique_ptr<CPDF_PageModule> m_pPageModule;
CFX_PrivateData m_privateData;
};
diff --git a/chromium/third_party/pdfium/core/fpdfapi/ipdf_pagemodule.h b/chromium/third_party/pdfium/core/fpdfapi/ipdf_pagemodule.h
deleted file mode 100644
index 3765cd91d2a..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/ipdf_pagemodule.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_IPDF_PAGEMODULE_H_
-#define CORE_FPDFAPI_IPDF_PAGEMODULE_H_
-
-class CPDF_ColorSpace;
-class CPDF_DocPageData;
-class CPDF_Document;
-class CPDF_FontGlobals;
-
-class IPDF_PageModule {
- public:
- virtual ~IPDF_PageModule() {}
-
- virtual CPDF_DocPageData* CreateDocData(CPDF_Document* pDoc) = 0;
- virtual void ReleaseDoc(CPDF_Document* pDoc) = 0;
- virtual void ClearDoc(CPDF_Document* pDoc) = 0;
- virtual CPDF_FontGlobals* GetFontGlobals() = 0;
- virtual void ClearStockFont(CPDF_Document* pDoc) = 0;
- virtual void NotifyCJKAvailable() = 0;
- virtual CPDF_ColorSpace* GetStockCS(int family) = 0;
-};
-
-#endif // CORE_FPDFAPI_IPDF_PAGEMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/ipdf_rendermodule.h b/chromium/third_party/pdfium/core/fpdfapi/ipdf_rendermodule.h
deleted file mode 100644
index 5082b19e8c3..00000000000
--- a/chromium/third_party/pdfium/core/fpdfapi/ipdf_rendermodule.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFAPI_IPDF_RENDERMODULE_H_
-#define CORE_FPDFAPI_IPDF_RENDERMODULE_H_
-
-class CPDF_DocRenderData;
-class CPDF_Document;
-class CPDF_Page;
-class CPDF_PageRenderCache;
-
-class IPDF_RenderModule {
- public:
- virtual ~IPDF_RenderModule() {}
-
- virtual CPDF_DocRenderData* CreateDocData(CPDF_Document* pDoc) = 0;
- virtual void DestroyDocData(CPDF_DocRenderData* pDocRenderData) = 0;
- virtual void ClearDocData(CPDF_DocRenderData* pDocRenderData) = 0;
-
- virtual CPDF_DocRenderData* GetRenderData() = 0;
-
- virtual CPDF_PageRenderCache* CreatePageCache(CPDF_Page* pPage) = 0;
- virtual void DestroyPageCache(CPDF_PageRenderCache* pCache) = 0;
-};
-
-#endif // CORE_FPDFAPI_IPDF_RENDERMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/cpdf_variabletext.cpp b/chromium/third_party/pdfium/core/fpdfdoc/cpdf_variabletext.cpp
index 67887400a47..a8b9c3c7783 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/cpdf_variabletext.cpp
@@ -4,10 +4,11 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fpdfdoc/include/cpdf_variabletext.h"
+
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
#include "core/fpdfdoc/cpvt_wordinfo.h"
#include "core/fpdfdoc/csection.h"
-#include "core/fpdfdoc/include/cpdf_variabletext.h"
#include "core/fpdfdoc/include/cpvt_section.h"
#include "core/fpdfdoc/include/cpvt_word.h"
#include "core/fpdfdoc/include/ipvt_fontmap.h"
@@ -70,11 +71,8 @@ int32_t CPDF_VariableText::Provider::GetWordFontIndex(uint16_t word,
}
FX_BOOL CPDF_VariableText::Provider::IsLatinWord(uint16_t word) {
- if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) ||
- word == 0x2D || word == 0x27) {
- return TRUE;
- }
- return FALSE;
+ return (word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) ||
+ word == 0x2D || word == 0x27;
}
int32_t CPDF_VariableText::Provider::GetDefaultFontIndex() {
@@ -256,11 +254,9 @@ CPDF_VariableText::CPDF_VariableText()
m_fFontSize(0.0f),
m_bInitial(FALSE),
m_bRichText(FALSE),
- m_pVTProvider(nullptr),
- m_pVTIterator(nullptr) {}
+ m_pVTProvider(nullptr) {}
CPDF_VariableText::~CPDF_VariableText() {
- delete m_pVTIterator;
ResetAll();
}
@@ -1053,22 +1049,20 @@ FX_FLOAT CPDF_VariableText::GetAutoFontSize() {
return (FX_FLOAT)gFontSizeSteps[nMid];
}
-FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) {
- FX_BOOL bBigger = FALSE;
- CPVT_Size szTotal;
+bool CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) const {
+ CFX_SizeF szTotal;
for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
if (CSection* pSection = m_SectionArray.GetAt(s)) {
- CPVT_Size size = pSection->GetSectionSize(fFontSize);
+ CFX_SizeF size = pSection->GetSectionSize(fFontSize);
szTotal.x = std::max(size.x, szTotal.x);
szTotal.y += size.y;
if (IsFloatBigger(szTotal.x, GetPlateWidth()) ||
IsFloatBigger(szTotal.y, GetPlateHeight())) {
- bBigger = TRUE;
- break;
+ return true;
}
}
}
- return bBigger;
+ return false;
}
CPVT_FloatRect CPDF_VariableText::RearrangeSections(
@@ -1118,9 +1112,8 @@ int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex,
int32_t nWordStyle) {
if (!m_pVTProvider)
return 0;
- if (SubWord > 0)
- return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle);
- return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle);
+ uint16_t word = SubWord ? SubWord : Word;
+ return m_pVTProvider->GetCharWidth(nFontIndex, word, nWordStyle);
}
int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex) {
@@ -1149,13 +1142,10 @@ FX_BOOL CPDF_VariableText::IsLatinWord(uint16_t word) {
CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() {
if (!m_pVTIterator)
- m_pVTIterator = new CPDF_VariableText::Iterator(this);
- return m_pVTIterator;
+ m_pVTIterator.reset(new CPDF_VariableText::Iterator(this));
+ return m_pVTIterator.get();
}
-CPDF_VariableText::Provider* CPDF_VariableText::SetProvider(
- CPDF_VariableText::Provider* pProvider) {
- CPDF_VariableText::Provider* pOld = m_pVTProvider;
+void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) {
m_pVTProvider = pProvider;
- return pOld;
}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/cpvt_color.cpp b/chromium/third_party/pdfium/core/fpdfdoc/cpvt_color.cpp
index 7ddb9df0d08..72b8140b7b9 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/cpvt_color.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/cpvt_color.cpp
@@ -10,7 +10,7 @@
// Static.
CPVT_Color CPVT_Color::ParseColor(const CFX_ByteString& str) {
- CPDF_SimpleParser syntax(str.AsByteStringC());
+ CPDF_SimpleParser syntax(str.AsStringC());
if (syntax.FindTagParamFromStart("g", 1))
return CPVT_Color(CPVT_Color::kGray, FX_atof(syntax.GetWord()));
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/cpvt_fontmap.cpp b/chromium/third_party/pdfium/core/fpdfdoc/cpvt_fontmap.cpp
index eb8869df2b2..d4171bd1470 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/cpvt_fontmap.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/cpvt_fontmap.cpp
@@ -38,9 +38,8 @@ void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc,
return;
if (CPDF_Dictionary* pFontList = pResDict->GetDictBy("Font")) {
- if (!pFontList->KeyExist(sSysFontAlias.AsByteStringC()))
- pFontList->SetAtReference(sSysFontAlias.AsByteStringC(), pDoc,
- pPDFFont->GetFontDict());
+ if (!pFontList->KeyExist(sSysFontAlias))
+ pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->GetFontDict());
}
pSysFont = pPDFFont;
}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.cpp b/chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.cpp
index f323d9a858b..aa49f79c124 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.cpp
@@ -14,8 +14,8 @@
#include "core/fpdfdoc/cpvt_color.h"
#include "core/fpdfdoc/cpvt_fontmap.h"
#include "core/fpdfdoc/include/cpvt_word.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fpdfdoc/pdf_vt.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
namespace {
@@ -36,9 +36,9 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
if (DA.IsEmpty())
return FALSE;
- CPDF_SimpleParser syntax(DA.AsByteStringC());
+ CPDF_SimpleParser syntax(DA.AsStringC());
syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString sFontName = syntax.GetWord();
+ CFX_ByteString sFontName(syntax.GetWord());
sFontName = PDF_NameDecode(sFontName);
if (sFontName.IsEmpty())
return FALSE;
@@ -54,12 +54,12 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
}
CPDF_Dictionary* pDRFontDict = pDRDict ? pDRDict->GetDictBy("Font") : nullptr;
if (pDRFontDict) {
- pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsByteStringC());
+ pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
if (!pFontDict && !bUseFormRes) {
pDRDict = pFormDict->GetDictBy("DR");
pDRFontDict = pDRDict->GetDictBy("Font");
if (pDRFontDict)
- pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1).AsByteStringC());
+ pFontDict = pDRFontDict->GetDictBy(sFontName.Mid(1));
}
}
if (!pDRFontDict)
@@ -72,8 +72,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
pFontDict->SetAtName("BaseFont", "Helvetica");
pFontDict->SetAtName("Encoding", "WinAnsiEncoding");
pDoc->AddIndirectObject(pFontDict);
- pDRFontDict->SetAtReference(sFontName.Mid(1).AsByteStringC(), pDoc,
- pFontDict);
+ pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict);
}
CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
if (!pDefFont)
@@ -108,7 +107,8 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
rcAnnot.right - rcAnnot.left);
break;
}
- int32_t nBorderStyle = PBS_SOLID;
+
+ BorderStyle nBorderStyle = BorderStyle::SOLID;
FX_FLOAT fBorderWidth = 1;
CPVT_Dash dsBorder(3, 0, 0);
CPVT_Color crLeftTop, crRightBottom;
@@ -122,25 +122,25 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
}
switch (pBSDict->GetStringBy("S").GetAt(0)) {
case 'S':
- nBorderStyle = PBS_SOLID;
+ nBorderStyle = BorderStyle::SOLID;
break;
case 'D':
- nBorderStyle = PBS_DASH;
+ nBorderStyle = BorderStyle::DASH;
break;
case 'B':
- nBorderStyle = PBS_BEVELED;
+ nBorderStyle = BorderStyle::BEVELED;
fBorderWidth *= 2;
crLeftTop = CPVT_Color(CPVT_Color::kGray, 1);
crRightBottom = CPVT_Color(CPVT_Color::kGray, 0.5);
break;
case 'I':
- nBorderStyle = PBS_INSET;
+ nBorderStyle = BorderStyle::INSET;
fBorderWidth *= 2;
crLeftTop = CPVT_Color(CPVT_Color::kGray, 0.5);
crRightBottom = CPVT_Color(CPVT_Color::kGray, 0.75);
break;
case 'U':
- nBorderStyle = PBS_UNDERLINED;
+ nBorderStyle = BorderStyle::UNDERLINE;
break;
}
}
@@ -190,9 +190,8 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
pStreamResFontList = new CPDF_Dictionary;
pStreamResList->SetAt("Font", pStreamResFontList);
}
- if (!pStreamResFontList->KeyExist(sFontName.AsByteStringC()))
- pStreamResFontList->SetAtReference(sFontName.AsByteStringC(), pDoc,
- pFontDict);
+ if (!pStreamResFontList->KeyExist(sFontName))
+ pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict);
} else {
pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone());
pStreamResList = pStreamDict->GetDictBy("Resources");
@@ -320,7 +319,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP(
rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0),
CPVT_Color(CPVT_Color::kGray, 1),
- CPVT_Color(CPVT_Color::kGray, 0.5), PBS_BEVELED,
+ CPVT_Color(CPVT_Color::kGray, 0.5), BorderStyle::BEVELED,
CPVT_Dash(3, 0, 0));
if (sButtonBorder.GetLength() > 0)
sAppStream << "q\n" << sButtonBorder << "Q\n";
@@ -357,7 +356,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
CFX_ByteTextBuf sBody;
if (pOpts) {
FX_FLOAT fy = rcBody.top;
- for (int32_t i = nTop, sz = pOpts->GetCount(); i < sz; i++) {
+ for (size_t i = nTop, sz = pOpts->GetCount(); i < sz; i++) {
if (IsFloatSmaller(fy, rcBody.bottom))
break;
@@ -370,8 +369,9 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
FX_BOOL bSelected = FALSE;
if (pSels) {
- for (uint32_t s = 0, ssz = pSels->GetCount(); s < ssz; s++) {
- if (i == pSels->GetIntegerAt(s)) {
+ for (size_t s = 0, ssz = pSels->GetCount(); s < ssz; s++) {
+ int value = pSels->GetIntegerAt(s);
+ if (value >= 0 && i == static_cast<size_t>(value)) {
bSelected = TRUE;
break;
}
@@ -419,7 +419,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
<< "q\n";
sAppStream << rcBody.left << " " << rcBody.bottom << " "
<< rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n";
- sAppStream << sBody.GetByteString() << "Q\nEMC\n";
+ sAppStream << sBody.AsStringC() << "Q\nEMC\n";
}
} break;
}
@@ -437,9 +437,8 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
pStreamResFontList = new CPDF_Dictionary;
pStreamResList->SetAt("Font", pStreamResFontList);
}
- if (!pStreamResFontList->KeyExist(sFontName.AsByteStringC()))
- pStreamResFontList->SetAtReference(sFontName.AsByteStringC(), pDoc,
- pFontDict);
+ if (!pStreamResFontList->KeyExist(sFontName))
+ pStreamResFontList->SetAtReference(sFontName, pDoc, pFontDict);
} else {
pStreamDict->SetAt("Resources", pFormDict->GetDictBy("DR")->Clone());
pStreamResList = pStreamDict->GetDictBy("Resources");
@@ -452,7 +451,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
} // namespace
FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) {
- if (!pAnnotDict || pAnnotDict->GetConstStringBy("Subtype") != "Widget") {
+ if (!pAnnotDict || pAnnotDict->GetStringBy("Subtype") != "Widget") {
return FALSE;
}
CFX_ByteString field_type = FPDF_GetFieldAttr(pAnnotDict, "FT")->GetString();
@@ -505,89 +504,83 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
CPDF_VariableText::Iterator* pIterator,
const CFX_FloatPoint& ptOffset,
FX_BOOL bContinuous,
- uint16_t SubWord,
- const CPVT_WordRange* pVisible) {
- CFX_ByteTextBuf sEditStream, sLineStream, sWords;
- CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
+ uint16_t SubWord) {
+ CFX_ByteTextBuf sEditStream;
+ CFX_ByteTextBuf sLineStream;
+ CFX_ByteTextBuf sWords;
+ CFX_FloatPoint ptOld(0.0f, 0.0f);
+ CFX_FloatPoint ptNew(0.0f, 0.0f);
int32_t nCurFontIndex = -1;
- if (pIterator) {
- if (pVisible)
- pIterator->SetAt(pVisible->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pVisible && place.WordCmp(pVisible->EndPos) > 0)
- break;
- if (bContinuous) {
- if (place.LineCmp(oldplace) != 0) {
- if (sWords.GetSize() > 0) {
- sLineStream << GetWordRenderString(sWords.GetByteString());
- sEditStream << sLineStream;
- sLineStream.Clear();
- sWords.Clear();
- }
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y);
- } else {
- CPVT_Line line;
- pIterator->GetLine(line);
- ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
- line.ptLine.y + ptOffset.y);
- }
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
- ptOld = ptNew;
- }
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (bContinuous) {
+ if (place.LineCmp(oldplace) != 0) {
+ if (sWords.GetSize() > 0) {
+ sLineStream << GetWordRenderString(sWords.MakeString());
+ sEditStream << sLineStream;
+ sLineStream.Clear();
+ sWords.Clear();
}
CPVT_Word word;
if (pIterator->GetWord(word)) {
- if (word.nFontIndex != nCurFontIndex) {
- if (sWords.GetSize() > 0) {
- sLineStream << GetWordRenderString(sWords.GetByteString());
- sWords.Clear();
- }
- sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
- word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
- sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word,
- SubWord);
- }
- oldplace = place;
- } else {
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
word.ptWord.y + ptOffset.y);
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
- ptOld = ptNew;
- }
- if (word.nFontIndex != nCurFontIndex) {
- sEditStream << GetFontSetString(pFontMap, word.nFontIndex,
- word.fFontSize);
- nCurFontIndex = word.nFontIndex;
+ } else {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+ ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
+ line.ptLine.y + ptOffset.y);
+ }
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+ ptOld = ptNew;
+ }
+ }
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (word.nFontIndex != nCurFontIndex) {
+ if (sWords.GetSize() > 0) {
+ sLineStream << GetWordRenderString(sWords.MakeString());
+ sWords.Clear();
}
- sEditStream << GetWordRenderString(
- GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord));
+ sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
+ word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
}
+ sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord);
+ }
+ oldplace = place;
+ } else {
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y);
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+ ptOld = ptNew;
+ }
+ if (word.nFontIndex != nCurFontIndex) {
+ sEditStream << GetFontSetString(pFontMap, word.nFontIndex,
+ word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
+ }
+ sEditStream << GetWordRenderString(
+ GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord));
}
}
- if (sWords.GetSize() > 0) {
- sLineStream << GetWordRenderString(sWords.GetByteString());
- sEditStream << sLineStream;
- sWords.Clear();
- }
}
- return sEditStream.GetByteString();
+ if (sWords.GetSize() > 0) {
+ sLineStream << GetWordRenderString(sWords.MakeString());
+ sEditStream << sLineStream;
+ sWords.Clear();
+ }
+ return sEditStream.MakeString();
}
// Static.
@@ -597,7 +590,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
const CPVT_Color& color,
const CPVT_Color& crLeftTop,
const CPVT_Color& crRightBottom,
- int32_t nStyle,
+ BorderStyle nStyle,
const CPVT_Dash& dash) {
CFX_ByteTextBuf sAppStream;
CFX_ByteString sColor;
@@ -609,7 +602,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
FX_FLOAT fHalfWidth = fWidth / 2.0f;
switch (nStyle) {
default:
- case PBS_SOLID:
+ case BorderStyle::SOLID:
sColor = GenerateColorAP(color, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
@@ -621,7 +614,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
sAppStream << "f*\n";
}
break;
- case PBS_DASH:
+ case BorderStyle::DASH:
sColor = GenerateColorAP(color, FALSE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
@@ -640,8 +633,8 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
<< " l S\n";
}
break;
- case PBS_BEVELED:
- case PBS_INSET:
+ case BorderStyle::BEVELED:
+ case BorderStyle::INSET:
sColor = GenerateColorAP(crLeftTop, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
@@ -684,7 +677,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
<< fTop - fBottom - fHalfWidth * 2 << " re f*\n";
}
break;
- case PBS_UNDERLINED:
+ case BorderStyle::UNDERLINE:
sColor = GenerateColorAP(color, FALSE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
@@ -695,7 +688,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
break;
}
}
- return sAppStream.GetByteString();
+ return sAppStream.MakeString();
}
// Static.
@@ -720,7 +713,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color,
case CPVT_Color::kTransparent:
break;
}
- return sColorStream.GetByteString();
+ return sColorStream.MakeString();
}
// Static.
@@ -768,5 +761,5 @@ CFX_ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap,
if (sFontAlias.GetLength() > 0 && fFontSize > 0)
sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
}
- return sRet.GetByteString();
+ return sRet.MakeString();
}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.h b/chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.h
index 09c0507941c..1258643d3eb 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/cpvt_generateap.h
@@ -10,18 +10,11 @@
#include "core/fpdfdoc/cpvt_color.h"
#include "core/fpdfdoc/cpvt_dash.h"
#include "core/fpdfdoc/include/cpdf_variabletext.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-// border style
-#define PBS_SOLID 0
-#define PBS_DASH 1
-#define PBS_BEVELED 2
-#define PBS_INSET 3
-#define PBS_UNDERLINED 4
-#define PBS_SHADOW 5
-
class CPDF_Dictionary;
class CPDF_Document;
class IPVT_FontMap;
@@ -42,14 +35,13 @@ class CPVT_GenerateAP {
CPDF_VariableText::Iterator* pIterator,
const CFX_FloatPoint& ptOffset,
FX_BOOL bContinuous,
- uint16_t SubWord = 0,
- const CPVT_WordRange* pVisible = NULL);
+ uint16_t SubWord);
static CFX_ByteString GenerateBorderAP(const CFX_FloatRect& rect,
FX_FLOAT fWidth,
const CPVT_Color& color,
const CPVT_Color& crLeftTop,
const CPVT_Color& crRightBottom,
- int32_t nStyle,
+ BorderStyle nStyle,
const CPVT_Dash& dash);
static CFX_ByteString GenerateColorAP(const CPVT_Color& color,
const FX_BOOL& bFillOrStroke);
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/csection.cpp b/chromium/third_party/pdfium/core/fpdfdoc/csection.cpp
new file mode 100644
index 00000000000..0cf08fd49bb
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdfdoc/csection.cpp
@@ -0,0 +1,290 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfdoc/csection.h"
+
+#include <algorithm>
+
+#include "core/fpdfdoc/cpvt_wordinfo.h"
+
+CSection::CSection(CPDF_VariableText* pVT) : m_pVT(pVT) {}
+
+CSection::~CSection() {
+ ResetAll();
+}
+
+void CSection::ResetAll() {
+ ResetWordArray();
+ ResetLineArray();
+}
+
+void CSection::ResetLineArray() {
+ m_LineArray.RemoveAll();
+}
+
+void CSection::ResetWordArray() {
+ for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++) {
+ delete m_WordArray.GetAt(i);
+ }
+ m_WordArray.RemoveAll();
+}
+
+void CSection::ResetLinePlace() {
+ for (int32_t i = 0, sz = m_LineArray.GetSize(); i < sz; i++) {
+ if (CLine* pLine = m_LineArray.GetAt(i)) {
+ pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1);
+ }
+ }
+}
+
+CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace& place,
+ const CPVT_WordInfo& wordinfo) {
+ CPVT_WordInfo* pWord = new CPVT_WordInfo(wordinfo);
+ int32_t nWordIndex =
+ std::max(std::min(place.nWordIndex, m_WordArray.GetSize()), 0);
+ if (nWordIndex == m_WordArray.GetSize()) {
+ m_WordArray.Add(pWord);
+ } else {
+ m_WordArray.InsertAt(nWordIndex, pWord);
+ }
+ return place;
+}
+
+CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) {
+ return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1);
+}
+
+CPVT_FloatRect CSection::Rearrange() {
+ if (m_pVT->m_nCharArray > 0) {
+ return CTypeset(this).CharArray();
+ }
+ return CTypeset(this).Typeset();
+}
+
+CFX_SizeF CSection::GetSectionSize(FX_FLOAT fFontSize) {
+ return CTypeset(this).GetEditSize(fFontSize);
+}
+
+CPVT_WordPlace CSection::GetBeginWordPlace() const {
+ if (CLine* pLine = m_LineArray.GetAt(0)) {
+ return pLine->GetBeginWordPlace();
+ }
+ return SecPlace;
+}
+
+CPVT_WordPlace CSection::GetEndWordPlace() const {
+ if (CLine* pLine = m_LineArray.GetAt(m_LineArray.GetSize() - 1)) {
+ return pLine->GetEndWordPlace();
+ }
+ return SecPlace;
+}
+
+CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace& place) const {
+ if (place.nLineIndex < 0) {
+ return GetBeginWordPlace();
+ }
+ if (place.nLineIndex >= m_LineArray.GetSize()) {
+ return GetEndWordPlace();
+ }
+ if (CLine* pLine = m_LineArray.GetAt(place.nLineIndex)) {
+ if (place.nWordIndex == pLine->m_LineInfo.nBeginWordIndex) {
+ return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1);
+ }
+ if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
+ if (CLine* pPrevLine = m_LineArray.GetAt(place.nLineIndex - 1)) {
+ return pPrevLine->GetEndWordPlace();
+ }
+ } else {
+ return pLine->GetPrevWordPlace(place);
+ }
+ }
+ return place;
+}
+
+CPVT_WordPlace CSection::GetNextWordPlace(const CPVT_WordPlace& place) const {
+ if (place.nLineIndex < 0) {
+ return GetBeginWordPlace();
+ }
+ if (place.nLineIndex >= m_LineArray.GetSize()) {
+ return GetEndWordPlace();
+ }
+ if (CLine* pLine = m_LineArray.GetAt(place.nLineIndex)) {
+ if (place.nWordIndex >= pLine->m_LineInfo.nEndWordIndex) {
+ if (CLine* pNextLine = m_LineArray.GetAt(place.nLineIndex + 1)) {
+ return pNextLine->GetBeginWordPlace();
+ }
+ } else {
+ return pLine->GetNextWordPlace(place);
+ }
+ }
+ return place;
+}
+
+void CSection::UpdateWordPlace(CPVT_WordPlace& place) const {
+ int32_t nLeft = 0;
+ int32_t nRight = m_LineArray.GetSize() - 1;
+ int32_t nMid = (nLeft + nRight) / 2;
+ while (nLeft <= nRight) {
+ if (CLine* pLine = m_LineArray.GetAt(nMid)) {
+ if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
+ nRight = nMid - 1;
+ nMid = (nLeft + nRight) / 2;
+ } else if (place.nWordIndex > pLine->m_LineInfo.nEndWordIndex) {
+ nLeft = nMid + 1;
+ nMid = (nLeft + nRight) / 2;
+ } else {
+ place.nLineIndex = nMid;
+ return;
+ }
+ } else {
+ break;
+ }
+ }
+}
+
+CPVT_WordPlace CSection::SearchWordPlace(const CFX_FloatPoint& point) const {
+ ASSERT(m_pVT);
+ CPVT_WordPlace place = GetBeginWordPlace();
+ FX_BOOL bUp = TRUE;
+ FX_BOOL bDown = TRUE;
+ int32_t nLeft = 0;
+ int32_t nRight = m_LineArray.GetSize() - 1;
+ int32_t nMid = m_LineArray.GetSize() / 2;
+ FX_FLOAT fTop = 0;
+ FX_FLOAT fBottom = 0;
+ while (nLeft <= nRight) {
+ if (CLine* pLine = m_LineArray.GetAt(nMid)) {
+ fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent -
+ m_pVT->GetLineLeading(m_SecInfo);
+ fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent;
+ if (IsFloatBigger(point.y, fTop)) {
+ bUp = FALSE;
+ }
+ if (IsFloatSmaller(point.y, fBottom)) {
+ bDown = FALSE;
+ }
+ if (IsFloatSmaller(point.y, fTop)) {
+ nRight = nMid - 1;
+ nMid = (nLeft + nRight) / 2;
+ continue;
+ } else if (IsFloatBigger(point.y, fBottom)) {
+ nLeft = nMid + 1;
+ nMid = (nLeft + nRight) / 2;
+ continue;
+ } else {
+ place = SearchWordPlace(
+ point.x,
+ CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()),
+ pLine->GetEndWordPlace()));
+ place.nLineIndex = nMid;
+ return place;
+ }
+ }
+ }
+ if (bUp) {
+ place = GetBeginWordPlace();
+ }
+ if (bDown) {
+ place = GetEndWordPlace();
+ }
+ return place;
+}
+
+CPVT_WordPlace CSection::SearchWordPlace(
+ FX_FLOAT fx,
+ const CPVT_WordPlace& lineplace) const {
+ if (CLine* pLine = m_LineArray.GetAt(lineplace.nLineIndex)) {
+ return SearchWordPlace(
+ fx - m_SecInfo.rcSection.left,
+ CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()),
+ pLine->GetEndWordPlace()));
+ }
+ return GetBeginWordPlace();
+}
+
+CPVT_WordPlace CSection::SearchWordPlace(FX_FLOAT fx,
+ const CPVT_WordRange& range) const {
+ CPVT_WordPlace wordplace = range.BeginPos;
+ wordplace.nWordIndex = -1;
+ if (!m_pVT) {
+ return wordplace;
+ }
+ int32_t nLeft = range.BeginPos.nWordIndex;
+ int32_t nRight = range.EndPos.nWordIndex + 1;
+ int32_t nMid = (nLeft + nRight) / 2;
+ while (nLeft < nRight) {
+ if (nMid == nLeft) {
+ break;
+ }
+ if (nMid == nRight) {
+ nMid--;
+ break;
+ }
+ if (CPVT_WordInfo* pWord = m_WordArray.GetAt(nMid)) {
+ if (fx >
+ pWord->fWordX + m_pVT->GetWordWidth(*pWord) * VARIABLETEXT_HALF) {
+ nLeft = nMid;
+ nMid = (nLeft + nRight) / 2;
+ continue;
+ } else {
+ nRight = nMid;
+ nMid = (nLeft + nRight) / 2;
+ continue;
+ }
+ } else {
+ break;
+ }
+ }
+ if (CPVT_WordInfo* pWord = m_WordArray.GetAt(nMid)) {
+ if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * VARIABLETEXT_HALF) {
+ wordplace.nWordIndex = nMid;
+ }
+ }
+ return wordplace;
+}
+
+void CSection::ClearLeftWords(int32_t nWordIndex) {
+ for (int32_t i = nWordIndex; i >= 0; i--) {
+ delete m_WordArray.GetAt(i);
+ m_WordArray.RemoveAt(i);
+ }
+}
+
+void CSection::ClearRightWords(int32_t nWordIndex) {
+ for (int32_t i = m_WordArray.GetSize() - 1; i > nWordIndex; i--) {
+ delete m_WordArray.GetAt(i);
+ m_WordArray.RemoveAt(i);
+ }
+}
+
+void CSection::ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex) {
+ for (int32_t i = nEndIndex; i > nBeginIndex; i--) {
+ delete m_WordArray.GetAt(i);
+ m_WordArray.RemoveAt(i);
+ }
+}
+
+void CSection::ClearWords(const CPVT_WordRange& PlaceRange) {
+ CPVT_WordPlace SecBeginPos = GetBeginWordPlace();
+ CPVT_WordPlace SecEndPos = GetEndWordPlace();
+ if (PlaceRange.BeginPos.WordCmp(SecBeginPos) >= 0) {
+ if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) {
+ ClearMidWords(PlaceRange.BeginPos.nWordIndex,
+ PlaceRange.EndPos.nWordIndex);
+ } else {
+ ClearRightWords(PlaceRange.BeginPos.nWordIndex);
+ }
+ } else if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) {
+ ClearLeftWords(PlaceRange.EndPos.nWordIndex);
+ } else {
+ ResetWordArray();
+ }
+}
+
+void CSection::ClearWord(const CPVT_WordPlace& place) {
+ delete m_WordArray.GetAt(place.nWordIndex);
+ m_WordArray.RemoveAt(place.nWordIndex);
+}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/csection.h b/chromium/third_party/pdfium/core/fpdfdoc/csection.h
index d8974cb0201..4ac345c8df7 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/csection.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/csection.h
@@ -18,10 +18,11 @@ struct CPVT_LineInfo;
struct CPVT_WordLine;
struct CPVT_WordPlace;
-class CSection {
+class CSection final {
public:
explicit CSection(CPDF_VariableText* pVT);
- virtual ~CSection();
+ ~CSection();
+
void ResetAll();
void ResetLineArray();
void ResetWordArray();
@@ -32,7 +33,7 @@ class CSection {
void ClearWords(const CPVT_WordRange& PlaceRange);
void ClearWord(const CPVT_WordPlace& place);
CPVT_FloatRect Rearrange();
- CPVT_Size GetSectionSize(FX_FLOAT fFontSize);
+ CFX_SizeF GetSectionSize(FX_FLOAT fFontSize);
CPVT_WordPlace GetBeginWordPlace() const;
CPVT_WordPlace GetEndWordPlace() const;
CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
@@ -56,7 +57,7 @@ class CSection {
void ClearRightWords(int32_t nWordIndex);
void ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex);
- CPDF_VariableText* m_pVT;
+ CPDF_VariableText* const m_pVT;
};
#endif // CORE_FPDFDOC_CSECTION_H_
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/ctypeset.cpp b/chromium/third_party/pdfium/core/fpdfdoc/ctypeset.cpp
new file mode 100644
index 00000000000..076c9018851
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdfdoc/ctypeset.cpp
@@ -0,0 +1,496 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfdoc/ctypeset.h"
+
+#include <algorithm>
+
+#include "core/fpdfdoc/csection.h"
+#include "core/fpdfdoc/cpvt_wordinfo.h"
+
+namespace {
+
+const uint8_t special_chars[128] = {
+ 0x00, 0x0C, 0x08, 0x0C, 0x08, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00,
+ 0x10, 0x00, 0x00, 0x28, 0x0C, 0x08, 0x00, 0x00, 0x28, 0x28, 0x28, 0x28,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x08,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x0C, 0x00, 0x08, 0x00, 0x00,
+};
+
+bool IsLatin(uint16_t word) {
+ if (word <= 0x007F)
+ return !!(special_chars[word] & 0x01);
+
+ return ((word >= 0x00C0 && word <= 0x00FF) ||
+ (word >= 0x0100 && word <= 0x024F) ||
+ (word >= 0x1E00 && word <= 0x1EFF) ||
+ (word >= 0x2C60 && word <= 0x2C7F) ||
+ (word >= 0xA720 && word <= 0xA7FF) ||
+ (word >= 0xFF21 && word <= 0xFF3A) ||
+ (word >= 0xFF41 && word <= 0xFF5A));
+}
+
+bool IsDigit(uint32_t word) {
+ return word >= 0x0030 && word <= 0x0039;
+}
+
+bool IsCJK(uint32_t word) {
+ if ((word >= 0x1100 && word <= 0x11FF) ||
+ (word >= 0x2E80 && word <= 0x2FFF) ||
+ (word >= 0x3040 && word <= 0x9FBF) ||
+ (word >= 0xAC00 && word <= 0xD7AF) ||
+ (word >= 0xF900 && word <= 0xFAFF) ||
+ (word >= 0xFE30 && word <= 0xFE4F) ||
+ (word >= 0x20000 && word <= 0x2A6DF) ||
+ (word >= 0x2F800 && word <= 0x2FA1F)) {
+ return true;
+ }
+ if (word >= 0x3000 && word <= 0x303F) {
+ return (
+ word == 0x3005 || word == 0x3006 || word == 0x3021 || word == 0x3022 ||
+ word == 0x3023 || word == 0x3024 || word == 0x3025 || word == 0x3026 ||
+ word == 0x3027 || word == 0x3028 || word == 0x3029 || word == 0x3031 ||
+ word == 0x3032 || word == 0x3033 || word == 0x3034 || word == 0x3035);
+ }
+ return word >= 0xFF66 && word <= 0xFF9D;
+}
+
+bool IsPunctuation(uint32_t word) {
+ if (word <= 0x007F)
+ return !!(special_chars[word] & 0x08);
+
+ if (word >= 0x0080 && word <= 0x00FF) {
+ return (word == 0x0082 || word == 0x0084 || word == 0x0085 ||
+ word == 0x0091 || word == 0x0092 || word == 0x0093 ||
+ word <= 0x0094 || word == 0x0096 || word == 0x00B4 ||
+ word == 0x00B8);
+ }
+
+ if (word >= 0x2000 && word <= 0x206F) {
+ return (
+ word == 0x2010 || word == 0x2011 || word == 0x2012 || word == 0x2013 ||
+ word == 0x2018 || word == 0x2019 || word == 0x201A || word == 0x201B ||
+ word == 0x201C || word == 0x201D || word == 0x201E || word == 0x201F ||
+ word == 0x2032 || word == 0x2033 || word == 0x2034 || word == 0x2035 ||
+ word == 0x2036 || word == 0x2037 || word == 0x203C || word == 0x203D ||
+ word == 0x203E || word == 0x2044);
+ }
+
+ if (word >= 0x3000 && word <= 0x303F) {
+ return (
+ word == 0x3001 || word == 0x3002 || word == 0x3003 || word == 0x3005 ||
+ word == 0x3009 || word == 0x300A || word == 0x300B || word == 0x300C ||
+ word == 0x300D || word == 0x300F || word == 0x300E || word == 0x3010 ||
+ word == 0x3011 || word == 0x3014 || word == 0x3015 || word == 0x3016 ||
+ word == 0x3017 || word == 0x3018 || word == 0x3019 || word == 0x301A ||
+ word == 0x301B || word == 0x301D || word == 0x301E || word == 0x301F);
+ }
+
+ if (word >= 0xFE50 && word <= 0xFE6F)
+ return (word >= 0xFE50 && word <= 0xFE5E) || word == 0xFE63;
+
+ if (word >= 0xFF00 && word <= 0xFFEF) {
+ return (
+ word == 0xFF01 || word == 0xFF02 || word == 0xFF07 || word == 0xFF08 ||
+ word == 0xFF09 || word == 0xFF0C || word == 0xFF0E || word == 0xFF0F ||
+ word == 0xFF1A || word == 0xFF1B || word == 0xFF1F || word == 0xFF3B ||
+ word == 0xFF3D || word == 0xFF40 || word == 0xFF5B || word == 0xFF5C ||
+ word == 0xFF5D || word == 0xFF61 || word == 0xFF62 || word == 0xFF63 ||
+ word == 0xFF64 || word == 0xFF65 || word == 0xFF9E || word == 0xFF9F);
+ }
+
+ return false;
+}
+
+bool IsConnectiveSymbol(uint32_t word) {
+ return word <= 0x007F && (special_chars[word] & 0x20);
+}
+
+bool IsOpenStylePunctuation(uint32_t word) {
+ if (word <= 0x007F)
+ return !!(special_chars[word] & 0x04);
+
+ return (word == 0x300A || word == 0x300C || word == 0x300E ||
+ word == 0x3010 || word == 0x3014 || word == 0x3016 ||
+ word == 0x3018 || word == 0x301A || word == 0xFF08 ||
+ word == 0xFF3B || word == 0xFF5B || word == 0xFF62);
+}
+
+bool IsCurrencySymbol(uint16_t word) {
+ return (word == 0x0024 || word == 0x0080 || word == 0x00A2 ||
+ word == 0x00A3 || word == 0x00A4 || word == 0x00A5 ||
+ (word >= 0x20A0 && word <= 0x20CF) || word == 0xFE69 ||
+ word == 0xFF04 || word == 0xFFE0 || word == 0xFFE1 ||
+ word == 0xFFE5 || word == 0xFFE6);
+}
+
+bool IsPrefixSymbol(uint16_t word) {
+ return IsCurrencySymbol(word) || word == 0x2116;
+}
+
+bool IsSpace(uint16_t word) {
+ return word == 0x0020 || word == 0x3000;
+}
+
+bool NeedDivision(uint16_t prevWord, uint16_t curWord) {
+ if ((IsLatin(prevWord) || IsDigit(prevWord)) &&
+ (IsLatin(curWord) || IsDigit(curWord))) {
+ return false;
+ }
+ if (IsSpace(curWord) || IsPunctuation(curWord)) {
+ return false;
+ }
+ if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) {
+ return false;
+ }
+ if (IsSpace(prevWord) || IsPunctuation(prevWord)) {
+ return true;
+ }
+ if (IsPrefixSymbol(prevWord)) {
+ return false;
+ }
+ if (IsPrefixSymbol(curWord) || IsCJK(curWord)) {
+ return true;
+ }
+ if (IsCJK(prevWord)) {
+ return true;
+ }
+ return false;
+}
+
+} // namespace
+
+CTypeset::CTypeset(CSection* pSection)
+ : m_rcRet(0.0f, 0.0f, 0.0f, 0.0f),
+ m_pVT(pSection->m_pVT),
+ m_pSection(pSection) {}
+
+CTypeset::~CTypeset() {}
+
+CPVT_FloatRect CTypeset::CharArray() {
+ ASSERT(m_pSection);
+ FX_FLOAT fLineAscent =
+ m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
+ FX_FLOAT fLineDescent =
+ m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
+ m_rcRet.Default();
+ FX_FLOAT x = 0.0f, y = 0.0f;
+ FX_FLOAT fNextWidth;
+ int32_t nStart = 0;
+ FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() /
+ (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray);
+ if (CLine* pLine = m_pSection->m_LineArray.GetAt(0)) {
+ x = 0.0f;
+ y += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
+ y += fLineAscent;
+ nStart = 0;
+ switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
+ case 0:
+ pLine->m_LineInfo.fLineX = fNodeWidth * VARIABLETEXT_HALF;
+ break;
+ case 1:
+ nStart = (m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize()) / 2;
+ pLine->m_LineInfo.fLineX =
+ fNodeWidth * nStart - fNodeWidth * VARIABLETEXT_HALF;
+ break;
+ case 2:
+ nStart = m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize();
+ pLine->m_LineInfo.fLineX =
+ fNodeWidth * nStart - fNodeWidth * VARIABLETEXT_HALF;
+ break;
+ }
+ for (int32_t w = 0, sz = m_pSection->m_WordArray.GetSize(); w < sz; w++) {
+ if (w >= m_pVT->m_nCharArray) {
+ break;
+ }
+ fNextWidth = 0;
+ if (CPVT_WordInfo* pNextWord =
+ (CPVT_WordInfo*)m_pSection->m_WordArray.GetAt(w + 1)) {
+ pNextWord->fWordTail = 0;
+ fNextWidth = m_pVT->GetWordWidth(*pNextWord);
+ }
+ if (CPVT_WordInfo* pWord =
+ (CPVT_WordInfo*)m_pSection->m_WordArray.GetAt(w)) {
+ pWord->fWordTail = 0;
+ FX_FLOAT fWordWidth = m_pVT->GetWordWidth(*pWord);
+ FX_FLOAT fWordAscent = m_pVT->GetWordAscent(*pWord);
+ FX_FLOAT fWordDescent = m_pVT->GetWordDescent(*pWord);
+ x = (FX_FLOAT)(fNodeWidth * (w + nStart + 0.5) -
+ fWordWidth * VARIABLETEXT_HALF);
+ pWord->fWordX = x;
+ pWord->fWordY = y;
+ if (w == 0) {
+ pLine->m_LineInfo.fLineX = x;
+ }
+ if (w != m_pSection->m_WordArray.GetSize() - 1) {
+ pWord->fWordTail =
+ (fNodeWidth - (fWordWidth + fNextWidth) * VARIABLETEXT_HALF > 0
+ ? fNodeWidth - (fWordWidth + fNextWidth) * VARIABLETEXT_HALF
+ : 0);
+ } else {
+ pWord->fWordTail = 0;
+ }
+ x += fWordWidth;
+ fLineAscent = std::max(fLineAscent, fWordAscent);
+ fLineDescent = std::min(fLineDescent, fWordDescent);
+ }
+ }
+ pLine->m_LineInfo.nBeginWordIndex = 0;
+ pLine->m_LineInfo.nEndWordIndex = m_pSection->m_WordArray.GetSize() - 1;
+ pLine->m_LineInfo.fLineY = y;
+ pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX;
+ pLine->m_LineInfo.fLineAscent = fLineAscent;
+ pLine->m_LineInfo.fLineDescent = fLineDescent;
+ y -= fLineDescent;
+ }
+ return m_rcRet = CPVT_FloatRect(0, 0, x, y);
+}
+
+CFX_SizeF CTypeset::GetEditSize(FX_FLOAT fFontSize) {
+ ASSERT(m_pSection);
+ ASSERT(m_pVT);
+ SplitLines(FALSE, fFontSize);
+ return CFX_SizeF(m_rcRet.Width(), m_rcRet.Height());
+}
+
+CPVT_FloatRect CTypeset::Typeset() {
+ ASSERT(m_pVT);
+ m_pSection->m_LineArray.Empty();
+ SplitLines(TRUE, 0.0f);
+ m_pSection->m_LineArray.Clear();
+ OutputLines();
+ return m_rcRet;
+}
+
+void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) {
+ ASSERT(m_pVT);
+ ASSERT(m_pSection);
+ int32_t nLineHead = 0;
+ int32_t nLineTail = 0;
+ FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f;
+ FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f;
+ FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f;
+ FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f;
+ int32_t nWordStartPos = 0;
+ FX_BOOL bFullWord = FALSE;
+ int32_t nLineFullWordIndex = 0;
+ int32_t nCharIndex = 0;
+ CPVT_LineInfo line;
+ FX_FLOAT fWordWidth = 0;
+ FX_FLOAT fTypesetWidth = std::max(
+ m_pVT->GetPlateWidth() - m_pVT->GetLineIndent(m_pSection->m_SecInfo),
+ 0.0f);
+ int32_t nTotalWords = m_pSection->m_WordArray.GetSize();
+ FX_BOOL bOpened = FALSE;
+ if (nTotalWords > 0) {
+ int32_t i = 0;
+ while (i < nTotalWords) {
+ CPVT_WordInfo* pWord = m_pSection->m_WordArray.GetAt(i);
+ CPVT_WordInfo* pOldWord = pWord;
+ if (i > 0) {
+ pOldWord = m_pSection->m_WordArray.GetAt(i - 1);
+ }
+ if (pWord) {
+ if (bTypeset) {
+ fLineAscent =
+ std::max(fLineAscent, m_pVT->GetWordAscent(*pWord, TRUE));
+ fLineDescent =
+ std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, TRUE));
+ fWordWidth = m_pVT->GetWordWidth(*pWord);
+ } else {
+ fLineAscent =
+ std::max(fLineAscent, m_pVT->GetWordAscent(*pWord, fFontSize));
+ fLineDescent =
+ std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, fFontSize));
+ fWordWidth = m_pVT->GetWordWidth(
+ pWord->nFontIndex, pWord->Word, m_pVT->m_wSubWord,
+ m_pVT->m_fCharSpace, m_pVT->m_nHorzScale, fFontSize,
+ pWord->fWordTail, 0);
+ }
+ if (!bOpened) {
+ if (IsOpenStylePunctuation(pWord->Word)) {
+ bOpened = TRUE;
+ bFullWord = TRUE;
+ } else if (pOldWord) {
+ if (NeedDivision(pOldWord->Word, pWord->Word)) {
+ bFullWord = TRUE;
+ }
+ }
+ } else {
+ if (!IsSpace(pWord->Word) && !IsOpenStylePunctuation(pWord->Word)) {
+ bOpened = FALSE;
+ }
+ }
+ if (bFullWord) {
+ bFullWord = FALSE;
+ if (nCharIndex > 0) {
+ nLineFullWordIndex++;
+ }
+ nWordStartPos = i;
+ fBackupLineWidth = fLineWidth;
+ fBackupLineAscent = fLineAscent;
+ fBackupLineDescent = fLineDescent;
+ }
+ nCharIndex++;
+ }
+ if (m_pVT->m_bLimitWidth && fTypesetWidth > 0 &&
+ fLineWidth + fWordWidth > fTypesetWidth) {
+ if (nLineFullWordIndex > 0) {
+ i = nWordStartPos;
+ fLineWidth = fBackupLineWidth;
+ fLineAscent = fBackupLineAscent;
+ fLineDescent = fBackupLineDescent;
+ }
+ if (nCharIndex == 1) {
+ fLineWidth = fWordWidth;
+ i++;
+ }
+ nLineTail = i - 1;
+ if (bTypeset) {
+ line.nBeginWordIndex = nLineHead;
+ line.nEndWordIndex = nLineTail;
+ line.nTotalWord = nLineTail - nLineHead + 1;
+ line.fLineWidth = fLineWidth;
+ line.fLineAscent = fLineAscent;
+ line.fLineDescent = fLineDescent;
+ m_pSection->AddLine(line);
+ }
+ fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo));
+ fMaxY -= fLineDescent;
+ fMaxX = std::max(fLineWidth, fMaxX);
+ nLineHead = i;
+ fLineWidth = 0.0f;
+ fLineAscent = 0.0f;
+ fLineDescent = 0.0f;
+ nCharIndex = 0;
+ nLineFullWordIndex = 0;
+ bFullWord = FALSE;
+ } else {
+ fLineWidth += fWordWidth;
+ i++;
+ }
+ }
+ if (nLineHead <= nTotalWords - 1) {
+ nLineTail = nTotalWords - 1;
+ if (bTypeset) {
+ line.nBeginWordIndex = nLineHead;
+ line.nEndWordIndex = nLineTail;
+ line.nTotalWord = nLineTail - nLineHead + 1;
+ line.fLineWidth = fLineWidth;
+ line.fLineAscent = fLineAscent;
+ line.fLineDescent = fLineDescent;
+ m_pSection->AddLine(line);
+ }
+ fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo));
+ fMaxY -= fLineDescent;
+ fMaxX = std::max(fLineWidth, fMaxX);
+ }
+ } else {
+ if (bTypeset) {
+ fLineAscent = m_pVT->GetLineAscent(m_pSection->m_SecInfo);
+ fLineDescent = m_pVT->GetLineDescent(m_pSection->m_SecInfo);
+ } else {
+ fLineAscent =
+ m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), fFontSize);
+ fLineDescent =
+ m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), fFontSize);
+ }
+ if (bTypeset) {
+ line.nBeginWordIndex = -1;
+ line.nEndWordIndex = -1;
+ line.nTotalWord = 0;
+ line.fLineWidth = 0;
+ line.fLineAscent = fLineAscent;
+ line.fLineDescent = fLineDescent;
+ m_pSection->AddLine(line);
+ }
+ fMaxY += m_pVT->GetLineLeading(m_pSection->m_SecInfo) + fLineAscent -
+ fLineDescent;
+ }
+ m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY);
+}
+
+void CTypeset::OutputLines() {
+ ASSERT(m_pVT);
+ ASSERT(m_pSection);
+ FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f;
+ FX_FLOAT fPosX = 0.0f, fPosY = 0.0f;
+ FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo);
+ FX_FLOAT fTypesetWidth = std::max(m_pVT->GetPlateWidth() - fLineIndent, 0.0f);
+ switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
+ default:
+ case 0:
+ fMinX = 0.0f;
+ break;
+ case 1:
+ fMinX = (fTypesetWidth - m_rcRet.Width()) * VARIABLETEXT_HALF;
+ break;
+ case 2:
+ fMinX = fTypesetWidth - m_rcRet.Width();
+ break;
+ }
+ fMaxX = fMinX + m_rcRet.Width();
+ fMinY = 0.0f;
+ fMaxY = m_rcRet.Height();
+ int32_t nTotalLines = m_pSection->m_LineArray.GetSize();
+ if (nTotalLines > 0) {
+ m_pSection->m_SecInfo.nTotalLine = nTotalLines;
+ for (int32_t l = 0; l < nTotalLines; l++) {
+ if (CLine* pLine = m_pSection->m_LineArray.GetAt(l)) {
+ switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
+ default:
+ case 0:
+ fPosX = 0;
+ break;
+ case 1:
+ fPosX = (fTypesetWidth - pLine->m_LineInfo.fLineWidth) *
+ VARIABLETEXT_HALF;
+ break;
+ case 2:
+ fPosX = fTypesetWidth - pLine->m_LineInfo.fLineWidth;
+ break;
+ }
+ fPosX += fLineIndent;
+ fPosY += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
+ fPosY += pLine->m_LineInfo.fLineAscent;
+ pLine->m_LineInfo.fLineX = fPosX - fMinX;
+ pLine->m_LineInfo.fLineY = fPosY - fMinY;
+ for (int32_t w = pLine->m_LineInfo.nBeginWordIndex;
+ w <= pLine->m_LineInfo.nEndWordIndex; w++) {
+ if (CPVT_WordInfo* pWord = m_pSection->m_WordArray.GetAt(w)) {
+ pWord->fWordX = fPosX - fMinX;
+ if (pWord->pWordProps) {
+ switch (pWord->pWordProps->nScriptType) {
+ default:
+ case CPDF_VariableText::ScriptType::Normal:
+ pWord->fWordY = fPosY - fMinY;
+ break;
+ case CPDF_VariableText::ScriptType::Super:
+ pWord->fWordY = fPosY - m_pVT->GetWordAscent(*pWord) - fMinY;
+ break;
+ case CPDF_VariableText::ScriptType::Sub:
+ pWord->fWordY = fPosY - m_pVT->GetWordDescent(*pWord) - fMinY;
+ break;
+ }
+ } else {
+ pWord->fWordY = fPosY - fMinY;
+ }
+ fPosX += m_pVT->GetWordWidth(*pWord);
+ }
+ }
+ fPosY -= pLine->m_LineInfo.fLineDescent;
+ }
+ }
+ }
+ m_rcRet = CPVT_FloatRect(fMinX, fMinY, fMaxX, fMaxY);
+}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/ctypeset.h b/chromium/third_party/pdfium/core/fpdfdoc/ctypeset.h
index 25bb31a8017..1ead422f6b6 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/ctypeset.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/ctypeset.h
@@ -13,11 +13,12 @@
class CPDF_VariableText;
class CSection;
-class CTypeset {
+class CTypeset final {
public:
explicit CTypeset(CSection* pSection);
- virtual ~CTypeset();
- CPVT_Size GetEditSize(FX_FLOAT fFontSize);
+ ~CTypeset();
+
+ CFX_SizeF GetEditSize(FX_FLOAT fFontSize);
CPVT_FloatRect Typeset();
CPVT_FloatRect CharArray();
@@ -26,7 +27,7 @@ class CTypeset {
void OutputLines();
CPVT_FloatRect m_rcRet;
- CPDF_VariableText* m_pVT;
+ CPDF_VariableText* const m_pVT;
CSection* const m_pSection;
};
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_action.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_action.cpp
index 9a43b58e981..6f3e2945fa8 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_action.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_action.cpp
@@ -8,7 +8,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
namespace {
@@ -38,8 +38,7 @@ CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const {
}
if (pDest->IsString() || pDest->IsName()) {
CPDF_NameTree name_tree(pDoc, "Dests");
- return CPDF_Dest(
- name_tree.LookupNamedDest(pDoc, pDest->GetString().AsByteStringC()));
+ return CPDF_Dest(name_tree.LookupNamedDest(pDoc, pDest->GetString()));
}
if (CPDF_Array* pArray = pDest->AsArray())
return CPDF_Dest(pArray);
@@ -73,7 +72,8 @@ CFX_WideString CPDF_Action::GetFilePath() const {
if (type == "Launch") {
CPDF_Dictionary* pWinDict = m_pDict->GetDictBy("Win");
if (pWinDict) {
- return CFX_WideString::FromLocal(pWinDict->GetStringBy("F"));
+ return CFX_WideString::FromLocal(
+ pWinDict->GetStringBy("F").AsStringC());
}
}
return path;
@@ -100,7 +100,7 @@ CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const {
}
return csURI;
}
-uint32_t CPDF_ActionFields::GetFieldsCount() const {
+size_t CPDF_ActionFields::GetFieldsCount() const {
if (!m_pAction) {
return 0;
}
@@ -147,8 +147,7 @@ std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
if (pFields->IsDictionary() || pFields->IsString()) {
fields.push_back(pFields);
} else if (CPDF_Array* pArray = pFields->AsArray()) {
- uint32_t iCount = pArray->GetCount();
- for (uint32_t i = 0; i < iCount; ++i) {
+ for (size_t i = 0; i < pArray->GetCount(); ++i) {
CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
if (pObj) {
fields.push_back(pObj);
@@ -158,7 +157,7 @@ std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
return fields;
}
-CPDF_Object* CPDF_ActionFields::GetField(uint32_t iIndex) const {
+CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const {
if (!m_pAction) {
return NULL;
}
@@ -232,7 +231,7 @@ int32_t CPDF_Action::GetOperationType() const {
}
return 0;
}
-uint32_t CPDF_Action::GetSubActionsCount() const {
+size_t CPDF_Action::GetSubActionsCount() const {
if (!m_pDict || !m_pDict->KeyExist("Next"))
return 0;
@@ -245,7 +244,7 @@ uint32_t CPDF_Action::GetSubActionsCount() const {
return pArray->GetCount();
return 0;
}
-CPDF_Action CPDF_Action::GetSubAction(uint32_t iIndex) const {
+CPDF_Action CPDF_Action::GetSubAction(size_t iIndex) const {
if (!m_pDict || !m_pDict->KeyExist("Next")) {
return CPDF_Action();
}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_annot.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_annot.cpp
index ca900acb9a1..db0322c768f 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_annot.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_annot.cpp
@@ -9,12 +9,11 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_occontext.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
#include "core/fpdfdoc/cpvt_generateap.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
+#include "core/fxge/include/fx_ge.h"
CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
: m_pDocument(pPage->m_pDocument) {
@@ -29,7 +28,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
FX_BOOL bRegenerateAP =
pAcroForm && pAcroForm->GetBooleanBy("NeedAppearances");
- for (uint32_t i = 0; i < pAnnots->GetCount(); ++i) {
+ for (size_t i = 0; i < pAnnots->GetCount(); ++i) {
CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i));
if (!pDict)
continue;
@@ -43,7 +42,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
pDict = pAnnots->GetDictAt(i);
}
m_AnnotList.push_back(new CPDF_Annot(pDict, this));
- if (bRegenerateAP && pDict->GetConstStringBy("Subtype") == "Widget" &&
+ if (bRegenerateAP && pDict->GetStringBy("Subtype") == "Widget" &&
CPDF_InterForm::UpdatingAPEnabled()) {
FPDF_GenerateAP(m_pDocument, pDict);
}
@@ -79,7 +78,7 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage,
continue;
if (pOptions) {
- IPDF_OCContext* pOCContext = pOptions->m_pOCContext;
+ CPDF_OCContext* pOCContext = pOptions->m_pOCContext;
CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict();
if (pOCContext && pAnnotDict &&
!pOCContext->CheckOCGVisible(pAnnotDict->GetDictBy("OC"))) {
@@ -127,10 +126,12 @@ void CPDF_AnnotList::DisplayAnnots(CPDF_Page* pPage,
CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_AnnotList* pList)
: m_pAnnotDict(pDict),
m_pList(pList),
- m_sSubtype(m_pAnnotDict->GetConstStringBy("Subtype")) {}
+ m_sSubtype(m_pAnnotDict->GetStringBy("Subtype")) {}
+
CPDF_Annot::~CPDF_Annot() {
ClearCachedAP();
}
+
void CPDF_Annot::ClearCachedAP() {
for (const auto& pair : m_APMap) {
delete pair.second;
@@ -181,12 +182,12 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
CPDF_Dictionary* pDict = pAnnotDict->GetDictBy("Parent");
value = pDict ? pDict->GetStringBy("V") : CFX_ByteString();
}
- if (value.IsEmpty() || !pDict->KeyExist(value.AsByteStringC()))
+ if (value.IsEmpty() || !pDict->KeyExist(value))
as = "Off";
else
as = value;
}
- return pDict->GetStreamBy(as.AsByteStringC());
+ return pDict->GetStreamBy(as);
}
return nullptr;
}
@@ -202,7 +203,7 @@ CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {
CPDF_Form* pNewForm =
new CPDF_Form(m_pList->GetDocument(), pPage->m_pResources, pStream);
- pNewForm->ParseContent(nullptr, nullptr, nullptr, nullptr);
+ pNewForm->ParseContent(nullptr, nullptr, nullptr);
m_APMap[pStream] = pNewForm;
return pNewForm;
}
@@ -286,8 +287,8 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice,
if (!pDashArray) {
return;
}
- int nLen = pDashArray->GetCount();
- int i = 0;
+ size_t nLen = pDashArray->GetCount();
+ size_t i = 0;
for (; i < nLen; ++i) {
CPDF_Object* pObj = pDashArray->GetDirectObjectAt(i);
if (pObj && pObj->GetInteger()) {
@@ -323,13 +324,13 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice,
graph_state.m_LineWidth = width;
if (style_char == 'D') {
if (pDashArray) {
- uint32_t dash_count = pDashArray->GetCount();
+ size_t dash_count = pDashArray->GetCount();
if (dash_count % 2) {
dash_count++;
}
graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
graph_state.m_DashCount = dash_count;
- uint32_t i;
+ size_t i;
for (i = 0; i < pDashArray->GetCount(); ++i) {
graph_state.m_DashArray[i] = pDashArray->GetNumberAt(i);
}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_basic.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_basic.cpp
index 2555d4839b1..ab99cff7724 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_basic.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_basic.cpp
@@ -7,7 +7,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfdoc/doc_utils.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
namespace {
@@ -71,16 +71,24 @@ FX_FLOAT CPDF_Dest::GetParam(int index) {
CFX_ByteString CPDF_Dest::GetRemoteName() {
return m_pObj ? m_pObj->GetString() : CFX_ByteString();
}
+
CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc,
- const CFX_ByteStringC& category) {
- if (pDoc->GetRoot() && pDoc->GetRoot()->GetDictBy("Names"))
- m_pRoot = pDoc->GetRoot()->GetDictBy("Names")->GetDictBy(category);
- else
- m_pRoot = NULL;
+ const CFX_ByteString& category)
+ : m_pRoot(nullptr) {
+ CPDF_Dictionary* pRoot = pDoc->GetRoot();
+ if (!pRoot)
+ return;
+
+ CPDF_Dictionary* pNames = pRoot->GetDictBy("Names");
+ if (!pNames)
+ return;
+
+ m_pRoot = pNames->GetDictBy(category);
}
+
static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
const CFX_ByteString& csName,
- int& nIndex,
+ size_t& nIndex,
CPDF_Array** ppFind,
int nLevel = 0) {
if (nLevel > nMaxRecursion) {
@@ -90,22 +98,22 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
if (pLimits) {
CFX_ByteString csLeft = pLimits->GetStringAt(0);
CFX_ByteString csRight = pLimits->GetStringAt(1);
- if (csLeft.Compare(csRight.AsByteStringC()) > 0) {
+ if (csLeft.Compare(csRight.AsStringC()) > 0) {
CFX_ByteString csTmp = csRight;
csRight = csLeft;
csLeft = csTmp;
}
- if (csName.Compare(csLeft.AsByteStringC()) < 0 ||
- csName.Compare(csRight.AsByteStringC()) > 0) {
+ if (csName.Compare(csLeft.AsStringC()) < 0 ||
+ csName.Compare(csRight.AsStringC()) > 0) {
return NULL;
}
}
CPDF_Array* pNames = pNode->GetArrayBy("Names");
if (pNames) {
- uint32_t dwCount = pNames->GetCount() / 2;
- for (uint32_t i = 0; i < dwCount; i++) {
+ size_t dwCount = pNames->GetCount() / 2;
+ for (size_t i = 0; i < dwCount; i++) {
CFX_ByteString csValue = pNames->GetStringAt(i * 2);
- int32_t iCompare = csValue.Compare(csName.AsByteStringC());
+ int32_t iCompare = csValue.Compare(csName.AsStringC());
if (iCompare <= 0) {
if (ppFind) {
*ppFind = pNames;
@@ -126,7 +134,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
if (!pKids) {
return NULL;
}
- for (uint32_t i = 0; i < pKids->GetCount(); i++) {
+ for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid) {
continue;
@@ -139,46 +147,44 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
}
return NULL;
}
+
static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode,
- int nIndex,
- int& nCurIndex,
+ size_t nIndex,
+ size_t& nCurIndex,
CFX_ByteString& csName,
CPDF_Array** ppFind,
int nLevel = 0) {
- if (nLevel > nMaxRecursion) {
+ if (nLevel > nMaxRecursion)
return NULL;
- }
+
CPDF_Array* pNames = pNode->GetArrayBy("Names");
if (pNames) {
- int nCount = pNames->GetCount() / 2;
+ size_t nCount = pNames->GetCount() / 2;
if (nIndex >= nCurIndex + nCount) {
nCurIndex += nCount;
return NULL;
}
- if (ppFind) {
+ if (ppFind)
*ppFind = pNames;
- }
csName = pNames->GetStringAt((nIndex - nCurIndex) * 2);
return pNames->GetDirectObjectAt((nIndex - nCurIndex) * 2 + 1);
}
CPDF_Array* pKids = pNode->GetArrayBy("Kids");
- if (!pKids) {
+ if (!pKids)
return NULL;
- }
- for (uint32_t i = 0; i < pKids->GetCount(); i++) {
+ for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
- if (!pKid) {
+ if (!pKid)
continue;
- }
CPDF_Object* pFound =
SearchNameNode(pKid, nIndex, nCurIndex, csName, ppFind, nLevel + 1);
- if (pFound) {
+ if (pFound)
return pFound;
- }
}
return NULL;
}
-static int CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
+
+static size_t CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
if (nLevel > nMaxRecursion) {
return 0;
}
@@ -190,8 +196,8 @@ static int CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
if (!pKids) {
return 0;
}
- int nCount = 0;
- for (uint32_t i = 0; i < pKids->GetCount(); i++) {
+ size_t nCount = 0;
+ for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid) {
continue;
@@ -200,17 +206,19 @@ static int CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
}
return nCount;
}
-int CPDF_NameTree::GetCount() const {
+
+size_t CPDF_NameTree::GetCount() const {
if (!m_pRoot) {
return 0;
}
return ::CountNames(m_pRoot);
}
+
int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const {
if (!m_pRoot) {
return -1;
}
- int nIndex = 0;
+ size_t nIndex = 0;
if (!SearchNameNode(m_pRoot, csName, nIndex, NULL)) {
return -1;
}
@@ -221,18 +229,18 @@ CPDF_Object* CPDF_NameTree::LookupValue(int nIndex,
if (!m_pRoot) {
return NULL;
}
- int nCurIndex = 0;
+ size_t nCurIndex = 0;
return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, NULL);
}
CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const {
if (!m_pRoot) {
return NULL;
}
- int nIndex = 0;
+ size_t nIndex = 0;
return SearchNameNode(m_pRoot, csName, nIndex, NULL);
}
CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc,
- const CFX_ByteStringC& sName) {
+ const CFX_ByteString& sName) {
CPDF_Object* pValue = LookupValue(sName);
if (!pValue) {
CPDF_Dictionary* pDests = pDoc->GetRoot()->GetDictBy("Dests");
@@ -288,26 +296,26 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideStringC& filepath) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac"))
- return ChangeSlashToPlatform(filepath.raw_str() + 1);
- return ChangeSlashToPlatform(filepath.raw_str());
+ return ChangeSlashToPlatform(filepath.c_str() + 1);
+ return ChangeSlashToPlatform(filepath.c_str());
#elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
if (filepath.GetAt(0) != '/')
- return ChangeSlashToPlatform(filepath.raw_str());
+ return ChangeSlashToPlatform(filepath.c_str());
if (filepath.GetAt(1) == '/')
- return ChangeSlashToPlatform(filepath.raw_str() + 1);
+ return ChangeSlashToPlatform(filepath.c_str() + 1);
if (filepath.GetAt(2) == '/') {
CFX_WideString result;
result += filepath.GetAt(1);
result += ':';
- result += ChangeSlashToPlatform(filepath.raw_str() + 2);
+ result += ChangeSlashToPlatform(filepath.c_str() + 2);
return result;
}
CFX_WideString result;
result += '\\';
- result += ChangeSlashToPlatform(filepath.raw_str());
+ result += ChangeSlashToPlatform(filepath.c_str());
return result;
#else
- return filepath;
+ return CFX_WideString(filepath);
#endif
}
@@ -315,27 +323,31 @@ bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const {
if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) {
*csFileName = pDict->GetUnicodeTextBy("UF");
if (csFileName->IsEmpty()) {
- *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("F"));
+ *csFileName =
+ CFX_WideString::FromLocal(pDict->GetStringBy("F").AsStringC());
}
if (pDict->GetStringBy("FS") == "URL")
return true;
if (csFileName->IsEmpty()) {
if (pDict->KeyExist("DOS")) {
- *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("DOS"));
+ *csFileName =
+ CFX_WideString::FromLocal(pDict->GetStringBy("DOS").AsStringC());
} else if (pDict->KeyExist("Mac")) {
- *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("Mac"));
+ *csFileName =
+ CFX_WideString::FromLocal(pDict->GetStringBy("Mac").AsStringC());
} else if (pDict->KeyExist("Unix")) {
- *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("Unix"));
+ *csFileName =
+ CFX_WideString::FromLocal(pDict->GetStringBy("Unix").AsStringC());
} else {
return false;
}
}
} else if (m_pObj->IsString()) {
- *csFileName = CFX_WideString::FromLocal(m_pObj->GetString());
+ *csFileName = CFX_WideString::FromLocal(m_pObj->GetString().AsStringC());
} else {
return false;
}
- *csFileName = DecodeFileName(csFileName->AsWideStringC());
+ *csFileName = DecodeFileName(csFileName->AsStringC());
return true;
}
@@ -356,29 +368,29 @@ CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) {
if (filepath.GetAt(2) != '\\') {
result += '/';
}
- result += ChangeSlashToPDF(filepath.raw_str() + 2);
+ result += ChangeSlashToPDF(filepath.c_str() + 2);
return result;
}
if (filepath.GetAt(0) == '\\' && filepath.GetAt(1) == '\\') {
- return ChangeSlashToPDF(filepath.raw_str() + 1);
+ return ChangeSlashToPDF(filepath.c_str() + 1);
}
if (filepath.GetAt(0) == '\\') {
CFX_WideString result;
result = '/';
- result += ChangeSlashToPDF(filepath.raw_str());
+ result += ChangeSlashToPDF(filepath.c_str());
return result;
}
- return ChangeSlashToPDF(filepath.raw_str());
+ return ChangeSlashToPDF(filepath.c_str());
#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
if (filepath.Left(sizeof("Mac") - 1) == FX_WSTRC(L"Mac")) {
CFX_WideString result;
result = '/';
- result += ChangeSlashToPDF(filepath.raw_str());
+ result += ChangeSlashToPDF(filepath.c_str());
return result;
}
- return ChangeSlashToPDF(filepath.raw_str());
+ return ChangeSlashToPDF(filepath.c_str());
#else
- return filepath;
+ return CFX_WideString(filepath);
#endif
}
@@ -477,7 +489,7 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
if (pLabel->KeyExist("P")) {
wsLabel += pLabel->GetUnicodeTextBy("P");
}
- CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", NULL);
+ CFX_ByteString bsNumberingStyle = pLabel->GetStringBy("S", nullptr);
int nLabelNum = nPage - n + pLabel->GetIntegerBy("St", 1);
CFX_WideString wsNumPortion =
_GetLabelNumPortion(nLabelNum, bsNumberingStyle);
@@ -488,30 +500,25 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
wsLabel.Format(L"%d", nPage + 1);
return wsLabel;
}
+
int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
- if (!m_pDocument) {
+ if (!m_pDocument)
return -1;
- }
+
CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
- if (!pPDFRoot) {
+ if (!pPDFRoot)
return -1;
- }
+
int nPages = m_pDocument->GetPageCount();
- CFX_ByteString bsLbl;
- CFX_ByteString bsOrig = bsLabel;
for (int i = 0; i < nPages; i++) {
- bsLbl = PDF_EncodeText(GetLabel(i));
- if (!bsLbl.Compare(bsOrig.AsByteStringC())) {
+ if (PDF_EncodeText(GetLabel(i)).Compare(bsLabel))
return i;
- }
}
- bsLbl = bsOrig;
- int nPage = FXSYS_atoi(bsLbl);
- if (nPage > 0 && nPage <= nPages) {
- return nPage;
- }
- return -1;
+
+ int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate.
+ return nPage > 0 && nPage <= nPages ? nPage : -1;
}
+
int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
- return GetPageByLabel(PDF_EncodeText(wsLabel.raw_str()).AsByteStringC());
+ return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC());
}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_basic_unittest.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_basic_unittest.cpp
index 0ab70c93049..5713a6debb4 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_basic_unittest.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_basic_unittest.cpp
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include <memory>
#include <vector>
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_bookmark.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_bookmark.cpp
index 35a04043fe1..2c6f0dddefa 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_bookmark.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_bookmark.cpp
@@ -10,47 +10,53 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild(
const CPDF_Bookmark& parent) const {
- if (!parent.GetDict()) {
- CPDF_Dictionary* pRoot = m_pDocument->GetRoot()->GetDictBy("Outlines");
- if (!pRoot)
- return CPDF_Bookmark();
- return CPDF_Bookmark(pRoot->GetDictBy("First"));
- }
- return CPDF_Bookmark(parent.GetDict()->GetDictBy("First"));
+ CPDF_Dictionary* pParentDict = parent.GetDict();
+ if (pParentDict)
+ return CPDF_Bookmark(pParentDict->GetDictBy("First"));
+
+ CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
+ if (!pRoot)
+ return CPDF_Bookmark();
+
+ CPDF_Dictionary* pOutlines = pRoot->GetDictBy("Outlines");
+ if (!pOutlines)
+ return CPDF_Bookmark();
+
+ return CPDF_Bookmark(pOutlines->GetDictBy("First"));
}
CPDF_Bookmark CPDF_BookmarkTree::GetNextSibling(
const CPDF_Bookmark& bookmark) const {
- if (!bookmark.GetDict())
+ CPDF_Dictionary* pDict = bookmark.GetDict();
+ if (!pDict)
return CPDF_Bookmark();
- CPDF_Dictionary* pNext = bookmark.GetDict()->GetDictBy("Next");
- return pNext == bookmark.GetDict() ? CPDF_Bookmark() : CPDF_Bookmark(pNext);
+ CPDF_Dictionary* pNext = pDict->GetDictBy("Next");
+ return pNext == pDict ? CPDF_Bookmark() : CPDF_Bookmark(pNext);
}
uint32_t CPDF_Bookmark::GetColorRef() const {
- if (!m_pDict) {
- return 0;
- }
+ if (!m_pDict)
+ return FXSYS_RGB(0, 0, 0);
+
CPDF_Array* pColor = m_pDict->GetArrayBy("C");
- if (!pColor) {
+ if (!pColor)
return FXSYS_RGB(0, 0, 0);
- }
+
int r = FXSYS_round(pColor->GetNumberAt(0) * 255);
int g = FXSYS_round(pColor->GetNumberAt(1) * 255);
int b = FXSYS_round(pColor->GetNumberAt(2) * 255);
return FXSYS_RGB(r, g, b);
}
+
uint32_t CPDF_Bookmark::GetFontStyle() const {
- if (!m_pDict) {
- return 0;
- }
- return m_pDict->GetIntegerBy("F");
+ return m_pDict ? m_pDict->GetIntegerBy("F") : 0;
}
+
CFX_WideString CPDF_Bookmark::GetTitle() const {
if (!m_pDict) {
return CFX_WideString();
@@ -80,8 +86,7 @@ CPDF_Dest CPDF_Bookmark::GetDest(CPDF_Document* pDocument) const {
return CPDF_Dest();
if (pDest->IsString() || pDest->IsName()) {
CPDF_NameTree name_tree(pDocument, "Dests");
- return CPDF_Dest(name_tree.LookupNamedDest(
- pDocument, pDest->GetString().AsByteStringC()));
+ return CPDF_Dest(name_tree.LookupNamedDest(pDocument, pDest->GetString()));
}
if (CPDF_Array* pArray = pDest->AsArray())
return CPDF_Dest(pArray);
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_form.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_form.cpp
index aa4b5c9f306..7c81f0ee6f8 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_form.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_form.cpp
@@ -13,7 +13,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfdoc/doc_utils.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -35,23 +35,25 @@ CFX_WideString FPDFDOC_FDF_GetFieldValue(const CPDF_Dictionary& pFieldDict,
const CFX_ByteString csBValue = pFieldDict.GetStringBy("V");
for (const auto& encoding : g_fieldEncoding) {
if (bsEncoding == encoding.m_name)
- return CFX_WideString::FromCodePage(csBValue, encoding.m_codePage);
+ return CFX_WideString::FromCodePage(csBValue.AsStringC(),
+ encoding.m_codePage);
}
CFX_ByteString csTemp = csBValue.Left(2);
if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF")
return PDF_DecodeText(csBValue);
- return CFX_WideString::FromLocal(csBValue);
+ return CFX_WideString::FromLocal(csBValue.AsStringC());
}
} // namespace
class CFieldNameExtractor {
public:
- explicit CFieldNameExtractor(const CFX_WideString& full_name) {
- m_pStart = full_name.c_str();
- m_pEnd = m_pStart + full_name.GetLength();
- m_pCur = m_pStart;
+ explicit CFieldNameExtractor(const CFX_WideString& full_name)
+ : m_FullName(full_name) {
+ m_pCur = m_FullName.c_str();
+ m_pEnd = m_pCur + m_FullName.GetLength();
}
+
void GetNext(const FX_WCHAR*& pSubName, FX_STRSIZE& size) {
pSubName = m_pCur;
while (m_pCur < m_pEnd && m_pCur[0] != L'.') {
@@ -64,10 +66,11 @@ class CFieldNameExtractor {
}
protected:
- const FX_WCHAR* m_pStart;
- const FX_WCHAR* m_pEnd;
+ CFX_WideString m_FullName;
const FX_WCHAR* m_pCur;
+ const FX_WCHAR* m_pEnd;
};
+
class CFieldTree {
public:
struct _Node {
@@ -277,10 +280,8 @@ CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bGenerateAP)
if (!pFields)
return;
- int count = pFields->GetCount();
- for (int i = 0; i < count; i++) {
+ for (size_t i = 0; i < pFields->GetCount(); i++)
LoadField(pFields->GetDictAt(i));
- }
}
CPDF_InterForm::~CPDF_InterForm() {
@@ -344,7 +345,7 @@ CFX_ByteString CPDF_InterForm::GenerateNewResourceName(
CFX_ByteString bsNum;
while (TRUE) {
CFX_ByteString csKey = csTmp + bsNum;
- if (!pDict->KeyExist(csKey.AsByteStringC())) {
+ if (!pDict->KeyExist(csKey)) {
return csKey;
}
if (m < iCount) {
@@ -415,7 +416,7 @@ CPDF_Font* CPDF_InterForm::AddStandardFont(CPDF_Document* pDocument,
CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) {
CFX_ByteString csFontName;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- LOGFONTA lf;
+ LOGFONTA lf = {};
FX_BOOL bRet;
if (charSet == ANSI_CHARSET) {
csFontName = "Helvetica";
@@ -634,11 +635,11 @@ FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl,
}
int CPDF_InterForm::CompareFieldName(const CFX_ByteString& name1,
const CFX_ByteString& name2) {
- const FX_CHAR* ptr1 = name1;
- const FX_CHAR* ptr2 = name2;
if (name1.GetLength() == name2.GetLength()) {
return name1 == name2 ? 1 : 0;
}
+ const FX_CHAR* ptr1 = name1.c_str();
+ const FX_CHAR* ptr2 = name2.c_str();
int i = 0;
while (ptr1[i] == ptr2[i]) {
i++;
@@ -703,8 +704,8 @@ CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
if (!pAnnotList)
return nullptr;
- for (uint32_t i = pAnnotList->GetCount(); i > 0; --i) {
- uint32_t annot_index = i - 1;
+ for (size_t i = pAnnotList->GetCount(); i > 0; --i) {
+ size_t annot_index = i - 1;
CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(annot_index);
if (!pAnnot)
continue;
@@ -719,7 +720,7 @@ CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
continue;
if (z_order)
- *z_order = annot_index;
+ *z_order = static_cast<int>(annot_index);
return pControl;
}
return nullptr;
@@ -741,6 +742,7 @@ void CPDF_InterForm::NeedConstructAP(FX_BOOL bNeedAP) {
m_pFormDict->SetAtBoolean("NeedAppearances", bNeedAP);
m_bGenerateAP = bNeedAP;
}
+
int CPDF_InterForm::CountFieldsInCalculationOrder() {
if (!m_pFormDict) {
return 0;
@@ -748,6 +750,7 @@ int CPDF_InterForm::CountFieldsInCalculationOrder() {
CPDF_Array* pArray = m_pFormDict->GetArrayBy("CO");
return pArray ? pArray->GetCount() : 0;
}
+
CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) {
if (!m_pFormDict || index < 0) {
return NULL;
@@ -770,7 +773,7 @@ int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) {
if (!pArray) {
return -1;
}
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pElement = pArray->GetDirectObjectAt(i);
if (pElement == pField->m_pDict) {
return i;
@@ -900,7 +903,7 @@ void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) {
return;
}
if (pFirstKid->KeyExist("T") || pFirstKid->KeyExist("Kids")) {
- for (uint32_t i = 0; i < pKids->GetCount(); i++) {
+ for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pChildDict = pKids->GetDictAt(i);
if (pChildDict) {
if (pChildDict->GetObjNum() != dwParentObjNum) {
@@ -924,8 +927,7 @@ void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) {
if (!pAnnots) {
return;
}
- int iAnnotCount = pAnnots->GetCount();
- for (int i = 0; i < iAnnotCount; i++) {
+ for (size_t i = 0; i < pAnnots->GetCount(); i++) {
CPDF_Dictionary* pAnnot = pAnnots->GetDictAt(i);
if (pAnnot && pAnnot->GetStringBy("Subtype") == "Widget") {
LoadField(pAnnot);
@@ -983,7 +985,7 @@ CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
AddControl(pField, pFieldDict);
}
} else {
- for (uint32_t i = 0; i < pKids->GetCount(); i++) {
+ for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid) {
continue;
@@ -1121,7 +1123,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict,
name += pFieldDict->GetUnicodeTextBy("T");
CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids");
if (pKids) {
- for (uint32_t i = 0; i < pKids->GetCount(); i++) {
+ for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid) {
continue;
@@ -1193,7 +1195,7 @@ FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF,
return FALSE;
}
}
- for (uint32_t i = 0; i < pFields->GetCount(); i++) {
+ for (size_t i = 0; i < pFields->GetCount(); i++) {
CPDF_Dictionary* pField = pFields->GetDictAt(i);
if (!pField) {
continue;
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_formcontrol.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_formcontrol.cpp
index 0a0a8c9a038..aa6cf986f16 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_formcontrol.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_formcontrol.cpp
@@ -11,7 +11,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField,
CPDF_Dictionary* pWidgetDict) {
@@ -78,7 +78,7 @@ void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
continue;
}
if (csKey2 != "Off") {
- pSubDict->ReplaceKey(csKey2.AsByteStringC(), csValue.AsByteStringC());
+ pSubDict->ReplaceKey(csKey2, csValue);
break;
}
}
@@ -176,7 +176,7 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
matrix.Concat(*pMatrix);
CPDF_Form form(m_pField->m_pForm->m_pDocument,
m_pField->m_pForm->m_pFormDict->GetDictBy("DR"), pStream);
- form.ParseContent(NULL, NULL, NULL, NULL);
+ form.ParseContent(nullptr, nullptr, nullptr);
CPDF_RenderContext context(pPage);
context.AppendLayer(&form, &matrix);
context.Render(pDevice, pOptions, nullptr);
@@ -201,33 +201,35 @@ CPDF_ApSettings CPDF_FormControl::GetMK() const {
: nullptr);
}
-bool CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) const {
- return GetMK().HasMKEntry(csEntry.AsByteStringC());
+bool CPDF_FormControl::HasMKEntry(const CFX_ByteString& csEntry) const {
+ return GetMK().HasMKEntry(csEntry);
}
int CPDF_FormControl::GetRotation() {
return GetMK().GetRotation();
}
-FX_ARGB CPDF_FormControl::GetColor(int& iColorType, CFX_ByteString csEntry) {
- return GetMK().GetColor(iColorType, csEntry.AsByteStringC());
+FX_ARGB CPDF_FormControl::GetColor(int& iColorType,
+ const CFX_ByteString& csEntry) {
+ return GetMK().GetColor(iColorType, csEntry);
}
-FX_FLOAT CPDF_FormControl::GetOriginalColor(int index, CFX_ByteString csEntry) {
- return GetMK().GetOriginalColor(index, csEntry.AsByteStringC());
+FX_FLOAT CPDF_FormControl::GetOriginalColor(int index,
+ const CFX_ByteString& csEntry) {
+ return GetMK().GetOriginalColor(index, csEntry);
}
void CPDF_FormControl::GetOriginalColor(int& iColorType,
FX_FLOAT fc[4],
- CFX_ByteString csEntry) {
- GetMK().GetOriginalColor(iColorType, fc, csEntry.AsByteStringC());
+ const CFX_ByteString& csEntry) {
+ GetMK().GetOriginalColor(iColorType, fc, csEntry);
}
-CFX_WideString CPDF_FormControl::GetCaption(CFX_ByteString csEntry) {
- return GetMK().GetCaption(csEntry.AsByteStringC());
+CFX_WideString CPDF_FormControl::GetCaption(const CFX_ByteString& csEntry) {
+ return GetMK().GetCaption(csEntry);
}
-CPDF_Stream* CPDF_FormControl::GetIcon(CFX_ByteString csEntry) {
- return GetMK().GetIcon(csEntry.AsByteStringC());
+CPDF_Stream* CPDF_FormControl::GetIcon(const CFX_ByteString& csEntry) {
+ return GetMK().GetIcon(csEntry);
}
CPDF_IconFit CPDF_FormControl::GetIconFit() {
@@ -286,8 +288,7 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
if (CPDF_Dictionary* pDict = ToDictionary(pObj)) {
CPDF_Dictionary* pFonts = pDict->GetDictBy("Font");
if (pFonts) {
- CPDF_Dictionary* pElement =
- pFonts->GetDictBy(csFontNameTag.AsByteStringC());
+ CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag);
if (pElement) {
CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement);
if (pFont) {
@@ -304,8 +305,7 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
if (CPDF_Dictionary* pDict = ToDictionary(pObj)) {
CPDF_Dictionary* pFonts = pDict->GetDictBy("Font");
if (pFonts) {
- CPDF_Dictionary* pElement =
- pFonts->GetDictBy(csFontNameTag.AsByteStringC());
+ CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag);
if (pElement) {
CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement);
if (pFont) {
@@ -332,7 +332,7 @@ int CPDF_FormControl::GetControlAlignment() {
CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
-bool CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry) const {
+bool CPDF_ApSettings::HasMKEntry(const CFX_ByteString& csEntry) const {
return m_pDict && m_pDict->KeyExist(csEntry);
}
@@ -341,7 +341,7 @@ int CPDF_ApSettings::GetRotation() const {
}
FX_ARGB CPDF_ApSettings::GetColor(int& iColorType,
- const CFX_ByteStringC& csEntry) const {
+ const CFX_ByteString& csEntry) const {
iColorType = COLORTYPE_TRANSPARENT;
if (!m_pDict)
return 0;
@@ -351,7 +351,7 @@ FX_ARGB CPDF_ApSettings::GetColor(int& iColorType,
return 0;
FX_ARGB color = 0;
- uint32_t dwCount = pEntry->GetCount();
+ size_t dwCount = pEntry->GetCount();
if (dwCount == 1) {
iColorType = COLORTYPE_GRAY;
FX_FLOAT g = pEntry->GetNumberAt(0) * 255;
@@ -378,7 +378,7 @@ FX_ARGB CPDF_ApSettings::GetColor(int& iColorType,
FX_FLOAT CPDF_ApSettings::GetOriginalColor(
int index,
- const CFX_ByteStringC& csEntry) const {
+ const CFX_ByteString& csEntry) const {
if (!m_pDict)
return 0;
@@ -388,7 +388,7 @@ FX_FLOAT CPDF_ApSettings::GetOriginalColor(
void CPDF_ApSettings::GetOriginalColor(int& iColorType,
FX_FLOAT fc[4],
- const CFX_ByteStringC& csEntry) const {
+ const CFX_ByteString& csEntry) const {
iColorType = COLORTYPE_TRANSPARENT;
for (int i = 0; i < 4; i++) {
fc[i] = 0;
@@ -400,7 +400,7 @@ void CPDF_ApSettings::GetOriginalColor(int& iColorType,
if (!pEntry) {
return;
}
- uint32_t dwCount = pEntry->GetCount();
+ size_t dwCount = pEntry->GetCount();
if (dwCount == 1) {
iColorType = COLORTYPE_GRAY;
fc[0] = pEntry->GetNumberAt(0);
@@ -419,11 +419,11 @@ void CPDF_ApSettings::GetOriginalColor(int& iColorType,
}
CFX_WideString CPDF_ApSettings::GetCaption(
- const CFX_ByteStringC& csEntry) const {
+ const CFX_ByteString& csEntry) const {
return m_pDict ? m_pDict->GetUnicodeTextBy(csEntry) : CFX_WideString();
}
-CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteStringC& csEntry) const {
+CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteString& csEntry) const {
return m_pDict ? m_pDict->GetStreamBy(csEntry) : nullptr;
}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_formfield.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_formfield.cpp
index 931f9e18d93..84d9a52dac8 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_formfield.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_formfield.cpp
@@ -12,7 +12,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfdoc/cpvt_generateap.h"
#include "core/fpdfdoc/doc_utils.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
FX_BOOL PDF_FormField_IsUnison(CPDF_FormField* pField) {
FX_BOOL bUnison = FALSE;
@@ -414,6 +414,7 @@ int CPDF_FormField::GetMaxLen() {
}
return 0;
}
+
int CPDF_FormField::CountSelectedItems() {
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (!pValue) {
@@ -428,6 +429,7 @@ int CPDF_FormField::CountSelectedItems() {
return pArray->GetCount();
return 0;
}
+
int CPDF_FormField::GetSelectedIndex(int index) {
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
if (!pValue) {
@@ -537,9 +539,9 @@ FX_BOOL CPDF_FormField::IsItemSelected(int index) {
break;
}
}
- for (uint32_t i = 0; i < pArray->GetCount(); i++)
+ for (int i = 0; i < static_cast<int>(pArray->GetCount()); i++)
if (pArray->GetDirectObjectAt(i)->GetUnicodeText() == opt_value &&
- (int)i == iPos) {
+ i == iPos) {
return TRUE;
}
return FALSE;
@@ -722,7 +724,8 @@ int CPDF_FormField::InsertOption(CFX_WideString csOptLabel,
return -1;
}
- CFX_ByteString csStr = PDF_EncodeText(csOptLabel, csOptLabel.GetLength());
+ CFX_ByteString csStr =
+ PDF_EncodeText(csOptLabel.c_str(), csOptLabel.GetLength());
CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "Opt");
CPDF_Array* pOpt = ToArray(pValue);
if (!pOpt) {
@@ -887,6 +890,7 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
m_pForm->m_bUpdated = TRUE;
return TRUE;
}
+
int CPDF_FormField::GetTopVisibleIndex() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI");
if (!pObj) {
@@ -894,6 +898,7 @@ int CPDF_FormField::GetTopVisibleIndex() {
}
return pObj->GetInteger();
}
+
int CPDF_FormField::CountSelectedOptions() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
if (!pObj) {
@@ -903,8 +908,9 @@ int CPDF_FormField::CountSelectedOptions() {
if (!pArray) {
return 0;
}
- return (int)pArray->GetCount();
+ return static_cast<int>(pArray->GetCount());
}
+
int CPDF_FormField::GetSelectedOptionIndex(int index) {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
if (!pObj) {
@@ -914,7 +920,7 @@ int CPDF_FormField::GetSelectedOptionIndex(int index) {
if (!pArray) {
return -1;
}
- int iCount = (int)pArray->GetCount();
+ int iCount = static_cast<int>(pArray->GetCount());
if (iCount > 0 && index < iCount) {
return pArray->GetIntegerAt(index);
}
@@ -929,8 +935,8 @@ FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) {
if (!pArray) {
return FALSE;
}
- int iCount = (int)pArray->GetCount();
- for (int i = 0; i < iCount; i++) {
+ size_t iCount = pArray->GetCount();
+ for (size_t i = 0; i < iCount; i++) {
if (pArray->GetIntegerAt(i) == iOptIndex) {
return TRUE;
}
@@ -949,7 +955,7 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex,
m_pDict->SetAt("I", pArray);
}
FX_BOOL bReturn = FALSE;
- for (int i = 0; i < (int)pArray->GetCount(); i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
int iFind = pArray->GetIntegerAt(i);
if (iFind == iOptIndex) {
if (bSelected) {
@@ -1054,16 +1060,16 @@ void CPDF_FormField::LoadDA() {
if (DA.IsEmpty()) {
return;
}
- CPDF_SimpleParser syntax(DA.AsByteStringC());
+ CPDF_SimpleParser syntax(DA.AsStringC());
syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString font_name = syntax.GetWord();
+ CFX_ByteString font_name(syntax.GetWord());
CPDF_Dictionary* pFontDict = NULL;
if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDictBy("DR") &&
- m_pForm->m_pFormDict->GetDictBy("DR")->GetDictBy("Font"))
+ m_pForm->m_pFormDict->GetDictBy("DR")->GetDictBy("Font")) {
pFontDict = m_pForm->m_pFormDict->GetDictBy("DR")
->GetDictBy("Font")
- ->GetDictBy(font_name.AsByteStringC());
-
+ ->GetDictBy(font_name);
+ }
if (!pFontDict) {
return;
}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_link.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_link.cpp
index d86bf203e40..5d21e1d9aa4 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_link.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_link.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include <vector>
@@ -63,7 +63,7 @@ void CPDF_LinkList::LoadPageLinks(CPDF_Page* pPage,
if (!pAnnotList)
return;
- for (uint32_t i = 0; i < pAnnotList->GetCount(); ++i) {
+ for (size_t i = 0; i < pAnnotList->GetCount(); ++i) {
CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(i);
bool add_link = (pAnnot && pAnnot->GetStringBy("Subtype") == "Link");
// Add non-links as nullptrs to preserve z-order.
@@ -81,8 +81,7 @@ CPDF_Dest CPDF_Link::GetDest(CPDF_Document* pDoc) {
if (pDest->IsString() || pDest->IsName()) {
CPDF_NameTree name_tree(pDoc, "Dests");
- return CPDF_Dest(
- name_tree.LookupNamedDest(pDoc, pDest->GetString().AsByteStringC()));
+ return CPDF_Dest(name_tree.LookupNamedDest(pDoc, pDest->GetString()));
}
if (CPDF_Array* pArray = pDest->AsArray())
return CPDF_Dest(pArray);
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_metadata.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_metadata.cpp
index c466193055e..f36250ab7a2 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_metadata.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_metadata.cpp
@@ -7,8 +7,8 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxcrt/include/fx_xml.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
CPDF_Metadata::CPDF_Metadata(CPDF_Document* pDoc) {
CPDF_Dictionary* pRoot = pDoc->GetRoot();
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_ocg.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_ocg.cpp
index 7464936b62c..51e018aea5d 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_ocg.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_ocg.cpp
@@ -4,9 +4,11 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fpdfapi/fpdf_page/cpdf_contentmarkdata.h"
+#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
static int32_t FPDFDOC_OCG_FindGroup(const CPDF_Object* pObject,
const CPDF_Dictionary* pGroupDict) {
@@ -14,8 +16,7 @@ static int32_t FPDFDOC_OCG_FindGroup(const CPDF_Object* pObject,
return -1;
if (const CPDF_Array* pArray = pObject->AsArray()) {
- uint32_t dwCount = pArray->GetCount();
- for (uint32_t i = 0; i < dwCount; i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
if (pArray->GetDictAt(i) == pGroupDict)
return i;
}
@@ -32,8 +33,7 @@ static FX_BOOL FPDFDOC_OCG_HasIntent(const CPDF_Dictionary* pDict,
}
CFX_ByteString bsIntent;
if (CPDF_Array* pArray = pIntent->AsArray()) {
- uint32_t dwCount = pArray->GetCount();
- for (uint32_t i = 0; i < dwCount; i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
bsIntent = pArray->GetStringAt(i);
if (bsIntent == "All" || bsIntent == csElement)
return TRUE;
@@ -43,27 +43,26 @@ static FX_BOOL FPDFDOC_OCG_HasIntent(const CPDF_Dictionary* pDict,
bsIntent = pIntent->GetString();
return bsIntent == "All" || bsIntent == csElement;
}
+
static CPDF_Dictionary* FPDFDOC_OCG_GetConfig(CPDF_Document* pDoc,
- const CPDF_Dictionary* pOCGDict,
- const CFX_ByteStringC& bsState) {
- FXSYS_assert(pDoc && pOCGDict);
+ const CPDF_Dictionary* pOCGDict) {
+ ASSERT(pOCGDict);
CPDF_Dictionary* pOCProperties = pDoc->GetRoot()->GetDictBy("OCProperties");
- if (!pOCProperties) {
- return NULL;
- }
+ if (!pOCProperties)
+ return nullptr;
+
CPDF_Array* pOCGs = pOCProperties->GetArrayBy("OCGs");
- if (!pOCGs) {
- return NULL;
- }
- if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0) {
- return NULL;
- }
+ if (!pOCGs)
+ return nullptr;
+
+ if (FPDFDOC_OCG_FindGroup(pOCGs, pOCGDict) < 0)
+ return nullptr;
+
CPDF_Dictionary* pConfig = pOCProperties->GetDictBy("D");
CPDF_Array* pConfigs = pOCProperties->GetArrayBy("Configs");
if (pConfigs) {
CPDF_Dictionary* pFind;
- int32_t iCount = pConfigs->GetCount();
- for (int32_t i = 0; i < iCount; i++) {
+ for (size_t i = 0; i < pConfigs->GetCount(); i++) {
pFind = pConfigs->GetDictAt(i);
if (!pFind) {
continue;
@@ -90,21 +89,21 @@ static CFX_ByteString FPDFDOC_OCG_GetUsageTypeString(
return csState;
}
CPDF_OCContext::CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType) {
- FXSYS_assert(pDoc);
+ ASSERT(pDoc);
m_pDocument = pDoc;
m_eUsageType = eUsageType;
}
CPDF_OCContext::~CPDF_OCContext() {
m_OCGStates.clear();
}
-FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig,
+
+FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteString& csConfig,
const CPDF_Dictionary* pOCGDict,
FX_BOOL& bValidConfig) const {
- CPDF_Dictionary* pConfig =
- FPDFDOC_OCG_GetConfig(m_pDocument, pOCGDict, csConfig);
- if (!pConfig) {
+ CPDF_Dictionary* pConfig = FPDFDOC_OCG_GetConfig(m_pDocument, pOCGDict);
+ if (!pConfig)
return TRUE;
- }
+
bValidConfig = TRUE;
FX_BOOL bState = pConfig->GetStringBy("BaseState", "ON") != "OFF";
CPDF_Array* pArray = pConfig->GetArrayBy("ON");
@@ -122,8 +121,7 @@ FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig,
pArray = pConfig->GetArrayBy("AS");
if (pArray) {
CFX_ByteString csFind = csConfig + "State";
- int32_t iCount = pArray->GetCount();
- for (int32_t i = 0; i < iCount; i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
CPDF_Dictionary* pUsage = pArray->GetDictAt(i);
if (!pUsage) {
continue;
@@ -142,7 +140,7 @@ FX_BOOL CPDF_OCContext::LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig,
if (!pState) {
continue;
}
- bState = pState->GetStringBy(csFind.AsByteStringC()) != "OFF";
+ bState = pState->GetStringBy(csFind) != "OFF";
}
}
return bState;
@@ -154,11 +152,11 @@ FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const {
CFX_ByteString csState = FPDFDOC_OCG_GetUsageTypeString(m_eUsageType);
CPDF_Dictionary* pUsage = pOCGDict->GetDictBy("Usage");
if (pUsage) {
- CPDF_Dictionary* pState = pUsage->GetDictBy(csState.AsByteStringC());
+ CPDF_Dictionary* pState = pUsage->GetDictBy(csState);
if (pState) {
CFX_ByteString csFind = csState + "State";
- if (pState->KeyExist(csFind.AsByteStringC())) {
- return pState->GetStringBy(csFind.AsByteStringC()) != "OFF";
+ if (pState->KeyExist(csFind)) {
+ return pState->GetStringBy(csFind) != "OFF";
}
}
if (csState != "View") {
@@ -169,7 +167,7 @@ FX_BOOL CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const {
}
}
FX_BOOL bDefValid = FALSE;
- return LoadOCGStateFromConfig(csState.AsByteStringC(), pOCGDict, bDefValid);
+ return LoadOCGStateFromConfig(csState, pOCGDict, bDefValid);
}
FX_BOOL CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) {
@@ -185,6 +183,19 @@ FX_BOOL CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) {
return bState;
}
+FX_BOOL CPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) {
+ const CPDF_ContentMarkData* pData = pObj->m_ContentMark;
+ for (int i = 0; i < pData->CountItems(); i++) {
+ const CPDF_ContentMarkItem& item = pData->GetItem(i);
+ if (item.GetName() == "OC" &&
+ item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict &&
+ !CheckOCGVisible(item.GetParam())) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression,
FX_BOOL bFromConfig,
int nLevel) {
@@ -194,7 +205,6 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression,
if (!pExpression) {
return FALSE;
}
- int32_t iCount = pExpression->GetCount();
CPDF_Object* pOCGObj;
CFX_ByteString csOperator = pExpression->GetStringAt(0);
if (csOperator == "Not") {
@@ -209,7 +219,7 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression,
}
if (csOperator == "Or" || csOperator == "And") {
FX_BOOL bValue = FALSE;
- for (int32_t i = 1; i < iCount; i++) {
+ for (size_t i = 1; i < pExpression->GetCount(); i++) {
pOCGObj = pExpression->GetDirectObjectAt(1);
if (!pOCGObj) {
continue;
@@ -255,8 +265,7 @@ FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict,
if (csP == "AllOn" || csP == "AllOff") {
bState = TRUE;
}
- int32_t iCount = pArray->GetCount();
- for (int32_t i = 0; i < iCount; i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
FX_BOOL bItem = TRUE;
CPDF_Dictionary* pItemDict = pArray->GetDictAt(i);
if (pItemDict)
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_tagged.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_tagged.cpp
index 2a3554c4998..cfa9e4663c5 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_tagged.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_tagged.cpp
@@ -12,46 +12,62 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfdoc/doc_utils.h"
+#include "core/fpdfdoc/include/fpdf_tagged.h"
#include "core/fpdfdoc/tagged_int.h"
-#include "core/include/fpdfdoc/fpdf_tagged.h"
+
+namespace {
const int nMaxRecursion = 32;
-static FX_BOOL IsTagged(const CPDF_Document* pDoc) {
+
+bool IsTagged(const CPDF_Document* pDoc) {
CPDF_Dictionary* pCatalog = pDoc->GetRoot();
CPDF_Dictionary* pMarkInfo = pCatalog->GetDictBy("MarkInfo");
return pMarkInfo && pMarkInfo->GetIntegerBy("Marked");
}
-CPDF_StructTree* CPDF_StructTree::LoadPage(const CPDF_Document* pDoc,
+
+} // namespace
+
+// static
+IPDF_StructTree* IPDF_StructTree::LoadPage(const CPDF_Document* pDoc,
const CPDF_Dictionary* pPageDict) {
- if (!IsTagged(pDoc)) {
- return NULL;
- }
+ if (!IsTagged(pDoc))
+ return nullptr;
+
CPDF_StructTreeImpl* pTree = new CPDF_StructTreeImpl(pDoc);
pTree->LoadPageTree(pPageDict);
return pTree;
}
-CPDF_StructTree* CPDF_StructTree::LoadDoc(const CPDF_Document* pDoc) {
- if (!IsTagged(pDoc)) {
- return NULL;
- }
+
+// static.
+IPDF_StructTree* IPDF_StructTree::LoadDoc(const CPDF_Document* pDoc) {
+ if (!IsTagged(pDoc))
+ return nullptr;
+
CPDF_StructTreeImpl* pTree = new CPDF_StructTreeImpl(pDoc);
pTree->LoadDocTree();
return pTree;
}
-CPDF_StructTreeImpl::CPDF_StructTreeImpl(const CPDF_Document* pDoc) {
- CPDF_Dictionary* pCatalog = pDoc->GetRoot();
- m_pTreeRoot = pCatalog->GetDictBy("StructTreeRoot");
- if (!m_pTreeRoot) {
- return;
- }
- m_pRoleMap = m_pTreeRoot->GetDictBy("RoleMap");
-}
+
+CPDF_StructTreeImpl::CPDF_StructTreeImpl(const CPDF_Document* pDoc)
+ : m_pTreeRoot(pDoc->GetRoot()->GetDictBy("StructTreeRoot")),
+ m_pRoleMap(m_pTreeRoot ? m_pTreeRoot->GetDictBy("RoleMap") : nullptr),
+ m_pPage(nullptr) {}
+
CPDF_StructTreeImpl::~CPDF_StructTreeImpl() {
- for (int i = 0; i < m_Kids.GetSize(); i++)
- if (m_Kids[i]) {
+ for (int i = 0; i < m_Kids.GetSize(); i++) {
+ if (m_Kids[i])
m_Kids[i]->Release();
- }
+ }
}
+
+int CPDF_StructTreeImpl::CountTopElements() const {
+ return m_Kids.GetSize();
+}
+
+IPDF_StructElement* CPDF_StructTreeImpl::GetTopElement(int i) const {
+ return m_Kids.GetAt(i);
+}
+
void CPDF_StructTreeImpl::LoadDocTree() {
m_pPage = nullptr;
if (!m_pTreeRoot)
@@ -70,7 +86,7 @@ void CPDF_StructTreeImpl::LoadDocTree() {
if (!pArray)
return;
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
CPDF_Dictionary* pKid = pArray->GetDictAt(i);
CPDF_StructElementImpl* pStructElementImpl =
new CPDF_StructElementImpl(this, nullptr, pKid);
@@ -197,23 +213,23 @@ FX_BOOL CPDF_StructTreeImpl::AddTopLevelNode(CPDF_Dictionary* pDict,
}
return TRUE;
}
+
CPDF_StructElementImpl::CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree,
CPDF_StructElementImpl* pParent,
CPDF_Dictionary* pDict)
- : m_RefCount(0) {
- m_pTree = pTree;
- m_pDict = pDict;
- m_Type = pDict->GetStringBy("S");
+ : m_RefCount(0),
+ m_pTree(pTree),
+ m_pParent(pParent),
+ m_pDict(pDict),
+ m_Type(pDict->GetStringBy("S")) {
if (pTree->m_pRoleMap) {
- CFX_ByteString mapped =
- pTree->m_pRoleMap->GetStringBy(m_Type.AsByteStringC());
- if (!mapped.IsEmpty()) {
+ CFX_ByteString mapped = pTree->m_pRoleMap->GetStringBy(m_Type);
+ if (!mapped.IsEmpty())
m_Type = mapped;
- }
}
- m_pParent = pParent;
LoadKids(pDict);
}
+
CPDF_StructElementImpl::~CPDF_StructElementImpl() {
for (int i = 0; i < m_Kids.GetSize(); i++) {
if (m_Kids[i].m_Type == CPDF_StructKid::Element &&
@@ -357,7 +373,7 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner,
if (pA) {
CPDF_Dictionary* pAttrDict = FindAttrDict(pA, owner);
if (pAttrDict) {
- CPDF_Object* pAttr = pAttrDict->GetDirectObjectBy(name);
+ CPDF_Object* pAttr = pAttrDict->GetDirectObjectBy(CFX_ByteString(name));
if (pAttr) {
return pAttr;
}
@@ -374,18 +390,16 @@ CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner,
if (CPDF_Array* pArray = pC->AsArray()) {
for (uint32_t i = 0; i < pArray->GetCount(); i++) {
CFX_ByteString class_name = pArray->GetStringAt(i);
- CPDF_Dictionary* pClassDict =
- pClassMap->GetDictBy(class_name.AsByteStringC());
+ CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name);
if (pClassDict && pClassDict->GetStringBy("O") == owner)
- return pClassDict->GetDirectObjectBy(name);
+ return pClassDict->GetDirectObjectBy(CFX_ByteString(name));
}
return nullptr;
}
CFX_ByteString class_name = pC->GetString();
- CPDF_Dictionary* pClassDict =
- pClassMap->GetDictBy(class_name.AsByteStringC());
+ CPDF_Dictionary* pClassDict = pClassMap->GetDictBy(class_name);
if (pClassDict && pClassDict->GetStringBy("O") == owner)
- return pClassDict->GetDirectObjectBy(name);
+ return pClassDict->GetDirectObjectBy(CFX_ByteString(name));
return nullptr;
}
CPDF_Object* CPDF_StructElementImpl::GetAttr(const CFX_ByteStringC& owner,
@@ -410,7 +424,7 @@ CFX_ByteString CPDF_StructElementImpl::GetName(
CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex);
if (ToName(pAttr))
return pAttr->GetString();
- return default_value;
+ return CFX_ByteString(default_value);
}
FX_ARGB CPDF_StructElementImpl::GetColor(const CFX_ByteStringC& owner,
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_utils.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_utils.cpp
index d3b3cac627d..408f0065e2d 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_utils.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_utils.cpp
@@ -12,8 +12,8 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h"
#include "core/fpdfdoc/doc_utils.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
-#include "core/include/fxge/fx_font.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
+#include "core/fxge/include/fx_font.h"
namespace {
@@ -27,8 +27,7 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) {
}
CPDF_Array* pNumbers = pNode->GetArrayBy("Nums");
if (pNumbers) {
- uint32_t dwCount = pNumbers->GetCount() / 2;
- for (uint32_t i = 0; i < dwCount; i++) {
+ for (size_t i = 0; i < pNumbers->GetCount() / 2; i++) {
int index = pNumbers->GetIntegerAt(i * 2);
if (num == index) {
return pNumbers->GetDirectObjectAt(i * 2 + 1);
@@ -43,7 +42,7 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) {
if (!pKids) {
return NULL;
}
- for (uint32_t i = 0; i < pKids->GetCount(); i++) {
+ for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid) {
continue;
@@ -82,7 +81,7 @@ FX_BOOL CPDF_DefaultAppearance::HasFont() {
if (m_csDA.IsEmpty()) {
return FALSE;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
return syntax.FindTagParamFromStart("Tf", 2);
}
CFX_ByteString CPDF_DefaultAppearance::GetFontString() {
@@ -90,13 +89,13 @@ CFX_ByteString CPDF_DefaultAppearance::GetFontString() {
if (m_csDA.IsEmpty()) {
return csFont;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
if (syntax.FindTagParamFromStart("Tf", 2)) {
- csFont += (CFX_ByteString)syntax.GetWord();
+ csFont += syntax.GetWord();
csFont += " ";
- csFont += (CFX_ByteString)syntax.GetWord();
+ csFont += syntax.GetWord();
csFont += " ";
- csFont += (CFX_ByteString)syntax.GetWord();
+ csFont += syntax.GetWord();
}
return csFont;
}
@@ -107,7 +106,7 @@ void CPDF_DefaultAppearance::GetFont(CFX_ByteString& csFontNameTag,
if (m_csDA.IsEmpty()) {
return;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
if (syntax.FindTagParamFromStart("Tf", 2)) {
csFontNameTag = CFX_ByteString(syntax.GetWord());
csFontNameTag.Delete(0, 1);
@@ -119,7 +118,7 @@ FX_BOOL CPDF_DefaultAppearance::HasColor(FX_BOOL bStrokingOperation) {
if (m_csDA.IsEmpty()) {
return FALSE;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
return TRUE;
}
@@ -134,33 +133,33 @@ CFX_ByteString CPDF_DefaultAppearance::GetColorString(
if (m_csDA.IsEmpty()) {
return csColor;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
csColor += " ";
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
return csColor;
}
if (syntax.FindTagParamFromStart(bStrokingOperation ? "RG" : "rg", 3)) {
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
csColor += " ";
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
csColor += " ";
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
csColor += " ";
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
return csColor;
}
if (syntax.FindTagParamFromStart(bStrokingOperation ? "K" : "k", 4)) {
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
csColor += " ";
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
csColor += " ";
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
csColor += " ";
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
csColor += " ";
- csColor += (CFX_ByteString)syntax.GetWord();
+ csColor += syntax.GetWord();
}
return csColor;
}
@@ -174,7 +173,7 @@ void CPDF_DefaultAppearance::GetColor(int& iColorType,
if (m_csDA.IsEmpty()) {
return;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
iColorType = COLORTYPE_GRAY;
fc[0] = FX_atof(syntax.GetWord());
@@ -203,7 +202,7 @@ void CPDF_DefaultAppearance::GetColor(FX_ARGB& color,
if (m_csDA.IsEmpty()) {
return;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
if (syntax.FindTagParamFromStart(bStrokingOperation ? "G" : "g", 1)) {
iColorType = COLORTYPE_GRAY;
FX_FLOAT g = FX_atof(syntax.GetWord()) * 255 + 0.5f;
@@ -235,7 +234,7 @@ FX_BOOL CPDF_DefaultAppearance::HasTextMatrix() {
if (m_csDA.IsEmpty()) {
return FALSE;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
return syntax.FindTagParamFromStart("Tm", 6);
}
CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() {
@@ -243,13 +242,13 @@ CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() {
if (m_csDA.IsEmpty()) {
return csTM;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
if (syntax.FindTagParamFromStart("Tm", 6)) {
for (int i = 0; i < 6; i++) {
- csTM += (CFX_ByteString)syntax.GetWord();
+ csTM += syntax.GetWord();
csTM += " ";
}
- csTM += (CFX_ByteString)syntax.GetWord();
+ csTM += syntax.GetWord();
}
return csTM;
}
@@ -258,7 +257,7 @@ CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() {
if (m_csDA.IsEmpty()) {
return tm;
}
- CPDF_SimpleParser syntax(m_csDA.AsByteStringC());
+ CPDF_SimpleParser syntax(m_csDA.AsStringC());
if (syntax.FindTagParamFromStart("Tm", 6)) {
FX_FLOAT f[6];
for (int i = 0; i < 6; i++) {
@@ -387,7 +386,7 @@ CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
if (!pFonts) {
return NULL;
}
- CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias.AsByteStringC());
+ CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias);
if (!pElement) {
return NULL;
}
@@ -604,10 +603,9 @@ void AddInterFormFont(CPDF_Dictionary*& pFormDict,
csNameTag = pFont->GetBaseFont();
}
csNameTag.Remove(' ');
- csNameTag =
- CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag);
- pFonts->SetAtReference(csNameTag.AsByteStringC(), pDocument,
- pFont->GetFontDict());
+ csNameTag = CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4,
+ csNameTag.c_str());
+ pFonts->SetAtReference(csNameTag, pDocument, pFont->GetFontDict());
}
CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict,
CPDF_Document* pDocument,
@@ -651,7 +649,7 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) {
}
CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR");
CPDF_Dictionary* pFonts = pDR->GetDictBy("Font");
- pFonts->RemoveAt(csTag.AsByteStringC());
+ pFonts->RemoveAt(csTag);
}
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) {
if (!pFormDict || csNameTag.IsEmpty()) {
@@ -665,7 +663,7 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) {
if (!pFonts) {
return;
}
- pFonts->RemoveAt(csNameTag.AsByteStringC());
+ pFonts->RemoveAt(csNameTag);
}
CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict,
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_viewerPreferences.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_viewerPreferences.cpp
index 035d192395d..a355635bf0e 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_viewerPreferences.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_viewerPreferences.cpp
@@ -5,7 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc)
: m_pDoc(pDoc) {}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/doc_vt.cpp b/chromium/third_party/pdfium/core/fpdfdoc/doc_vt.cpp
index fa3d3a2dc2a..7b902f81a7b 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/doc_vt.cpp
+++ b/chromium/third_party/pdfium/core/fpdfdoc/doc_vt.cpp
@@ -4,13 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include <algorithm>
-
-#include "core/fpdfdoc/cpvt_wordinfo.h"
-#include "core/fpdfdoc/csection.h"
-#include "core/fpdfdoc/include/cpdf_variabletext.h"
#include "core/fpdfdoc/pdf_vt.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
CLine::CLine() {}
CLine::~CLine() {}
@@ -37,733 +31,3 @@ CPVT_WordPlace CLine::GetNextWordPlace(const CPVT_WordPlace& place) const {
return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
place.nWordIndex + 1);
}
-CSection::CSection(CPDF_VariableText* pVT) : m_pVT(pVT) {}
-CSection::~CSection() {
- ResetAll();
-}
-void CSection::ResetAll() {
- ResetWordArray();
- ResetLineArray();
-}
-void CSection::ResetLineArray() {
- m_LineArray.RemoveAll();
-}
-void CSection::ResetWordArray() {
- for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++) {
- delete m_WordArray.GetAt(i);
- }
- m_WordArray.RemoveAll();
-}
-void CSection::ResetLinePlace() {
- for (int32_t i = 0, sz = m_LineArray.GetSize(); i < sz; i++) {
- if (CLine* pLine = m_LineArray.GetAt(i)) {
- pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1);
- }
- }
-}
-CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace& place,
- const CPVT_WordInfo& wordinfo) {
- CPVT_WordInfo* pWord = new CPVT_WordInfo(wordinfo);
- int32_t nWordIndex =
- std::max(std::min(place.nWordIndex, m_WordArray.GetSize()), 0);
- if (nWordIndex == m_WordArray.GetSize()) {
- m_WordArray.Add(pWord);
- } else {
- m_WordArray.InsertAt(nWordIndex, pWord);
- }
- return place;
-}
-CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) {
- return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1);
-}
-CPVT_FloatRect CSection::Rearrange() {
- if (m_pVT->m_nCharArray > 0) {
- return CTypeset(this).CharArray();
- }
- return CTypeset(this).Typeset();
-}
-CPVT_Size CSection::GetSectionSize(FX_FLOAT fFontSize) {
- return CTypeset(this).GetEditSize(fFontSize);
-}
-CPVT_WordPlace CSection::GetBeginWordPlace() const {
- if (CLine* pLine = m_LineArray.GetAt(0)) {
- return pLine->GetBeginWordPlace();
- }
- return SecPlace;
-}
-CPVT_WordPlace CSection::GetEndWordPlace() const {
- if (CLine* pLine = m_LineArray.GetAt(m_LineArray.GetSize() - 1)) {
- return pLine->GetEndWordPlace();
- }
- return SecPlace;
-}
-CPVT_WordPlace CSection::GetPrevWordPlace(const CPVT_WordPlace& place) const {
- if (place.nLineIndex < 0) {
- return GetBeginWordPlace();
- }
- if (place.nLineIndex >= m_LineArray.GetSize()) {
- return GetEndWordPlace();
- }
- if (CLine* pLine = m_LineArray.GetAt(place.nLineIndex)) {
- if (place.nWordIndex == pLine->m_LineInfo.nBeginWordIndex) {
- return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1);
- }
- if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
- if (CLine* pPrevLine = m_LineArray.GetAt(place.nLineIndex - 1)) {
- return pPrevLine->GetEndWordPlace();
- }
- } else {
- return pLine->GetPrevWordPlace(place);
- }
- }
- return place;
-}
-CPVT_WordPlace CSection::GetNextWordPlace(const CPVT_WordPlace& place) const {
- if (place.nLineIndex < 0) {
- return GetBeginWordPlace();
- }
- if (place.nLineIndex >= m_LineArray.GetSize()) {
- return GetEndWordPlace();
- }
- if (CLine* pLine = m_LineArray.GetAt(place.nLineIndex)) {
- if (place.nWordIndex >= pLine->m_LineInfo.nEndWordIndex) {
- if (CLine* pNextLine = m_LineArray.GetAt(place.nLineIndex + 1)) {
- return pNextLine->GetBeginWordPlace();
- }
- } else {
- return pLine->GetNextWordPlace(place);
- }
- }
- return place;
-}
-void CSection::UpdateWordPlace(CPVT_WordPlace& place) const {
- int32_t nLeft = 0;
- int32_t nRight = m_LineArray.GetSize() - 1;
- int32_t nMid = (nLeft + nRight) / 2;
- while (nLeft <= nRight) {
- if (CLine* pLine = m_LineArray.GetAt(nMid)) {
- if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
- nRight = nMid - 1;
- nMid = (nLeft + nRight) / 2;
- } else if (place.nWordIndex > pLine->m_LineInfo.nEndWordIndex) {
- nLeft = nMid + 1;
- nMid = (nLeft + nRight) / 2;
- } else {
- place.nLineIndex = nMid;
- return;
- }
- } else {
- break;
- }
- }
-}
-CPVT_WordPlace CSection::SearchWordPlace(const CFX_FloatPoint& point) const {
- ASSERT(m_pVT);
- CPVT_WordPlace place = GetBeginWordPlace();
- FX_BOOL bUp = TRUE;
- FX_BOOL bDown = TRUE;
- int32_t nLeft = 0;
- int32_t nRight = m_LineArray.GetSize() - 1;
- int32_t nMid = m_LineArray.GetSize() / 2;
- FX_FLOAT fTop = 0;
- FX_FLOAT fBottom = 0;
- while (nLeft <= nRight) {
- if (CLine* pLine = m_LineArray.GetAt(nMid)) {
- fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent -
- m_pVT->GetLineLeading(m_SecInfo);
- fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent;
- if (IsFloatBigger(point.y, fTop)) {
- bUp = FALSE;
- }
- if (IsFloatSmaller(point.y, fBottom)) {
- bDown = FALSE;
- }
- if (IsFloatSmaller(point.y, fTop)) {
- nRight = nMid - 1;
- nMid = (nLeft + nRight) / 2;
- continue;
- } else if (IsFloatBigger(point.y, fBottom)) {
- nLeft = nMid + 1;
- nMid = (nLeft + nRight) / 2;
- continue;
- } else {
- place = SearchWordPlace(
- point.x,
- CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()),
- pLine->GetEndWordPlace()));
- place.nLineIndex = nMid;
- return place;
- }
- }
- }
- if (bUp) {
- place = GetBeginWordPlace();
- }
- if (bDown) {
- place = GetEndWordPlace();
- }
- return place;
-}
-CPVT_WordPlace CSection::SearchWordPlace(
- FX_FLOAT fx,
- const CPVT_WordPlace& lineplace) const {
- if (CLine* pLine = m_LineArray.GetAt(lineplace.nLineIndex)) {
- return SearchWordPlace(
- fx - m_SecInfo.rcSection.left,
- CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()),
- pLine->GetEndWordPlace()));
- }
- return GetBeginWordPlace();
-}
-CPVT_WordPlace CSection::SearchWordPlace(FX_FLOAT fx,
- const CPVT_WordRange& range) const {
- CPVT_WordPlace wordplace = range.BeginPos;
- wordplace.nWordIndex = -1;
- if (!m_pVT) {
- return wordplace;
- }
- int32_t nLeft = range.BeginPos.nWordIndex;
- int32_t nRight = range.EndPos.nWordIndex + 1;
- int32_t nMid = (nLeft + nRight) / 2;
- while (nLeft < nRight) {
- if (nMid == nLeft) {
- break;
- }
- if (nMid == nRight) {
- nMid--;
- break;
- }
- if (CPVT_WordInfo* pWord = m_WordArray.GetAt(nMid)) {
- if (fx >
- pWord->fWordX + m_pVT->GetWordWidth(*pWord) * VARIABLETEXT_HALF) {
- nLeft = nMid;
- nMid = (nLeft + nRight) / 2;
- continue;
- } else {
- nRight = nMid;
- nMid = (nLeft + nRight) / 2;
- continue;
- }
- } else {
- break;
- }
- }
- if (CPVT_WordInfo* pWord = m_WordArray.GetAt(nMid)) {
- if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * VARIABLETEXT_HALF) {
- wordplace.nWordIndex = nMid;
- }
- }
- return wordplace;
-}
-void CSection::ClearLeftWords(int32_t nWordIndex) {
- for (int32_t i = nWordIndex; i >= 0; i--) {
- delete m_WordArray.GetAt(i);
- m_WordArray.RemoveAt(i);
- }
-}
-void CSection::ClearRightWords(int32_t nWordIndex) {
- for (int32_t i = m_WordArray.GetSize() - 1; i > nWordIndex; i--) {
- delete m_WordArray.GetAt(i);
- m_WordArray.RemoveAt(i);
- }
-}
-void CSection::ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex) {
- for (int32_t i = nEndIndex; i > nBeginIndex; i--) {
- delete m_WordArray.GetAt(i);
- m_WordArray.RemoveAt(i);
- }
-}
-void CSection::ClearWords(const CPVT_WordRange& PlaceRange) {
- CPVT_WordPlace SecBeginPos = GetBeginWordPlace();
- CPVT_WordPlace SecEndPos = GetEndWordPlace();
- if (PlaceRange.BeginPos.WordCmp(SecBeginPos) >= 0) {
- if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) {
- ClearMidWords(PlaceRange.BeginPos.nWordIndex,
- PlaceRange.EndPos.nWordIndex);
- } else {
- ClearRightWords(PlaceRange.BeginPos.nWordIndex);
- }
- } else if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) {
- ClearLeftWords(PlaceRange.EndPos.nWordIndex);
- } else {
- ResetWordArray();
- }
-}
-void CSection::ClearWord(const CPVT_WordPlace& place) {
- delete m_WordArray.GetAt(place.nWordIndex);
- m_WordArray.RemoveAt(place.nWordIndex);
-}
-CTypeset::CTypeset(CSection* pSection)
- : m_rcRet(0.0f, 0.0f, 0.0f, 0.0f),
- m_pVT(pSection->m_pVT),
- m_pSection(pSection) {}
-CTypeset::~CTypeset() {}
-CPVT_FloatRect CTypeset::CharArray() {
- ASSERT(m_pSection);
- FX_FLOAT fLineAscent =
- m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
- FX_FLOAT fLineDescent =
- m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
- m_rcRet.Default();
- FX_FLOAT x = 0.0f, y = 0.0f;
- FX_FLOAT fNextWidth;
- int32_t nStart = 0;
- FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() /
- (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray);
- if (CLine* pLine = m_pSection->m_LineArray.GetAt(0)) {
- x = 0.0f;
- y += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
- y += fLineAscent;
- nStart = 0;
- switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
- case 0:
- pLine->m_LineInfo.fLineX = fNodeWidth * VARIABLETEXT_HALF;
- break;
- case 1:
- nStart = (m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize()) / 2;
- pLine->m_LineInfo.fLineX =
- fNodeWidth * nStart - fNodeWidth * VARIABLETEXT_HALF;
- break;
- case 2:
- nStart = m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize();
- pLine->m_LineInfo.fLineX =
- fNodeWidth * nStart - fNodeWidth * VARIABLETEXT_HALF;
- break;
- }
- for (int32_t w = 0, sz = m_pSection->m_WordArray.GetSize(); w < sz; w++) {
- if (w >= m_pVT->m_nCharArray) {
- break;
- }
- fNextWidth = 0;
- if (CPVT_WordInfo* pNextWord =
- (CPVT_WordInfo*)m_pSection->m_WordArray.GetAt(w + 1)) {
- pNextWord->fWordTail = 0;
- fNextWidth = m_pVT->GetWordWidth(*pNextWord);
- }
- if (CPVT_WordInfo* pWord =
- (CPVT_WordInfo*)m_pSection->m_WordArray.GetAt(w)) {
- pWord->fWordTail = 0;
- FX_FLOAT fWordWidth = m_pVT->GetWordWidth(*pWord);
- FX_FLOAT fWordAscent = m_pVT->GetWordAscent(*pWord);
- FX_FLOAT fWordDescent = m_pVT->GetWordDescent(*pWord);
- x = (FX_FLOAT)(fNodeWidth * (w + nStart + 0.5) -
- fWordWidth * VARIABLETEXT_HALF);
- pWord->fWordX = x;
- pWord->fWordY = y;
- if (w == 0) {
- pLine->m_LineInfo.fLineX = x;
- }
- if (w != m_pSection->m_WordArray.GetSize() - 1) {
- pWord->fWordTail =
- (fNodeWidth - (fWordWidth + fNextWidth) * VARIABLETEXT_HALF > 0
- ? fNodeWidth - (fWordWidth + fNextWidth) * VARIABLETEXT_HALF
- : 0);
- } else {
- pWord->fWordTail = 0;
- }
- x += fWordWidth;
- fLineAscent = std::max(fLineAscent, fWordAscent);
- fLineDescent = std::min(fLineDescent, fWordDescent);
- }
- }
- pLine->m_LineInfo.nBeginWordIndex = 0;
- pLine->m_LineInfo.nEndWordIndex = m_pSection->m_WordArray.GetSize() - 1;
- pLine->m_LineInfo.fLineY = y;
- pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX;
- pLine->m_LineInfo.fLineAscent = fLineAscent;
- pLine->m_LineInfo.fLineDescent = fLineDescent;
- y += (-fLineDescent);
- }
- return m_rcRet = CPVT_FloatRect(0, 0, x, y);
-}
-CPVT_Size CTypeset::GetEditSize(FX_FLOAT fFontSize) {
- ASSERT(m_pSection);
- ASSERT(m_pVT);
- SplitLines(FALSE, fFontSize);
- return CPVT_Size(m_rcRet.Width(), m_rcRet.Height());
-}
-CPVT_FloatRect CTypeset::Typeset() {
- ASSERT(m_pVT);
- m_pSection->m_LineArray.Empty();
- SplitLines(TRUE, 0.0f);
- m_pSection->m_LineArray.Clear();
- OutputLines();
- return m_rcRet;
-}
-
-static const uint8_t special_chars[128] = {
- 0x00, 0x0C, 0x08, 0x0C, 0x08, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00,
- 0x10, 0x00, 0x00, 0x28, 0x0C, 0x08, 0x00, 0x00, 0x28, 0x28, 0x28, 0x28,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x08,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x00, 0x08, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x0C, 0x00, 0x08, 0x00, 0x00,
-};
-
-static bool IsLatin(uint16_t word) {
- if (word <= 0x007F)
- return !!(special_chars[word] & 0x01);
-
- return ((word >= 0x00C0 && word <= 0x00FF) ||
- (word >= 0x0100 && word <= 0x024F) ||
- (word >= 0x1E00 && word <= 0x1EFF) ||
- (word >= 0x2C60 && word <= 0x2C7F) ||
- (word >= 0xA720 && word <= 0xA7FF) ||
- (word >= 0xFF21 && word <= 0xFF3A) ||
- (word >= 0xFF41 && word <= 0xFF5A));
-}
-
-static bool IsDigit(uint32_t word) {
- return word >= 0x0030 && word <= 0x0039;
-}
-
-static bool IsCJK(uint32_t word) {
- if ((word >= 0x1100 && word <= 0x11FF) ||
- (word >= 0x2E80 && word <= 0x2FFF) ||
- (word >= 0x3040 && word <= 0x9FBF) ||
- (word >= 0xAC00 && word <= 0xD7AF) ||
- (word >= 0xF900 && word <= 0xFAFF) ||
- (word >= 0xFE30 && word <= 0xFE4F) ||
- (word >= 0x20000 && word <= 0x2A6DF) ||
- (word >= 0x2F800 && word <= 0x2FA1F)) {
- return true;
- }
- if (word >= 0x3000 && word <= 0x303F) {
- return (
- word == 0x3005 || word == 0x3006 || word == 0x3021 || word == 0x3022 ||
- word == 0x3023 || word == 0x3024 || word == 0x3025 || word == 0x3026 ||
- word == 0x3027 || word == 0x3028 || word == 0x3029 || word == 0x3031 ||
- word == 0x3032 || word == 0x3033 || word == 0x3034 || word == 0x3035);
- }
- return word >= 0xFF66 && word <= 0xFF9D;
-}
-
-static bool IsPunctuation(uint32_t word) {
- if (word <= 0x007F)
- return !!(special_chars[word] & 0x08);
-
- if (word >= 0x0080 && word <= 0x00FF) {
- return (word == 0x0082 || word == 0x0084 || word == 0x0085 ||
- word == 0x0091 || word == 0x0092 || word == 0x0093 ||
- word <= 0x0094 || word == 0x0096 || word == 0x00B4 ||
- word == 0x00B8);
- }
-
- if (word >= 0x2000 && word <= 0x206F) {
- return (
- word == 0x2010 || word == 0x2011 || word == 0x2012 || word == 0x2013 ||
- word == 0x2018 || word == 0x2019 || word == 0x201A || word == 0x201B ||
- word == 0x201C || word == 0x201D || word == 0x201E || word == 0x201F ||
- word == 0x2032 || word == 0x2033 || word == 0x2034 || word == 0x2035 ||
- word == 0x2036 || word == 0x2037 || word == 0x203C || word == 0x203D ||
- word == 0x203E || word == 0x2044);
- }
-
- if (word >= 0x3000 && word <= 0x303F) {
- return (
- word == 0x3001 || word == 0x3002 || word == 0x3003 || word == 0x3005 ||
- word == 0x3009 || word == 0x300A || word == 0x300B || word == 0x300C ||
- word == 0x300D || word == 0x300F || word == 0x300E || word == 0x3010 ||
- word == 0x3011 || word == 0x3014 || word == 0x3015 || word == 0x3016 ||
- word == 0x3017 || word == 0x3018 || word == 0x3019 || word == 0x301A ||
- word == 0x301B || word == 0x301D || word == 0x301E || word == 0x301F);
- }
-
- if (word >= 0xFE50 && word <= 0xFE6F)
- return (word >= 0xFE50 && word <= 0xFE5E) || word == 0xFE63;
-
- if (word >= 0xFF00 && word <= 0xFFEF) {
- return (
- word == 0xFF01 || word == 0xFF02 || word == 0xFF07 || word == 0xFF08 ||
- word == 0xFF09 || word == 0xFF0C || word == 0xFF0E || word == 0xFF0F ||
- word == 0xFF1A || word == 0xFF1B || word == 0xFF1F || word == 0xFF3B ||
- word == 0xFF3D || word == 0xFF40 || word == 0xFF5B || word == 0xFF5C ||
- word == 0xFF5D || word == 0xFF61 || word == 0xFF62 || word == 0xFF63 ||
- word == 0xFF64 || word == 0xFF65 || word == 0xFF9E || word == 0xFF9F);
- }
-
- return false;
-}
-
-static bool IsConnectiveSymbol(uint32_t word) {
- return word <= 0x007F && (special_chars[word] & 0x20);
-}
-
-static bool IsOpenStylePunctuation(uint32_t word) {
- if (word <= 0x007F)
- return !!(special_chars[word] & 0x04);
-
- return (word == 0x300A || word == 0x300C || word == 0x300E ||
- word == 0x3010 || word == 0x3014 || word == 0x3016 ||
- word == 0x3018 || word == 0x301A || word == 0xFF08 ||
- word == 0xFF3B || word == 0xFF5B || word == 0xFF62);
-}
-
-static bool IsCurrencySymbol(uint16_t word) {
- return (word == 0x0024 || word == 0x0080 || word == 0x00A2 ||
- word == 0x00A3 || word == 0x00A4 || word == 0x00A5 ||
- (word >= 0x20A0 && word <= 0x20CF) || word == 0xFE69 ||
- word == 0xFF04 || word == 0xFFE0 || word == 0xFFE1 ||
- word == 0xFFE5 || word == 0xFFE6);
-}
-
-static bool IsPrefixSymbol(uint16_t word) {
- return IsCurrencySymbol(word) || word == 0x2116;
-}
-
-static bool IsSpace(uint16_t word) {
- return word == 0x0020 || word == 0x3000;
-}
-
-static bool NeedDivision(uint16_t prevWord, uint16_t curWord) {
- if ((IsLatin(prevWord) || IsDigit(prevWord)) &&
- (IsLatin(curWord) || IsDigit(curWord))) {
- return false;
- }
- if (IsSpace(curWord) || IsPunctuation(curWord)) {
- return false;
- }
- if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) {
- return false;
- }
- if (IsSpace(prevWord) || IsPunctuation(prevWord)) {
- return true;
- }
- if (IsPrefixSymbol(prevWord)) {
- return false;
- }
- if (IsPrefixSymbol(curWord) || IsCJK(curWord)) {
- return true;
- }
- if (IsCJK(prevWord)) {
- return true;
- }
- return false;
-}
-
-void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) {
- ASSERT(m_pVT);
- ASSERT(m_pSection);
- int32_t nLineHead = 0;
- int32_t nLineTail = 0;
- FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f;
- FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f;
- FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f;
- FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f;
- int32_t nWordStartPos = 0;
- FX_BOOL bFullWord = FALSE;
- int32_t nLineFullWordIndex = 0;
- int32_t nCharIndex = 0;
- CPVT_LineInfo line;
- FX_FLOAT fWordWidth = 0;
- FX_FLOAT fTypesetWidth = std::max(
- m_pVT->GetPlateWidth() - m_pVT->GetLineIndent(m_pSection->m_SecInfo),
- 0.0f);
- int32_t nTotalWords = m_pSection->m_WordArray.GetSize();
- FX_BOOL bOpened = FALSE;
- if (nTotalWords > 0) {
- int32_t i = 0;
- while (i < nTotalWords) {
- CPVT_WordInfo* pWord = m_pSection->m_WordArray.GetAt(i);
- CPVT_WordInfo* pOldWord = pWord;
- if (i > 0) {
- pOldWord = m_pSection->m_WordArray.GetAt(i - 1);
- }
- if (pWord) {
- if (bTypeset) {
- fLineAscent =
- std::max(fLineAscent, m_pVT->GetWordAscent(*pWord, TRUE));
- fLineDescent =
- std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, TRUE));
- fWordWidth = m_pVT->GetWordWidth(*pWord);
- } else {
- fLineAscent =
- std::max(fLineAscent, m_pVT->GetWordAscent(*pWord, fFontSize));
- fLineDescent =
- std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, fFontSize));
- fWordWidth = m_pVT->GetWordWidth(
- pWord->nFontIndex, pWord->Word, m_pVT->m_wSubWord,
- m_pVT->m_fCharSpace, m_pVT->m_nHorzScale, fFontSize,
- pWord->fWordTail, 0);
- }
- if (!bOpened) {
- if (IsOpenStylePunctuation(pWord->Word)) {
- bOpened = TRUE;
- bFullWord = TRUE;
- } else if (pOldWord) {
- if (NeedDivision(pOldWord->Word, pWord->Word)) {
- bFullWord = TRUE;
- }
- }
- } else {
- if (!IsSpace(pWord->Word) && !IsOpenStylePunctuation(pWord->Word)) {
- bOpened = FALSE;
- }
- }
- if (bFullWord) {
- bFullWord = FALSE;
- if (nCharIndex > 0) {
- nLineFullWordIndex++;
- }
- nWordStartPos = i;
- fBackupLineWidth = fLineWidth;
- fBackupLineAscent = fLineAscent;
- fBackupLineDescent = fLineDescent;
- }
- nCharIndex++;
- }
- if (m_pVT->m_bLimitWidth && fTypesetWidth > 0 &&
- fLineWidth + fWordWidth > fTypesetWidth) {
- if (nLineFullWordIndex > 0) {
- i = nWordStartPos;
- fLineWidth = fBackupLineWidth;
- fLineAscent = fBackupLineAscent;
- fLineDescent = fBackupLineDescent;
- }
- if (nCharIndex == 1) {
- fLineWidth = fWordWidth;
- i++;
- }
- nLineTail = i - 1;
- if (bTypeset) {
- line.nBeginWordIndex = nLineHead;
- line.nEndWordIndex = nLineTail;
- line.nTotalWord = nLineTail - nLineHead + 1;
- line.fLineWidth = fLineWidth;
- line.fLineAscent = fLineAscent;
- line.fLineDescent = fLineDescent;
- m_pSection->AddLine(line);
- }
- fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo));
- fMaxY += (-fLineDescent);
- fMaxX = std::max(fLineWidth, fMaxX);
- nLineHead = i;
- fLineWidth = 0.0f;
- fLineAscent = 0.0f;
- fLineDescent = 0.0f;
- nCharIndex = 0;
- nLineFullWordIndex = 0;
- bFullWord = FALSE;
- } else {
- fLineWidth += fWordWidth;
- i++;
- }
- }
- if (nLineHead <= nTotalWords - 1) {
- nLineTail = nTotalWords - 1;
- if (bTypeset) {
- line.nBeginWordIndex = nLineHead;
- line.nEndWordIndex = nLineTail;
- line.nTotalWord = nLineTail - nLineHead + 1;
- line.fLineWidth = fLineWidth;
- line.fLineAscent = fLineAscent;
- line.fLineDescent = fLineDescent;
- m_pSection->AddLine(line);
- }
- fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo));
- fMaxY += (-fLineDescent);
- fMaxX = std::max(fLineWidth, fMaxX);
- }
- } else {
- if (bTypeset) {
- fLineAscent = m_pVT->GetLineAscent(m_pSection->m_SecInfo);
- fLineDescent = m_pVT->GetLineDescent(m_pSection->m_SecInfo);
- } else {
- fLineAscent =
- m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), fFontSize);
- fLineDescent =
- m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), fFontSize);
- }
- if (bTypeset) {
- line.nBeginWordIndex = -1;
- line.nEndWordIndex = -1;
- line.nTotalWord = 0;
- line.fLineWidth = 0;
- line.fLineAscent = fLineAscent;
- line.fLineDescent = fLineDescent;
- m_pSection->AddLine(line);
- }
- fMaxY += (m_pVT->GetLineLeading(m_pSection->m_SecInfo) + fLineAscent +
- (-fLineDescent));
- }
- m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY);
-}
-void CTypeset::OutputLines() {
- ASSERT(m_pVT);
- ASSERT(m_pSection);
- FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f;
- FX_FLOAT fPosX = 0.0f, fPosY = 0.0f;
- FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo);
- FX_FLOAT fTypesetWidth = std::max(m_pVT->GetPlateWidth() - fLineIndent, 0.0f);
- switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
- default:
- case 0:
- fMinX = 0.0f;
- break;
- case 1:
- fMinX = (fTypesetWidth - m_rcRet.Width()) * VARIABLETEXT_HALF;
- break;
- case 2:
- fMinX = fTypesetWidth - m_rcRet.Width();
- break;
- }
- fMaxX = fMinX + m_rcRet.Width();
- fMinY = 0.0f;
- fMaxY = m_rcRet.Height();
- int32_t nTotalLines = m_pSection->m_LineArray.GetSize();
- if (nTotalLines > 0) {
- m_pSection->m_SecInfo.nTotalLine = nTotalLines;
- for (int32_t l = 0; l < nTotalLines; l++) {
- if (CLine* pLine = m_pSection->m_LineArray.GetAt(l)) {
- switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
- default:
- case 0:
- fPosX = 0;
- break;
- case 1:
- fPosX = (fTypesetWidth - pLine->m_LineInfo.fLineWidth) *
- VARIABLETEXT_HALF;
- break;
- case 2:
- fPosX = fTypesetWidth - pLine->m_LineInfo.fLineWidth;
- break;
- }
- fPosX += fLineIndent;
- fPosY += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
- fPosY += pLine->m_LineInfo.fLineAscent;
- pLine->m_LineInfo.fLineX = fPosX - fMinX;
- pLine->m_LineInfo.fLineY = fPosY - fMinY;
- for (int32_t w = pLine->m_LineInfo.nBeginWordIndex;
- w <= pLine->m_LineInfo.nEndWordIndex; w++) {
- if (CPVT_WordInfo* pWord = m_pSection->m_WordArray.GetAt(w)) {
- pWord->fWordX = fPosX - fMinX;
- if (pWord->pWordProps) {
- switch (pWord->pWordProps->nScriptType) {
- default:
- case CPDF_VariableText::ScriptType::Normal:
- pWord->fWordY = fPosY - fMinY;
- break;
- case CPDF_VariableText::ScriptType::Super:
- pWord->fWordY = fPosY - m_pVT->GetWordAscent(*pWord) - fMinY;
- break;
- case CPDF_VariableText::ScriptType::Sub:
- pWord->fWordY = fPosY - m_pVT->GetWordDescent(*pWord) - fMinY;
- break;
- }
- } else {
- pWord->fWordY = fPosY - fMinY;
- }
- fPosX += m_pVT->GetWordWidth(*pWord);
- }
- }
- fPosY += (-pLine->m_LineInfo.fLineDescent);
- }
- }
- }
- m_rcRet = CPVT_FloatRect(fMinX, fMinY, fMaxX, fMaxY);
-}
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/include/cpdf_variabletext.h b/chromium/third_party/pdfium/core/fpdfdoc/include/cpdf_variabletext.h
index b73d3df8c1d..faa50364693 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/include/cpdf_variabletext.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/include/cpdf_variabletext.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_
#define CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_
+#include <memory>
+
#include "core/fpdfdoc/cpvt_floatrect.h"
#include "core/fpdfdoc/cpvt_lineinfo.h"
#include "core/fpdfdoc/include/cpvt_line.h"
@@ -24,8 +26,8 @@ struct CPVT_SecProps;
struct CPVT_Section;
struct CPVT_SectionInfo;
struct CPVT_Word;
-struct CPVT_WordProps;
struct CPVT_WordInfo;
+struct CPVT_WordProps;
#define VARIABLETEXT_HALF 0.5f
@@ -60,7 +62,7 @@ class CPDF_VariableText : private CPDF_EditContainer {
class Provider {
public:
- Provider(IPVT_FontMap* pFontMap);
+ explicit Provider(IPVT_FontMap* pFontMap);
virtual ~Provider();
virtual int32_t GetCharWidth(int32_t nFontIndex,
@@ -75,14 +77,13 @@ class CPDF_VariableText : private CPDF_EditContainer {
virtual int32_t GetDefaultFontIndex();
private:
- IPVT_FontMap* m_pFontMap;
+ IPVT_FontMap* const m_pFontMap;
};
CPDF_VariableText();
- virtual ~CPDF_VariableText();
+ ~CPDF_VariableText() override;
- CPDF_VariableText::Provider* SetProvider(
- CPDF_VariableText::Provider* pProvider);
+ void SetProvider(CPDF_VariableText::Provider* pProvider);
CPDF_VariableText::Iterator* GetIterator();
// CPDF_EditContainer.
@@ -227,7 +228,7 @@ class CPDF_VariableText : private CPDF_EditContainer {
CPVT_FloatRect Rearrange(const CPVT_WordRange& PlaceRange);
FX_FLOAT GetAutoFontSize();
- FX_BOOL IsBigger(FX_FLOAT fFontSize);
+ bool IsBigger(FX_FLOAT fFontSize) const;
CPVT_FloatRect RearrangeSections(const CPVT_WordRange& PlaceRange);
void ResetSectionArray();
@@ -247,7 +248,7 @@ class CPDF_VariableText : private CPDF_EditContainer {
FX_BOOL m_bInitial;
FX_BOOL m_bRichText;
CPDF_VariableText::Provider* m_pVTProvider;
- CPDF_VariableText::Iterator* m_pVTIterator;
+ std::unique_ptr<CPDF_VariableText::Iterator> m_pVTIterator;
};
#endif // CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/include/cpvt_wordprops.h b/chromium/third_party/pdfium/core/fpdfdoc/include/cpvt_wordprops.h
index e091579239a..690a5e1950a 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/include/cpvt_wordprops.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/include/cpvt_wordprops.h
@@ -9,7 +9,7 @@
#include "core/fpdfdoc/include/cpdf_variabletext.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
struct CPVT_WordProps {
CPVT_WordProps()
diff --git a/chromium/third_party/pdfium/core/include/fpdfdoc/fpdf_doc.h b/chromium/third_party/pdfium/core/fpdfdoc/include/fpdf_doc.h
index f7788b7c9eb..8758ab9a423 100644
--- a/chromium/third_party/pdfium/core/include/fpdfdoc/fpdf_doc.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/include/fpdf_doc.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
-#define CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
+#ifndef CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_
+#define CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_
#include <map>
#include <memory>
@@ -13,8 +13,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
-#include "core/fpdfapi/fpdf_parser/ipdf_occontext.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
class CFDF_Document;
class CFieldTree;
@@ -40,6 +39,7 @@ class CPDF_Link;
class CPDF_Metadata;
class CPDF_OCContext;
class CPDF_Page;
+class CPDF_PageObject;
class CPDF_Font;
class CPDF_Form;
class CPDF_RenderOptions;
@@ -48,17 +48,18 @@ class CPDF_ViewerPreferences;
class CXML_Element;
class CFX_RenderDevice;
+enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE };
+
class CPDF_NameTree {
public:
explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
- CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteStringC& category);
+ CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category);
CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const;
CPDF_Object* LookupValue(const CFX_ByteString& csName) const;
- CPDF_Array* LookupNamedDest(CPDF_Document* pDoc,
- const CFX_ByteStringC& sName);
+ CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteString& sName);
int GetIndex(const CFX_ByteString& csName) const;
- int GetCount() const;
+ size_t GetCount() const;
CPDF_Dictionary* GetRoot() const { return m_pRoot; }
protected:
@@ -119,15 +120,15 @@ class CPDF_Dest {
CPDF_Object* m_pObj;
};
-class CPDF_OCContext : public IPDF_OCContext {
+class CPDF_OCContext {
public:
enum UsageType { View = 0, Design, Print, Export };
explicit CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType = View);
- ~CPDF_OCContext() override;
+ ~CPDF_OCContext();
- // IPDF_OCContext:
- FX_BOOL CheckOCGVisible(const CPDF_Dictionary* pOCGDict) override;
+ FX_BOOL CheckOCGVisible(const CPDF_Dictionary* pOCGDict);
+ FX_BOOL CheckObjectVisible(const CPDF_PageObject* pObj);
CPDF_Document* GetDocument() const { return m_pDocument; }
UsageType GetUsageType() const { return m_eUsageType; }
@@ -135,7 +136,7 @@ class CPDF_OCContext : public IPDF_OCContext {
void ResetOCContext();
protected:
- FX_BOOL LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig,
+ FX_BOOL LoadOCGStateFromConfig(const CFX_ByteString& csConfig,
const CPDF_Dictionary* pOCGDict,
FX_BOOL& bValidConfig) const;
FX_BOOL LoadOCGState(const CPDF_Dictionary* pOCGDict) const;
@@ -154,9 +155,9 @@ class CPDF_ActionFields {
public:
explicit CPDF_ActionFields(const CPDF_Action* pAction) : m_pAction(pAction) {}
- uint32_t GetFieldsCount() const;
+ size_t GetFieldsCount() const;
std::vector<CPDF_Object*> GetAllFields() const;
- CPDF_Object* GetField(uint32_t iIndex) const;
+ CPDF_Object* GetField(size_t iIndex) const;
protected:
const CPDF_Action* const m_pAction;
@@ -213,8 +214,8 @@ class CPDF_Action {
FX_BOOL IsSynchronous() const { return m_pDict->GetBooleanBy("Synchronous"); }
FX_BOOL IsRepeat() const { return m_pDict->GetBooleanBy("Repeat"); }
FX_BOOL IsMixPlay() const { return m_pDict->GetBooleanBy("Mix"); }
- uint32_t GetSubActionsCount() const;
- CPDF_Action GetSubAction(uint32_t iIndex) const;
+ size_t GetSubActionsCount() const;
+ CPDF_Action GetSubAction(size_t iIndex) const;
protected:
CPDF_Dictionary* const m_pDict;
@@ -724,9 +725,7 @@ class CPDF_FormField {
int FindOptionValue(const CFX_WideString& csOptValue);
- FX_BOOL CheckControl(int iControlIndex,
- bool bChecked,
- bool bNotify = false);
+ FX_BOOL CheckControl(int iControlIndex, bool bChecked, bool bNotify = false);
int GetTopVisibleIndex();
@@ -842,7 +841,7 @@ class CPDF_FormControl {
bool IsDefaultChecked() const;
HighlightingMode GetHighlightingMode();
- bool HasMKEntry(CFX_ByteString csEntry) const;
+ bool HasMKEntry(const CFX_ByteString& csEntry) const;
int GetRotation();
inline FX_ARGB GetBorderColor(int& iColorType) {
@@ -870,29 +869,20 @@ class CPDF_FormControl {
}
CFX_WideString GetNormalCaption() { return GetCaption("CA"); }
-
CFX_WideString GetRolloverCaption() { return GetCaption("RC"); }
-
CFX_WideString GetDownCaption() { return GetCaption("AC"); }
CPDF_Stream* GetNormalIcon() { return GetIcon("I"); }
-
CPDF_Stream* GetRolloverIcon() { return GetIcon("RI"); }
-
CPDF_Stream* GetDownIcon() { return GetIcon("IX"); }
-
CPDF_IconFit GetIconFit();
int GetTextPosition();
-
CPDF_Action GetAction();
-
CPDF_AAction GetAdditionalAction();
-
CPDF_DefaultAppearance GetDefaultAppearance();
CPDF_Font* GetDefaultControlFont();
-
int GetControlAlignment();
protected:
@@ -900,28 +890,21 @@ class CPDF_FormControl {
CFX_ByteString GetOnStateName() const;
void SetOnStateName(const CFX_ByteString& csOn);
-
void CheckControl(FX_BOOL bChecked);
-
- FX_ARGB GetColor(int& iColorType, CFX_ByteString csEntry);
-
- FX_FLOAT GetOriginalColor(int index, CFX_ByteString csEntry);
-
+ FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry);
+ FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry);
void GetOriginalColor(int& iColorType,
FX_FLOAT fc[4],
- CFX_ByteString csEntry);
-
- CFX_WideString GetCaption(CFX_ByteString csEntry);
-
- CPDF_Stream* GetIcon(CFX_ByteString csEntry);
+ const CFX_ByteString& csEntry);
+ CFX_WideString GetCaption(const CFX_ByteString& csEntry);
+ CPDF_Stream* GetIcon(const CFX_ByteString& csEntry);
CPDF_ApSettings GetMK() const;
CPDF_InterForm* m_pForm;
-
CPDF_FormField* m_pField;
-
CPDF_Dictionary* m_pWidgetDict;
+
friend class CPDF_InterForm;
friend class CPDF_FormField;
};
@@ -989,7 +972,7 @@ class CPDF_ApSettings {
public:
explicit CPDF_ApSettings(CPDF_Dictionary* pDict);
- bool HasMKEntry(const CFX_ByteStringC& csEntry) const;
+ bool HasMKEntry(const CFX_ByteString& csEntry) const;
int GetRotation() const;
FX_ARGB GetBorderColor(int& iColorType) const {
@@ -1017,39 +1000,27 @@ class CPDF_ApSettings {
}
CFX_WideString GetNormalCaption() const { return GetCaption("CA"); }
-
CFX_WideString GetRolloverCaption() const { return GetCaption("RC"); }
-
CFX_WideString GetDownCaption() const { return GetCaption("AC"); }
-
CPDF_Stream* GetNormalIcon() const { return GetIcon("I"); }
-
CPDF_Stream* GetRolloverIcon() const { return GetIcon("RI"); }
-
CPDF_Stream* GetDownIcon() const { return GetIcon("IX"); }
-
CPDF_IconFit GetIconFit() const;
-
int GetTextPosition() const;
protected:
friend class CPDF_FormControl;
- FX_ARGB GetColor(int& iColorType, const CFX_ByteStringC& csEntry) const;
-
- FX_FLOAT GetOriginalColor(int index, const CFX_ByteStringC& csEntry) const;
-
+ FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry) const;
+ FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry) const;
void GetOriginalColor(int& iColorType,
FX_FLOAT fc[4],
- const CFX_ByteStringC& csEntry) const;
-
- CFX_WideString GetCaption(const CFX_ByteStringC& csEntry) const;
+ const CFX_ByteString& csEntry) const;
- CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry) const;
+ CFX_WideString GetCaption(const CFX_ByteString& csEntry) const;
+ CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const;
CPDF_Dictionary* const m_pDict;
};
-CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath);
-
-#endif // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
+#endif // CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_
diff --git a/chromium/third_party/pdfium/core/include/fpdfdoc/fpdf_tagged.h b/chromium/third_party/pdfium/core/fpdfdoc/include/fpdf_tagged.h
index d17b724d539..43d69e8db92 100644
--- a/chromium/third_party/pdfium/core/include/fpdfdoc/fpdf_tagged.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/include/fpdf_tagged.h
@@ -4,71 +4,60 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FPDFDOC_FPDF_TAGGED_H_
-#define CORE_INCLUDE_FPDFDOC_FPDF_TAGGED_H_
+#ifndef CORE_FPDFDOC_INCLUDE_FPDF_TAGGED_H_
+#define CORE_FPDFDOC_INCLUDE_FPDF_TAGGED_H_
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
+class CPDF_Dictionary;
class CPDF_Document;
-class CPDF_StructElement;
-class CPDF_StructTree;
-struct CPDF_StructKid;
+class IPDF_StructElement;
-class CPDF_StructTree {
+class IPDF_StructTree {
public:
- static CPDF_StructTree* LoadDoc(const CPDF_Document* pDoc);
-
- static CPDF_StructTree* LoadPage(const CPDF_Document* pDoc,
+ static IPDF_StructTree* LoadDoc(const CPDF_Document* pDoc);
+ static IPDF_StructTree* LoadPage(const CPDF_Document* pDoc,
const CPDF_Dictionary* pPageDict);
- virtual ~CPDF_StructTree() {}
+ virtual ~IPDF_StructTree() {}
virtual int CountTopElements() const = 0;
-
- virtual CPDF_StructElement* GetTopElement(int i) const = 0;
+ virtual IPDF_StructElement* GetTopElement(int i) const = 0;
};
+
struct CPDF_StructKid {
enum { Invalid, Element, PageContent, StreamContent, Object } m_Type;
union {
struct {
- CPDF_StructElement* m_pElement;
-
+ IPDF_StructElement* m_pElement;
CPDF_Dictionary* m_pDict;
} m_Element;
struct {
uint32_t m_PageObjNum;
-
uint32_t m_ContentId;
} m_PageContent;
struct {
uint32_t m_PageObjNum;
-
uint32_t m_ContentId;
-
uint32_t m_RefObjNum;
} m_StreamContent;
struct {
uint32_t m_PageObjNum;
-
uint32_t m_RefObjNum;
} m_Object;
};
};
-class CPDF_StructElement {
- public:
- virtual ~CPDF_StructElement() {}
- virtual CPDF_StructTree* GetTree() const = 0;
+class IPDF_StructElement {
+ public:
+ virtual ~IPDF_StructElement() {}
+ virtual IPDF_StructTree* GetTree() const = 0;
virtual const CFX_ByteString& GetType() const = 0;
-
- virtual CPDF_StructElement* GetParent() const = 0;
-
+ virtual IPDF_StructElement* GetParent() const = 0;
virtual CPDF_Dictionary* GetDict() const = 0;
-
virtual int CountKids() const = 0;
-
virtual const CPDF_StructKid& GetKid(int index) const = 0;
virtual CPDF_Object* GetAttr(const CFX_ByteStringC& owner,
@@ -101,4 +90,4 @@ class CPDF_StructElement {
int subindex = -1) = 0;
};
-#endif // CORE_INCLUDE_FPDFDOC_FPDF_TAGGED_H_
+#endif // CORE_FPDFDOC_INCLUDE_FPDF_TAGGED_H_
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/pdf_vt.h b/chromium/third_party/pdfium/core/fpdfdoc/pdf_vt.h
index a3b7883a9b7..9026eeee9ed 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/pdf_vt.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/pdf_vt.h
@@ -20,22 +20,6 @@ struct CPVT_WordInfo;
#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-class CPVT_Size {
- public:
- CPVT_Size() : x(0.0f), y(0.0f) {}
- CPVT_Size(FX_FLOAT other_x, FX_FLOAT other_y) {
- x = other_x;
- y = other_y;
- }
- FX_FLOAT x, y;
-};
-
-struct CPVT_FloatRange {
- CPVT_FloatRange() : fMin(0.0f), fMax(0.0f) {}
- CPVT_FloatRange(FX_FLOAT min, FX_FLOAT max) : fMin(min), fMax(max) {}
- FX_FLOAT Range() const { return fMax - fMin; }
- FX_FLOAT fMin, fMax;
-};
template <class TYPE>
class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
public:
@@ -52,10 +36,11 @@ class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
}
}
};
-class CLine {
+class CLine final {
public:
CLine();
- virtual ~CLine();
+ ~CLine();
+
CPVT_WordPlace GetBeginWordPlace() const;
CPVT_WordPlace GetEndWordPlace() const;
CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
@@ -63,10 +48,12 @@ class CLine {
CPVT_WordPlace LinePlace;
CPVT_LineInfo m_LineInfo;
};
-class CLines {
+
+class CLines final {
public:
CLines() : m_nTotal(0) {}
- virtual ~CLines() { RemoveAll(); }
+ ~CLines() { RemoveAll(); }
+
int32_t GetSize() const { return m_Lines.GetSize(); }
CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); }
void Empty() { m_nTotal = 0; }
@@ -103,6 +90,7 @@ class CPDF_EditContainer {
public:
CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {}
virtual ~CPDF_EditContainer() {}
+
virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; }
virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; }
virtual void SetContentRect(const CPVT_FloatRect& rect) {
@@ -111,8 +99,8 @@ class CPDF_EditContainer {
virtual CFX_FloatRect GetContentRect() const { return m_rcContent; }
FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; }
FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; }
- CPVT_Size GetPlateSize() const {
- return CPVT_Size(GetPlateWidth(), GetPlateHeight());
+ CFX_SizeF GetPlateSize() const {
+ return CFX_SizeF(GetPlateWidth(), GetPlateHeight());
}
CFX_FloatPoint GetBTPoint() const {
return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top);
diff --git a/chromium/third_party/pdfium/core/fpdfdoc/tagged_int.h b/chromium/third_party/pdfium/core/fpdfdoc/tagged_int.h
index 4877069bf67..7b9a32fa84d 100644
--- a/chromium/third_party/pdfium/core/fpdfdoc/tagged_int.h
+++ b/chromium/third_party/pdfium/core/fpdfdoc/tagged_int.h
@@ -9,20 +9,18 @@
#include <map>
-#include "core/include/fpdfdoc/fpdf_tagged.h"
+#include "core/fpdfdoc/include/fpdf_tagged.h"
class CPDF_StructElementImpl;
-class CPDF_StructTreeImpl : public CPDF_StructTree {
+class CPDF_StructTreeImpl final : public IPDF_StructTree {
public:
explicit CPDF_StructTreeImpl(const CPDF_Document* pDoc);
~CPDF_StructTreeImpl() override;
- // CPDF_StructTree
- int CountTopElements() const override { return m_Kids.GetSize(); }
- CPDF_StructElement* GetTopElement(int i) const override {
- return (CPDF_StructElement*)m_Kids.GetAt(i);
- }
+ // IPDF_StructTree:
+ int CountTopElements() const override;
+ IPDF_StructElement* GetTopElement(int i) const override;
void LoadDocTree();
void LoadPageTree(const CPDF_Dictionary* pPageDict);
@@ -34,23 +32,23 @@ class CPDF_StructTreeImpl : public CPDF_StructTree {
CPDF_StructElementImpl* pElement);
protected:
- const CPDF_Dictionary* m_pTreeRoot;
- const CPDF_Dictionary* m_pRoleMap;
+ const CPDF_Dictionary* const m_pTreeRoot;
+ const CPDF_Dictionary* const m_pRoleMap;
const CPDF_Dictionary* m_pPage;
CFX_ArrayTemplate<CPDF_StructElementImpl*> m_Kids;
friend class CPDF_StructElementImpl;
};
-class CPDF_StructElementImpl final : public CPDF_StructElement {
+class CPDF_StructElementImpl final : public IPDF_StructElement {
public:
CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree,
CPDF_StructElementImpl* pParent,
CPDF_Dictionary* pDict);
- // CPDF_StructTreeImpl
- CPDF_StructTree* GetTree() const override { return m_pTree; }
+ // IPDF_StructElement:
+ IPDF_StructTree* GetTree() const override { return m_pTree; }
const CFX_ByteString& GetType() const override { return m_Type; }
- CPDF_StructElement* GetParent() const override { return m_pParent; }
+ IPDF_StructElement* GetParent() const override { return m_pParent; }
CPDF_Dictionary* GetDict() const override { return m_pDict; }
int CountKids() const override { return m_Kids.GetSize(); }
const CPDF_StructKid& GetKid(int index) const override {
@@ -93,12 +91,12 @@ class CPDF_StructElementImpl final : public CPDF_StructElement {
protected:
~CPDF_StructElementImpl() override;
- CPDF_StructTreeImpl* m_pTree;
+ int m_RefCount;
+ CPDF_StructTreeImpl* const m_pTree;
+ CPDF_StructElementImpl* const m_pParent;
+ CPDF_Dictionary* const m_pDict;
CFX_ByteString m_Type;
- CPDF_StructElementImpl* m_pParent;
- CPDF_Dictionary* m_pDict;
CFX_ArrayTemplate<CPDF_StructKid> m_Kids;
- int m_RefCount;
friend class CPDF_StructTreeImpl;
};
diff --git a/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.cpp b/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.cpp
index 8d8fa4e9ed8..136c44b5ed0 100644
--- a/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.cpp
+++ b/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.cpp
@@ -4,8 +4,6 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fpdftext/fpdf_text_int.h"
-
#include <algorithm>
#include <cctype>
#include <cwctype>
@@ -14,31 +12,50 @@
#include <vector>
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
+#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_formobject.h"
+#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
-#include "core/fpdftext/include/ipdf_linkextract.h"
-#include "core/fpdftext/include/ipdf_textpage.h"
-#include "core/fpdftext/include/ipdf_textpagefind.h"
-#include "core/fpdftext/unicodenormalization.h"
+#include "core/fpdftext/include/cpdf_linkextract.h"
+#include "core/fpdftext/include/cpdf_textpage.h"
+#include "core/fpdftext/include/cpdf_textpagefind.h"
+#include "core/fpdftext/unicodenormalizationdata.h"
#include "core/fxcrt/fx_bidi.h"
#include "core/fxcrt/include/fx_ext.h"
#include "core/fxcrt/include/fx_ucd.h"
#include "third_party/base/stl_util.h"
-#define FPDFTEXT_RLTB 1
-#define FPDFTEXT_LEFT -1
-#define FPDFTEXT_RIGHT 1
-
#define FPDFTEXT_MATCHCASE 0x00000001
#define FPDFTEXT_MATCHWHOLEWORD 0x00000002
#define FPDFTEXT_CONSECUTIVE 0x00000004
+#define FPDFTEXT_CHAR_ERROR -1
+#define FPDFTEXT_CHAR_NORMAL 0
+#define FPDFTEXT_CHAR_GENERATED 1
+#define FPDFTEXT_CHAR_UNUNICODE 2
+#define FPDFTEXT_CHAR_HYPHEN 3
+#define FPDFTEXT_CHAR_PIECE 4
+
+#define TEXT_BLANK_CHAR L' '
+#define TEXT_LINEFEED_CHAR L'\n'
+#define TEXT_RETURN_CHAR L'\r'
+#define TEXT_EMPTY L""
+#define TEXT_BLANK L" "
+#define TEXT_RETURN_LINEFEED L"\r\n"
+#define TEXT_LINEFEED L"\n"
+#define TEXT_CHARRATIO_GAPDELTA 0.070
+
namespace {
-FX_BOOL _IsIgnoreSpaceCharacter(FX_WCHAR curChar) {
+const FX_FLOAT kDefaultFontSize = 1.0f;
+const uint16_t* const g_UnicodeData_Normalization_Maps[5] = {
+ nullptr, g_UnicodeData_Normalization_Map1, g_UnicodeData_Normalization_Map2,
+ g_UnicodeData_Normalization_Map3, g_UnicodeData_Normalization_Map4};
+
+FX_BOOL IsIgnoreSpaceCharacter(FX_WCHAR curChar) {
if (curChar < 255) {
return FALSE;
}
@@ -55,7 +72,7 @@ FX_BOOL _IsIgnoreSpaceCharacter(FX_WCHAR curChar) {
return TRUE;
}
-FX_FLOAT _NormalizeThreshold(FX_FLOAT threshold) {
+FX_FLOAT NormalizeThreshold(FX_FLOAT threshold) {
if (threshold < 300) {
return threshold / 2.0f;
}
@@ -68,8 +85,8 @@ FX_FLOAT _NormalizeThreshold(FX_FLOAT threshold) {
return threshold / 6.0f;
}
-FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj,
- const CFX_Matrix& matrix) {
+FX_FLOAT CalculateBaseSpace(const CPDF_TextObject* pTextObj,
+ const CFX_Matrix& matrix) {
FX_FLOAT baseSpace = 0.0;
const int nItems = pTextObj->CountItems();
if (pTextObj->m_TextState.GetObject()->m_CharSpace && nItems >= 3) {
@@ -94,34 +111,41 @@ FX_FLOAT _CalculateBaseSpace(const CPDF_TextObject* pTextObj,
return baseSpace;
}
-const FX_FLOAT kDefaultFontSize = 1.0f;
-
-} // namespace
-
-IPDF_TextPage* IPDF_TextPage::CreateTextPage(const CPDF_Page* pPage,
- int flags) {
- return new CPDF_TextPage(pPage, flags);
-}
-
-IPDF_TextPageFind* IPDF_TextPageFind::CreatePageFind(
- const IPDF_TextPage* pTextPage) {
- return pTextPage ? new CPDF_TextPageFind(pTextPage) : nullptr;
-}
-
-IPDF_LinkExtract* IPDF_LinkExtract::CreateLinkExtract() {
- return new CPDF_LinkExtract();
+FX_STRSIZE Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst) {
+ wch = wch & 0xFFFF;
+ FX_WCHAR wFind = g_UnicodeData_Normalization[wch];
+ if (!wFind) {
+ if (pDst) {
+ *pDst = wch;
+ }
+ return 1;
+ }
+ if (wFind >= 0x8000) {
+ wch = wFind - 0x8000;
+ wFind = 1;
+ } else {
+ wch = wFind & 0x0FFF;
+ wFind >>= 12;
+ }
+ const uint16_t* pMap = g_UnicodeData_Normalization_Maps[wFind];
+ if (pMap == g_UnicodeData_Normalization_Map4) {
+ pMap = g_UnicodeData_Normalization_Map4 + wch;
+ wFind = (FX_WCHAR)(*pMap++);
+ } else {
+ pMap += wch;
+ }
+ if (pDst) {
+ FX_WCHAR n = wFind;
+ while (n--) {
+ *pDst++ = *pMap++;
+ }
+ }
+ return (FX_STRSIZE)wFind;
}
-#define TEXT_BLANK_CHAR L' '
-#define TEXT_LINEFEED_CHAR L'\n'
-#define TEXT_RETURN_CHAR L'\r'
-#define TEXT_EMPTY L""
-#define TEXT_BLANK L" "
-#define TEXT_RETURN_LINEFEED L"\r\n"
-#define TEXT_LINEFEED L"\n"
-#define TEXT_CHARRATIO_GAPDELTA 0.070
+} // namespace
-CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags)
+CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags)
: m_pPage(pPage),
m_parserflag(flags),
m_pPreTextObj(nullptr),
@@ -229,23 +253,21 @@ int CPDF_TextPage::TextIndexFromCharIndex(int CharIndex) const {
return -1;
}
-void CPDF_TextPage::GetRectArray(int start,
- int nCount,
- CFX_RectArray& rectArray) const {
- if (start < 0 || nCount == 0) {
- return;
- }
- if (!m_bIsParsed) {
- return;
- }
- CPDF_TextObject* pCurObj = NULL;
- CFX_FloatRect rect;
- int curPos = start;
- FX_BOOL flagNewRect = TRUE;
+std::vector<CFX_FloatRect> CPDF_TextPage::GetRectArray(int start,
+ int nCount) const {
+ if (start < 0 || nCount == 0 || !m_bIsParsed)
+ return std::vector<CFX_FloatRect>();
+
if (nCount + start > pdfium::CollectionSize<int>(m_CharList) ||
nCount == -1) {
nCount = pdfium::CollectionSize<int>(m_CharList) - start;
}
+
+ std::vector<CFX_FloatRect> rectArray;
+ CPDF_TextObject* pCurObj = nullptr;
+ CFX_FloatRect rect;
+ int curPos = start;
+ FX_BOOL flagNewRect = TRUE;
while (nCount--) {
PAGECHAR_INFO info_curchar = m_CharList[curPos++];
if (info_curchar.m_Flag == FPDFTEXT_CHAR_GENERATED) {
@@ -259,7 +281,7 @@ void CPDF_TextPage::GetRectArray(int start,
pCurObj = info_curchar.m_pTextObj;
}
if (pCurObj != info_curchar.m_pTextObj) {
- rectArray.Add(rect);
+ rectArray.push_back(rect);
pCurObj = info_curchar.m_pTextObj;
flagNewRect = TRUE;
}
@@ -312,7 +334,8 @@ void CPDF_TextPage::GetRectArray(int start,
}
}
}
- rectArray.Add(rect);
+ rectArray.push_back(rect);
+ return rectArray;
}
int CPDF_TextPage::GetIndexAtPos(CFX_FloatPoint point,
@@ -396,12 +419,13 @@ CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
return strText;
}
-void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect,
- CFX_RectArray& resRectArray) const {
+std::vector<CFX_FloatRect> CPDF_TextPage::GetRectsArrayByRect(
+ const CFX_FloatRect& rect) const {
if (!m_bIsParsed)
- return;
+ return std::vector<CFX_FloatRect>();
CFX_FloatRect curRect;
+ std::vector<CFX_FloatRect> result;
bool flagNewRect = true;
CPDF_TextObject* pCurObj = nullptr;
for (auto info_curchar : m_CharList) {
@@ -415,7 +439,7 @@ void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect,
pCurObj = info_curchar.m_pTextObj;
}
if (pCurObj != info_curchar.m_pTextObj) {
- resRectArray.Add(curRect);
+ result.push_back(curRect);
pCurObj = info_curchar.m_pTextObj;
flagNewRect = true;
}
@@ -431,7 +455,8 @@ void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect,
curRect.top = std::max(curRect.top, info_curchar.m_CharBox.top);
}
}
- resRectArray.Add(curRect);
+ result.push_back(curRect);
+ return result;
}
int CPDF_TextPage::GetIndexAtPos(FX_FLOAT x,
@@ -512,8 +537,8 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
if (nCount == -1) {
nCount = pdfium::CollectionSize<int>(m_CharList) - start;
- return m_TextBuf.GetWideString().Mid(start,
- m_TextBuf.GetWideString().GetLength());
+ return CFX_WideString(
+ m_TextBuf.AsStringC().Mid(start, m_TextBuf.AsStringC().GetLength()));
}
if (nCount <= 0 || m_CharList.empty()) {
return L"";
@@ -550,7 +575,7 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const {
if (nCount <= 0) {
return L"";
}
- return m_TextBuf.GetWideString().Mid(startindex, nCount);
+ return CFX_WideString(m_TextBuf.AsStringC().Mid(startindex, nCount));
}
int CPDF_TextPage::CountRects(int start, int nCount) {
@@ -561,9 +586,8 @@ int CPDF_TextPage::CountRects(int start, int nCount) {
nCount + start > pdfium::CollectionSize<int>(m_CharList)) {
nCount = pdfium::CollectionSize<int>(m_CharList) - start;
}
- m_SelRects.RemoveAll();
- GetRectArray(start, nCount, m_SelRects);
- return m_SelRects.GetSize();
+ m_SelRects = GetRectArray(start, nCount);
+ return pdfium::CollectionSize<int>(m_SelRects);
}
void CPDF_TextPage::GetRect(int rectIndex,
@@ -574,78 +598,13 @@ void CPDF_TextPage::GetRect(int rectIndex,
if (!m_bIsParsed)
return;
- if (rectIndex < 0 || rectIndex >= m_SelRects.GetSize())
+ if (rectIndex < 0 || rectIndex >= pdfium::CollectionSize<int>(m_SelRects))
return;
- left = m_SelRects.GetAt(rectIndex).left;
- top = m_SelRects.GetAt(rectIndex).top;
- right = m_SelRects.GetAt(rectIndex).right;
- bottom = m_SelRects.GetAt(rectIndex).bottom;
-}
-
-FX_BOOL CPDF_TextPage::GetBaselineRotate(int start, int end, int& Rotate) {
- if (end == start) {
- return FALSE;
- }
- FPDF_CHAR_INFO info_start;
- FPDF_CHAR_INFO info_end;
- GetCharInfo(start, &info_start);
- GetCharInfo(end, &info_end);
- while (info_end.m_CharBox.Width() == 0 || info_end.m_CharBox.Height() == 0) {
- if (--end <= start)
- return FALSE;
-
- GetCharInfo(end, &info_end);
- }
- FX_FLOAT dx = (info_end.m_OriginX - info_start.m_OriginX);
- FX_FLOAT dy = (info_end.m_OriginY - info_start.m_OriginY);
- if (dx == 0) {
- if (dy > 0) {
- Rotate = 90;
- } else if (dy < 0) {
- Rotate = 270;
- } else {
- Rotate = 0;
- }
- } else {
- float a = FXSYS_atan2(dy, dx);
- Rotate = (int)(a * 180 / FX_PI + 0.5);
- }
- if (Rotate < 0) {
- Rotate = -Rotate;
- } else if (Rotate > 0) {
- Rotate = 360 - Rotate;
- }
- return TRUE;
-}
-
-FX_BOOL CPDF_TextPage::GetBaselineRotate(const CFX_FloatRect& rect,
- int& Rotate) {
- int start, end, count,
- n = CountBoundedSegments(rect.left, rect.top, rect.right, rect.bottom,
- TRUE);
- if (n < 1) {
- return FALSE;
- }
- if (n > 1) {
- GetBoundedSegment(n - 1, start, count);
- end = start + count - 1;
- GetBoundedSegment(0, start, count);
- } else {
- GetBoundedSegment(0, start, count);
- end = start + count - 1;
- }
- return GetBaselineRotate(start, end, Rotate);
-}
-FX_BOOL CPDF_TextPage::GetBaselineRotate(int rectIndex, int& Rotate) {
- if (!m_bIsParsed)
- return FALSE;
-
- if (rectIndex < 0 || rectIndex >= m_SelRects.GetSize())
- return FALSE;
-
- CFX_FloatRect rect = m_SelRects.GetAt(rectIndex);
- return GetBaselineRotate(rect, Rotate);
+ left = m_SelRects[rectIndex].left;
+ top = m_SelRects[rectIndex].top;
+ right = m_SelRects[rectIndex].right;
+ bottom = m_SelRects[rectIndex].bottom;
}
int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left,
@@ -726,46 +685,6 @@ int CPDF_TextPage::CountBoundedSegments(FX_FLOAT left,
return m_Segments.GetSize();
}
-void CPDF_TextPage::GetBoundedSegment(int index, int& start, int& count) const {
- if (index < 0 || index >= m_Segments.GetSize()) {
- return;
- }
- start = m_Segments.GetAt(index).m_Start;
- count = m_Segments.GetAt(index).m_nCount;
-}
-
-int CPDF_TextPage::GetWordBreak(int index, int direction) const {
- if (!m_bIsParsed)
- return -1;
-
- if (direction != FPDFTEXT_LEFT && direction != FPDFTEXT_RIGHT)
- return -1;
-
- if (index < 0 || index >= pdfium::CollectionSize<int>(m_CharList))
- return -1;
-
- const PAGECHAR_INFO& charinfo = m_CharList[index];
- if (charinfo.m_Index == -1 || charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) {
- return index;
- }
- if (!IsLetter(charinfo.m_Unicode)) {
- return index;
- }
- int breakPos = index;
- if (direction == FPDFTEXT_LEFT) {
- while (--breakPos > 0) {
- if (!IsLetter(m_CharList[breakPos].m_Unicode))
- break;
- }
- } else if (direction == FPDFTEXT_RIGHT) {
- while (++breakPos < pdfium::CollectionSize<int>(m_CharList)) {
- if (!IsLetter(m_CharList[breakPos].m_Unicode))
- break;
- }
- }
- return breakPos;
-}
-
int32_t CPDF_TextPage::FindTextlineFlowDirection() {
const int32_t nPageWidth = static_cast<int32_t>(m_pPage->GetPageWidth());
const int32_t nPageHeight = static_cast<int32_t>(m_pPage->GetPageHeight());
@@ -906,37 +825,22 @@ int CPDF_TextPage::GetCharWidth(uint32_t charCode, CPDF_Font* pFont) const {
CFX_ByteString str;
pFont->AppendChar(str, charCode);
- if (int w = pFont->GetStringWidth(str, 1))
+ if (int w = pFont->GetStringWidth(str.c_str(), 1))
return w;
return pFont->GetCharBBox(charCode).Width();
}
-void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) {
- CFX_BidiChar::Segment seg = pBidi->GetSegmentInfo();
- if (seg.direction == CFX_BidiChar::RIGHT) {
- for (int i = seg.start + seg.count; i > seg.start; i--) {
- m_TextBuf.AppendChar(str.GetAt(i - i));
- m_CharList.push_back(m_TempCharList[i - 1]);
- }
- } else {
- for (int i = seg.start; i < seg.start + seg.count; i++) {
- m_TextBuf.AppendChar(str.GetAt(i));
- m_CharList.push_back(m_TempCharList[i]);
- }
- }
-}
-
void CPDF_TextPage::AddCharInfoByLRDirection(FX_WCHAR wChar,
PAGECHAR_INFO info) {
if (!IsControlChar(info)) {
info.m_Index = m_TextBuf.GetLength();
if (wChar >= 0xFB00 && wChar <= 0xFB06) {
FX_WCHAR* pDst = NULL;
- FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
+ FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst);
if (nCount >= 1) {
pDst = FX_Alloc(FX_WCHAR, nCount);
- FX_Unicode_GetNormalization(wChar, pDst);
+ Unicode_GetNormalization(wChar, pDst);
for (int nIndex = 0; nIndex < nCount; nIndex++) {
PAGECHAR_INFO info2 = info;
info2.m_Unicode = pDst[nIndex];
@@ -961,10 +865,10 @@ void CPDF_TextPage::AddCharInfoByRLDirection(FX_WCHAR wChar,
info.m_Index = m_TextBuf.GetLength();
wChar = FX_GetMirrorChar(wChar, TRUE, FALSE);
FX_WCHAR* pDst = NULL;
- FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
+ FX_STRSIZE nCount = Unicode_GetNormalization(wChar, pDst);
if (nCount >= 1) {
pDst = FX_Alloc(FX_WCHAR, nCount);
- FX_Unicode_GetNormalization(wChar, pDst);
+ Unicode_GetNormalization(wChar, pDst);
for (int nIndex = 0; nIndex < nCount; nIndex++) {
PAGECHAR_INFO info2 = info;
info2.m_Unicode = pDst[nIndex];
@@ -987,7 +891,7 @@ void CPDF_TextPage::CloseTempLine() {
if (m_TempCharList.empty())
return;
- CFX_WideString str = m_TempTextBuf.GetWideString();
+ CFX_WideString str = m_TempTextBuf.MakeString();
FX_BOOL bPrevSpace = FALSE;
for (int i = 0; i < str.GetLength(); i++) {
if (str.GetAt(i) != ' ') {
@@ -1003,7 +907,7 @@ void CPDF_TextPage::CloseTempLine() {
bPrevSpace = TRUE;
}
CFX_BidiString bidi(str);
- if (m_parserflag == FPDFTEXT_RLTB)
+ if (m_parserflag == FPDFText_Direction::Right)
bidi.SetOverallDirectionRight();
CFX_BidiChar::Direction eCurrentDirection = bidi.OverallDirection();
for (const auto& segment : bidi) {
@@ -1105,16 +1009,17 @@ void CPDF_TextPage::ProcessTextObject(
}
}
-int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
+FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
CPDF_TextObject* pTextObj = Obj.m_pTextObj;
CPDF_ContentMarkData* pMarkData =
(CPDF_ContentMarkData*)pTextObj->m_ContentMark.GetObject();
if (!pMarkData)
- return FPDFTEXT_MC_PASS;
+ return FPDFText_MarkedContent::Pass;
int nContentMark = pMarkData->CountItems();
if (nContentMark < 1)
- return FPDFTEXT_MC_PASS;
+ return FPDFText_MarkedContent::Pass;
+
CFX_WideString actText;
FX_BOOL bExist = FALSE;
CPDF_Dictionary* pDict = NULL;
@@ -1132,19 +1037,19 @@ int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
}
}
if (!bExist)
- return FPDFTEXT_MC_PASS;
+ return FPDFText_MarkedContent::Pass;
if (m_pPreTextObj) {
CPDF_ContentMarkData* pPreMarkData =
(CPDF_ContentMarkData*)m_pPreTextObj->m_ContentMark.GetObject();
if (pPreMarkData && pPreMarkData->CountItems() == n &&
pDict == pPreMarkData->GetItem(n - 1).GetParam()) {
- return FPDFTEXT_MC_DONE;
+ return FPDFText_MarkedContent::Done;
}
}
FX_STRSIZE nItems = actText.GetLength();
if (nItems < 1)
- return FPDFTEXT_MC_PASS;
+ return FPDFText_MarkedContent::Pass;
CPDF_Font* pFont = pTextObj->GetFont();
bExist = FALSE;
@@ -1156,7 +1061,7 @@ int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
}
}
if (!bExist)
- return FPDFTEXT_MC_PASS;
+ return FPDFText_MarkedContent::Pass;
bExist = FALSE;
for (FX_STRSIZE i = 0; i < nItems; i++) {
@@ -1167,9 +1072,9 @@ int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
}
}
if (!bExist)
- return FPDFTEXT_MC_DONE;
+ return FPDFText_MarkedContent::Done;
- return FPDFTEXT_MC_DELAY;
+ return FPDFText_MarkedContent::Delay;
}
void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) {
@@ -1292,8 +1197,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
CFX_Matrix matrix;
pTextObj->GetTextMatrix(&matrix);
matrix.Concat(formMatrix);
- int32_t bPreMKC = PreMarkedContent(Obj);
- if (FPDFTEXT_MC_DONE == bPreMKC) {
+ FPDFText_MarkedContent ePreMKC = PreMarkedContent(Obj);
+ if (ePreMKC == FPDFText_MarkedContent::Done) {
m_pPreTextObj = pTextObj;
m_perMatrix.Copy(formMatrix);
return;
@@ -1353,8 +1258,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
}
}
while (m_TempTextBuf.GetSize() > 0 &&
- m_TempTextBuf.GetWideString().GetAt(m_TempTextBuf.GetLength() -
- 1) == 0x20) {
+ m_TempTextBuf.AsStringC().GetAt(m_TempTextBuf.GetLength() - 1) ==
+ 0x20) {
m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
m_TempCharList.pop_back();
}
@@ -1369,7 +1274,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom,
Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top);
}
- if (FPDFTEXT_MC_DELAY == bPreMKC) {
+ if (ePreMKC == FPDFText_MarkedContent::Delay) {
ProcessMarkedContent(Obj);
m_pPreTextObj = pTextObj;
m_perMatrix.Copy(formMatrix);
@@ -1378,7 +1283,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
m_pPreTextObj = pTextObj;
m_perMatrix.Copy(formMatrix);
int nItems = pTextObj->CountItems();
- FX_FLOAT baseSpace = _CalculateBaseSpace(pTextObj, matrix);
+ FX_FLOAT baseSpace = CalculateBaseSpace(pTextObj, matrix);
const FX_BOOL bR2L = IsRightToLeft(pTextObj, pFont, nItems);
const FX_BOOL bIsBidiAndMirrorInverse =
@@ -1395,9 +1300,9 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
charinfo.m_OriginY = 0;
pTextObj->GetItemInfo(i, &item);
if (item.m_CharCode == (uint32_t)-1) {
- CFX_WideString str = m_TempTextBuf.GetWideString();
+ CFX_WideString str = m_TempTextBuf.MakeString();
if (str.IsEmpty()) {
- str = m_TextBuf.GetWideString();
+ str = m_TextBuf.AsStringC();
}
if (str.IsEmpty() || str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) {
continue;
@@ -1431,7 +1336,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
int this_width = FXSYS_abs(GetCharWidth(item.m_CharCode, pFont));
threshold = this_width > last_width ? (FX_FLOAT)this_width
: (FX_FLOAT)last_width;
- threshold = _NormalizeThreshold(threshold);
+ threshold = NormalizeThreshold(threshold);
threshold = fontsize_h * threshold / 1000;
}
if (threshold && (spacing && spacing >= threshold)) {
@@ -1531,7 +1436,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
m_TempCharList.push_back(charinfo);
}
} else if (i == 0) {
- CFX_WideString str = m_TempTextBuf.GetWideString();
+ CFX_WideString str = m_TempTextBuf.MakeString();
if (!str.IsEmpty() &&
str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) {
m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
@@ -1574,9 +1479,9 @@ int32_t CPDF_TextPage::GetTextObjectWritingMode(
return m_TextlineDir;
}
FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) {
- CFX_WideString strCurText = m_TempTextBuf.GetWideString();
+ CFX_WideString strCurText = m_TempTextBuf.MakeString();
if (strCurText.GetLength() == 0) {
- strCurText = m_TextBuf.GetWideString();
+ strCurText = m_TextBuf.AsStringC();
}
FX_STRSIZE nCount = strCurText.GetLength();
int nIndex = nCount - 1;
@@ -1886,20 +1791,7 @@ FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1,
return !rect.IsEmpty();
}
-FX_BOOL CPDF_TextPage::IsLetter(FX_WCHAR unicode) {
- if (unicode < L'A') {
- return FALSE;
- }
- if (unicode > L'Z' && unicode < L'a') {
- return FALSE;
- }
- if (unicode > L'z') {
- return FALSE;
- }
- return TRUE;
-}
-
-CPDF_TextPageFind::CPDF_TextPageFind(const IPDF_TextPage* pTextPage)
+CPDF_TextPageFind::CPDF_TextPageFind(const CPDF_TextPage* pTextPage)
: m_pTextPage(pTextPage),
m_flags(0),
m_findNextStart(-1),
@@ -2004,7 +1896,7 @@ FX_BOOL CPDF_TextPageFind::FindNext() {
if (!m_pTextPage) {
return FALSE;
}
- m_resArray.RemoveAll();
+ m_resArray.clear();
if (m_findNextStart == -1) {
return FALSE;
}
@@ -2055,8 +1947,8 @@ FX_BOOL CPDF_TextPageFind::FindNext() {
CFX_WideString lastWord = m_csFindWhatArray[iWord - 1];
int lastChar = lastWord.GetAt(lastWord.GetLength() - 1);
if (nStartPos == nResultPos &&
- !(_IsIgnoreSpaceCharacter(lastChar) ||
- _IsIgnoreSpaceCharacter(curChar))) {
+ !(IsIgnoreSpaceCharacter(lastChar) ||
+ IsIgnoreSpaceCharacter(curChar))) {
bMatch = FALSE;
}
for (int d = PreResEndPos; d < nResultPos; d++) {
@@ -2096,7 +1988,7 @@ FX_BOOL CPDF_TextPageFind::FindNext() {
m_IsFind = TRUE;
int resStart = GetCharIndex(m_resStart);
int resEnd = GetCharIndex(m_resEnd);
- m_pTextPage->GetRectArray(resStart, resEnd - resStart + 1, m_resArray);
+ m_resArray = m_pTextPage->GetRectArray(resStart, resEnd - resStart + 1);
if (m_flags & FPDFTEXT_CONSECUTIVE) {
m_findNextStart = m_resStart + 1;
m_findPreStart = m_resEnd - 1;
@@ -2111,7 +2003,7 @@ FX_BOOL CPDF_TextPageFind::FindPrev() {
if (!m_pTextPage) {
return FALSE;
}
- m_resArray.RemoveAll();
+ m_resArray.clear();
if (m_strText.IsEmpty() || m_findPreStart < 0) {
m_IsFind = FALSE;
return m_IsFind;
@@ -2142,7 +2034,7 @@ FX_BOOL CPDF_TextPageFind::FindPrev() {
m_resStart = m_pTextPage->TextIndexFromCharIndex(order);
m_resEnd = m_pTextPage->TextIndexFromCharIndex(order + MatchedCount - 1);
m_IsFind = TRUE;
- m_pTextPage->GetRectArray(order, MatchedCount, m_resArray);
+ m_resArray = m_pTextPage->GetRectArray(order, MatchedCount);
if (m_flags & FPDFTEXT_CONSECUTIVE) {
m_findNextStart = m_resStart + 1;
m_findPreStart = m_resEnd - 1;
@@ -2175,7 +2067,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
while (pos < csWord.GetLength()) {
CFX_WideString curStr = csWord.Mid(pos, 1);
FX_WCHAR curChar = csWord.GetAt(pos);
- if (_IsIgnoreSpaceCharacter(curChar)) {
+ if (IsIgnoreSpaceCharacter(curChar)) {
if (pos > 0 && curChar == 0x2019) {
pos++;
continue;
@@ -2185,7 +2077,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
}
m_csFindWhatArray.push_back(curStr);
if (pos == csWord.GetLength() - 1) {
- csWord.Empty();
+ csWord.clear();
break;
}
csWord = csWord.Right(csWord.GetLength() - pos - 1);
@@ -2256,9 +2148,9 @@ FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString,
return FALSE;
}
while (iSubString--) {
- lpszFullString = FXSYS_wcschr(lpszFullString, chSep);
+ lpszFullString = wcschr(lpszFullString, chSep);
if (!lpszFullString) {
- rString.Empty();
+ rString.clear();
return FALSE;
}
lpszFullString++;
@@ -2266,7 +2158,7 @@ FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString,
lpszFullString++;
}
}
- const FX_WCHAR* lpchEnd = FXSYS_wcschr(lpszFullString, chSep);
+ const FX_WCHAR* lpchEnd = wcschr(lpszFullString, chSep);
int nLen = lpchEnd ? (int)(lpchEnd - lpszFullString)
: (int)FXSYS_wcslen(lpszFullString);
ASSERT(nLen >= 0);
@@ -2278,7 +2170,7 @@ FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString,
CFX_WideString CPDF_TextPageFind::MakeReverse(const CFX_WideString& str) {
CFX_WideString str2;
- str2.Empty();
+ str2.clear();
int nlen = str.GetLength();
for (int i = nlen - 1; i >= 0; i--) {
str2 += str.GetAt(i);
@@ -2286,10 +2178,6 @@ CFX_WideString CPDF_TextPageFind::MakeReverse(const CFX_WideString& str) {
return str2;
}
-void CPDF_TextPageFind::GetRectArray(CFX_RectArray& rects) const {
- rects.Copy(m_resArray);
-}
-
int CPDF_TextPageFind::GetCurOrder() const {
return GetCharIndex(m_resStart);
}
@@ -2300,43 +2188,22 @@ int CPDF_TextPageFind::GetMatchedCount() const {
return resEnd - resStart + 1;
}
-CPDF_LinkExtract::CPDF_LinkExtract()
- : m_pTextPage(nullptr), m_bIsParsed(false) {}
+CPDF_LinkExtract::CPDF_LinkExtract(const CPDF_TextPage* pTextPage)
+ : m_pTextPage(pTextPage) {}
CPDF_LinkExtract::~CPDF_LinkExtract() {
- DeleteLinkList();
}
-FX_BOOL CPDF_LinkExtract::ExtractLinks(const IPDF_TextPage* pTextPage) {
- if (!pTextPage || !pTextPage->IsParsed())
- return FALSE;
+void CPDF_LinkExtract::ExtractLinks() {
+ m_LinkArray.clear();
+ if (!m_pTextPage->IsParsed())
+ return;
- m_pTextPage = (const CPDF_TextPage*)pTextPage;
m_strPageText = m_pTextPage->GetPageText(0, -1);
- DeleteLinkList();
- if (m_strPageText.IsEmpty()) {
- return FALSE;
- }
- ParseLink();
- m_bIsParsed = true;
- return TRUE;
-}
-
-void CPDF_LinkExtract::DeleteLinkList() {
- while (m_LinkList.GetSize()) {
- CPDF_LinkExt* linkinfo = NULL;
- linkinfo = m_LinkList.GetAt(0);
- m_LinkList.RemoveAt(0);
- delete linkinfo;
- }
- m_LinkList.RemoveAll();
-}
+ if (m_strPageText.IsEmpty())
+ return;
-int CPDF_LinkExtract::CountLinks() const {
- if (!m_bIsParsed) {
- return -1;
- }
- return m_LinkList.GetSize();
+ ParseLink();
}
void CPDF_LinkExtract::ParseLink() {
@@ -2365,7 +2232,7 @@ void CPDF_LinkExtract::ParseLink() {
}
if (nCount > 5 &&
(CheckWebLink(strBeCheck) || CheckMailLink(strBeCheck))) {
- AppendToLinkList(start, nCount, strBeCheck);
+ m_LinkArray.push_back({start, nCount, strBeCheck});
}
}
start = ++pos;
@@ -2375,47 +2242,46 @@ void CPDF_LinkExtract::ParseLink() {
}
}
-FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) {
+bool CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) {
CFX_WideString str = strBeCheck;
str.MakeLower();
if (str.Find(L"http://www.") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www."));
- return TRUE;
+ return true;
}
if (str.Find(L"http://") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://"));
- return TRUE;
+ return true;
}
if (str.Find(L"https://www.") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www."));
- return TRUE;
+ return true;
}
if (str.Find(L"https://") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://"));
- return TRUE;
+ return true;
}
if (str.Find(L"www.") != -1) {
strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www."));
strBeCheck = L"http://" + strBeCheck;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
bool CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) {
int aPos = str.Find(L'@');
// Invalid when no '@'.
- if (aPos < 1) {
- return FALSE;
- }
+ if (aPos < 1)
+ return false;
// Check the local part.
int pPos = aPos; // Used to track the position of '@' or '.'.
for (int i = aPos - 1; i >= 0; i--) {
FX_WCHAR ch = str.GetAt(i);
- if (ch == L'_' || ch == L'-' || FXSYS_iswalnum(ch)) {
+ if (ch == L'_' || ch == L'-' || FXSYS_iswalnum(ch))
continue;
- }
+
if (ch != L'.' || i == pPos - 1 || i == 0) {
if (i == aPos - 1) {
// There is '.' or invalid char before '@'.
@@ -2433,25 +2299,25 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) {
// Check the domain name part.
aPos = str.Find(L'@');
- if (aPos < 1) {
- return FALSE;
- }
+ if (aPos < 1)
+ return false;
+
str.TrimRight(L'.');
// At least one '.' in domain name, but not at the beginning.
// TODO(weili): RFC5322 allows domain names to be a local name without '.'.
// Check whether we should remove this check.
int ePos = str.Find(L'.', aPos + 1);
- if (ePos == -1 || ePos == aPos + 1) {
- return FALSE;
- }
+ if (ePos == -1 || ePos == aPos + 1)
+ return false;
+
// Validate all other chars in domain name.
int nLen = str.GetLength();
pPos = 0; // Used to track the position of '.'.
for (int i = aPos + 1; i < nLen; i++) {
FX_WCHAR wch = str.GetAt(i);
- if (wch == L'-' || FXSYS_iswalnum(wch)) {
+ if (wch == L'-' || FXSYS_iswalnum(wch))
continue;
- }
+
if (wch != L'.' || i == pPos + 1) {
// Domain name should end before invalid char.
int host_end = i == pPos + 1 ? i - 2 : i - 1;
@@ -2460,61 +2326,25 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) {
str = str.Left(host_end + 1);
break;
}
- return FALSE;
+ return false;
}
pPos = i;
}
- if (str.Find(L"mailto:") == -1) {
+ if (str.Find(L"mailto:") == -1)
str = L"mailto:" + str;
- }
- return TRUE;
-}
-void CPDF_LinkExtract::AppendToLinkList(int start,
- int count,
- const CFX_WideString& strUrl) {
- CPDF_LinkExt* linkInfo = new CPDF_LinkExt;
- linkInfo->m_strUrl = strUrl;
- linkInfo->m_Start = start;
- linkInfo->m_Count = count;
- m_LinkList.Add(linkInfo);
+ return true;
}
-CFX_WideString CPDF_LinkExtract::GetURL(int index) const {
- if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
- return L"";
- }
- CPDF_LinkExt* link = NULL;
- link = m_LinkList.GetAt(index);
- if (!link) {
- return L"";
- }
- return link->m_strUrl;
-}
-void CPDF_LinkExtract::GetBoundedSegment(int index,
- int& start,
- int& count) const {
- if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
- return;
- }
- CPDF_LinkExt* link = NULL;
- link = m_LinkList.GetAt(index);
- if (!link) {
- return;
- }
- start = link->m_Start;
- count = link->m_Count;
+CFX_WideString CPDF_LinkExtract::GetURL(size_t index) const {
+ return index < m_LinkArray.size() ? m_LinkArray[index].m_strUrl : L"";
}
-void CPDF_LinkExtract::GetRects(int index, CFX_RectArray& rects) const {
- if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
- return;
- }
- CPDF_LinkExt* link = NULL;
- link = m_LinkList.GetAt(index);
- if (!link) {
- return;
- }
- m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
+std::vector<CFX_FloatRect> CPDF_LinkExtract::GetRects(size_t index) const {
+ if (index >= m_LinkArray.size())
+ return std::vector<CFX_FloatRect>();
+
+ return m_pTextPage->GetRectArray(m_LinkArray[index].m_Start,
+ m_LinkArray[index].m_Count);
}
diff --git a/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.h b/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.h
deleted file mode 100644
index 7acab55ccb8..00000000000
--- a/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int.h
+++ /dev/null
@@ -1,247 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFTEXT_FPDF_TEXT_INT_H_
-#define CORE_FPDFTEXT_FPDF_TEXT_INT_H_
-
-#include <deque>
-#include <vector>
-
-#include "core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h"
-#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
-#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
-#include "core/fpdftext/include/ipdf_linkextract.h"
-#include "core/fpdftext/include/ipdf_textpage.h"
-#include "core/fpdftext/include/ipdf_textpagefind.h"
-#include "core/fxcrt/include/fx_basic.h"
-
-class CFX_BidiChar;
-class CPDF_FormObject;
-class CPDF_LinkExtract;
-class CPDF_TextPageFind;
-class CPDF_Font;
-
-#define FPDFTEXT_CHAR_ERROR -1
-#define FPDFTEXT_CHAR_NORMAL 0
-#define FPDFTEXT_CHAR_GENERATED 1
-#define FPDFTEXT_CHAR_UNUNICODE 2
-#define FPDFTEXT_CHAR_HYPHEN 3
-#define FPDFTEXT_CHAR_PIECE 4
-#define FPDFTEXT_MC_PASS 0
-#define FPDFTEXT_MC_DONE 1
-#define FPDFTEXT_MC_DELAY 2
-
-struct PAGECHAR_INFO {
- int m_CharCode;
- FX_WCHAR m_Unicode;
- FX_FLOAT m_OriginX;
- FX_FLOAT m_OriginY;
- int32_t m_Flag;
- CFX_FloatRect m_CharBox;
- CPDF_TextObject* m_pTextObj;
- CFX_Matrix m_Matrix;
- int m_Index;
-};
-
-struct FPDF_SEGMENT {
- int m_Start;
- int m_nCount;
-};
-
-struct PDFTEXT_Obj {
- CPDF_TextObject* m_pTextObj;
- CFX_Matrix m_formMatrix;
-};
-
-class CPDF_TextPage : public IPDF_TextPage {
- public:
- CPDF_TextPage(const CPDF_Page* pPage, int flags);
- ~CPDF_TextPage() override {}
-
- // IPDF_TextPage:
- void ParseTextPage() override;
- bool IsParsed() const override { return m_bIsParsed; }
- int CharIndexFromTextIndex(int TextIndex) const override;
- int TextIndexFromCharIndex(int CharIndex) const override;
- int CountChars() const override;
- void GetCharInfo(int index, FPDF_CHAR_INFO* info) const override;
- void GetRectArray(int start,
- int nCount,
- CFX_RectArray& rectArray) const override;
- int GetIndexAtPos(CFX_FloatPoint point,
- FX_FLOAT xTolerance,
- FX_FLOAT yTolerance) const override;
- int GetIndexAtPos(FX_FLOAT x,
- FX_FLOAT y,
- FX_FLOAT xTolerance,
- FX_FLOAT yTolerance) const override;
- CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const override;
- void GetRectsArrayByRect(const CFX_FloatRect& rect,
- CFX_RectArray& resRectArray) const override;
- CFX_WideString GetPageText(int start = 0, int nCount = -1) const override;
- int CountRects(int start, int nCount) override;
- void GetRect(int rectIndex,
- FX_FLOAT& left,
- FX_FLOAT& top,
- FX_FLOAT& right,
- FX_FLOAT& bottom) const override;
- FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate) override;
- FX_BOOL GetBaselineRotate(const CFX_FloatRect& rect, int& Rotate) override;
- int CountBoundedSegments(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT right,
- FX_FLOAT bottom,
- FX_BOOL bContains = FALSE) override;
- void GetBoundedSegment(int index, int& start, int& count) const override;
- int GetWordBreak(int index, int direction) const override;
-
- static FX_BOOL IsRectIntersect(const CFX_FloatRect& rect1,
- const CFX_FloatRect& rect2);
- static FX_BOOL IsLetter(FX_WCHAR unicode);
-
- private:
- FX_BOOL IsHyphen(FX_WCHAR curChar);
- bool IsControlChar(const PAGECHAR_INFO& charInfo);
- FX_BOOL GetBaselineRotate(int start, int end, int& Rotate);
- void ProcessObject();
- void ProcessFormObject(CPDF_FormObject* pFormObj,
- const CFX_Matrix& formMatrix);
- void ProcessTextObject(PDFTEXT_Obj pObj);
- void ProcessTextObject(CPDF_TextObject* pTextObj,
- const CFX_Matrix& formMatrix,
- const CPDF_PageObjectList* pObjList,
- CPDF_PageObjectList::const_iterator ObjPos);
- int ProcessInsertObject(const CPDF_TextObject* pObj,
- const CFX_Matrix& formMatrix);
- FX_BOOL GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info);
- FX_BOOL IsSameAsPreTextObject(CPDF_TextObject* pTextObj,
- const CPDF_PageObjectList* pObjList,
- CPDF_PageObjectList::const_iterator ObjPos);
- FX_BOOL IsSameTextObject(CPDF_TextObject* pTextObj1,
- CPDF_TextObject* pTextObj2);
- int GetCharWidth(uint32_t charCode, CPDF_Font* pFont) const;
- void CloseTempLine();
- void OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str);
- int32_t PreMarkedContent(PDFTEXT_Obj pObj);
- void ProcessMarkedContent(PDFTEXT_Obj pObj);
- void CheckMarkedContentObject(int32_t& start, int32_t& nCount) const;
- void FindPreviousTextObject(void);
- void AddCharInfoByLRDirection(FX_WCHAR wChar, PAGECHAR_INFO info);
- void AddCharInfoByRLDirection(FX_WCHAR wChar, PAGECHAR_INFO info);
- int32_t GetTextObjectWritingMode(const CPDF_TextObject* pTextObj);
- int32_t FindTextlineFlowDirection();
-
- void SwapTempTextBuf(int32_t iCharListStartAppend, int32_t iBufStartAppend);
- FX_BOOL IsRightToLeft(const CPDF_TextObject* pTextObj,
- const CPDF_Font* pFont,
- int nItems) const;
-
- const CPDF_Page* const m_pPage;
- std::vector<uint16_t> m_CharIndex;
- std::deque<PAGECHAR_INFO> m_CharList;
- std::deque<PAGECHAR_INFO> m_TempCharList;
- CFX_WideTextBuf m_TextBuf;
- CFX_WideTextBuf m_TempTextBuf;
- const int m_parserflag;
- CPDF_TextObject* m_pPreTextObj;
- CFX_Matrix m_perMatrix;
- bool m_bIsParsed;
- CFX_Matrix m_DisplayMatrix;
- CFX_ArrayTemplate<FPDF_SEGMENT> m_Segments;
- CFX_RectArray m_SelRects;
- CFX_ArrayTemplate<PDFTEXT_Obj> m_LineObj;
- int32_t m_TextlineDir;
- CFX_FloatRect m_CurlineRect;
-};
-
-class CPDF_TextPageFind : public IPDF_TextPageFind {
- public:
- explicit CPDF_TextPageFind(const IPDF_TextPage* pTextPage);
- ~CPDF_TextPageFind() override {}
-
- // IPDF_TextPageFind
- FX_BOOL FindFirst(const CFX_WideString& findwhat,
- int flags,
- int startPos = 0) override;
- FX_BOOL FindNext() override;
- FX_BOOL FindPrev() override;
- void GetRectArray(CFX_RectArray& rects) const override;
- int GetCurOrder() const override;
- int GetMatchedCount() const override;
-
- protected:
- void ExtractFindWhat(const CFX_WideString& findwhat);
- FX_BOOL IsMatchWholeWord(const CFX_WideString& csPageText,
- int startPos,
- int endPos);
- FX_BOOL ExtractSubString(CFX_WideString& rString,
- const FX_WCHAR* lpszFullString,
- int iSubString,
- FX_WCHAR chSep);
- CFX_WideString MakeReverse(const CFX_WideString& str);
- int ReverseFind(const CFX_WideString& csPageText,
- const CFX_WideString& csWord,
- int nStartPos,
- int& WordLength);
- int GetCharIndex(int index) const;
-
- private:
- std::vector<uint16_t> m_CharIndex;
- const IPDF_TextPage* m_pTextPage;
- CFX_WideString m_strText;
- CFX_WideString m_findWhat;
- int m_flags;
- std::vector<CFX_WideString> m_csFindWhatArray;
- int m_findNextStart;
- int m_findPreStart;
- FX_BOOL m_bMatchCase;
- FX_BOOL m_bMatchWholeWord;
- int m_resStart;
- int m_resEnd;
- CFX_RectArray m_resArray;
- FX_BOOL m_IsFind;
-};
-
-class CPDF_LinkExt {
- public:
- CPDF_LinkExt() {}
- int m_Start;
- int m_Count;
- CFX_WideString m_strUrl;
- virtual ~CPDF_LinkExt() {}
-};
-
-typedef CFX_ArrayTemplate<CPDF_LinkExt*> LINK_InfoArray;
-
-class CPDF_LinkExtract : public IPDF_LinkExtract {
- public:
- CPDF_LinkExtract();
- ~CPDF_LinkExtract() override;
-
- // IPDF_LinkExtract
- FX_BOOL ExtractLinks(const IPDF_TextPage* pTextPage) override;
- int CountLinks() const override;
- CFX_WideString GetURL(int index) const override;
- void GetBoundedSegment(int index, int& start, int& count) const override;
- void GetRects(int index, CFX_RectArray& rects) const override;
-
- FX_BOOL IsExtract() const { return m_bIsParsed; }
-
- protected:
- void ParseLink();
- void DeleteLinkList();
- FX_BOOL CheckWebLink(CFX_WideString& strBeCheck);
- bool CheckMailLink(CFX_WideString& str);
- void AppendToLinkList(int start, int count, const CFX_WideString& strUrl);
-
- private:
- LINK_InfoArray m_LinkList;
- const CPDF_TextPage* m_pTextPage;
- CFX_WideString m_strPageText;
- bool m_bIsParsed;
-};
-
-#endif // CORE_FPDFTEXT_FPDF_TEXT_INT_H_
diff --git a/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int_unittest.cpp b/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int_unittest.cpp
index e62e885d4b3..0ee11d2d57c 100644
--- a/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int_unittest.cpp
+++ b/chromium/third_party/pdfium/core/fpdftext/fpdf_text_int_unittest.cpp
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/fpdftext/fpdf_text_int.h"
+#include "core/fpdftext/include/cpdf_linkextract.h"
#include "testing/gtest/include/gtest/gtest.h"
// Class to help test functions in CPDF_LinkExtract class.
class CPDF_TestLinkExtract : public CPDF_LinkExtract {
+ public:
+ CPDF_TestLinkExtract() : CPDF_LinkExtract(nullptr) {}
+
private:
// Add test cases as friends to access protected member functions.
// Access CheckMailLink.
diff --git a/chromium/third_party/pdfium/core/fpdftext/include/cpdf_linkextract.h b/chromium/third_party/pdfium/core/fpdftext/include/cpdf_linkextract.h
new file mode 100644
index 00000000000..5d471e0f1cc
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdftext/include/cpdf_linkextract.h
@@ -0,0 +1,46 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_
+#define CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_
+
+#include <vector>
+
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_TextPage;
+
+class CPDF_LinkExtract {
+ public:
+ explicit CPDF_LinkExtract(const CPDF_TextPage* pTextPage);
+ ~CPDF_LinkExtract();
+
+ void ExtractLinks();
+ size_t CountLinks() const { return m_LinkArray.size(); }
+ CFX_WideString GetURL(size_t index) const;
+ std::vector<CFX_FloatRect> GetRects(size_t index) const;
+
+ protected:
+ void ParseLink();
+ bool CheckWebLink(CFX_WideString& str);
+ bool CheckMailLink(CFX_WideString& str);
+
+ private:
+ struct Link {
+ int m_Start;
+ int m_Count;
+ CFX_WideString m_strUrl;
+ };
+
+ const CPDF_TextPage* const m_pTextPage;
+ CFX_WideString m_strPageText;
+ std::vector<Link> m_LinkArray;
+};
+
+#endif // CORE_FPDFTEXT_INCLUDE_CPDF_LINKEXTRACT_H_
diff --git a/chromium/third_party/pdfium/core/fpdftext/include/cpdf_textpage.h b/chromium/third_party/pdfium/core/fpdftext/include/cpdf_textpage.h
new file mode 100644
index 00000000000..c7c673c23e6
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdftext/include/cpdf_textpage.h
@@ -0,0 +1,154 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGE_H_
+#define CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGE_H_
+
+#include <deque>
+#include <vector>
+
+#include "core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h"
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxcrt/include/fx_string.h"
+
+class CFX_BidiChar;
+class CPDF_Font;
+class CPDF_FormObject;
+class CPDF_Page;
+class CPDF_TextObject;
+
+enum class FPDFText_MarkedContent { Pass = 0, Done, Delay };
+
+enum class FPDFText_Direction { Left = -1, Right = 1 };
+
+struct FPDF_CHAR_INFO {
+ FX_WCHAR m_Unicode;
+ FX_WCHAR m_Charcode;
+ int32_t m_Flag;
+ FX_FLOAT m_FontSize;
+ FX_FLOAT m_OriginX;
+ FX_FLOAT m_OriginY;
+ CFX_FloatRect m_CharBox;
+ CPDF_TextObject* m_pTextObj;
+ CFX_Matrix m_Matrix;
+};
+
+struct FPDF_SEGMENT {
+ int m_Start;
+ int m_nCount;
+};
+
+struct PAGECHAR_INFO {
+ int m_CharCode;
+ FX_WCHAR m_Unicode;
+ FX_FLOAT m_OriginX;
+ FX_FLOAT m_OriginY;
+ int32_t m_Flag;
+ CFX_FloatRect m_CharBox;
+ CPDF_TextObject* m_pTextObj;
+ CFX_Matrix m_Matrix;
+ int m_Index;
+};
+
+struct PDFTEXT_Obj {
+ CPDF_TextObject* m_pTextObj;
+ CFX_Matrix m_formMatrix;
+};
+
+class CPDF_TextPage {
+ public:
+ static FX_BOOL IsRectIntersect(const CFX_FloatRect& rect1,
+ const CFX_FloatRect& rect2);
+
+ CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags);
+ ~CPDF_TextPage() {}
+
+ // IPDF_TextPage:
+ void ParseTextPage();
+ bool IsParsed() const { return m_bIsParsed; }
+ int CharIndexFromTextIndex(int TextIndex) const;
+ int TextIndexFromCharIndex(int CharIndex) const;
+ int CountChars() const;
+ void GetCharInfo(int index, FPDF_CHAR_INFO* info) const;
+ std::vector<CFX_FloatRect> GetRectArray(int start, int nCount) const;
+ int GetIndexAtPos(CFX_FloatPoint point,
+ FX_FLOAT xTolerance,
+ FX_FLOAT yTolerance) const;
+ int GetIndexAtPos(FX_FLOAT x,
+ FX_FLOAT y,
+ FX_FLOAT xTolerance,
+ FX_FLOAT yTolerance) const;
+ CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const;
+ std::vector<CFX_FloatRect> GetRectsArrayByRect(
+ const CFX_FloatRect& rect) const;
+ CFX_WideString GetPageText(int start = 0, int nCount = -1) const;
+ int CountRects(int start, int nCount);
+ void GetRect(int rectIndex,
+ FX_FLOAT& left,
+ FX_FLOAT& top,
+ FX_FLOAT& right,
+ FX_FLOAT& bottom) const;
+ int CountBoundedSegments(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT right,
+ FX_FLOAT bottom,
+ FX_BOOL bContains = FALSE);
+
+ private:
+ FX_BOOL IsHyphen(FX_WCHAR curChar);
+ bool IsControlChar(const PAGECHAR_INFO& charInfo);
+ void ProcessObject();
+ void ProcessFormObject(CPDF_FormObject* pFormObj,
+ const CFX_Matrix& formMatrix);
+ void ProcessTextObject(PDFTEXT_Obj pObj);
+ void ProcessTextObject(CPDF_TextObject* pTextObj,
+ const CFX_Matrix& formMatrix,
+ const CPDF_PageObjectList* pObjList,
+ CPDF_PageObjectList::const_iterator ObjPos);
+ int ProcessInsertObject(const CPDF_TextObject* pObj,
+ const CFX_Matrix& formMatrix);
+ FX_BOOL GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info);
+ FX_BOOL IsSameAsPreTextObject(CPDF_TextObject* pTextObj,
+ const CPDF_PageObjectList* pObjList,
+ CPDF_PageObjectList::const_iterator ObjPos);
+ FX_BOOL IsSameTextObject(CPDF_TextObject* pTextObj1,
+ CPDF_TextObject* pTextObj2);
+ int GetCharWidth(uint32_t charCode, CPDF_Font* pFont) const;
+ void CloseTempLine();
+ FPDFText_MarkedContent PreMarkedContent(PDFTEXT_Obj pObj);
+ void ProcessMarkedContent(PDFTEXT_Obj pObj);
+ void CheckMarkedContentObject(int32_t& start, int32_t& nCount) const;
+ void FindPreviousTextObject(void);
+ void AddCharInfoByLRDirection(FX_WCHAR wChar, PAGECHAR_INFO info);
+ void AddCharInfoByRLDirection(FX_WCHAR wChar, PAGECHAR_INFO info);
+ int32_t GetTextObjectWritingMode(const CPDF_TextObject* pTextObj);
+ int32_t FindTextlineFlowDirection();
+
+ void SwapTempTextBuf(int32_t iCharListStartAppend, int32_t iBufStartAppend);
+ FX_BOOL IsRightToLeft(const CPDF_TextObject* pTextObj,
+ const CPDF_Font* pFont,
+ int nItems) const;
+
+ const CPDF_Page* const m_pPage;
+ std::vector<uint16_t> m_CharIndex;
+ std::deque<PAGECHAR_INFO> m_CharList;
+ std::deque<PAGECHAR_INFO> m_TempCharList;
+ CFX_WideTextBuf m_TextBuf;
+ CFX_WideTextBuf m_TempTextBuf;
+ const FPDFText_Direction m_parserflag;
+ CPDF_TextObject* m_pPreTextObj;
+ CFX_Matrix m_perMatrix;
+ bool m_bIsParsed;
+ CFX_Matrix m_DisplayMatrix;
+ CFX_ArrayTemplate<FPDF_SEGMENT> m_Segments;
+ std::vector<CFX_FloatRect> m_SelRects;
+ CFX_ArrayTemplate<PDFTEXT_Obj> m_LineObj;
+ int32_t m_TextlineDir;
+ CFX_FloatRect m_CurlineRect;
+};
+
+#endif // CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGE_H_
diff --git a/chromium/third_party/pdfium/core/fpdftext/include/cpdf_textpagefind.h b/chromium/third_party/pdfium/core/fpdftext/include/cpdf_textpagefind.h
new file mode 100644
index 00000000000..d9937772d1b
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fpdftext/include/cpdf_textpagefind.h
@@ -0,0 +1,64 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGEFIND_H_
+#define CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGEFIND_H_
+
+#include <vector>
+
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_TextPage;
+
+class CPDF_TextPageFind {
+ public:
+ explicit CPDF_TextPageFind(const CPDF_TextPage* pTextPage);
+ ~CPDF_TextPageFind() {}
+
+ FX_BOOL FindFirst(const CFX_WideString& findwhat,
+ int flags,
+ int startPos = 0);
+ FX_BOOL FindNext();
+ FX_BOOL FindPrev();
+ int GetCurOrder() const;
+ int GetMatchedCount() const;
+
+ protected:
+ void ExtractFindWhat(const CFX_WideString& findwhat);
+ FX_BOOL IsMatchWholeWord(const CFX_WideString& csPageText,
+ int startPos,
+ int endPos);
+ FX_BOOL ExtractSubString(CFX_WideString& rString,
+ const FX_WCHAR* lpszFullString,
+ int iSubString,
+ FX_WCHAR chSep);
+ CFX_WideString MakeReverse(const CFX_WideString& str);
+ int ReverseFind(const CFX_WideString& csPageText,
+ const CFX_WideString& csWord,
+ int nStartPos,
+ int& WordLength);
+ int GetCharIndex(int index) const;
+
+ private:
+ std::vector<uint16_t> m_CharIndex;
+ const CPDF_TextPage* m_pTextPage;
+ CFX_WideString m_strText;
+ CFX_WideString m_findWhat;
+ int m_flags;
+ std::vector<CFX_WideString> m_csFindWhatArray;
+ int m_findNextStart;
+ int m_findPreStart;
+ FX_BOOL m_bMatchCase;
+ FX_BOOL m_bMatchWholeWord;
+ int m_resStart;
+ int m_resEnd;
+ std::vector<CFX_FloatRect> m_resArray;
+ FX_BOOL m_IsFind;
+};
+
+#endif // CORE_FPDFTEXT_INCLUDE_CPDF_TEXTPAGEFIND_H_
diff --git a/chromium/third_party/pdfium/core/fpdftext/include/ipdf_linkextract.h b/chromium/third_party/pdfium/core/fpdftext/include/ipdf_linkextract.h
deleted file mode 100644
index c1a5f2f04ef..00000000000
--- a/chromium/third_party/pdfium/core/fpdftext/include/ipdf_linkextract.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFTEXT_INCLUDE_IPDF_LINKEXTRACT_H_
-#define CORE_FPDFTEXT_INCLUDE_IPDF_LINKEXTRACT_H_
-
-#include "core/fpdftext/include/ipdf_textpage.h"
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class IPDF_LinkExtract {
- public:
- static IPDF_LinkExtract* CreateLinkExtract();
- virtual ~IPDF_LinkExtract() {}
-
- virtual FX_BOOL ExtractLinks(const IPDF_TextPage* pTextPage) = 0;
- virtual int CountLinks() const = 0;
- virtual CFX_WideString GetURL(int index) const = 0;
- virtual void GetBoundedSegment(int index, int& start, int& count) const = 0;
- virtual void GetRects(int index, CFX_RectArray& rects) const = 0;
-};
-
-#endif // CORE_FPDFTEXT_INCLUDE_IPDF_LINKEXTRACT_H_
diff --git a/chromium/third_party/pdfium/core/fpdftext/include/ipdf_textpage.h b/chromium/third_party/pdfium/core/fpdftext/include/ipdf_textpage.h
deleted file mode 100644
index 3849cd4004d..00000000000
--- a/chromium/third_party/pdfium/core/fpdftext/include/ipdf_textpage.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGE_H_
-#define CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGE_H_
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_TextObject;
-class CPDF_Page;
-
-struct FPDF_CHAR_INFO {
- FX_WCHAR m_Unicode;
- FX_WCHAR m_Charcode;
- int32_t m_Flag;
- FX_FLOAT m_FontSize;
- FX_FLOAT m_OriginX;
- FX_FLOAT m_OriginY;
- CFX_FloatRect m_CharBox;
- CPDF_TextObject* m_pTextObj;
- CFX_Matrix m_Matrix;
-};
-
-class IPDF_TextPage {
- public:
- static IPDF_TextPage* CreateTextPage(const CPDF_Page* pPage, int flags = 0);
- virtual ~IPDF_TextPage() {}
-
- virtual void ParseTextPage() = 0;
- virtual bool IsParsed() const = 0;
- virtual int CharIndexFromTextIndex(int TextIndex) const = 0;
- virtual int TextIndexFromCharIndex(int CharIndex) const = 0;
- virtual int CountChars() const = 0;
- virtual void GetCharInfo(int index, FPDF_CHAR_INFO* info) const = 0;
- virtual void GetRectArray(int start,
- int nCount,
- CFX_RectArray& rectArray) const = 0;
- virtual int GetIndexAtPos(CFX_FloatPoint point,
- FX_FLOAT xTolerance,
- FX_FLOAT yTolerance) const = 0;
- virtual int GetIndexAtPos(FX_FLOAT x,
- FX_FLOAT y,
- FX_FLOAT xTolerance,
- FX_FLOAT yTolerance) const = 0;
- virtual CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const = 0;
- virtual void GetRectsArrayByRect(const CFX_FloatRect& rect,
- CFX_RectArray& resRectArray) const = 0;
- virtual int CountRects(int start, int nCount) = 0;
- virtual void GetRect(int rectIndex,
- FX_FLOAT& left,
- FX_FLOAT& top,
- FX_FLOAT& right,
- FX_FLOAT& bottom) const = 0;
- virtual FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate) = 0;
- virtual FX_BOOL GetBaselineRotate(const CFX_FloatRect& rect, int& Rotate) = 0;
- virtual int CountBoundedSegments(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT right,
- FX_FLOAT bottom,
- FX_BOOL bContains = FALSE) = 0;
- virtual void GetBoundedSegment(int index, int& start, int& count) const = 0;
- virtual int GetWordBreak(int index, int direction) const = 0;
- virtual CFX_WideString GetPageText(int start = 0, int nCount = -1) const = 0;
-};
-
-#endif // CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGE_H_
diff --git a/chromium/third_party/pdfium/core/fpdftext/include/ipdf_textpagefind.h b/chromium/third_party/pdfium/core/fpdftext/include/ipdf_textpagefind.h
deleted file mode 100644
index b13432b59b6..00000000000
--- a/chromium/third_party/pdfium/core/fpdftext/include/ipdf_textpagefind.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGEFIND_H_
-#define CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGEFIND_H_
-
-#include "core/fpdftext/include/ipdf_textpage.h"
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_string.h"
-
-class IPDF_TextPageFind {
- public:
- static IPDF_TextPageFind* CreatePageFind(const IPDF_TextPage* pTextPage);
- virtual ~IPDF_TextPageFind() {}
-
- virtual FX_BOOL FindFirst(const CFX_WideString& findwhat,
- int flags,
- int startPos = 0) = 0;
- virtual FX_BOOL FindNext() = 0;
- virtual FX_BOOL FindPrev() = 0;
- virtual void GetRectArray(CFX_RectArray& rects) const = 0;
- virtual int GetCurOrder() const = 0;
- virtual int GetMatchedCount() const = 0;
-};
-
-#endif // CORE_FPDFTEXT_INCLUDE_IPDF_TEXTPAGEFIND_H_
diff --git a/chromium/third_party/pdfium/core/fpdftext/unicodenormalization.cpp b/chromium/third_party/pdfium/core/fpdftext/unicodenormalization.cpp
deleted file mode 100644
index 67ab57cb5dc..00000000000
--- a/chromium/third_party/pdfium/core/fpdftext/unicodenormalization.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fpdftext/unicodenormalization.h"
-
-#include "core/fpdftext/unicodenormalizationdata.h"
-#include "core/fxcrt/include/fx_string.h"
-
-namespace {
-
-const uint16_t* const g_UnicodeData_Normalization_Maps[5] = {
- nullptr, g_UnicodeData_Normalization_Map1, g_UnicodeData_Normalization_Map2,
- g_UnicodeData_Normalization_Map3, g_UnicodeData_Normalization_Map4};
-
-} // namespace
-
-FX_STRSIZE FX_Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst) {
- wch = wch & 0xFFFF;
- FX_WCHAR wFind = g_UnicodeData_Normalization[wch];
- if (!wFind) {
- if (pDst) {
- *pDst = wch;
- }
- return 1;
- }
- if (wFind >= 0x8000) {
- wch = wFind - 0x8000;
- wFind = 1;
- } else {
- wch = wFind & 0x0FFF;
- wFind >>= 12;
- }
- const uint16_t* pMap = g_UnicodeData_Normalization_Maps[wFind];
- if (pMap == g_UnicodeData_Normalization_Map4) {
- pMap = g_UnicodeData_Normalization_Map4 + wch;
- wFind = (FX_WCHAR)(*pMap++);
- } else {
- pMap += wch;
- }
- if (pDst) {
- FX_WCHAR n = wFind;
- while (n--) {
- *pDst++ = *pMap++;
- }
- }
- return (FX_STRSIZE)wFind;
-}
diff --git a/chromium/third_party/pdfium/core/fpdftext/unicodenormalization.h b/chromium/third_party/pdfium/core/fpdftext/unicodenormalization.h
deleted file mode 100644
index ee3c8b20242..00000000000
--- a/chromium/third_party/pdfium/core/fpdftext/unicodenormalization.h
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFTEXT_UNICODENORMALIZATION_H_
-#define CORE_FPDFTEXT_UNICODENORMALIZATION_H_
-
-#include "core/fxcrt/include/fx_system.h"
-
-FX_STRSIZE FX_Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst);
-
-#endif // CORE_FPDFTEXT_UNICODENORMALIZATION_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_basicmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_basicmodule.h
new file mode 100644
index 00000000000..4151b4f0f15
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_basicmodule.h
@@ -0,0 +1,32 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_ScanlineDecoder;
+
+class CCodec_BasicModule {
+ public:
+ FX_BOOL RunLengthEncode(const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+ FX_BOOL A85Encode(const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+ CCodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ int nComps,
+ int bpc);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_BASICMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_bmpmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_bmpmodule.h
new file mode 100644
index 00000000000..b465edd874e
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_bmpmodule.h
@@ -0,0 +1,46 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+struct FXBMP_Context;
+class CFX_DIBAttribute;
+
+class CCodec_BmpModule {
+ public:
+ CCodec_BmpModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); }
+
+ FXBMP_Context* Start(void* pModule);
+ void Finish(FXBMP_Context* pContext);
+
+ uint32_t GetAvailInput(FXBMP_Context* pContext, uint8_t** avail_buf_ptr);
+ void Input(FXBMP_Context* pContext,
+ const uint8_t* src_buf,
+ uint32_t src_size);
+
+ int32_t ReadHeader(FXBMP_Context* pContext,
+ int32_t* width,
+ int32_t* height,
+ FX_BOOL* tb_flag,
+ int32_t* components,
+ int32_t* pal_num,
+ uint32_t** pal_pp,
+ CFX_DIBAttribute* pAttribute);
+ int32_t LoadImage(FXBMP_Context* pContext);
+
+ FX_BOOL (*InputImagePositionBufCallback)(void* pModule, uint32_t rcd_pos);
+ void (*ReadScanlineCallback)(void* pModule,
+ int32_t row_num,
+ uint8_t* row_buf);
+
+ protected:
+ FX_CHAR m_szLastError[256];
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_BMPMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_faxmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_faxmodule.h
new file mode 100644
index 00000000000..ad7e9b60631
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_faxmodule.h
@@ -0,0 +1,34 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_ScanlineDecoder;
+
+class CCodec_FaxModule {
+ public:
+ CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ int K,
+ FX_BOOL EndOfLine,
+ FX_BOOL EncodedByteAlign,
+ FX_BOOL BlackIs1,
+ int Columns,
+ int Rows);
+ FX_BOOL Encode(const uint8_t* src_buf,
+ int width,
+ int height,
+ int pitch,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_FAXMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_flatemodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_flatemodule.h
new file mode 100644
index 00000000000..aee03719de2
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_flatemodule.h
@@ -0,0 +1,51 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_ScanlineDecoder;
+
+class CCodec_FlateModule {
+ public:
+ CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ int nComps,
+ int bpc,
+ int predictor,
+ int Colors,
+ int BitsPerComponent,
+ int Columns);
+ uint32_t FlateOrLZWDecode(FX_BOOL bLZW,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ FX_BOOL bEarlyChange,
+ int predictor,
+ int Colors,
+ int BitsPerComponent,
+ int Columns,
+ uint32_t estimated_size,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+ FX_BOOL Encode(const uint8_t* src_buf,
+ uint32_t src_size,
+ int predictor,
+ int Colors,
+ int BitsPerComponent,
+ int Columns,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+ FX_BOOL Encode(const uint8_t* src_buf,
+ uint32_t src_size,
+ uint8_t*& dest_buf,
+ uint32_t& dest_size);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_FLATEMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_gifmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_gifmodule.h
new file mode 100644
index 00000000000..48780744073
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_gifmodule.h
@@ -0,0 +1,63 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+struct FXGIF_Context;
+
+class CCodec_GifModule {
+ public:
+ CCodec_GifModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); }
+
+ FXGIF_Context* Start(void* pModule);
+ void Finish(FXGIF_Context* pContext);
+
+ uint32_t GetAvailInput(FXGIF_Context* pContext,
+ uint8_t** avail_buf_ptr = nullptr);
+ void Input(FXGIF_Context* pContext,
+ const uint8_t* src_buf,
+ uint32_t src_size);
+
+ int32_t ReadHeader(FXGIF_Context* pContext,
+ int* width,
+ int* height,
+ int* pal_num,
+ void** pal_pp,
+ int* bg_index,
+ CFX_DIBAttribute* pAttribute);
+
+ int32_t LoadFrameInfo(FXGIF_Context* pContext, int* frame_num);
+
+ int32_t LoadFrame(FXGIF_Context* pContext,
+ int frame_num,
+ CFX_DIBAttribute* pAttribute);
+
+ void (*RecordCurrentPositionCallback)(void* pModule, uint32_t& cur_pos);
+ uint8_t* (*AskLocalPaletteBufCallback)(void* pModule,
+ int32_t frame_num,
+ int32_t pal_size);
+ FX_BOOL (*InputRecordPositionBufCallback)(void* pModule,
+ uint32_t rcd_pos,
+ const FX_RECT& img_rc,
+ int32_t pal_num,
+ void* pal_ptr,
+ int32_t delay_time,
+ FX_BOOL user_input,
+ int32_t trans_index,
+ int32_t disposal_method,
+ FX_BOOL interlace);
+ void (*ReadScanlineCallback)(void* pModule,
+ int32_t row_num,
+ uint8_t* row_buf);
+
+ protected:
+ FX_CHAR m_szLastError[256];
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_GIFMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_iccmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_iccmodule.h
new file mode 100644
index 00000000000..9eabd384827
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_iccmodule.h
@@ -0,0 +1,95 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_
+
+#include "core/fxcodec/include/fx_codec_def.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CFX_BinaryBuf;
+class CFX_IccProfileCache;
+class CFX_IccTransformCache;
+class CFX_PrivateData;
+class IFX_FileRead;
+
+class CCodec_IccModule {
+ public:
+ enum IccCS {
+ IccCS_Unknown = 0,
+ IccCS_XYZ,
+ IccCS_Lab,
+ IccCS_Luv,
+ IccCS_YCbCr,
+ IccCS_Yxy,
+ IccCS_Hsv,
+ IccCS_Hls,
+ IccCS_Gray,
+ IccCS_Rgb,
+ IccCS_Cmyk,
+ IccCS_Cmy
+ };
+
+ struct IccParam {
+ uint32_t Version;
+ IccCS ColorSpace;
+ uint32_t dwProfileType;
+ uint32_t dwFormat;
+ uint8_t* pProfileData;
+ uint32_t dwProfileSize;
+ double Gamma;
+ };
+
+ ~CCodec_IccModule();
+
+ IccCS GetProfileCS(const uint8_t* pProfileData, unsigned int dwProfileSize);
+ IccCS GetProfileCS(IFX_FileRead* pFile);
+ void* CreateTransform(CCodec_IccModule::IccParam* pInputParam,
+ CCodec_IccModule::IccParam* pOutputParam,
+ CCodec_IccModule::IccParam* pProofParam = nullptr,
+ uint32_t dwIntent = Icc_INTENT_PERCEPTUAL,
+ uint32_t dwFlag = Icc_FLAGS_DEFAULT,
+ uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
+ uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING);
+ void* CreateTransform_sRGB(const uint8_t* pProfileData,
+ uint32_t dwProfileSize,
+ uint32_t& nComponents,
+ int32_t intent = 0,
+ uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT);
+ void* CreateTransform_CMYK(const uint8_t* pSrcProfileData,
+ uint32_t dwSrcProfileSize,
+ uint32_t& nSrcComponents,
+ const uint8_t* pDstProfileData,
+ uint32_t dwDstProfileSize,
+ int32_t intent = 0,
+ uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT,
+ uint32_t dwDstFormat = Icc_FORMAT_DEFAULT);
+ void DestroyTransform(void* pTransform);
+ void Translate(void* pTransform, FX_FLOAT* pSrcValues, FX_FLOAT* pDestValues);
+ void TranslateScanline(void* pTransform,
+ uint8_t* pDest,
+ const uint8_t* pSrc,
+ int pixels);
+ void SetComponents(uint32_t nComponents) { m_nComponents = nComponents; }
+
+ protected:
+ enum Icc_CLASS {
+ Icc_CLASS_INPUT = 0,
+ Icc_CLASS_OUTPUT,
+ Icc_CLASS_PROOF,
+ Icc_CLASS_MAX
+ };
+ void* CreateProfile(CCodec_IccModule::IccParam* pIccParam,
+ Icc_CLASS ic,
+ CFX_BinaryBuf* pTransformKey);
+
+ uint32_t m_nComponents;
+ std::map<CFX_ByteString, CFX_IccTransformCache*> m_MapTranform;
+ std::map<CFX_ByteString, CFX_IccProfileCache*> m_MapProfile;
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jbig2module.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jbig2module.h
new file mode 100644
index 00000000000..20578c8cdb8
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jbig2module.h
@@ -0,0 +1,34 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_StreamAcc;
+class IFX_Pause;
+
+class CCodec_Jbig2Module {
+ public:
+ CCodec_Jbig2Module() {}
+ ~CCodec_Jbig2Module();
+
+ void* CreateJbig2Context();
+ FXCODEC_STATUS StartDecode(void* pJbig2Context,
+ CFX_PrivateData* pPrivateData,
+ uint32_t width,
+ uint32_t height,
+ CPDF_StreamAcc* src_stream,
+ CPDF_StreamAcc* global_stream,
+ uint8_t* dest_buf,
+ uint32_t dest_pitch,
+ IFX_Pause* pPause);
+ FXCODEC_STATUS ContinueDecode(void* pJbig2Context, IFX_Pause* pPause);
+ void DestroyJbig2Context(void* pJbig2Context);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_JBIG2MODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jpegmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jpegmodule.h
new file mode 100644
index 00000000000..98554fea1ca
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jpegmodule.h
@@ -0,0 +1,68 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_ScanlineDecoder;
+class CFX_DIBSource;
+struct FXJPEG_Context;
+
+#ifdef PDF_ENABLE_XFA
+class CFX_DIBAttribute;
+#endif // PDF_ENABLE_XFA
+
+class CCodec_JpegModule {
+ public:
+ CCodec_JpegModule() {}
+ CCodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ int nComps,
+ FX_BOOL ColorTransform);
+ FX_BOOL LoadInfo(const uint8_t* src_buf,
+ uint32_t src_size,
+ int& width,
+ int& height,
+ int& num_components,
+ int& bits_per_components,
+ FX_BOOL& color_transform,
+ uint8_t** icc_buf_ptr = nullptr,
+ uint32_t* icc_length = nullptr);
+ FX_BOOL Encode(const CFX_DIBSource* pSource,
+ uint8_t*& dest_buf,
+ FX_STRSIZE& dest_size,
+ int quality = 75,
+ const uint8_t* icc_buf = nullptr,
+ uint32_t icc_length = 0);
+ FXJPEG_Context* Start();
+ void Finish(FXJPEG_Context* pContext);
+ void Input(FXJPEG_Context* pContext,
+ const uint8_t* src_buf,
+ uint32_t src_size);
+
+#ifndef PDF_ENABLE_XFA
+ int ReadHeader(FXJPEG_Context* pContext,
+ int* width,
+ int* height,
+ int* nComps);
+#else // PDF_ENABLE_XFA
+ int ReadHeader(FXJPEG_Context* pContext,
+ int* width,
+ int* height,
+ int* nComps,
+ CFX_DIBAttribute* pAttribute);
+#endif // PDF_ENABLE_XFA
+
+ int StartScanline(FXJPEG_Context* pContext, int down_scale);
+ FX_BOOL ReadScanline(FXJPEG_Context* pContext, uint8_t* dest_buf);
+ uint32_t GetAvailInput(FXJPEG_Context* pContext, uint8_t** avail_buf_ptr);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_JPEGMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jpxmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jpxmodule.h
new file mode 100644
index 00000000000..149e8a7c9a6
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_jpxmodule.h
@@ -0,0 +1,36 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_
+
+#include <vector>
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CJPX_Decoder;
+class CPDF_ColorSpace;
+
+class CCodec_JpxModule {
+ public:
+ CCodec_JpxModule();
+ ~CCodec_JpxModule();
+
+ CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
+ uint32_t src_size,
+ CPDF_ColorSpace* cs);
+ void GetImageInfo(CJPX_Decoder* pDecoder,
+ uint32_t* width,
+ uint32_t* height,
+ uint32_t* components);
+ bool Decode(CJPX_Decoder* pDecoder,
+ uint8_t* dest_data,
+ int pitch,
+ const std::vector<uint8_t>& offsets);
+ void DestroyDecoder(CJPX_Decoder* pDecoder);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_JPXMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_pngmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_pngmodule.h
new file mode 100644
index 00000000000..23b5d4b5b99
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_pngmodule.h
@@ -0,0 +1,42 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CFX_DIBAttribute;
+struct FXPNG_Context;
+
+#define PNG_ERROR_SIZE 256
+
+class CCodec_PngModule {
+ public:
+ CCodec_PngModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); }
+
+ FXPNG_Context* Start(void* pModule);
+ void Finish(FXPNG_Context* pContext);
+ FX_BOOL Input(FXPNG_Context* pContext,
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ CFX_DIBAttribute* pAttribute);
+
+ FX_BOOL (*ReadHeaderCallback)(void* pModule,
+ int width,
+ int height,
+ int bpc,
+ int pass,
+ int* color_type,
+ double* gamma);
+ FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf);
+ void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line);
+
+ protected:
+ FX_CHAR m_szLastError[PNG_ERROR_SIZE];
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_scanlinedecoder.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_scanlinedecoder.h
new file mode 100644
index 00000000000..cd18c8d76ec
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_scanlinedecoder.h
@@ -0,0 +1,46 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_SCANLINEDECODER_H_
+#define CORE_FXCODEC_CODEC_CCODEC_SCANLINEDECODER_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class IFX_Pause;
+
+class CCodec_ScanlineDecoder {
+ public:
+ CCodec_ScanlineDecoder();
+ virtual ~CCodec_ScanlineDecoder();
+
+ const uint8_t* GetScanline(int line);
+ FX_BOOL SkipToScanline(int line, IFX_Pause* pPause);
+
+ int GetWidth() { return m_OutputWidth; }
+ int GetHeight() { return m_OutputHeight; }
+ int CountComps() { return m_nComps; }
+ int GetBPC() { return m_bpc; }
+
+ virtual uint32_t GetSrcOffset() = 0;
+
+ protected:
+ virtual FX_BOOL v_Rewind() = 0;
+ virtual uint8_t* v_GetNextLine() = 0;
+
+ uint8_t* ReadNextLine();
+
+ int m_OrigWidth;
+ int m_OrigHeight;
+ int m_OutputWidth;
+ int m_OutputHeight;
+ int m_nComps;
+ int m_bpc;
+ uint32_t m_Pitch;
+ int m_NextLine;
+ uint8_t* m_pLastScanline;
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_SCANLINEDECODER_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_tiffmodule.h b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_tiffmodule.h
new file mode 100644
index 00000000000..d746bb7e85c
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/ccodec_tiffmodule.h
@@ -0,0 +1,35 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_
+#define CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+
+class CCodec_TiffContext;
+class CFX_DIBAttribute;
+class CFX_DIBitmap;
+class IFX_FileRead;
+
+class CCodec_TiffModule {
+ public:
+ ~CCodec_TiffModule() {}
+
+ CCodec_TiffContext* CreateDecoder(IFX_FileRead* file_ptr);
+
+ void GetFrames(CCodec_TiffContext* ctx, int32_t& frames);
+ FX_BOOL LoadFrameInfo(CCodec_TiffContext* ctx,
+ int32_t frame,
+ uint32_t& width,
+ uint32_t& height,
+ uint32_t& comps,
+ uint32_t& bpc,
+ CFX_DIBAttribute* pAttribute);
+ FX_BOOL Decode(CCodec_TiffContext* ctx, class CFX_DIBitmap* pDIBitmap);
+ void DestroyDecoder(CCodec_TiffContext* ctx);
+};
+
+#endif // CORE_FXCODEC_CODEC_CCODEC_TIFFMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/codec_int.h b/chromium/third_party/pdfium/core/fxcodec/codec/codec_int.h
index c7bd9fc6fe1..e0d2ff494fe 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/codec_int.h
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/codec_int.h
@@ -14,395 +14,12 @@
#include <memory>
#include <vector>
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcodec/jbig2/JBig2_Context.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T.
+#include "third_party/libopenjpeg20/openjpeg.h"
-class CFX_IccProfileCache;
-class CFX_IccTransformCache;
class CPDF_ColorSpace;
-class CCodec_BasicModule : public ICodec_BasicModule {
- public:
- // ICodec_BasicModule:
- FX_BOOL RunLengthEncode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) override;
- FX_BOOL A85Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) override;
- ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- int bpc) override;
-};
-
-class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder {
- public:
- CCodec_ScanlineDecoder();
- ~CCodec_ScanlineDecoder() override;
-
- // ICodec_ScanlineDecoder
- void DownScale(int dest_width, int dest_height) override;
- const uint8_t* GetScanline(int line) override;
- FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) override;
- int GetWidth() override { return m_OutputWidth; }
- int GetHeight() override { return m_OutputHeight; }
- int CountComps() override { return m_nComps; }
- int GetBPC() override { return m_bpc; }
- FX_BOOL IsColorTransformed() override { return m_bColorTransformed; }
- void ClearImageData() override { m_pDataCache.reset(); }
-
- protected:
- class ImageDataCache {
- public:
- ImageDataCache(int width, int height, uint32_t pitch);
- ~ImageDataCache();
-
- bool AllocateCache();
- void AppendLine(const uint8_t* line);
-
- int NumLines() const { return m_nCachedLines; }
- const uint8_t* GetLine(int line) const;
- bool IsSameDimensions(int width, int height) const {
- return width == m_Width && height == m_Height;
- }
-
- private:
- bool IsValid() const { return m_Data.get() != nullptr; }
-
- const int m_Width;
- const int m_Height;
- const uint32_t m_Pitch;
- int m_nCachedLines;
- std::unique_ptr<uint8_t, FxFreeDeleter> m_Data;
- };
-
- virtual FX_BOOL v_Rewind() = 0;
- virtual uint8_t* v_GetNextLine() = 0;
- virtual void v_DownScale(int dest_width, int dest_height) = 0;
-
- uint8_t* ReadNextLine();
-
- int m_OrigWidth;
- int m_OrigHeight;
- int m_DownScale;
- int m_OutputWidth;
- int m_OutputHeight;
- int m_nComps;
- int m_bpc;
- uint32_t m_Pitch;
- FX_BOOL m_bColorTransformed;
- int m_NextLine;
- uint8_t* m_pLastScanline;
- std::unique_ptr<ImageDataCache> m_pDataCache;
-};
-
-class CCodec_FaxModule : public ICodec_FaxModule {
- public:
- // ICodec_FaxModule:
- ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int K,
- FX_BOOL EndOfLine,
- FX_BOOL EncodedByteAlign,
- FX_BOOL BlackIs1,
- int Columns,
- int Rows) override;
- FX_BOOL Encode(const uint8_t* src_buf,
- int width,
- int height,
- int pitch,
- uint8_t*& dest_buf,
- uint32_t& dest_size) override;
-};
-
-class CCodec_FlateModule : public ICodec_FlateModule {
- public:
- virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- int bpc,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns);
- virtual uint32_t FlateOrLZWDecode(FX_BOOL bLZW,
- const uint8_t* src_buf,
- uint32_t src_size,
- FX_BOOL bEarlyChange,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint32_t estimated_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size);
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- uint32_t src_size,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint8_t*& dest_buf,
- uint32_t& dest_size);
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size);
-};
-
-class CCodec_JpegModule : public ICodec_JpegModule {
- public:
- CCodec_JpegModule() {}
- ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- FX_BOOL ColorTransform) override;
- FX_BOOL LoadInfo(const uint8_t* src_buf,
- uint32_t src_size,
- int& width,
- int& height,
- int& num_components,
- int& bits_per_components,
- FX_BOOL& color_transform,
- uint8_t** icc_buf_ptr,
- uint32_t* icc_length) override;
- FX_BOOL Encode(const CFX_DIBSource* pSource,
- uint8_t*& dest_buf,
- FX_STRSIZE& dest_size,
- int quality,
- const uint8_t* icc_buf,
- uint32_t icc_length) override;
- void* Start() override;
- void Finish(void* pContext) override;
- void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) override;
-#ifndef PDF_ENABLE_XFA
- int ReadHeader(void* pContext, int* width, int* height, int* nComps) override;
-#else // PDF_ENABLE_XFA
- int ReadHeader(void* pContext,
- int* width,
- int* height,
- int* nComps,
- CFX_DIBAttribute* pAttribute) override;
-#endif // PDF_ENABLE_XFA
- int StartScanline(void* pContext, int down_scale) override;
- FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) override;
- uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override;
-};
-
-#ifdef PDF_ENABLE_XFA
-#define PNG_ERROR_SIZE 256
-class CCodec_PngModule : public ICodec_PngModule {
- public:
- CCodec_PngModule() { FXSYS_memset(m_szLastError, '\0', PNG_ERROR_SIZE); }
-
- virtual void* Start(void* pModule);
- virtual void Finish(void* pContext);
- virtual FX_BOOL Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_DIBAttribute* pAttribute);
-
- protected:
- FX_CHAR m_szLastError[PNG_ERROR_SIZE];
-};
-class CCodec_GifModule : public ICodec_GifModule {
- public:
- CCodec_GifModule() { FXSYS_memset(m_szLastError, '\0', 256); }
- virtual void* Start(void* pModule);
- virtual void Finish(void* pContext);
- virtual uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr);
- virtual void Input(void* pContext, const uint8_t* src_buf, uint32_t src_size);
-
- virtual int32_t ReadHeader(void* pContext,
- int* width,
- int* height,
- int* pal_num,
- void** pal_pp,
- int* bg_index,
- CFX_DIBAttribute* pAttribute);
-
- virtual int32_t LoadFrameInfo(void* pContext, int* frame_num);
-
- virtual int32_t LoadFrame(void* pContext,
- int frame_num,
- CFX_DIBAttribute* pAttribute);
-
- protected:
- FX_CHAR m_szLastError[256];
-};
-class CCodec_BmpModule : public ICodec_BmpModule {
- public:
- CCodec_BmpModule() { FXSYS_memset(m_szLastError, 0, sizeof(m_szLastError)); }
- void* Start(void* pModule) override;
- void Finish(void* pContext) override;
- uint32_t GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override;
- void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) override;
- int32_t ReadHeader(void* pContext,
- int32_t* width,
- int32_t* height,
- FX_BOOL* tb_flag,
- int32_t* components,
- int32_t* pal_num,
- uint32_t** pal_pp,
- CFX_DIBAttribute* pAttribute) override;
- int32_t LoadImage(void* pContext) override;
-
- protected:
- FX_CHAR m_szLastError[256];
-};
-#endif // PDF_ENABLE_XFA
-
-class CCodec_IccModule : public ICodec_IccModule {
- public:
- ~CCodec_IccModule() override;
-
- // ICodec_IccModule:
- IccCS GetProfileCS(const uint8_t* pProfileData,
- unsigned int dwProfileSize) override;
- IccCS GetProfileCS(IFX_FileRead* pFile) override;
- void* CreateTransform(ICodec_IccModule::IccParam* pInputParam,
- ICodec_IccModule::IccParam* pOutputParam,
- ICodec_IccModule::IccParam* pProofParam = NULL,
- uint32_t dwIntent = Icc_INTENT_PERCEPTUAL,
- uint32_t dwFlag = Icc_FLAGS_DEFAULT,
- uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
- uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING) override;
- void* CreateTransform_sRGB(
- const uint8_t* pProfileData,
- uint32_t dwProfileSize,
- uint32_t& nComponents,
- int32_t intent = 0,
- uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT) override;
- void* CreateTransform_CMYK(
- const uint8_t* pSrcProfileData,
- uint32_t dwSrcProfileSize,
- uint32_t& nSrcComponents,
- const uint8_t* pDstProfileData,
- uint32_t dwDstProfileSize,
- int32_t intent = 0,
- uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT,
- uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) override;
- void DestroyTransform(void* pTransform) override;
- void Translate(void* pTransform,
- FX_FLOAT* pSrcValues,
- FX_FLOAT* pDestValues) override;
- void TranslateScanline(void* pTransform,
- uint8_t* pDest,
- const uint8_t* pSrc,
- int pixels) override;
- void SetComponents(uint32_t nComponents) override {
- m_nComponents = nComponents;
- }
-
- protected:
- enum Icc_CLASS {
- Icc_CLASS_INPUT = 0,
- Icc_CLASS_OUTPUT,
- Icc_CLASS_PROOF,
- Icc_CLASS_MAX
- };
- void* CreateProfile(ICodec_IccModule::IccParam* pIccParam,
- Icc_CLASS ic,
- CFX_BinaryBuf* pTransformKey);
-
- uint32_t m_nComponents;
- std::map<CFX_ByteString, CFX_IccTransformCache*> m_MapTranform;
- std::map<CFX_ByteString, CFX_IccProfileCache*> m_MapProfile;
-};
-
-class CCodec_JpxModule : public ICodec_JpxModule {
- public:
- CCodec_JpxModule();
- ~CCodec_JpxModule() override;
-
- // ICodec_JpxModule:
- CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- CPDF_ColorSpace* cs) override;
- void GetImageInfo(CJPX_Decoder* pDecoder,
- uint32_t* width,
- uint32_t* height,
- uint32_t* components) override;
- bool Decode(CJPX_Decoder* pDecoder,
- uint8_t* dest_data,
- int pitch,
- const std::vector<uint8_t>& offsets) override;
- void DestroyDecoder(CJPX_Decoder* pDecoder) override;
-};
-
-#ifdef PDF_ENABLE_XFA
-class CCodec_TiffModule : public ICodec_TiffModule {
- public:
- // ICodec_TiffModule
- void* CreateDecoder(IFX_FileRead* file_ptr) override;
- void GetFrames(void* ctx, int32_t& frames) override;
- FX_BOOL LoadFrameInfo(void* ctx,
- int32_t frame,
- uint32_t& width,
- uint32_t& height,
- uint32_t& comps,
- uint32_t& bpc,
- CFX_DIBAttribute* pAttribute) override;
- FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) override;
- void DestroyDecoder(void* ctx) override;
-
- protected:
- ~CCodec_TiffModule() override {}
-};
-#endif // PDF_ENABLE_XFA
-
-class CCodec_Jbig2Context {
- public:
- CCodec_Jbig2Context();
- ~CCodec_Jbig2Context() {}
-
- uint32_t m_width;
- uint32_t m_height;
- CPDF_StreamAcc* m_pGlobalStream;
- CPDF_StreamAcc* m_pSrcStream;
- uint8_t* m_dest_buf;
- uint32_t m_dest_pitch;
- IFX_Pause* m_pPause;
- CJBig2_Context* m_pContext;
- CJBig2_Image* m_dest_image;
-};
-class CCodec_Jbig2Module : public ICodec_Jbig2Module {
- public:
- CCodec_Jbig2Module() {}
- ~CCodec_Jbig2Module() override;
-
- // ICodec_Jbig2Module
- void* CreateJbig2Context() override;
- FXCODEC_STATUS StartDecode(void* pJbig2Context,
- CFX_PrivateData* pPrivateData,
- uint32_t width,
- uint32_t height,
- CPDF_StreamAcc* src_stream,
- CPDF_StreamAcc* global_stream,
- uint8_t* dest_buf,
- uint32_t dest_pitch,
- IFX_Pause* pPause) override;
- FXCODEC_STATUS ContinueDecode(void* pJbig2Context,
- IFX_Pause* pPause) override;
- void DestroyJbig2Context(void* pJbig2Context) override;
-};
-
struct DecodeData {
public:
DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size)
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec.cpp
index 0952c809ac8..f0f03ab0e93 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec.cpp
@@ -4,9 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fxcodec/include/fx_codec.h"
#include <cmath>
+#include <memory>
#include <utility>
#include "core/fxcodec/codec/codec_int.h"
@@ -30,55 +31,12 @@ CCodec_ModuleMgr::CCodec_ModuleMgr()
m_pFlateModule(new CCodec_FlateModule) {
}
-CCodec_ScanlineDecoder::ImageDataCache::ImageDataCache(int width,
- int height,
- uint32_t pitch)
- : m_Width(width), m_Height(height), m_Pitch(pitch), m_nCachedLines(0) {}
-
-CCodec_ScanlineDecoder::ImageDataCache::~ImageDataCache() {}
-
-bool CCodec_ScanlineDecoder::ImageDataCache::AllocateCache() {
- if (m_Pitch == 0 || m_Height < 0)
- return false;
-
- FX_SAFE_SIZE_T size = m_Pitch;
- size *= m_Height;
- if (!size.IsValid())
- return false;
-
- m_Data.reset(FX_TryAlloc(uint8_t, size.ValueOrDie()));
- return IsValid();
-}
-
-void CCodec_ScanlineDecoder::ImageDataCache::AppendLine(const uint8_t* line) {
- // If the callers adds more lines than there is room, fail.
- if (m_Pitch == 0 || m_nCachedLines >= m_Height) {
- NOTREACHED();
- return;
- }
-
- size_t offset = m_Pitch;
- FXSYS_memcpy(m_Data.get() + offset * m_nCachedLines, line, m_Pitch);
- ++m_nCachedLines;
-}
-
-const uint8_t* CCodec_ScanlineDecoder::ImageDataCache::GetLine(int line) const {
- if (m_Pitch == 0 || line < 0 || line >= m_nCachedLines)
- return nullptr;
-
- size_t offset = m_Pitch;
- return m_Data.get() + offset * line;
-}
-
CCodec_ScanlineDecoder::CCodec_ScanlineDecoder()
: m_NextLine(-1), m_pLastScanline(nullptr) {}
CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder() {}
const uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) {
- if (m_pDataCache && line < m_pDataCache->NumLines())
- return m_pDataCache->GetLine(line);
-
if (m_NextLine == line + 1)
return m_pLastScanline;
@@ -97,9 +55,6 @@ const uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) {
}
FX_BOOL CCodec_ScanlineDecoder::SkipToScanline(int line, IFX_Pause* pPause) {
- if (m_pDataCache && line < m_pDataCache->NumLines())
- return FALSE;
-
if (m_NextLine == line || m_NextLine == line + 1)
return FALSE;
@@ -119,31 +74,7 @@ FX_BOOL CCodec_ScanlineDecoder::SkipToScanline(int line, IFX_Pause* pPause) {
}
uint8_t* CCodec_ScanlineDecoder::ReadNextLine() {
- uint8_t* pLine = v_GetNextLine();
- if (!pLine)
- return nullptr;
-
- if (m_pDataCache && m_NextLine == m_pDataCache->NumLines())
- m_pDataCache->AppendLine(pLine);
- return pLine;
-}
-
-void CCodec_ScanlineDecoder::DownScale(int dest_width, int dest_height) {
- dest_width = std::abs(dest_width);
- dest_height = std::abs(dest_height);
- v_DownScale(dest_width, dest_height);
-
- if (m_pDataCache &&
- m_pDataCache->IsSameDimensions(m_OutputWidth, m_OutputHeight)) {
- return;
- }
-
- std::unique_ptr<ImageDataCache> cache(
- new ImageDataCache(m_OutputWidth, m_OutputHeight, m_Pitch));
- if (!cache->AllocateCache())
- return;
-
- m_pDataCache = std::move(cache);
+ return v_GetNextLine();
}
FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf,
@@ -294,7 +225,6 @@ class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder {
int bpc);
// CCodec_ScanlineDecoder
- void v_DownScale(int dest_width, int dest_height) override {}
FX_BOOL v_Rewind() override;
uint8_t* v_GetNextLine() override;
uint32_t GetSrcOffset() override { return m_SrcOffset; }
@@ -364,10 +294,8 @@ FX_BOOL CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf,
m_OutputHeight = m_OrigHeight = height;
m_nComps = nComps;
m_bpc = bpc;
- m_bColorTransformed = FALSE;
- m_DownScale = 1;
// Aligning the pitch to 4 bytes requires an integer overflow check.
- FX_SAFE_DWORD pitch = width;
+ FX_SAFE_UINT32 pitch = width;
pitch *= nComps;
pitch *= bpc;
pitch += 31;
@@ -447,7 +375,7 @@ void CCodec_RLScanlineDecoder::UpdateOperator(uint8_t used_bytes) {
return;
}
if (m_Operator < 128) {
- FXSYS_assert((uint32_t)m_Operator + 1 >= used_bytes);
+ ASSERT((uint32_t)m_Operator + 1 >= used_bytes);
if (used_bytes == m_Operator + 1) {
m_SrcOffset += used_bytes;
GetNextOperator();
@@ -461,7 +389,7 @@ void CCodec_RLScanlineDecoder::UpdateOperator(uint8_t used_bytes) {
return;
}
uint8_t count = 257 - m_Operator;
- FXSYS_assert((uint32_t)count >= used_bytes);
+ ASSERT((uint32_t)count >= used_bytes);
if (used_bytes == count) {
m_SrcOffset++;
GetNextOperator();
@@ -470,18 +398,20 @@ void CCodec_RLScanlineDecoder::UpdateOperator(uint8_t used_bytes) {
count -= used_bytes;
m_Operator = 257 - count;
}
-ICodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder(
+
+CCodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
int height,
int nComps,
int bpc) {
- CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder;
+ std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder(
+ new CCodec_RLScanlineDecoder);
if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps,
bpc)) {
- delete pRLScanlineDecoder;
- return NULL;
+ return nullptr;
}
- return pRLScanlineDecoder;
+
+ return pRLScanlineDecoder.release();
}
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_bmp.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_bmp.cpp
index 31383774aac..03390cfea3d 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_bmp.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_bmp.cpp
@@ -5,9 +5,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxcodec/codec/codec_int.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcodec/lbmp/fx_bmp.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
struct FXBMP_Context {
bmp_decompress_struct_p bmp_ptr;
void* parent_ptr;
@@ -42,24 +42,25 @@ static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr,
CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr;
return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos);
}
-void* CCodec_BmpModule::Start(void* pModule) {
- FXBMP_Context* p = (FXBMP_Context*)FX_Alloc(uint8_t, sizeof(FXBMP_Context));
- if (p == NULL) {
- return NULL;
- }
+
+FXBMP_Context* CCodec_BmpModule::Start(void* pModule) {
+ FXBMP_Context* p = FX_Alloc(FXBMP_Context, 1);
+ if (!p)
+ return nullptr;
+
FXSYS_memset(p, 0, sizeof(FXBMP_Context));
- if (p == NULL) {
- return NULL;
- }
+ if (!p)
+ return nullptr;
+
p->m_AllocFunc = bmp_alloc_func;
p->m_FreeFunc = bmp_free_func;
- p->bmp_ptr = NULL;
+ p->bmp_ptr = nullptr;
p->parent_ptr = (void*)this;
p->child_ptr = pModule;
p->bmp_ptr = bmp_create_decompress();
- if (p->bmp_ptr == NULL) {
+ if (!p->bmp_ptr) {
FX_Free(p);
- return NULL;
+ return nullptr;
}
p->bmp_ptr->context_ptr = (void*)p;
p->bmp_ptr->err_ptr = m_szLastError;
@@ -68,14 +69,14 @@ void* CCodec_BmpModule::Start(void* pModule) {
p->bmp_ptr->bmp_get_data_position_fn = bmp_get_data_position;
return p;
}
-void CCodec_BmpModule::Finish(void* pContext) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- if (p) {
- bmp_destroy_decompress(&p->bmp_ptr);
- p->m_FreeFunc(p);
+
+void CCodec_BmpModule::Finish(FXBMP_Context* ctx) {
+ if (ctx) {
+ bmp_destroy_decompress(&ctx->bmp_ptr);
+ ctx->m_FreeFunc(ctx);
}
}
-int32_t CCodec_BmpModule::ReadHeader(void* pContext,
+int32_t CCodec_BmpModule::ReadHeader(FXBMP_Context* ctx,
int32_t* width,
int32_t* height,
FX_BOOL* tb_flag,
@@ -83,43 +84,41 @@ int32_t CCodec_BmpModule::ReadHeader(void* pContext,
int32_t* pal_num,
uint32_t** pal_pp,
CFX_DIBAttribute* pAttribute) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- if (setjmp(p->bmp_ptr->jmpbuf)) {
+ if (setjmp(ctx->bmp_ptr->jmpbuf)) {
return 0;
}
- int32_t ret = bmp_read_header(p->bmp_ptr);
+ int32_t ret = bmp_read_header(ctx->bmp_ptr);
if (ret != 1) {
return ret;
}
- *width = p->bmp_ptr->width;
- *height = p->bmp_ptr->height;
- *tb_flag = p->bmp_ptr->imgTB_flag;
- *components = p->bmp_ptr->components;
- *pal_num = p->bmp_ptr->pal_num;
- *pal_pp = p->bmp_ptr->pal_ptr;
+ *width = ctx->bmp_ptr->width;
+ *height = ctx->bmp_ptr->height;
+ *tb_flag = ctx->bmp_ptr->imgTB_flag;
+ *components = ctx->bmp_ptr->components;
+ *pal_num = ctx->bmp_ptr->pal_num;
+ *pal_pp = ctx->bmp_ptr->pal_ptr;
if (pAttribute) {
pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER;
- pAttribute->m_nXDPI = p->bmp_ptr->dpi_x;
- pAttribute->m_nYDPI = p->bmp_ptr->dpi_y;
- pAttribute->m_nBmpCompressType = p->bmp_ptr->compress_flag;
+ pAttribute->m_nXDPI = ctx->bmp_ptr->dpi_x;
+ pAttribute->m_nYDPI = ctx->bmp_ptr->dpi_y;
+ pAttribute->m_nBmpCompressType = ctx->bmp_ptr->compress_flag;
}
return 1;
}
-int32_t CCodec_BmpModule::LoadImage(void* pContext) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- if (setjmp(p->bmp_ptr->jmpbuf)) {
+
+int32_t CCodec_BmpModule::LoadImage(FXBMP_Context* ctx) {
+ if (setjmp(ctx->bmp_ptr->jmpbuf))
return 0;
- }
- return bmp_decode_image(p->bmp_ptr);
+ return bmp_decode_image(ctx->bmp_ptr);
}
-uint32_t CCodec_BmpModule::GetAvailInput(void* pContext,
+
+uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx,
uint8_t** avial_buf_ptr) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- return bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr);
+ return bmp_get_avail_input(ctx->bmp_ptr, avial_buf_ptr);
}
-void CCodec_BmpModule::Input(void* pContext,
+
+void CCodec_BmpModule::Input(FXBMP_Context* ctx,
const uint8_t* src_buf,
uint32_t src_size) {
- FXBMP_Context* p = (FXBMP_Context*)pContext;
- bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size);
+ bmp_input_buffer(ctx->bmp_ptr, (uint8_t*)src_buf, src_size);
}
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_fax.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_fax.cpp
index 0ccebba14e2..97b7ee2ad6e 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_fax.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_fax.cpp
@@ -5,7 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxcodec/codec/codec_int.h"
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fxcodec/include/fx_codec.h"
namespace {
@@ -132,11 +132,6 @@ void FaxFillBits(uint8_t* dest_buf, int columns, int startpos, int endpos) {
#define NEXTBIT \
src_buf[bitpos / 8] & (1 << (7 - bitpos % 8)); \
bitpos++;
-#define ADDBIT(code, bit) \
- code = code << 1; \
- if (bit) \
- code++;
-#define GETBIT(bitpos) src_buf[bitpos / 8] & (1 << (7 - bitpos % 8))
const uint8_t FaxBlackRunIns[] = {
0, 2, 0x02, 3, 0, 0x03,
@@ -613,7 +608,6 @@ class CCodec_FaxDecoder : public CCodec_ScanlineDecoder {
int Rows);
// CCodec_ScanlineDecoder
- void v_DownScale(int dest_width, int dest_height) override {}
FX_BOOL v_Rewind() override;
uint8_t* v_GetNextLine() override;
uint32_t GetSrcOffset() override;
@@ -666,7 +660,6 @@ FX_BOOL CCodec_FaxDecoder::Create(const uint8_t* src_buf,
m_SrcSize = src_size;
m_nComps = 1;
m_bpc = 1;
- m_bColorTransformed = FALSE;
return TRUE;
}
FX_BOOL CCodec_FaxDecoder::v_Rewind() {
@@ -812,7 +805,7 @@ FX_BOOL CCodec_FaxModule::Encode(const uint8_t* src_buf,
encoder.Encode(dest_buf, dest_size);
return TRUE;
}
-ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(
+CCodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_flate.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
index 6961dcccb3b..c23de277fb6 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_flate.cpp
@@ -9,9 +9,9 @@
#include <algorithm>
#include <memory>
+#include "core/fxcodec/include/fx_codec.h"
+#include "core/fxcodec/include/fx_codec_flate.h"
#include "core/fxcrt/include/fx_ext.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxcodec/fx_codec_flate.h"
#include "third_party/zlib_v128/zlib.h"
extern "C" {
@@ -750,10 +750,8 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder {
int Colors,
int BitsPerComponent,
int Columns);
- void Destroy() { delete this; }
// CCodec_ScanlineDecoder
- void v_DownScale(int dest_width, int dest_height) override {}
FX_BOOL v_Rewind() override;
uint8_t* v_GetNextLine() override;
uint32_t GetSrcOffset() override;
@@ -806,7 +804,6 @@ void CCodec_FlateScanlineDecoder::Create(const uint8_t* src_buf,
m_OutputHeight = m_OrigHeight = height;
m_nComps = nComps;
m_bpc = bpc;
- m_bColorTransformed = FALSE;
m_Pitch = (static_cast<uint32_t>(width) * nComps * bpc + 7) / 8;
m_pScanline = FX_Alloc(uint8_t, m_Pitch);
m_Predictor = 0;
@@ -899,7 +896,7 @@ uint32_t CCodec_FlateScanlineDecoder::GetSrcOffset() {
return FPDFAPI_FlateGetTotalIn(m_pFlate);
}
-ICodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder(
+CCodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_gif.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_gif.cpp
index 1657d7257e1..13576412c2f 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_gif.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_gif.cpp
@@ -5,9 +5,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxcodec/codec/codec_int.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcodec/lgif/fx_gif.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
struct FXGIF_Context {
gif_decompress_struct_p gif_ptr;
void* parent_ptr;
@@ -69,21 +69,22 @@ static FX_BOOL gif_get_record_position(gif_decompress_struct_p gif_ptr,
pal_num, pal_ptr, delay_time, user_input, trans_index, disposal_method,
interlace);
}
-void* CCodec_GifModule::Start(void* pModule) {
- FXGIF_Context* p = (FXGIF_Context*)FX_Alloc(uint8_t, sizeof(FXGIF_Context));
- if (p == NULL) {
- return NULL;
- }
+
+FXGIF_Context* CCodec_GifModule::Start(void* pModule) {
+ FXGIF_Context* p = FX_Alloc(FXGIF_Context, 1);
+ if (!p)
+ return nullptr;
+
FXSYS_memset(p, 0, sizeof(FXGIF_Context));
p->m_AllocFunc = gif_alloc_func;
p->m_FreeFunc = gif_free_func;
- p->gif_ptr = NULL;
+ p->gif_ptr = nullptr;
p->parent_ptr = (void*)this;
p->child_ptr = pModule;
p->gif_ptr = gif_create_decompress();
- if (p->gif_ptr == NULL) {
+ if (!p->gif_ptr) {
FX_Free(p);
- return NULL;
+ return nullptr;
}
p->gif_ptr->context_ptr = (void*)p;
p->gif_ptr->err_ptr = m_szLastError;
@@ -94,74 +95,72 @@ void* CCodec_GifModule::Start(void* pModule) {
p->gif_ptr->gif_get_record_position_fn = gif_get_record_position;
return p;
}
-void CCodec_GifModule::Finish(void* pContext) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (p) {
- gif_destroy_decompress(&p->gif_ptr);
- p->m_FreeFunc(p);
+
+void CCodec_GifModule::Finish(FXGIF_Context* ctx) {
+ if (ctx) {
+ gif_destroy_decompress(&ctx->gif_ptr);
+ ctx->m_FreeFunc(ctx);
}
}
-int32_t CCodec_GifModule::ReadHeader(void* pContext,
+
+int32_t CCodec_GifModule::ReadHeader(FXGIF_Context* ctx,
int* width,
int* height,
int* pal_num,
void** pal_pp,
int* bg_index,
CFX_DIBAttribute* pAttribute) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (setjmp(p->gif_ptr->jmpbuf)) {
+ if (setjmp(ctx->gif_ptr->jmpbuf))
return 0;
- }
- int32_t ret = gif_read_header(p->gif_ptr);
- if (ret != 1) {
+
+ int32_t ret = gif_read_header(ctx->gif_ptr);
+ if (ret != 1)
return ret;
- }
- if (pAttribute) {
- }
- *width = p->gif_ptr->width;
- *height = p->gif_ptr->height;
- *pal_num = p->gif_ptr->global_pal_num;
- *pal_pp = p->gif_ptr->global_pal_ptr;
- *bg_index = p->gif_ptr->bc_index;
+
+ *width = ctx->gif_ptr->width;
+ *height = ctx->gif_ptr->height;
+ *pal_num = ctx->gif_ptr->global_pal_num;
+ *pal_pp = ctx->gif_ptr->global_pal_ptr;
+ *bg_index = ctx->gif_ptr->bc_index;
return 1;
}
-int32_t CCodec_GifModule::LoadFrameInfo(void* pContext, int* frame_num) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (setjmp(p->gif_ptr->jmpbuf)) {
+
+int32_t CCodec_GifModule::LoadFrameInfo(FXGIF_Context* ctx, int* frame_num) {
+ if (setjmp(ctx->gif_ptr->jmpbuf))
return 0;
- }
- int32_t ret = gif_get_frame(p->gif_ptr);
- if (ret != 1) {
+
+ int32_t ret = gif_get_frame(ctx->gif_ptr);
+ if (ret != 1)
return ret;
- }
- *frame_num = gif_get_frame_num(p->gif_ptr);
+
+ *frame_num = gif_get_frame_num(ctx->gif_ptr);
return 1;
}
-int32_t CCodec_GifModule::LoadFrame(void* pContext,
+
+int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx,
int frame_num,
CFX_DIBAttribute* pAttribute) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- if (setjmp(p->gif_ptr->jmpbuf)) {
+ if (setjmp(ctx->gif_ptr->jmpbuf))
return 0;
- }
- int32_t ret = gif_load_frame(p->gif_ptr, frame_num);
+
+ int32_t ret = gif_load_frame(ctx->gif_ptr, frame_num);
if (ret == 1) {
if (pAttribute) {
pAttribute->m_nGifLeft =
- p->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left;
+ ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left;
pAttribute->m_nGifTop =
- p->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top;
- pAttribute->m_fAspectRatio = p->gif_ptr->pixel_aspect;
- if (p->gif_ptr->cmt_data_ptr) {
+ ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top;
+ pAttribute->m_fAspectRatio = ctx->gif_ptr->pixel_aspect;
+ if (ctx->gif_ptr->cmt_data_ptr) {
const uint8_t* buf =
- (const uint8_t*)p->gif_ptr->cmt_data_ptr->GetBuffer(0);
- uint32_t len = p->gif_ptr->cmt_data_ptr->GetLength();
+ (const uint8_t*)ctx->gif_ptr->cmt_data_ptr->GetBuffer(0);
+ uint32_t len = ctx->gif_ptr->cmt_data_ptr->GetLength();
if (len > 21) {
uint8_t size = *buf++;
if (size) {
pAttribute->m_strAuthor = CFX_ByteString(buf, size);
} else {
- pAttribute->m_strAuthor.Empty();
+ pAttribute->m_strAuthor.clear();
}
buf += size;
size = *buf++;
@@ -174,14 +173,14 @@ int32_t CCodec_GifModule::LoadFrame(void* pContext,
}
return ret;
}
-uint32_t CCodec_GifModule::GetAvailInput(void* pContext,
+
+uint32_t CCodec_GifModule::GetAvailInput(FXGIF_Context* ctx,
uint8_t** avial_buf_ptr) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- return gif_get_avail_input(p->gif_ptr, avial_buf_ptr);
+ return gif_get_avail_input(ctx->gif_ptr, avial_buf_ptr);
}
-void CCodec_GifModule::Input(void* pContext,
+
+void CCodec_GifModule::Input(FXGIF_Context* ctx,
const uint8_t* src_buf,
uint32_t src_size) {
- FXGIF_Context* p = (FXGIF_Context*)pContext;
- gif_input_buffer(p->gif_ptr, (uint8_t*)src_buf, src_size);
+ gif_input_buffer(ctx->gif_ptr, (uint8_t*)src_buf, src_size);
}
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_icc.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_icc.cpp
index 13280d7f49d..876297fd40f 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_icc.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_icc.cpp
@@ -5,7 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxcodec/codec/codec_int.h"
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "third_party/lcms2-2.6/include/lcms2.h"
const uint32_t N_COMPONENT_LAB = 3;
@@ -251,41 +251,41 @@ void* CreateProfile_Gray(double gamma) {
cmsFreeToneCurve(curve);
return profile;
}
-ICodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) {
+CCodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) {
if (!pProfile) {
- return ICodec_IccModule::IccCS_Unknown;
+ return CCodec_IccModule::IccCS_Unknown;
}
switch (cmsGetColorSpace(pProfile)) {
case cmsSigXYZData:
- return ICodec_IccModule::IccCS_XYZ;
+ return CCodec_IccModule::IccCS_XYZ;
case cmsSigLabData:
- return ICodec_IccModule::IccCS_Lab;
+ return CCodec_IccModule::IccCS_Lab;
case cmsSigLuvData:
- return ICodec_IccModule::IccCS_Luv;
+ return CCodec_IccModule::IccCS_Luv;
case cmsSigYCbCrData:
- return ICodec_IccModule::IccCS_YCbCr;
+ return CCodec_IccModule::IccCS_YCbCr;
case cmsSigYxyData:
- return ICodec_IccModule::IccCS_Yxy;
+ return CCodec_IccModule::IccCS_Yxy;
case cmsSigRgbData:
- return ICodec_IccModule::IccCS_Rgb;
+ return CCodec_IccModule::IccCS_Rgb;
case cmsSigGrayData:
- return ICodec_IccModule::IccCS_Gray;
+ return CCodec_IccModule::IccCS_Gray;
case cmsSigHsvData:
- return ICodec_IccModule::IccCS_Hsv;
+ return CCodec_IccModule::IccCS_Hsv;
case cmsSigHlsData:
- return ICodec_IccModule::IccCS_Hls;
+ return CCodec_IccModule::IccCS_Hls;
case cmsSigCmykData:
- return ICodec_IccModule::IccCS_Cmyk;
+ return CCodec_IccModule::IccCS_Cmyk;
case cmsSigCmyData:
- return ICodec_IccModule::IccCS_Cmy;
+ return CCodec_IccModule::IccCS_Cmy;
default:
- return ICodec_IccModule::IccCS_Unknown;
+ return CCodec_IccModule::IccCS_Unknown;
}
}
-ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
+CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
const uint8_t* pProfileData,
uint32_t dwProfileSize) {
- ICodec_IccModule::IccCS cs;
+ CCodec_IccModule::IccCS cs;
cmsHPROFILE hProfile =
cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize);
if (!hProfile) {
@@ -297,11 +297,11 @@ ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
}
return cs;
}
-ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) {
+CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) {
if (!pFile) {
return IccCS_Unknown;
}
- ICodec_IccModule::IccCS cs;
+ CCodec_IccModule::IccCS cs;
uint32_t dwSize = (uint32_t)pFile->GetSize();
uint8_t* pBuf = FX_Alloc(uint8_t, dwSize);
pFile->ReadBlock(pBuf, 0, dwSize);
@@ -406,7 +406,7 @@ CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) {
AppendBlock(&i, sizeof(uint32_t));
return *this;
}
-void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam,
+void* CCodec_IccModule::CreateProfile(CCodec_IccModule::IccParam* pIccParam,
Icc_CLASS ic,
CFX_BinaryBuf* pTransformKey) {
CFX_IccProfileCache* pCache = NULL;
@@ -469,9 +469,9 @@ void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam,
return pCache->m_pProfile;
}
void* CCodec_IccModule::CreateTransform(
- ICodec_IccModule::IccParam* pInputParam,
- ICodec_IccModule::IccParam* pOutputParam,
- ICodec_IccModule::IccParam* pProofParam,
+ CCodec_IccModule::IccParam* pInputParam,
+ CCodec_IccModule::IccParam* pOutputParam,
+ CCodec_IccModule::IccParam* pProofParam,
uint32_t dwIntent,
uint32_t dwFlag,
uint32_t dwPrfIntent,
@@ -500,7 +500,7 @@ void* CCodec_IccModule::CreateTransform(
}
key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag
<< (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag;
- CFX_ByteStringC TransformKey(key.GetBuffer(), key.GetSize());
+ CFX_ByteString TransformKey(key.GetBuffer(), key.GetSize());
CFX_IccTransformCache* pTransformCache;
auto it = m_MapTranform.find(TransformKey);
if (it == m_MapTranform.end()) {
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jbig.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jbig.cpp
index ddcec6c6bb8..b5e32f130dd 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jbig.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jbig.cpp
@@ -7,7 +7,27 @@
#include <list>
#include "core/fxcodec/codec/codec_int.h"
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fxcodec/include/fx_codec.h"
+
+namespace {
+
+class CCodec_Jbig2Context {
+ public:
+ CCodec_Jbig2Context();
+ ~CCodec_Jbig2Context() {}
+
+ uint32_t m_width;
+ uint32_t m_height;
+ CPDF_StreamAcc* m_pGlobalStream;
+ CPDF_StreamAcc* m_pSrcStream;
+ uint8_t* m_dest_buf;
+ uint32_t m_dest_pitch;
+ IFX_Pause* m_pPause;
+ CJBig2_Context* m_pContext;
+ CJBig2_Image* m_dest_image;
+};
+
+} // namespace
// Holds per-document JBig2 related data.
class JBig2DocumentContext : public CFX_DestructObject {
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
index a81926e053a..c41dde943f0 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpeg.cpp
@@ -7,9 +7,9 @@
#include <setjmp.h>
#include "core/fxcodec/codec/codec_int.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcrt/include/fx_safe_types.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
extern "C" {
#undef FAR
@@ -142,7 +142,7 @@ static void _JpegEncode(const CFX_DIBSource* pSource,
uint32_t pitch = pSource->GetPitch();
uint32_t width = pdfium::base::checked_cast<uint32_t>(pSource->GetWidth());
uint32_t height = pdfium::base::checked_cast<uint32_t>(pSource->GetHeight());
- FX_SAFE_DWORD safe_buf_len = width;
+ FX_SAFE_UINT32 safe_buf_len = width;
safe_buf_len *= height;
safe_buf_len *= nComponents;
safe_buf_len += 1024;
@@ -318,10 +318,8 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder {
int height,
int nComps,
FX_BOOL ColorTransform);
- void Destroy() { delete this; }
// CCodec_ScanlineDecoder
- void v_DownScale(int dest_width, int dest_height) override;
FX_BOOL v_Rewind() override;
uint8_t* v_GetNextLine() override;
uint32_t GetSrcOffset() override;
@@ -346,7 +344,6 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder {
CCodec_JpegDecoder::CCodec_JpegDecoder() {
m_pScanlineBuf = NULL;
- m_DownScale = 1;
m_bStarted = FALSE;
m_bInited = FALSE;
FXSYS_memset(&cinfo, 0, sizeof(cinfo));
@@ -437,41 +434,10 @@ FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf,
m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch);
m_nComps = cinfo.num_components;
m_bpc = 8;
- m_bColorTransformed = FALSE;
m_bStarted = FALSE;
return TRUE;
}
-extern "C" {
-int32_t FX_GetDownsampleRatio(int32_t originWidth,
- int32_t originHeight,
- int32_t downsampleWidth,
- int32_t downsampleHeight) {
- int iratio_w = originWidth / downsampleWidth;
- int iratio_h = originHeight / downsampleHeight;
- int ratio = (iratio_w > iratio_h) ? iratio_h : iratio_w;
- if (ratio >= 8) {
- return 8;
- }
- if (ratio >= 4) {
- return 4;
- }
- if (ratio >= 2) {
- return 2;
- }
- return 1;
-}
-}
-void CCodec_JpegDecoder::v_DownScale(int dest_width, int dest_height) {
- int old_scale = m_DownScale;
- m_DownScale =
- FX_GetDownsampleRatio(m_OrigWidth, m_OrigHeight, dest_width, dest_height);
- m_OutputWidth = (m_OrigWidth + m_DownScale - 1) / m_DownScale;
- m_OutputHeight = (m_OrigHeight + m_DownScale - 1) / m_DownScale;
- m_Pitch = (static_cast<uint32_t>(m_OutputWidth) * m_nComps + 3) / 4 * 4;
- if (old_scale != m_DownScale) {
- m_NextLine = -1;
- }
-}
+
FX_BOOL CCodec_JpegDecoder::v_Rewind() {
if (m_bStarted) {
jpeg_destroy_decompress(&cinfo);
@@ -482,15 +448,15 @@ FX_BOOL CCodec_JpegDecoder::v_Rewind() {
if (setjmp(m_JmpBuf) == -1) {
return FALSE;
}
- cinfo.scale_denom = m_nDefaultScaleDenom * m_DownScale;
- m_OutputWidth = (m_OrigWidth + m_DownScale - 1) / m_DownScale;
- m_OutputHeight = (m_OrigHeight + m_DownScale - 1) / m_DownScale;
+ cinfo.scale_denom = m_nDefaultScaleDenom;
+ m_OutputWidth = m_OrigWidth;
+ m_OutputHeight = m_OrigHeight;
if (!jpeg_start_decompress(&cinfo)) {
jpeg_destroy_decompress(&cinfo);
return FALSE;
}
if ((int)cinfo.output_width > m_OrigWidth) {
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
return FALSE;
}
m_bStarted = TRUE;
@@ -509,7 +475,7 @@ uint8_t* CCodec_JpegDecoder::v_GetNextLine() {
uint32_t CCodec_JpegDecoder::GetSrcOffset() {
return (uint32_t)(m_SrcSize - src.bytes_in_buffer);
}
-ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
+CCodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
const uint8_t* src_buf,
uint32_t src_size,
int width,
@@ -584,7 +550,7 @@ static void* jpeg_alloc_func(unsigned int size) {
static void jpeg_free_func(void* p) {
FX_Free(p);
}
-void* CCodec_JpegModule::Start() {
+FXJPEG_Context* CCodec_JpegModule::Start() {
FXJPEG_Context* p = FX_Alloc(FXJPEG_Context, 1);
p->m_AllocFunc = jpeg_alloc_func;
p->m_FreeFunc = jpeg_free_func;
@@ -608,85 +574,83 @@ void* CCodec_JpegModule::Start() {
p->m_SkipSize = 0;
return p;
}
-void CCodec_JpegModule::Finish(void* pContext) {
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- jpeg_destroy_decompress(&p->m_Info);
- p->m_FreeFunc(p);
+
+void CCodec_JpegModule::Finish(FXJPEG_Context* ctx) {
+ jpeg_destroy_decompress(&ctx->m_Info);
+ ctx->m_FreeFunc(ctx);
}
-void CCodec_JpegModule::Input(void* pContext,
+
+void CCodec_JpegModule::Input(FXJPEG_Context* ctx,
const unsigned char* src_buf,
uint32_t src_size) {
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- if (p->m_SkipSize) {
- if (p->m_SkipSize > src_size) {
- p->m_SrcMgr.bytes_in_buffer = 0;
- p->m_SkipSize -= src_size;
+ if (ctx->m_SkipSize) {
+ if (ctx->m_SkipSize > src_size) {
+ ctx->m_SrcMgr.bytes_in_buffer = 0;
+ ctx->m_SkipSize -= src_size;
return;
}
- src_size -= p->m_SkipSize;
- src_buf += p->m_SkipSize;
- p->m_SkipSize = 0;
+ src_size -= ctx->m_SkipSize;
+ src_buf += ctx->m_SkipSize;
+ ctx->m_SkipSize = 0;
}
- p->m_SrcMgr.next_input_byte = src_buf;
- p->m_SrcMgr.bytes_in_buffer = src_size;
+ ctx->m_SrcMgr.next_input_byte = src_buf;
+ ctx->m_SrcMgr.bytes_in_buffer = src_size;
}
#ifdef PDF_ENABLE_XFA
-int CCodec_JpegModule::ReadHeader(void* pContext,
+int CCodec_JpegModule::ReadHeader(FXJPEG_Context* ctx,
int* width,
int* height,
int* nComps,
CFX_DIBAttribute* pAttribute) {
#else // PDF_ENABLE_XFA
-int CCodec_JpegModule::ReadHeader(void* pContext,
+int CCodec_JpegModule::ReadHeader(FXJPEG_Context* ctx,
int* width,
int* height,
int* nComps) {
#endif // PDF_ENABLE_XFA
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- if (setjmp(p->m_JumpMark) == -1) {
+ if (setjmp(ctx->m_JumpMark) == -1)
return 1;
- }
- int ret = jpeg_read_header(&p->m_Info, true);
- if (ret == JPEG_SUSPENDED) {
+
+ int ret = jpeg_read_header(&ctx->m_Info, true);
+ if (ret == JPEG_SUSPENDED)
return 2;
- }
- if (ret != JPEG_HEADER_OK) {
+ if (ret != JPEG_HEADER_OK)
return 1;
- }
- *width = p->m_Info.image_width;
- *height = p->m_Info.image_height;
- *nComps = p->m_Info.num_components;
+
+ *width = ctx->m_Info.image_width;
+ *height = ctx->m_Info.image_height;
+ *nComps = ctx->m_Info.num_components;
#ifdef PDF_ENABLE_XFA
- _JpegLoadAttribute(&p->m_Info, pAttribute);
+ _JpegLoadAttribute(&ctx->m_Info, pAttribute);
#endif
return 0;
}
-int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) {
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- if (setjmp(p->m_JumpMark) == -1) {
+
+int CCodec_JpegModule::StartScanline(FXJPEG_Context* ctx, int down_scale) {
+ if (setjmp(ctx->m_JumpMark) == -1)
return 0;
- }
- p->m_Info.scale_denom = down_scale;
- return jpeg_start_decompress(&p->m_Info);
+
+ ctx->m_Info.scale_denom = down_scale;
+ return jpeg_start_decompress(&ctx->m_Info);
}
-FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext,
+
+FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx,
unsigned char* dest_buf) {
- FXJPEG_Context* p = (FXJPEG_Context*)pContext;
- if (setjmp(p->m_JumpMark) == -1) {
+ if (setjmp(ctx->m_JumpMark) == -1)
return FALSE;
- }
- int nlines = jpeg_read_scanlines(&p->m_Info, &dest_buf, 1);
+
+ int nlines = jpeg_read_scanlines(&ctx->m_Info, &dest_buf, 1);
return nlines == 1;
}
-uint32_t CCodec_JpegModule::GetAvailInput(void* pContext,
+
+uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx,
uint8_t** avail_buf_ptr) {
if (avail_buf_ptr) {
*avail_buf_ptr = NULL;
- if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) {
- *avail_buf_ptr =
- (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte;
+ if (ctx->m_SrcMgr.bytes_in_buffer > 0) {
+ *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte;
}
}
- return (uint32_t)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer;
+ return (uint32_t)ctx->m_SrcMgr.bytes_in_buffer;
}
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpx_opj.cpp
index 27b645c1370..a0f2e65c753 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -10,8 +10,8 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h"
#include "core/fxcodec/codec/codec_int.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcrt/include/fx_safe_types.h"
-#include "core/include/fxcodec/fx_codec.h"
#include "third_party/lcms2-2.6/include/lcms2.h"
#include "third_party/libopenjpeg20/openjpeg.h"
@@ -169,14 +169,15 @@ static void sycc_to_rgb(int offset,
}
*out_b = b;
}
+
static void sycc444_to_rgb(opj_image_t* img) {
int prec = img->comps[0].prec;
int offset = 1 << (prec - 1);
int upb = (1 << prec) - 1;
OPJ_UINT32 maxw =
- std::min(std::min(img->comps[0].w, img->comps[1].w), img->comps[2].w);
+ std::min({img->comps[0].w, img->comps[1].w, img->comps[2].w});
OPJ_UINT32 maxh =
- std::min(std::min(img->comps[0].h, img->comps[1].h), img->comps[2].h);
+ std::min({img->comps[0].h, img->comps[1].h, img->comps[2].h});
FX_SAFE_SIZE_T max_size = maxw;
max_size *= maxh;
if (!max_size.IsValid())
@@ -185,10 +186,15 @@ static void sycc444_to_rgb(opj_image_t* img) {
const int* y = img->comps[0].data;
const int* cb = img->comps[1].data;
const int* cr = img->comps[2].data;
- int *d0, *d1, *d2, *r, *g, *b;
- d0 = r = FX_Alloc(int, max_size.ValueOrDie());
- d1 = g = FX_Alloc(int, max_size.ValueOrDie());
- d2 = b = FX_Alloc(int, max_size.ValueOrDie());
+ if (!y || !cb || !cr)
+ return;
+
+ int* r = FX_Alloc(int, max_size.ValueOrDie());
+ int* g = FX_Alloc(int, max_size.ValueOrDie());
+ int* b = FX_Alloc(int, max_size.ValueOrDie());
+ int* d0 = r;
+ int* d1 = g;
+ int* d2 = b;
for (size_t i = 0; i < max_size.ValueOrDie(); ++i) {
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
++y;
@@ -199,12 +205,13 @@ static void sycc444_to_rgb(opj_image_t* img) {
++b;
}
FX_Free(img->comps[0].data);
- img->comps[0].data = d0;
FX_Free(img->comps[1].data);
- img->comps[1].data = d1;
FX_Free(img->comps[2].data);
+ img->comps[0].data = d0;
+ img->comps[1].data = d1;
img->comps[2].data = d2;
}
+
static bool sycc420_422_size_is_valid(opj_image_t* img) {
return (img && img->comps[0].w != std::numeric_limits<OPJ_UINT32>::max() &&
(img->comps[0].w + 1) / 2 == img->comps[1].w &&
@@ -301,7 +308,7 @@ void sycc420_to_rgb(opj_image_t* img) {
OPJ_UINT32 crw = img->comps[2].w;
bool extw = sycc420_must_extend_cbcr(yw, cbw);
bool exth = sycc420_must_extend_cbcr(yh, cbh);
- FX_SAFE_DWORD safeSize = yw;
+ FX_SAFE_UINT32 safeSize = yw;
safeSize *= yh;
if (!safeSize.IsValid())
return;
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_png.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_png.cpp
index f8621001b6f..61d4cebdbba 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_png.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_png.cpp
@@ -7,8 +7,8 @@
#include <algorithm>
#include "core/fxcodec/codec/codec_int.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxcodec/include/fx_codec.h"
+#include "core/fxge/include/fx_dib.h"
extern "C" {
#undef FAR
@@ -82,9 +82,9 @@ static void _png_load_bmp_attribute(png_structp png_ptr,
} else {
buf = "Author";
if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) {
- pAttribute->m_strAuthor.Empty();
- pAttribute->m_strAuthor.Load((uint8_t*)text[i].text,
- (FX_STRSIZE)text[i].text_length);
+ pAttribute->m_strAuthor =
+ CFX_ByteString(reinterpret_cast<uint8_t*>(text[i].text),
+ static_cast<FX_STRSIZE>(text[i].text_length));
}
}
}
@@ -195,34 +195,36 @@ static void _png_get_row_func(png_structp png_ptr,
}
pModule->FillScanlineBufCompletedCallback(p->child_ptr, pass, row_num);
}
-void* CCodec_PngModule::Start(void* pModule) {
+
+FXPNG_Context* CCodec_PngModule::Start(void* pModule) {
FXPNG_Context* p = (FXPNG_Context*)FX_Alloc(uint8_t, sizeof(FXPNG_Context));
- if (p == NULL) {
- return NULL;
- }
+ if (!p)
+ return nullptr;
+
p->m_AllocFunc = _png_alloc_func;
p->m_FreeFunc = _png_free_func;
- p->png_ptr = NULL;
- p->info_ptr = NULL;
+ p->png_ptr = nullptr;
+ p->info_ptr = nullptr;
p->parent_ptr = (void*)this;
p->child_ptr = pModule;
- p->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (p->png_ptr == NULL) {
+ p->png_ptr =
+ png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
+ if (!p->png_ptr) {
FX_Free(p);
- return NULL;
+ return nullptr;
}
p->info_ptr = png_create_info_struct(p->png_ptr);
- if (p->info_ptr == NULL) {
- png_destroy_read_struct(&(p->png_ptr), (png_infopp)NULL, (png_infopp)NULL);
+ if (!p->info_ptr) {
+ png_destroy_read_struct(&(p->png_ptr), nullptr, nullptr);
FX_Free(p);
- return NULL;
+ return nullptr;
}
if (setjmp(png_jmpbuf(p->png_ptr))) {
if (p) {
- png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), (png_infopp)NULL);
+ png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), nullptr);
FX_Free(p);
}
- return NULL;
+ return nullptr;
}
png_set_progressive_read_fn(p->png_ptr, p, _png_get_header_func,
_png_get_row_func, _png_get_end_func);
@@ -230,25 +232,25 @@ void* CCodec_PngModule::Start(void* pModule) {
(png_error_ptr)_png_warning_data);
return p;
}
-void CCodec_PngModule::Finish(void* pContext) {
- FXPNG_Context* p = (FXPNG_Context*)pContext;
- if (p) {
- png_destroy_read_struct(&(p->png_ptr), &(p->info_ptr), (png_infopp)NULL);
- p->m_FreeFunc(p);
+
+void CCodec_PngModule::Finish(FXPNG_Context* ctx) {
+ if (ctx) {
+ png_destroy_read_struct(&(ctx->png_ptr), &(ctx->info_ptr), nullptr);
+ ctx->m_FreeFunc(ctx);
}
}
-FX_BOOL CCodec_PngModule::Input(void* pContext,
+
+FX_BOOL CCodec_PngModule::Input(FXPNG_Context* ctx,
const uint8_t* src_buf,
uint32_t src_size,
CFX_DIBAttribute* pAttribute) {
- FXPNG_Context* p = (FXPNG_Context*)pContext;
- if (setjmp(png_jmpbuf(p->png_ptr))) {
+ if (setjmp(png_jmpbuf(ctx->png_ptr))) {
if (pAttribute &&
0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) {
- _png_load_bmp_attribute(p->png_ptr, p->info_ptr, pAttribute);
+ _png_load_bmp_attribute(ctx->png_ptr, ctx->info_ptr, pAttribute);
}
return FALSE;
}
- png_process_data(p->png_ptr, p->info_ptr, (uint8_t*)src_buf, src_size);
+ png_process_data(ctx->png_ptr, ctx->info_ptr, (uint8_t*)src_buf, src_size);
return TRUE;
}
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_progress.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_progress.cpp
index 9e113c695cd..95a90b3e689 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_progress.cpp
@@ -4,18 +4,26 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcodec/codec/fx_codec_progress.h"
+#include "core/fxcodec/codec/include/ccodec_progressivedecoder.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxcodec/include/fx_codec.h"
+#include "core/fxge/include/fx_dib.h"
-void CFXCODEC_WeightTable::Calc(int dest_len,
- int dest_min,
- int dest_max,
- int src_len,
- int src_min,
- int src_max,
- FX_BOOL bInterpol) {
+#define FXCODEC_BLOCK_SIZE 4096
+#define FXCODEC_PNG_GAMMA 2.2
+
+#if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
+#undef FXCODEC_PNG_GAMMA
+#define FXCODEC_PNG_GAMMA 1.7
+#endif
+
+void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len,
+ int dest_min,
+ int dest_max,
+ int src_len,
+ int src_min,
+ int src_max,
+ FX_BOOL bInterpol) {
if (m_pWeightTables) {
FX_Free(m_pWeightTables);
}
@@ -113,7 +121,9 @@ void CFXCODEC_WeightTable::Calc(int dest_len,
}
}
}
-void CFXCODEC_HorzTable::Calc(int dest_len, int src_len, FX_BOOL bInterpol) {
+void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len,
+ int src_len,
+ FX_BOOL bInterpol) {
if (m_pWeightTables) {
FX_Free(m_pWeightTables);
}
@@ -173,7 +183,8 @@ void CFXCODEC_HorzTable::Calc(int dest_len, int src_len, FX_BOOL bInterpol) {
pWeight->m_Weights[1] = 0;
}
}
-void CFXCODEC_VertTable::Calc(int dest_len, int src_len) {
+void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
+ int src_len) {
if (m_pWeightTables) {
FX_Free(m_pWeightTables);
}
@@ -294,7 +305,7 @@ CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
FX_Free(m_pSrcPalette);
}
FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData(
- ICodec_JpegModule* pJpegModule,
+ CCodec_JpegModule* pJpegModule,
FXCODEC_STATUS& err_status) {
uint32_t dwSize = (uint32_t)m_pFile->GetSize();
if (dwSize <= m_offSet) {
@@ -552,7 +563,7 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc(void* pModule,
}
}
}
-FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(ICodec_GifModule* pGifModule,
+FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule,
FXCODEC_STATUS& err_status) {
uint32_t dwSize = (uint32_t)m_pFile->GetSize();
if (dwSize <= m_offSet) {
@@ -834,7 +845,7 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert(
GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y);
}
}
-FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(ICodec_BmpModule* pBmpModule,
+FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule,
FXCODEC_STATUS& err_status) {
uint32_t dwSize = (uint32_t)m_pFile->GetSize();
if (dwSize <= m_offSet) {
@@ -1008,7 +1019,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
m_SrcSize = size;
switch (imageType) {
case FXCODEC_IMAGE_BMP: {
- ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
+ CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
if (pBmpModule == NULL) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
@@ -1063,7 +1074,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
return FALSE;
} break;
case FXCODEC_IMAGE_JPG: {
- ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
+ CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
if (pJpegModule == NULL) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
@@ -1106,7 +1117,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
return FALSE;
} break;
case FXCODEC_IMAGE_PNG: {
- ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
+ CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
if (pPngModule == NULL) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
@@ -1167,7 +1178,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
}
} break;
case FXCODEC_IMAGE_GIF: {
- ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
+ CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
if (pGifModule == NULL) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
@@ -1219,7 +1230,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
return FALSE;
} break;
case FXCODEC_IMAGE_TIF: {
- ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
+ CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
if (pTiffModule == NULL) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
@@ -1799,7 +1810,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames,
frames = m_FrameNumber = 1;
return m_status = FXCODEC_STATUS_DECODE_READY;
case FXCODEC_IMAGE_GIF: {
- ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
+ CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
while (TRUE) {
int32_t readResult =
pGifModule->LoadFrameInfo(m_pGifContext, &m_FrameNumber);
@@ -1888,7 +1899,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
}
switch (m_imagType) {
case FXCODEC_IMAGE_JPG: {
- ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
+ CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
int down_scale = 1;
GetDownScale(down_scale);
FX_BOOL bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale);
@@ -1924,7 +1935,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
} break;
case FXCODEC_IMAGE_PNG: {
- ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
+ CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
if (pPngModule == NULL) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
@@ -1972,7 +1983,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
} break;
case FXCODEC_IMAGE_GIF: {
- ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
+ CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
if (pGifModule == NULL) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
@@ -1991,7 +2002,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
return m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
} break;
case FXCODEC_IMAGE_BMP: {
- ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
+ CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
if (pBmpModule == NULL) {
m_pDeviceBitmap = NULL;
m_pFile = NULL;
@@ -2031,7 +2042,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
switch (m_imagType) {
case FXCODEC_IMAGE_JPG: {
- ICodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
+ CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
while (TRUE) {
FX_BOOL readRes =
pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf);
@@ -2061,7 +2072,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
} break;
case FXCODEC_IMAGE_PNG: {
- ICodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
+ CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
while (TRUE) {
uint32_t remain_size = (uint32_t)m_pFile->GetSize() - m_offSet;
uint32_t input_size =
@@ -2101,7 +2112,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
} break;
case FXCODEC_IMAGE_GIF: {
- ICodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
+ CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
while (TRUE) {
int32_t readRes =
pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
@@ -2128,7 +2139,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
} break;
case FXCODEC_IMAGE_BMP: {
- ICodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
+ CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
while (TRUE) {
int32_t readRes = pBmpModule->LoadImage(m_pBmpContext);
while (readRes == 2) {
@@ -2154,7 +2165,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
} break;
case FXCODEC_IMAGE_TIF: {
- ICodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
+ CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
FX_BOOL ret = FALSE;
if (m_pDeviceBitmap->GetBPP() == 32 &&
m_pDeviceBitmap->GetWidth() == m_SrcWidth && m_SrcWidth == m_sizeX &&
@@ -2296,6 +2307,6 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
return FXCODEC_STATUS_ERROR;
}
-ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() {
+CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() {
return new CCodec_ProgressiveDecoder(this);
}
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_tiff.cpp b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_tiff.cpp
index 96249f9d147..d4dc1392655 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_tiff.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_tiff.cpp
@@ -5,8 +5,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxcodec/codec/codec_int.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxcodec/include/fx_codec.h"
+#include "core/fxge/include/fx_dib.h"
extern "C" {
#include "third_party/libtiff/tiffiop.h"
@@ -512,33 +512,35 @@ FX_BOOL CCodec_TiffContext::Decode(CFX_DIBitmap* pDIBitmap) {
}
return FALSE;
}
-void* CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr) {
+
+CCodec_TiffContext* CCodec_TiffModule::CreateDecoder(IFX_FileRead* file_ptr) {
CCodec_TiffContext* pDecoder = new CCodec_TiffContext;
if (!pDecoder->InitDecoder(file_ptr)) {
delete pDecoder;
- return NULL;
+ return nullptr;
}
return pDecoder;
}
-void CCodec_TiffModule::GetFrames(void* ctx, int32_t& frames) {
- CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx;
- pDecoder->GetFrames(frames);
+
+void CCodec_TiffModule::GetFrames(CCodec_TiffContext* ctx, int32_t& frames) {
+ ctx->GetFrames(frames);
}
-FX_BOOL CCodec_TiffModule::LoadFrameInfo(void* ctx,
+
+FX_BOOL CCodec_TiffModule::LoadFrameInfo(CCodec_TiffContext* ctx,
int32_t frame,
uint32_t& width,
uint32_t& height,
uint32_t& comps,
uint32_t& bpc,
CFX_DIBAttribute* pAttribute) {
- CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx;
- return pDecoder->LoadFrameInfo(frame, width, height, comps, bpc, pAttribute);
+ return ctx->LoadFrameInfo(frame, width, height, comps, bpc, pAttribute);
}
-FX_BOOL CCodec_TiffModule::Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) {
- CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx;
- return pDecoder->Decode(pDIBitmap);
+
+FX_BOOL CCodec_TiffModule::Decode(CCodec_TiffContext* ctx,
+ class CFX_DIBitmap* pDIBitmap) {
+ return ctx->Decode(pDIBitmap);
}
-void CCodec_TiffModule::DestroyDecoder(void* ctx) {
- CCodec_TiffContext* pDecoder = (CCodec_TiffContext*)ctx;
- delete pDecoder;
+
+void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) {
+ delete ctx;
}
diff --git a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_progress.h b/chromium/third_party/pdfium/core/fxcodec/codec/include/ccodec_progressivedecoder.h
index ccd52a95b13..83b73e1ba7c 100644
--- a/chromium/third_party/pdfium/core/fxcodec/codec/fx_codec_progress.h
+++ b/chromium/third_party/pdfium/core/fxcodec/codec/include/ccodec_progressivedecoder.h
@@ -4,108 +4,161 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_
-#define CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_
+#ifndef CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_
+#define CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_
-#include "core/fxcrt/include/fx_memory.h"
+#include "core/fxcodec/include/fx_codec_def.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_dib.h"
-
-#define FXCODEC_BLOCK_SIZE 4096
-#define FXCODEC_PNG_GAMMA 2.2
-
-#if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
-#undef FXCODEC_PNG_GAMMA
-#define FXCODEC_PNG_GAMMA 1.7
-#endif
-
-struct PixelWeight {
- int m_SrcStart;
- int m_SrcEnd;
- int m_Weights[1];
-};
-
-class CFXCODEC_WeightTable {
- public:
- CFXCODEC_WeightTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); }
-
- void Calc(int dest_len,
- int dest_min,
- int dest_max,
- int src_len,
- int src_min,
- int src_max,
- FX_BOOL bInterpol);
- PixelWeight* GetPixelWeight(int pixel) {
- return (PixelWeight*)(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize);
- }
-
- int m_DestMin, m_ItemSize;
- uint8_t* m_pWeightTables;
-};
-class CFXCODEC_HorzTable {
+#include "core/fxge/include/fx_dib.h"
+
+class CCodec_BmpModule;
+class CCodec_GifContext;
+class CCodec_GifModule;
+class CCodec_JpegModule;
+class CCodec_ModuleMgr;
+class CCodec_PngContext;
+class CCodec_TiffContext;
+class CFX_DIBAttribute;
+class IFX_FileRead;
+class IFX_Pause;
+struct FXBMP_Context;
+struct FXGIF_Context;
+struct FXJPEG_Context;
+struct FXPNG_Context;
+
+class CCodec_ProgressiveDecoder {
public:
- CFXCODEC_HorzTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); }
-
- void Calc(int dest_len, int src_len, FX_BOOL bInterpol);
- PixelWeight* GetPixelWeight(int pixel) {
- return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
- }
+ enum FXCodec_Format {
+ FXCodec_Invalid = 0,
+ FXCodec_1bppGray = 0x101,
+ FXCodec_1bppRgb = 0x001,
+ FXCodec_8bppGray = 0x108,
+ FXCodec_8bppRgb = 0x008,
+ FXCodec_Rgb = 0x018,
+ FXCodec_Rgb32 = 0x020,
+ FXCodec_Argb = 0x220,
+ FXCodec_Cmyk = 0x120
+ };
- int m_ItemSize;
- uint8_t* m_pWeightTables;
-};
-class CFXCODEC_VertTable {
- public:
- CFXCODEC_VertTable() { m_pWeightTables = NULL; }
- ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); }
- void Calc(int dest_len, int src_len);
- PixelWeight* GetPixelWeight(int pixel) {
- return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
- }
- int m_ItemSize;
- uint8_t* m_pWeightTables;
-};
-enum FXCodec_Format {
- FXCodec_Invalid = 0,
- FXCodec_1bppGray = 0x101,
- FXCodec_1bppRgb = 0x001,
- FXCodec_8bppGray = 0x108,
- FXCodec_8bppRgb = 0x008,
- FXCodec_Rgb = 0x018,
- FXCodec_Rgb32 = 0x020,
- FXCodec_Argb = 0x220,
- FXCodec_Cmyk = 0x120
-};
-class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder {
- public:
CCodec_ProgressiveDecoder(CCodec_ModuleMgr* pCodecMgr);
- ~CCodec_ProgressiveDecoder() override;
+ ~CCodec_ProgressiveDecoder();
FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile,
FXCODEC_IMAGE_TYPE imageType,
- CFX_DIBAttribute* pAttribute) override;
+ CFX_DIBAttribute* pAttribute);
- FXCODEC_IMAGE_TYPE GetType() const override { return m_imagType; }
- int32_t GetWidth() const override { return m_SrcWidth; }
- int32_t GetHeight() const override { return m_SrcHeight; }
- int32_t GetNumComponents() const override { return m_SrcComponents; }
- int32_t GetBPC() const override { return m_SrcBPC; }
- void SetClipBox(FX_RECT* clip) override;
+ FXCODEC_IMAGE_TYPE GetType() const { return m_imagType; }
+ int32_t GetWidth() const { return m_SrcWidth; }
+ int32_t GetHeight() const { return m_SrcHeight; }
+ int32_t GetNumComponents() const { return m_SrcComponents; }
+ int32_t GetBPC() const { return m_SrcBPC; }
+ void SetClipBox(FX_RECT* clip);
- FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause) override;
+ FXCODEC_STATUS GetFrames(int32_t& frames, IFX_Pause* pPause = nullptr);
FXCODEC_STATUS StartDecode(CFX_DIBitmap* pDIBitmap,
int start_x,
int start_y,
int size_x,
int size_y,
- int32_t frames,
- FX_BOOL bInterpol) override;
+ int32_t frames = 0,
+ FX_BOOL bInterpol = TRUE);
+
+ FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = nullptr);
+
+ struct PixelWeight {
+ int m_SrcStart;
+ int m_SrcEnd;
+ int m_Weights[1];
+ };
+
+ class CFXCODEC_WeightTable {
+ public:
+ CFXCODEC_WeightTable() { m_pWeightTables = NULL; }
+ ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); }
+
+ void Calc(int dest_len,
+ int dest_min,
+ int dest_max,
+ int src_len,
+ int src_min,
+ int src_max,
+ FX_BOOL bInterpol);
+ PixelWeight* GetPixelWeight(int pixel) {
+ return (PixelWeight*)(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize);
+ }
+
+ int m_DestMin, m_ItemSize;
+ uint8_t* m_pWeightTables;
+ };
+
+ class CFXCODEC_HorzTable {
+ public:
+ CFXCODEC_HorzTable() { m_pWeightTables = NULL; }
+ ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); }
+
+ void Calc(int dest_len, int src_len, FX_BOOL bInterpol);
+ PixelWeight* GetPixelWeight(int pixel) {
+ return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
+ }
+
+ int m_ItemSize;
+ uint8_t* m_pWeightTables;
+ };
+
+ class CFXCODEC_VertTable {
+ public:
+ CFXCODEC_VertTable() { m_pWeightTables = NULL; }
+ ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); }
+ void Calc(int dest_len, int src_len);
+ PixelWeight* GetPixelWeight(int pixel) {
+ return (PixelWeight*)(m_pWeightTables + pixel * m_ItemSize);
+ }
+ int m_ItemSize;
+ uint8_t* m_pWeightTables;
+ };
- FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause) override;
+ IFX_FileRead* m_pFile;
+ CCodec_ModuleMgr* m_pCodecMgr;
+ FXJPEG_Context* m_pJpegContext;
+ FXPNG_Context* m_pPngContext;
+ FXGIF_Context* m_pGifContext;
+ FXBMP_Context* m_pBmpContext;
+ CCodec_TiffContext* m_pTiffContext;
+ FXCODEC_IMAGE_TYPE m_imagType;
+ uint32_t m_offSet;
+ uint8_t* m_pSrcBuf;
+ uint32_t m_SrcSize;
+ uint8_t* m_pDecodeBuf;
+ int m_ScanlineSize;
+ CFX_DIBitmap* m_pDeviceBitmap;
+ FX_BOOL m_bInterpol;
+ CFXCODEC_WeightTable m_WeightHorz;
+ CFXCODEC_VertTable m_WeightVert;
+ CFXCODEC_HorzTable m_WeightHorzOO;
+ int m_SrcWidth;
+ int m_SrcHeight;
+ int m_SrcComponents;
+ int m_SrcBPC;
+ FX_RECT m_clipBox;
+ int m_startX;
+ int m_startY;
+ int m_sizeX;
+ int m_sizeY;
+ int m_TransMethod;
+ FX_ARGB* m_pSrcPalette;
+ int m_SrcPaletteNumber;
+ int m_SrcRow;
+ FXCodec_Format m_SrcFormat;
+ int m_SrcPassNumber;
+ int m_FrameNumber;
+ int m_FrameCur;
+ int m_GifBgIndex;
+ uint8_t* m_pGifPalette;
+ int32_t m_GifPltNumber;
+ int m_GifTransIndex;
+ FX_RECT m_GifFrameRect;
+ FX_BOOL m_BmpIsTopBottom;
+ FXCODEC_STATUS m_status;
protected:
static FX_BOOL PngReadHeaderFunc(void* pModule,
@@ -158,64 +211,20 @@ class CCodec_ProgressiveDecoder : public ICodec_ProgressiveDecoder {
uint8_t* src_scan,
FXCodec_Format src_format);
void ResampleVert(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row);
- FX_BOOL JpegReadMoreData(ICodec_JpegModule* pJpegModule,
+ FX_BOOL JpegReadMoreData(CCodec_JpegModule* pJpegModule,
FXCODEC_STATUS& err_status);
void PngOneOneMapResampleHorz(CFX_DIBitmap* pDeviceBitmap,
int32_t des_line,
uint8_t* src_scan,
FXCodec_Format src_format);
- FX_BOOL GifReadMoreData(ICodec_GifModule* pGifModule,
+ FX_BOOL GifReadMoreData(CCodec_GifModule* pGifModule,
FXCODEC_STATUS& err_status);
void GifDoubleLineResampleVert(CFX_DIBitmap* pDeviceBitmap,
double scale_y,
int des_row);
- FX_BOOL BmpReadMoreData(ICodec_BmpModule* pBmpModule,
+ FX_BOOL BmpReadMoreData(CCodec_BmpModule* pBmpModule,
FXCODEC_STATUS& err_status);
void ResampleVertBT(CFX_DIBitmap* pDeviceBitmap, double scale_y, int des_row);
-
- public:
- IFX_FileRead* m_pFile;
- CCodec_ModuleMgr* m_pCodecMgr;
- void* m_pJpegContext;
- void* m_pPngContext;
- void* m_pGifContext;
- void* m_pBmpContext;
- void* m_pTiffContext;
- FXCODEC_IMAGE_TYPE m_imagType;
- uint32_t m_offSet;
- uint8_t* m_pSrcBuf;
- uint32_t m_SrcSize;
- uint8_t* m_pDecodeBuf;
- int m_ScanlineSize;
- CFX_DIBitmap* m_pDeviceBitmap;
- FX_BOOL m_bInterpol;
- CFXCODEC_WeightTable m_WeightHorz;
- CFXCODEC_VertTable m_WeightVert;
- CFXCODEC_HorzTable m_WeightHorzOO;
- int m_SrcWidth;
- int m_SrcHeight;
- int m_SrcComponents;
- int m_SrcBPC;
- FX_RECT m_clipBox;
- int m_startX;
- int m_startY;
- int m_sizeX;
- int m_sizeY;
- int m_TransMethod;
- FX_ARGB* m_pSrcPalette;
- int m_SrcPaletteNumber;
- int m_SrcRow;
- FXCodec_Format m_SrcFormat;
- int m_SrcPassNumber;
- int m_FrameNumber;
- int m_FrameCur;
- int m_GifBgIndex;
- uint8_t* m_pGifPalette;
- int32_t m_GifPltNumber;
- int m_GifTransIndex;
- FX_RECT m_GifFrameRect;
- FX_BOOL m_BmpIsTopBottom;
- FXCODEC_STATUS m_status;
};
-#endif // CORE_FXCODEC_CODEC_FX_CODEC_PROGRESS_H_
+#endif // CORE_FXCODEC_CODEC_INCLUDE_CCODEC_PROGRESSIVEDECODER_H_
diff --git a/chromium/third_party/pdfium/core/include/fxcodec/DEPS b/chromium/third_party/pdfium/core/fxcodec/include/DEPS
index 548eb61a3b2..548eb61a3b2 100644
--- a/chromium/third_party/pdfium/core/include/fxcodec/DEPS
+++ b/chromium/third_party/pdfium/core/fxcodec/include/DEPS
diff --git a/chromium/third_party/pdfium/core/fxcodec/include/fx_codec.h b/chromium/third_party/pdfium/core/fxcodec/include/fx_codec.h
new file mode 100644
index 00000000000..4853e26a6aa
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcodec/include/fx_codec.h
@@ -0,0 +1,128 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCODEC_INCLUDE_FX_CODEC_H_
+#define CORE_FXCODEC_INCLUDE_FX_CODEC_H_
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "core/fxcodec/codec/ccodec_basicmodule.h"
+#include "core/fxcodec/codec/ccodec_faxmodule.h"
+#include "core/fxcodec/codec/ccodec_flatemodule.h"
+#include "core/fxcodec/codec/ccodec_iccmodule.h"
+#include "core/fxcodec/codec/ccodec_jbig2module.h"
+#include "core/fxcodec/codec/ccodec_jpegmodule.h"
+#include "core/fxcodec/codec/ccodec_jpxmodule.h"
+#include "core/fxcodec/codec/ccodec_scanlinedecoder.h"
+#include "core/fxcodec/include/fx_codec_def.h"
+#include "core/fxcrt/include/fx_basic.h"
+#include "core/fxcrt/include/fx_coordinates.h"
+
+class CFX_DIBSource;
+class CJPX_Decoder;
+class CPDF_ColorSpace;
+class CPDF_StreamAcc;
+
+#ifdef PDF_ENABLE_XFA
+#include "core/fxcodec/codec/ccodec_bmpmodule.h"
+#include "core/fxcodec/codec/ccodec_gifmodule.h"
+#include "core/fxcodec/codec/ccodec_pngmodule.h"
+#include "core/fxcodec/codec/ccodec_tiffmodule.h"
+
+class CCodec_ProgressiveDecoder;
+
+class CFX_DIBAttribute {
+ public:
+ CFX_DIBAttribute();
+ ~CFX_DIBAttribute();
+
+ int32_t m_nXDPI;
+ int32_t m_nYDPI;
+ FX_FLOAT m_fAspectRatio;
+ uint16_t m_wDPIUnit;
+ CFX_ByteString m_strAuthor;
+ uint8_t m_strTime[20];
+ int32_t m_nGifLeft;
+ int32_t m_nGifTop;
+ uint32_t* m_pGifLocalPalette;
+ uint32_t m_nGifLocalPalNum;
+ int32_t m_nBmpCompressType;
+ std::map<uint32_t, void*> m_Exif;
+};
+#endif // PDF_ENABLE_XFA
+
+class CCodec_ModuleMgr {
+ public:
+ CCodec_ModuleMgr();
+
+ CCodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
+ CCodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
+ CCodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
+ CCodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); }
+ CCodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
+ CCodec_IccModule* GetIccModule() const { return m_pIccModule.get(); }
+ CCodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); }
+
+#ifdef PDF_ENABLE_XFA
+ CCodec_ProgressiveDecoder* CreateProgressiveDecoder();
+ CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
+ CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
+ CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
+ CCodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
+#endif // PDF_ENABLE_XFA
+
+ protected:
+ std::unique_ptr<CCodec_BasicModule> m_pBasicModule;
+ std::unique_ptr<CCodec_FaxModule> m_pFaxModule;
+ std::unique_ptr<CCodec_JpegModule> m_pJpegModule;
+ std::unique_ptr<CCodec_JpxModule> m_pJpxModule;
+ std::unique_ptr<CCodec_Jbig2Module> m_pJbig2Module;
+ std::unique_ptr<CCodec_IccModule> m_pIccModule;
+
+#ifdef PDF_ENABLE_XFA
+ std::unique_ptr<CCodec_PngModule> m_pPngModule;
+ std::unique_ptr<CCodec_GifModule> m_pGifModule;
+ std::unique_ptr<CCodec_BmpModule> m_pBmpModule;
+ std::unique_ptr<CCodec_TiffModule> m_pTiffModule;
+#endif // PDF_ENABLE_XFA
+
+ std::unique_ptr<CCodec_FlateModule> m_pFlateModule;
+};
+
+void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels);
+void sRGB_to_AdobeCMYK(FX_FLOAT R,
+ FX_FLOAT G,
+ FX_FLOAT B,
+ FX_FLOAT& c,
+ FX_FLOAT& m,
+ FX_FLOAT& y,
+ FX_FLOAT& k);
+void AdobeCMYK_to_sRGB(FX_FLOAT c,
+ FX_FLOAT m,
+ FX_FLOAT y,
+ FX_FLOAT k,
+ FX_FLOAT& R,
+ FX_FLOAT& G,
+ FX_FLOAT& B);
+void AdobeCMYK_to_sRGB1(uint8_t c,
+ uint8_t m,
+ uint8_t y,
+ uint8_t k,
+ uint8_t& R,
+ uint8_t& G,
+ uint8_t& B);
+FX_BOOL MD5ComputeID(const void* buf, uint32_t dwSize, uint8_t ID[16]);
+void FaxG4Decode(const uint8_t* src_buf,
+ uint32_t src_size,
+ int* pbitpos,
+ uint8_t* dest_buf,
+ int width,
+ int height,
+ int pitch);
+
+#endif // CORE_FXCODEC_INCLUDE_FX_CODEC_H_
diff --git a/chromium/third_party/pdfium/core/include/fxcodec/fx_codec_def.h b/chromium/third_party/pdfium/core/fxcodec/include/fx_codec_def.h
index 99ccf15f0ff..fb1b5bcdacf 100644
--- a/chromium/third_party/pdfium/core/include/fxcodec/fx_codec_def.h
+++ b/chromium/third_party/pdfium/core/fxcodec/include/fx_codec_def.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_DEF_H_
-#define CORE_INCLUDE_FXCODEC_FX_CODEC_DEF_H_
+#ifndef CORE_FXCODEC_INCLUDE_FX_CODEC_DEF_H_
+#define CORE_FXCODEC_INCLUDE_FX_CODEC_DEF_H_
enum FXCODEC_STATUS {
FXCODEC_STATUS_ERROR = -1,
@@ -89,4 +89,4 @@ enum FXCODEC_RESUNIT {
#define EXIFTAG_STRING_DATETIME 306
#define EXIFTAG_STRING_COPYRIGHT 33432
-#endif // CORE_INCLUDE_FXCODEC_FX_CODEC_DEF_H_
+#endif // CORE_FXCODEC_INCLUDE_FX_CODEC_DEF_H_
diff --git a/chromium/third_party/pdfium/core/include/fxcodec/fx_codec_flate.h b/chromium/third_party/pdfium/core/fxcodec/include/fx_codec_flate.h
index a0d151d2585..83e9281b486 100644
--- a/chromium/third_party/pdfium/core/include/fxcodec/fx_codec_flate.h
+++ b/chromium/third_party/pdfium/core/fxcodec/include/fx_codec_flate.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_FLATE_H_
-#define CORE_INCLUDE_FXCODEC_FX_CODEC_FLATE_H_
+#ifndef CORE_FXCODEC_INCLUDE_FX_CODEC_FLATE_H_
+#define CORE_FXCODEC_INCLUDE_FX_CODEC_FLATE_H_
#include "third_party/zlib_v128/zlib.h"
@@ -30,4 +30,4 @@ void FPDFAPI_FlateEnd(void* context);
} // extern "C"
#endif
-#endif // CORE_INCLUDE_FXCODEC_FX_CODEC_FLATE_H_
+#endif // CORE_FXCODEC_INCLUDE_FX_CODEC_FLATE_H_
diff --git a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.cpp b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.cpp
index 1ff78e121fe..5a0b2c0d738 100644
--- a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -1285,7 +1285,7 @@ JBig2HuffmanCode* CJBig2_Context::decodeSymbolIDHuffmanTable(
std::unique_ptr<JBig2HuffmanCode, FxFreeDeleter> SBSYMCODES(
FX_Alloc(JBig2HuffmanCode, SBNUMSYMS));
- int32_t run;
+ int32_t run = 0;
int32_t i = 0;
while (i < (int)SBNUMSYMS) {
size_t j;
diff --git a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.h b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.h
index 4a32e61489b..fa68588a4a5 100644
--- a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.h
+++ b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Context.h
@@ -12,10 +12,10 @@
#include <utility>
#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
+#include "core/fxcodec/include/fx_codec_def.h"
#include "core/fxcodec/jbig2/JBig2_List.h"
#include "core/fxcodec/jbig2/JBig2_Page.h"
#include "core/fxcodec/jbig2/JBig2_Segment.h"
-#include "core/include/fxcodec/fx_codec_def.h"
class CJBig2_ArithDecoder;
class CJBig2_GRDProc;
diff --git a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.cpp b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.cpp
index 5f3b47f6597..2391fb2b07a 100644
--- a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.cpp
@@ -8,10 +8,10 @@
#include <memory>
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcodec/jbig2/JBig2_ArithDecoder.h"
#include "core/fxcodec/jbig2/JBig2_BitStream.h"
#include "core/fxcodec/jbig2/JBig2_Image.h"
-#include "core/include/fxcodec/fx_codec.h"
CJBig2_GRDProc::CJBig2_GRDProc()
: m_loopIndex(0),
diff --git a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.h b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.h
index f6a5448769a..b24e2f36fa6 100644
--- a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.h
+++ b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_GrdProc.h
@@ -7,9 +7,9 @@
#ifndef CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_
#define CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_
+#include "core/fxcodec/include/fx_codec_def.h"
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxcodec/fx_codec_def.h"
class CJBig2_ArithDecoder;
class CJBig2_BitStream;
diff --git a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Image.cpp b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Image.cpp
index 72971991120..6a1c060b752 100644
--- a/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Image.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/jbig2/JBig2_Image.cpp
@@ -216,7 +216,7 @@ void CJBig2_Image::expand(int32_t h, FX_BOOL v) {
uint32_t dwH = pdfium::base::checked_cast<uint32_t>(h);
uint32_t dwStride = pdfium::base::checked_cast<uint32_t>(m_nStride);
uint32_t dwHeight = pdfium::base::checked_cast<uint32_t>(m_nHeight);
- FX_SAFE_DWORD safeMemSize = dwH;
+ FX_SAFE_UINT32 safeMemSize = dwH;
safeMemSize *= dwStride;
if (!safeMemSize.IsValid()) {
return;
diff --git a/chromium/third_party/pdfium/core/fxcodec/lgif/fx_gif.cpp b/chromium/third_party/pdfium/core/fxcodec/lgif/fx_gif.cpp
index 059fa9a70b4..53298c831a7 100644
--- a/chromium/third_party/pdfium/core/fxcodec/lgif/fx_gif.cpp
+++ b/chromium/third_party/pdfium/core/fxcodec/lgif/fx_gif.cpp
@@ -647,7 +647,7 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
- gif_ptr->cmt_data_ptr->Empty();
+ gif_ptr->cmt_data_ptr->clear();
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
uint8_t data_size = *data_size_ptr;
if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
diff --git a/chromium/third_party/pdfium/core/fxcrt/cfx_string_c_template.h b/chromium/third_party/pdfium/core/fxcrt/cfx_string_c_template.h
new file mode 100644
index 00000000000..70b9fcd6094
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxcrt/cfx_string_c_template.h
@@ -0,0 +1,168 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCRT_CFX_STRING_C_TEMPLATE_H_
+#define CORE_FXCRT_CFX_STRING_C_TEMPLATE_H_
+
+#include <algorithm>
+#include <type_traits>
+
+#include "core/fxcrt/include/fx_system.h"
+
+// An immutable string with caller-provided storage which must outlive the
+// string itself. These are not necessarily nul-terminated, so that substring
+// extraction (via the Mid(), Left(), and Right() methods) is copy-free.
+template <typename T>
+class CFX_StringCTemplate {
+ public:
+ using CharType = T;
+ using UnsignedType = typename std::make_unsigned<CharType>::type;
+
+ CFX_StringCTemplate() : m_Ptr(nullptr), m_Length(0) {}
+
+ // Deliberately implicit to avoid calling on every string literal.
+ CFX_StringCTemplate(const CharType* ptr)
+ : m_Ptr(reinterpret_cast<const UnsignedType*>(ptr)),
+ m_Length(ptr ? FXSYS_len(ptr) : 0) {}
+
+ CFX_StringCTemplate(const CharType* ptr, FX_STRSIZE len)
+ : m_Ptr(reinterpret_cast<const UnsignedType*>(ptr)),
+ m_Length(len == -1 ? FXSYS_len(ptr) : len) {}
+
+ template <typename U = UnsignedType>
+ CFX_StringCTemplate(
+ const UnsignedType* ptr,
+ FX_STRSIZE size,
+ typename std::enable_if<!std::is_same<U, CharType>::value>::type* = 0)
+ : m_Ptr(ptr), m_Length(size) {}
+
+ // Deliberately implicit to avoid calling on every string literal.
+ // |ch| must be an lvalue that outlives the the CFX_StringCTemplate.
+ CFX_StringCTemplate(CharType& ch) {
+ m_Ptr = reinterpret_cast<const UnsignedType*>(&ch);
+ m_Length = 1;
+ }
+
+ CFX_StringCTemplate(const CFX_StringCTemplate& src) {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ }
+
+ CFX_StringCTemplate& operator=(const CharType* src) {
+ m_Ptr = reinterpret_cast<const UnsignedType*>(src);
+ m_Length = src ? FXSYS_len(src) : 0;
+ return *this;
+ }
+
+ CFX_StringCTemplate& operator=(const CFX_StringCTemplate& src) {
+ m_Ptr = src.m_Ptr;
+ m_Length = src.m_Length;
+ return *this;
+ }
+
+ bool operator==(const CharType* ptr) const {
+ return FXSYS_len(ptr) == m_Length &&
+ FXSYS_cmp(ptr, reinterpret_cast<const CharType*>(m_Ptr), m_Length) ==
+ 0;
+ }
+ bool operator==(const CFX_StringCTemplate& other) const {
+ return other.m_Length == m_Length &&
+ FXSYS_cmp(reinterpret_cast<const CharType*>(other.m_Ptr),
+ reinterpret_cast<const CharType*>(m_Ptr), m_Length) == 0;
+ }
+ bool operator!=(const CharType* ptr) const { return !(*this == ptr); }
+ bool operator!=(const CFX_StringCTemplate& other) const {
+ return !(*this == other);
+ }
+
+ uint32_t GetID(FX_STRSIZE start_pos = 0) const {
+ if (m_Length == 0 || start_pos < 0 || start_pos >= m_Length)
+ return 0;
+
+ uint32_t strid = 0;
+ FX_STRSIZE size = std::min(4, m_Length - start_pos);
+ for (FX_STRSIZE i = 0; i < size; i++)
+ strid = strid * 256 + m_Ptr[start_pos + i];
+
+ return strid << ((4 - size) * 8);
+ }
+
+ const UnsignedType* raw_str() const { return m_Ptr; }
+ const CharType* c_str() const {
+ return reinterpret_cast<const CharType*>(m_Ptr);
+ }
+
+ FX_STRSIZE GetLength() const { return m_Length; }
+ bool IsEmpty() const { return m_Length == 0; }
+
+ UnsignedType GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
+ CharType CharAt(FX_STRSIZE index) const {
+ return static_cast<CharType>(m_Ptr[index]);
+ }
+
+ FX_STRSIZE Find(CharType ch) const {
+ const UnsignedType* found = reinterpret_cast<const UnsignedType*>(
+ FXSYS_chr(reinterpret_cast<const CharType*>(m_Ptr), ch, m_Length));
+ return found ? found - m_Ptr : -1;
+ }
+
+ CFX_StringCTemplate Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
+ index = std::max(0, index);
+ if (index > m_Length)
+ return CFX_StringCTemplate();
+
+ if (count < 0 || count > m_Length - index)
+ count = m_Length - index;
+
+ return CFX_StringCTemplate(m_Ptr + index, count);
+ }
+
+ CFX_StringCTemplate Left(FX_STRSIZE count) const {
+ if (count <= 0)
+ return CFX_StringCTemplate();
+
+ return CFX_StringCTemplate(m_Ptr, std::min(count, m_Length));
+ }
+
+ CFX_StringCTemplate Right(FX_STRSIZE count) const {
+ if (count <= 0)
+ return CFX_StringCTemplate();
+
+ count = std::min(count, m_Length);
+ return CFX_StringCTemplate(m_Ptr + m_Length - count, count);
+ }
+
+ const UnsignedType& operator[](size_t index) const { return m_Ptr[index]; }
+
+ bool operator<(const CFX_StringCTemplate& that) const {
+ int result = FXSYS_cmp(reinterpret_cast<const CharType*>(m_Ptr),
+ reinterpret_cast<const CharType*>(that.m_Ptr),
+ std::min(m_Length, that.m_Length));
+ return result < 0 || (result == 0 && m_Length < that.m_Length);
+ }
+
+ protected:
+ const UnsignedType* m_Ptr;
+ FX_STRSIZE m_Length;
+
+ private:
+ void* operator new(size_t) throw() { return nullptr; }
+};
+
+template <typename T>
+inline bool operator==(const T* lhs, const CFX_StringCTemplate<T>& rhs) {
+ return rhs == lhs;
+}
+
+template <typename T>
+inline bool operator!=(const T* lhs, const CFX_StringCTemplate<T>& rhs) {
+ return rhs != lhs;
+}
+
+extern template class CFX_StringCTemplate<FX_CHAR>;
+extern template class CFX_StringCTemplate<FX_WCHAR>;
+
+#endif // CORE_FXCRT_CFX_STRING_C_TEMPLATE_H_
diff --git a/chromium/third_party/pdfium/core/fxcrt/cfx_string_data_template.h b/chromium/third_party/pdfium/core/fxcrt/cfx_string_data_template.h
index b53b2511c27..225020a7dd9 100644
--- a/chromium/third_party/pdfium/core/fxcrt/cfx_string_data_template.h
+++ b/chromium/third_party/pdfium/core/fxcrt/cfx_string_data_template.h
@@ -15,7 +15,7 @@ template <typename CharType>
class CFX_StringDataTemplate {
public:
static CFX_StringDataTemplate* Create(FX_STRSIZE nLen) {
- FXSYS_assert(nLen > 0);
+ ASSERT(nLen > 0);
// Calculate space needed for the fixed portion of the struct plus the
// NUL char that is not included in |m_nAllocLength|.
@@ -32,7 +32,7 @@ class CFX_StringDataTemplate {
nSize += 7;
int totalSize = nSize.ValueOrDie() & ~7;
int usableLen = (totalSize - overhead) / sizeof(CharType);
- FXSYS_assert(usableLen >= nLen);
+ ASSERT(usableLen >= nLen);
void* pData = FX_Alloc(uint8_t, totalSize);
return new (pData) CFX_StringDataTemplate(nLen, usableLen);
@@ -61,13 +61,13 @@ class CFX_StringDataTemplate {
}
void CopyContents(const CFX_StringDataTemplate& other) {
- FXSYS_assert(other.m_nDataLength <= m_nAllocLength);
+ ASSERT(other.m_nDataLength <= m_nAllocLength);
FXSYS_memcpy(m_String, other.m_String,
(other.m_nDataLength + 1) * sizeof(CharType));
}
void CopyContents(const CharType* pStr, FX_STRSIZE nLen) {
- FXSYS_assert(nLen >= 0 && nLen <= m_nAllocLength);
+ ASSERT(nLen >= 0 && nLen <= m_nAllocLength);
FXSYS_memcpy(m_String, pStr, nLen * sizeof(CharType));
m_String[nLen] = 0;
}
@@ -75,7 +75,7 @@ class CFX_StringDataTemplate {
void CopyContentsAt(FX_STRSIZE offset,
const CharType* pStr,
FX_STRSIZE nLen) {
- FXSYS_assert(offset >= 0 && nLen >= 0 && offset + nLen <= m_nAllocLength);
+ ASSERT(offset >= 0 && nLen >= 0 && offset + nLen <= m_nAllocLength);
FXSYS_memcpy(m_String + offset, pStr, nLen * sizeof(CharType));
m_String[offset + nLen] = 0;
}
@@ -101,8 +101,8 @@ class CFX_StringDataTemplate {
private:
CFX_StringDataTemplate(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
: m_nRefs(0), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
- FXSYS_assert(dataLen >= 0);
- FXSYS_assert(dataLen <= allocLen);
+ ASSERT(dataLen >= 0);
+ ASSERT(dataLen <= allocLen);
m_String[dataLen] = 0;
}
diff --git a/chromium/third_party/pdfium/core/fxcrt/extension.h b/chromium/third_party/pdfium/core/fxcrt/extension.h
index a9f3c23d294..b0e7b9e117e 100644
--- a/chromium/third_party/pdfium/core/fxcrt/extension.h
+++ b/chromium/third_party/pdfium/core/fxcrt/extension.h
@@ -52,7 +52,7 @@ class CFX_CRTFileAccess : public IFX_FileAccess {
void GetPath(CFX_WideString& wsPath) override { wsPath = m_path; }
IFX_FileStream* CreateFileStream(uint32_t dwModes) override {
- return FX_CreateFileStream(m_path, dwModes);
+ return FX_CreateFileStream(m_path.c_str(), dwModes);
}
FX_BOOL Init(const CFX_WideStringC& wsPath) {
@@ -241,7 +241,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream {
}
FX_BOOL Flush() override { return TRUE; }
FX_BOOL IsConsecutive() const override {
- return m_dwFlags & FX_MEMSTREAM_Consecutive;
+ return !!(m_dwFlags & FX_MEMSTREAM_Consecutive);
}
void EstimateSize(size_t nInitSize, size_t nGrowSize) override {
if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_arabic.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_arabic.cpp
index 95fa8f52a0f..01a1a2a15e3 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_arabic.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_arabic.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcrt/fx_arabic.h"
+#include "core/fxcrt/include/fx_arabic.h"
#include "core/fxcrt/include/fx_ucd.h"
namespace {
@@ -114,6 +114,23 @@ const FX_ARASHADDA gs_FX_ShaddaTable[] = {
{0x064F, 0xFC61}, {0x0650, 0xFC62},
};
+const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
+ FX_WCHAR& wChar,
+ FX_CHARTYPE& eType) {
+ if (!pTC) {
+ eType = FX_CHARTYPE_Unknown;
+ wChar = 0xFEFF;
+ return nullptr;
+ }
+ eType = (FX_CHARTYPE)pTC->GetCharType();
+ wChar = (FX_WCHAR)pTC->m_wCharCode;
+ const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar);
+ if (!pFT || eType >= FX_CHARTYPE_ArabicNormal)
+ eType = FX_CHARTYPE_Unknown;
+
+ return pFT;
+}
+
} // namespace
const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode) {
@@ -145,29 +162,30 @@ FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda) {
return shadda;
}
-IFX_ArabicChar* IFX_ArabicChar::Create() {
- return new CFX_ArabicChar;
-}
-FX_BOOL CFX_ArabicChar::IsArabicChar(FX_WCHAR wch) const {
+namespace pdfium {
+namespace arabic {
+
+bool IsArabicChar(FX_WCHAR wch) {
uint32_t dwRet =
kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK;
return dwRet >= FX_CHARTYPE_ArabicAlef;
}
-FX_BOOL CFX_ArabicChar::IsArabicFormChar(FX_WCHAR wch) const {
+
+bool IsArabicFormChar(FX_WCHAR wch) {
return (kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK) ==
FX_CHARTYPE_ArabicForm;
}
-FX_WCHAR CFX_ArabicChar::GetFormChar(FX_WCHAR wch,
- FX_WCHAR prev,
- FX_WCHAR next) const {
+
+FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev, FX_WCHAR next) {
CFX_Char c(wch, kTextLayoutCodeProperties[(uint16_t)wch]);
CFX_Char p(prev, kTextLayoutCodeProperties[(uint16_t)prev]);
CFX_Char n(next, kTextLayoutCodeProperties[(uint16_t)next]);
return GetFormChar(&c, &p, &n);
}
-FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur,
- const CFX_Char* prev,
- const CFX_Char* next) const {
+
+FX_WCHAR GetFormChar(const CFX_Char* cur,
+ const CFX_Char* prev,
+ const CFX_Char* next) {
FX_CHARTYPE eCur;
FX_WCHAR wCur;
const FX_ARBFORMTABLE* ft = ParseChar(cur, wCur, eCur);
@@ -187,44 +205,29 @@ FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur,
if (ePrev < FX_CHARTYPE_ArabicAlef) {
if (bAlef) {
return FX_GetArabicFromAlefTable(wNext);
- } else {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
- }
- } else {
- if (bAlef) {
- wCur = FX_GetArabicFromAlefTable(wNext);
- return (ePrev != FX_CHARTYPE_ArabicDistortion) ? wCur : ++wCur;
- } else if (ePrev == FX_CHARTYPE_ArabicAlef ||
- ePrev == FX_CHARTYPE_ArabicSpecial) {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
- } else {
- return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wFinal : ft->wMedial;
}
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
}
-}
-const FX_ARBFORMTABLE* CFX_ArabicChar::ParseChar(const CFX_Char* pTC,
- FX_WCHAR& wChar,
- FX_CHARTYPE& eType) const {
- if (pTC == NULL) {
- eType = FX_CHARTYPE_Unknown;
- wChar = 0xFEFF;
- return NULL;
+ if (bAlef) {
+ wCur = FX_GetArabicFromAlefTable(wNext);
+ return (ePrev != FX_CHARTYPE_ArabicDistortion) ? wCur : ++wCur;
}
- eType = (FX_CHARTYPE)pTC->GetCharType();
- wChar = (FX_WCHAR)pTC->m_wCharCode;
- const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar);
- if (pFT == NULL || eType >= FX_CHARTYPE_ArabicNormal) {
- eType = FX_CHARTYPE_Unknown;
+ if (ePrev == FX_CHARTYPE_ArabicAlef || ePrev == FX_CHARTYPE_ArabicSpecial) {
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
}
- return pFT;
+ return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wFinal : ft->wMedial;
}
+
+} // namespace arabic
+} // namespace pdfium
+
void FX_BidiReverseString(CFX_WideString& wsText,
int32_t iStart,
int32_t iCount) {
- FXSYS_assert(iStart > -1 && iStart < wsText.GetLength());
- FXSYS_assert(iCount >= 0 && iStart + iCount <= wsText.GetLength());
+ ASSERT(iStart > -1 && iStart < wsText.GetLength());
+ ASSERT(iCount >= 0 && iStart + iCount <= wsText.GetLength());
FX_WCHAR wch;
- FX_WCHAR* pStart = (FX_WCHAR*)(const FX_WCHAR*)wsText;
+ FX_WCHAR* pStart = const_cast<FX_WCHAR*>(wsText.c_str());
pStart += iStart;
FX_WCHAR* pEnd = pStart + iCount - 1;
while (pStart < pEnd) {
@@ -237,8 +240,8 @@ void FX_BidiSetDeferredRun(CFX_Int32Array& values,
int32_t iStart,
int32_t iCount,
int32_t iValue) {
- FXSYS_assert(iStart > -1 && iStart <= values.GetSize());
- FXSYS_assert(iStart - iCount > -1);
+ ASSERT(iStart > -1 && iStart <= values.GetSize());
+ ASSERT(iStart - iCount > -1);
for (int32_t i = iStart - 1; i >= iStart - iCount; i--) {
values.SetAt(i, iValue);
}
@@ -253,9 +256,9 @@ const int32_t gc_FX_BidiNTypes[] = {
void FX_BidiClassify(const CFX_WideString& wsText,
CFX_Int32Array& classes,
FX_BOOL bWS) {
- FXSYS_assert(wsText.GetLength() == classes.GetSize());
+ ASSERT(wsText.GetLength() == classes.GetSize());
int32_t iCount = wsText.GetLength();
- const FX_WCHAR* pwsStart = (const FX_WCHAR*)wsText;
+ const FX_WCHAR* pwsStart = wsText.c_str();
FX_WCHAR wch;
int32_t iCls;
if (bWS) {
@@ -283,10 +286,10 @@ int32_t FX_BidiResolveExplicit(int32_t iBaseLevel,
int32_t iStart,
int32_t iCount,
int32_t iNest) {
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL && iNest >= 0);
- FXSYS_assert(classes.GetSize() == levels.GetSize());
- FXSYS_assert(iStart >= 0 && iStart < classes.GetSize());
- FXSYS_assert(iCount >= 0 && iStart + iCount <= classes.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL && iNest >= 0);
+ ASSERT(classes.GetSize() == levels.GetSize());
+ ASSERT(iStart >= 0 && iStart < classes.GetSize());
+ ASSERT(iCount >= 0 && iStart + iCount <= classes.GetSize());
if (iCount < 1) {
return 0;
}
@@ -393,8 +396,8 @@ const int32_t gc_FX_BidiWeakActions[][10] = {
void FX_BidiResolveWeak(int32_t iBaseLevel,
CFX_Int32Array& classes,
CFX_Int32Array& levels) {
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
- FXSYS_assert(classes.GetSize() == levels.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(classes.GetSize() == levels.GetSize());
int32_t iSize = classes.GetSize();
if (iSize < 1) {
return;
@@ -406,7 +409,7 @@ void FX_BidiResolveWeak(int32_t iBaseLevel,
for (; i <= iSize; i++) {
iClsCur = classes.GetAt(i);
- FXSYS_assert(iClsCur <= FX_BIDICLASS_BN);
+ ASSERT(iClsCur <= FX_BIDICLASS_BN);
iAction = gc_FX_BidiWeakActions[iState][iClsCur];
iClsRun = FX_BidiGetDeferredType(iAction);
if (iClsRun != FX_BIDIWEAKACTION_XX && iCount > 0) {
@@ -438,10 +441,10 @@ const int32_t gc_FX_BidiNeutralStates[][5] = {
};
const int32_t gc_FX_BidiNeutralActions[][5] = {
{FX_BNAIn, 0, 0, 0, 0},
- {FX_BNAIn, 0, 0, 0, FX_BCL},
+ {FX_BNAIn, 0, 0, 0, FX_BIDICLASS_L},
{FX_BNAIn, FX_BNAEn, FX_BNARn, FX_BNARn, FX_BNARn},
{FX_BNAIn, FX_BNALn, FX_BNAEn, FX_BNAEn, FX_BNALnL},
- {FX_BNAIn, 0, 0, 0, FX_BCL},
+ {FX_BNAIn, 0, 0, 0, FX_BIDICLASS_L},
{FX_BNAIn, FX_BNAEn, FX_BNARn, FX_BNARn, FX_BNAEn},
};
int32_t FX_BidiGetDeferredNeutrals(int32_t iAction, int32_t iLevel) {
@@ -463,8 +466,8 @@ int32_t FX_BidiGetResolvedNeutrals(int32_t iAction) {
void FX_BidiResolveNeutrals(int32_t iBaseLevel,
CFX_Int32Array& classes,
const CFX_Int32Array& levels) {
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
- FXSYS_assert(classes.GetSize() == levels.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(classes.GetSize() == levels.GetSize());
int32_t iSize = classes.GetSize();
if (iSize < 1) {
return;
@@ -481,7 +484,7 @@ void FX_BidiResolveNeutrals(int32_t iBaseLevel,
}
continue;
}
- FXSYS_assert(iClsCur < FX_BIDICLASS_AL);
+ ASSERT(iClsCur < FX_BIDICLASS_AL);
iAction = gc_FX_BidiNeutralActions[iState][iClsCur];
iClsRun = FX_BidiGetDeferredNeutrals(iAction, iLevel);
if (iClsRun != FX_BIDICLASS_N && iCount > 0) {
@@ -511,7 +514,7 @@ const int32_t gc_FX_BidiAddLevel[][4] = {
};
void FX_BidiResolveImplicit(const CFX_Int32Array& classes,
CFX_Int32Array& levels) {
- FXSYS_assert(classes.GetSize() == levels.GetSize());
+ ASSERT(classes.GetSize() == levels.GetSize());
int32_t iSize = classes.GetSize();
if (iSize < 1) {
return;
@@ -523,7 +526,7 @@ void FX_BidiResolveImplicit(const CFX_Int32Array& classes,
if (iCls == FX_BIDICLASS_BN) {
continue;
}
- FXSYS_assert(iCls > FX_BIDICLASS_ON && iCls < FX_BIDICLASS_AL);
+ ASSERT(iCls > FX_BIDICLASS_ON && iCls < FX_BIDICLASS_AL);
iLevel = levels.GetAt(i);
iLevel += gc_FX_BidiAddLevel[FX_IsOdd(iLevel)][iCls - 1];
levels.SetAt(i, iLevel);
@@ -532,8 +535,8 @@ void FX_BidiResolveImplicit(const CFX_Int32Array& classes,
void FX_BidiResolveWhitespace(int32_t iBaseLevel,
const CFX_Int32Array& classes,
CFX_Int32Array& levels) {
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
- FXSYS_assert(classes.GetSize() == levels.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(classes.GetSize() == levels.GetSize());
int32_t iSize = classes.GetSize();
if (iSize < 1) {
return;
@@ -578,9 +581,9 @@ int32_t FX_BidiReorderLevel(int32_t iBaseLevel,
const CFX_Int32Array& levels,
int32_t iStart,
FX_BOOL bReverse) {
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
- FXSYS_assert(wsText.GetLength() == levels.GetSize());
- FXSYS_assert(iStart >= 0 && iStart < wsText.GetLength());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(wsText.GetLength() == levels.GetSize());
+ ASSERT(iStart >= 0 && iStart < wsText.GetLength());
int32_t iSize = wsText.GetLength();
if (iSize < 1) {
return 0;
@@ -605,8 +608,8 @@ int32_t FX_BidiReorderLevel(int32_t iBaseLevel,
void FX_BidiReorder(int32_t iBaseLevel,
CFX_WideString& wsText,
const CFX_Int32Array& levels) {
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
- FXSYS_assert(wsText.GetLength() == levels.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(wsText.GetLength() == levels.GetSize());
int32_t iSize = wsText.GetLength();
if (iSize < 1) {
return;
@@ -642,8 +645,8 @@ class CFX_BidiLineTemplate {
void FX_BidiReverseString(CFX_ArrayTemplate<baseType>& chars,
int32_t iStart,
int32_t iCount) {
- FXSYS_assert(iStart > -1 && iStart < chars.GetSize());
- FXSYS_assert(iCount >= 0 && iStart + iCount <= chars.GetSize());
+ ASSERT(iStart > -1 && iStart < chars.GetSize());
+ ASSERT(iCount >= 0 && iStart + iCount <= chars.GetSize());
baseType *pStart, *pEnd;
int32_t iEnd = iStart + iCount - 1, iTemp;
while (iStart < iEnd) {
@@ -659,8 +662,8 @@ class CFX_BidiLineTemplate {
int32_t iStart,
int32_t iCount,
int32_t iValue) {
- FXSYS_assert(iStart > -1 && iStart <= chars.GetSize());
- FXSYS_assert(iStart - iCount > -1);
+ ASSERT(iStart > -1 && iStart <= chars.GetSize());
+ ASSERT(iStart - iCount > -1);
baseType* pTC;
int32_t iLast = iStart - iCount;
if (bClass) {
@@ -678,7 +681,7 @@ class CFX_BidiLineTemplate {
void FX_BidiClassify(CFX_ArrayTemplate<baseType>& chars,
int32_t iCount,
FX_BOOL bWS) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
baseType* pTC;
if (bWS) {
for (int32_t i = 0; i < iCount; i++) {
@@ -699,8 +702,8 @@ class CFX_BidiLineTemplate {
void FX_BidiResolveExplicit(CFX_ArrayTemplate<baseType>& chars,
int32_t iCount,
int32_t iBaseLevel) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
if (iCount < 1) {
return;
}
@@ -713,7 +716,7 @@ class CFX_BidiLineTemplate {
void FX_BidiResolveWeak(CFX_ArrayTemplate<baseType>& chars,
int32_t iCount,
int32_t iBaseLevel) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
iCount--;
if (iCount < 1) {
return;
@@ -757,7 +760,7 @@ class CFX_BidiLineTemplate {
continue;
}
}
- FXSYS_assert(iClsCur <= FX_BIDICLASS_BN);
+ ASSERT(iClsCur <= FX_BIDICLASS_BN);
iAction = gc_FX_BidiWeakActions[iState][iClsCur];
iClsRun = FX_BidiGetDeferredType(iAction);
if (iClsRun != FX_BIDIWEAKACTION_XX && iNum > 0) {
@@ -784,8 +787,8 @@ class CFX_BidiLineTemplate {
void FX_BidiResolveNeutrals(CFX_ArrayTemplate<baseType>& chars,
int32_t iCount,
int32_t iBaseLevel) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
iCount--;
if (iCount < 1) {
return;
@@ -803,7 +806,7 @@ class CFX_BidiLineTemplate {
}
continue;
}
- FXSYS_assert(iClsCur < FX_BIDICLASS_AL);
+ ASSERT(iClsCur < FX_BIDICLASS_AL);
iAction = gc_FX_BidiNeutralActions[iState][iClsCur];
iClsRun = FX_BidiGetDeferredNeutrals(iAction, iLevel);
if (iClsRun != FX_BIDICLASS_N && iNum > 0) {
@@ -831,7 +834,7 @@ class CFX_BidiLineTemplate {
}
void FX_BidiResolveImplicit(CFX_ArrayTemplate<baseType>& chars,
int32_t iCount) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
baseType* pTC;
int32_t iCls, iLevel;
for (int32_t i = 0; i < iCount; i++) {
@@ -840,7 +843,7 @@ class CFX_BidiLineTemplate {
if (iCls == FX_BIDICLASS_BN) {
continue;
}
- FXSYS_assert(iCls > FX_BIDICLASS_ON && iCls < FX_BIDICLASS_AL);
+ ASSERT(iCls > FX_BIDICLASS_ON && iCls < FX_BIDICLASS_AL);
iLevel = pTC->m_iBidiLevel;
iLevel += gc_FX_BidiAddLevel[FX_IsOdd(iLevel)][iCls - 1];
pTC->m_iBidiLevel = (int16_t)iLevel;
@@ -849,8 +852,8 @@ class CFX_BidiLineTemplate {
void FX_BidiResolveWhitespace(CFX_ArrayTemplate<baseType>& chars,
int32_t iCount,
int32_t iBaseLevel) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
if (iCount < 1) {
return;
}
@@ -896,9 +899,9 @@ class CFX_BidiLineTemplate {
int32_t iBaseLevel,
int32_t iStart,
FX_BOOL bReverse) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
- FXSYS_assert(iStart >= 0 && iStart < iCount);
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(iStart >= 0 && iStart < iCount);
if (iCount < 1) {
return 0;
}
@@ -924,15 +927,15 @@ class CFX_BidiLineTemplate {
void FX_BidiReorder(CFX_ArrayTemplate<baseType>& chars,
int32_t iCount,
int32_t iBaseLevel) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
- FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
int32_t i = 0;
while (i < iCount) {
i += FX_BidiReorderLevel(chars, iCount, iBaseLevel, i, FALSE);
}
}
void FX_BidiPosition(CFX_ArrayTemplate<baseType>& chars, int32_t iCount) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
baseType* pTC;
int32_t i = 0;
while (i < iCount) {
@@ -945,7 +948,7 @@ class CFX_BidiLineTemplate {
void FX_BidiLine(CFX_ArrayTemplate<baseType>& chars,
int32_t iCount,
int32_t iBaseLevel) {
- FXSYS_assert(iCount > -1 && iCount <= chars.GetSize());
+ ASSERT(iCount > -1 && iCount <= chars.GetSize());
if (iCount < 2) {
return;
}
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_array.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_array.cpp
index 74988f77473..eb6570d9504 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_array.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_array.cpp
@@ -134,209 +134,3 @@ const void* CFX_BasicArray::GetDataPtr(int index) const {
}
return m_pData + index * m_nUnitSize;
}
-#ifdef PDF_ENABLE_XFA
-CFX_BaseSegmentedArray::CFX_BaseSegmentedArray(int unit_size,
- int segment_units,
- int index_size)
- : m_UnitSize(unit_size),
- m_SegmentSize(segment_units),
- m_IndexSize(index_size),
- m_IndexDepth(0),
- m_DataSize(0),
- m_pIndex(NULL) {}
-void CFX_BaseSegmentedArray::SetUnitSize(int unit_size,
- int segment_units,
- int index_size) {
- ASSERT(m_DataSize == 0);
- m_UnitSize = unit_size;
- m_SegmentSize = segment_units;
- m_IndexSize = index_size;
-}
-CFX_BaseSegmentedArray::~CFX_BaseSegmentedArray() {
- RemoveAll();
-}
-static void _ClearIndex(int level, int size, void** pIndex) {
- if (level == 0) {
- FX_Free(pIndex);
- return;
- }
- for (int i = 0; i < size; ++i) {
- if (pIndex[i])
- _ClearIndex(level - 1, size, (void**)pIndex[i]);
- }
- FX_Free(pIndex);
-}
-void CFX_BaseSegmentedArray::RemoveAll() {
- if (!m_pIndex) {
- return;
- }
- _ClearIndex(m_IndexDepth, m_IndexSize, (void**)m_pIndex);
- m_pIndex = NULL;
- m_IndexDepth = 0;
- m_DataSize = 0;
-}
-void* CFX_BaseSegmentedArray::Add() {
- if (m_DataSize % m_SegmentSize) {
- return GetAt(m_DataSize++);
- }
- void* pSegment = FX_Alloc2D(uint8_t, m_UnitSize, m_SegmentSize);
- if (!m_pIndex) {
- m_pIndex = pSegment;
- m_DataSize++;
- return pSegment;
- }
- if (m_IndexDepth == 0) {
- void** pIndex = FX_Alloc(void*, m_IndexSize);
- pIndex[0] = m_pIndex;
- pIndex[1] = pSegment;
- m_pIndex = pIndex;
- m_DataSize++;
- m_IndexDepth++;
- return pSegment;
- }
- int seg_index = m_DataSize / m_SegmentSize;
- if (seg_index % m_IndexSize) {
- void** pIndex = GetIndex(seg_index);
- pIndex[seg_index % m_IndexSize] = pSegment;
- m_DataSize++;
- return pSegment;
- }
- int tree_size = 1;
- int i;
- for (i = 0; i < m_IndexDepth; i++) {
- tree_size *= m_IndexSize;
- }
- if (m_DataSize == tree_size * m_SegmentSize) {
- void** pIndex = FX_Alloc(void*, m_IndexSize);
- pIndex[0] = m_pIndex;
- m_pIndex = pIndex;
- m_IndexDepth++;
- } else {
- tree_size /= m_IndexSize;
- }
- void** pSpot = (void**)m_pIndex;
- for (i = 1; i < m_IndexDepth; i++) {
- if (!pSpot[seg_index / tree_size]) {
- pSpot[seg_index / tree_size] = FX_Alloc(void*, m_IndexSize);
- }
- pSpot = (void**)pSpot[seg_index / tree_size];
- seg_index = seg_index % tree_size;
- tree_size /= m_IndexSize;
- }
- if (i < m_IndexDepth) {
- FX_Free(pSegment);
- RemoveAll();
- return NULL;
- }
- pSpot[seg_index % m_IndexSize] = pSegment;
- m_DataSize++;
- return pSegment;
-}
-void** CFX_BaseSegmentedArray::GetIndex(int seg_index) const {
- ASSERT(m_IndexDepth != 0);
- if (m_IndexDepth == 1) {
- return (void**)m_pIndex;
- }
- if (m_IndexDepth == 2) {
- return (void**)((void**)m_pIndex)[seg_index / m_IndexSize];
- }
- int tree_size = 1;
- int i;
- for (i = 1; i < m_IndexDepth; i++) {
- tree_size *= m_IndexSize;
- }
- void** pSpot = (void**)m_pIndex;
- for (i = 1; i < m_IndexDepth; i++) {
- pSpot = (void**)pSpot[seg_index / tree_size];
- seg_index = seg_index % tree_size;
- tree_size /= m_IndexSize;
- }
- return pSpot;
-}
-void* CFX_BaseSegmentedArray::IterateSegment(const uint8_t* pSegment,
- int count,
- FX_BOOL (*callback)(void* param,
- void* pData),
- void* param) const {
- for (int i = 0; i < count; i++) {
- if (!callback(param, (void*)(pSegment + i * m_UnitSize))) {
- return (void*)(pSegment + i * m_UnitSize);
- }
- }
- return NULL;
-}
-void* CFX_BaseSegmentedArray::IterateIndex(int level,
- int& start,
- void** pIndex,
- FX_BOOL (*callback)(void* param,
- void* pData),
- void* param) const {
- if (level == 0) {
- int count = m_DataSize - start;
- if (count > m_SegmentSize) {
- count = m_SegmentSize;
- }
- start += count;
- return IterateSegment((const uint8_t*)pIndex, count, callback, param);
- }
- for (int i = 0; i < m_IndexSize; i++) {
- if (!pIndex[i]) {
- continue;
- }
- void* p =
- IterateIndex(level - 1, start, (void**)pIndex[i], callback, param);
- if (p) {
- return p;
- }
- }
- return NULL;
-}
-void* CFX_BaseSegmentedArray::Iterate(FX_BOOL (*callback)(void* param,
- void* pData),
- void* param) const {
- if (!m_pIndex) {
- return NULL;
- }
- int start = 0;
- return IterateIndex(m_IndexDepth, start, (void**)m_pIndex, callback, param);
-}
-void* CFX_BaseSegmentedArray::GetAt(int index) const {
- if (index < 0 || index >= m_DataSize) {
- return NULL;
- }
- if (m_IndexDepth == 0) {
- return (uint8_t*)m_pIndex + m_UnitSize * index;
- }
- int seg_index = index / m_SegmentSize;
- return (uint8_t*)GetIndex(seg_index)[seg_index % m_IndexSize] +
- (index % m_SegmentSize) * m_UnitSize;
-}
-void CFX_BaseSegmentedArray::Delete(int index, int count) {
- if (index < 0 || count < 1 || index + count > m_DataSize) {
- return;
- }
- int i;
- for (i = index; i < m_DataSize - count; i++) {
- uint8_t* pSrc = (uint8_t*)GetAt(i + count);
- uint8_t* pDest = (uint8_t*)GetAt(i);
- for (int j = 0; j < m_UnitSize; j++) {
- pDest[j] = pSrc[j];
- }
- }
- int new_segs = (m_DataSize - count + m_SegmentSize - 1) / m_SegmentSize;
- int old_segs = (m_DataSize + m_SegmentSize - 1) / m_SegmentSize;
- if (new_segs < old_segs) {
- if (m_IndexDepth) {
- for (i = new_segs; i < old_segs; i++) {
- void** pIndex = GetIndex(i);
- FX_Free(pIndex[i % m_IndexSize]);
- pIndex[i % m_IndexSize] = NULL;
- }
- } else {
- FX_Free(m_pIndex);
- m_pIndex = NULL;
- }
- }
- m_DataSize -= count;
-}
-#endif // PDF_ENABLE_XFA
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring.cpp
index 3e4e9c354e9..379f1ee882c 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring.cpp
@@ -6,12 +6,14 @@
#include <stddef.h>
+#include <algorithm>
#include <cctype>
#include "core/fxcrt/include/fx_basic.h"
#include "third_party/base/numerics/safe_math.h"
template class CFX_StringDataTemplate<FX_CHAR>;
+template class CFX_StringCTemplate<FX_CHAR>;
namespace {
@@ -48,8 +50,35 @@ int Buffer_itoa(char* buf, int i, uint32_t flags) {
return len;
}
+const FX_CHAR* FX_strstr(const FX_CHAR* haystack,
+ int haystack_len,
+ const FX_CHAR* needle,
+ int needle_len) {
+ if (needle_len > haystack_len || needle_len == 0) {
+ return nullptr;
+ }
+ const FX_CHAR* end_ptr = haystack + haystack_len - needle_len;
+ while (haystack <= end_ptr) {
+ int i = 0;
+ while (1) {
+ if (haystack[i] != needle[i]) {
+ break;
+ }
+ i++;
+ if (i == needle_len) {
+ return haystack;
+ }
+ }
+ haystack++;
+ }
+ return nullptr;
+}
+
} // namespace
+static_assert(sizeof(CFX_ByteString) <= sizeof(FX_CHAR*),
+ "Strings must not require more space than pointers");
+
CFX_ByteString::CFX_ByteString(const FX_CHAR* pStr, FX_STRSIZE nLen) {
if (nLen < 0)
nLen = pStr ? FXSYS_strlen(pStr) : 0;
@@ -71,9 +100,8 @@ CFX_ByteString::CFX_ByteString(char ch) {
}
CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) {
- if (!stringSrc.IsEmpty()) {
+ if (!stringSrc.IsEmpty())
m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength()));
- }
}
CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1,
@@ -98,11 +126,12 @@ const CFX_ByteString& CFX_ByteString::operator=(const FX_CHAR* pStr) {
return *this;
}
-const CFX_ByteString& CFX_ByteString::operator=(const CFX_ByteStringC& str) {
- if (str.IsEmpty())
+const CFX_ByteString& CFX_ByteString::operator=(
+ const CFX_ByteStringC& stringSrc) {
+ if (stringSrc.IsEmpty())
clear();
else
- AssignCopy(str.c_str(), str.GetLength());
+ AssignCopy(stringSrc.c_str(), stringSrc.GetLength());
return *this;
}
@@ -115,20 +144,6 @@ const CFX_ByteString& CFX_ByteString::operator=(
return *this;
}
-const CFX_ByteString& CFX_ByteString::operator=(const CFX_BinaryBuf& buf) {
- Load(buf.GetBuffer(), buf.GetSize());
- return *this;
-}
-
-void CFX_ByteString::Load(const uint8_t* buf, FX_STRSIZE len) {
- if (!len) {
- clear();
- return;
- }
-
- m_pData.Reset(StringData::Create(reinterpret_cast<const FX_CHAR*>(buf), len));
-}
-
const CFX_ByteString& CFX_ByteString::operator+=(const FX_CHAR* pStr) {
if (pStr)
Concat(pStr, FXSYS_strlen(pStr));
@@ -261,20 +276,25 @@ void CFX_ByteString::ReleaseBuffer(FX_STRSIZE nNewLength) {
if (nNewLength == -1)
nNewLength = FXSYS_strlen(m_pData->m_String);
+ nNewLength = std::min(nNewLength, m_pData->m_nAllocLength);
if (nNewLength == 0) {
clear();
return;
}
- FXSYS_assert(nNewLength <= m_pData->m_nAllocLength);
- ReallocBeforeWrite(nNewLength);
+ ASSERT(m_pData->m_nRefs == 1);
m_pData->m_nDataLength = nNewLength;
m_pData->m_String[nNewLength] = 0;
+ if (m_pData->m_nAllocLength - nNewLength >= 32) {
+ // Over arbitrary threshold, so pay the price to relocate. Force copy to
+ // always occur by holding a second reference to the string.
+ CFX_ByteString preserve(*this);
+ ReallocBeforeWrite(nNewLength);
+ }
}
void CFX_ByteString::Reserve(FX_STRSIZE len) {
GetBuffer(len);
- ReleaseBuffer(GetLength());
}
FX_CHAR* CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) {
@@ -317,9 +337,9 @@ FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) {
return m_pData->m_nDataLength;
}
ReallocBeforeWrite(nOldLength);
- int nBytesToCopy = nOldLength - mLength + 1;
+ int nCharsToCopy = nOldLength - mLength + 1;
FXSYS_memmove(m_pData->m_String + nIndex, m_pData->m_String + mLength,
- nBytesToCopy);
+ nCharsToCopy);
m_pData->m_nDataLength = nOldLength - nCount;
}
return m_pData->m_nDataLength;
@@ -388,7 +408,7 @@ void CFX_ByteString::AllocCopy(CFX_ByteString& dest,
CFX_ByteString CFX_ByteString::FormatInteger(int i, uint32_t flags) {
char buf[32];
- return CFX_ByteStringC(buf, Buffer_itoa(buf, i, flags));
+ return CFX_ByteString(buf, Buffer_itoa(buf, i, flags));
}
void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) {
@@ -653,11 +673,12 @@ FX_STRSIZE CFX_ByteString::Find(FX_CHAR ch, FX_STRSIZE nStart) const {
if (!m_pData)
return -1;
- if (nStart >= m_pData->m_nDataLength)
+ if (nStart < 0 || nStart >= m_pData->m_nDataLength)
return -1;
- const FX_CHAR* pStr = FXSYS_strchr(m_pData->m_String + nStart, ch);
- return pStr ? (int)(pStr - m_pData->m_String) : -1;
+ const FX_CHAR* pStr = static_cast<const FX_CHAR*>(
+ memchr(m_pData->m_String + nStart, ch, m_pData->m_nDataLength - nStart));
+ return pStr ? pStr - m_pData->m_String : -1;
}
FX_STRSIZE CFX_ByteString::ReverseFind(FX_CHAR ch) const {
@@ -672,30 +693,6 @@ FX_STRSIZE CFX_ByteString::ReverseFind(FX_CHAR ch) const {
return -1;
}
-const FX_CHAR* FX_strstr(const FX_CHAR* str1,
- int len1,
- const FX_CHAR* str2,
- int len2) {
- if (len2 > len1 || len2 == 0) {
- return nullptr;
- }
- const FX_CHAR* end_ptr = str1 + len1 - len2;
- while (str1 <= end_ptr) {
- int i = 0;
- while (1) {
- if (str1[i] != str2[i]) {
- break;
- }
- i++;
- if (i == len2) {
- return str1;
- }
- }
- str1++;
- }
- return nullptr;
-}
-
FX_STRSIZE CFX_ByteString::Find(const CFX_ByteStringC& pSub,
FX_STRSIZE nStart) const {
if (!m_pData)
@@ -731,17 +728,30 @@ FX_STRSIZE CFX_ByteString::Remove(FX_CHAR chRemove) {
if (!m_pData || m_pData->m_nDataLength < 1)
return 0;
- ReallocBeforeWrite(m_pData->m_nDataLength);
FX_CHAR* pstrSource = m_pData->m_String;
- FX_CHAR* pstrDest = m_pData->m_String;
FX_CHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength;
while (pstrSource < pstrEnd) {
+ if (*pstrSource == chRemove)
+ break;
+ pstrSource++;
+ }
+ if (pstrSource == pstrEnd)
+ return 0;
+
+ ptrdiff_t copied = pstrSource - m_pData->m_String;
+ ReallocBeforeWrite(m_pData->m_nDataLength);
+ pstrSource = m_pData->m_String + copied;
+ pstrEnd = m_pData->m_String + m_pData->m_nDataLength;
+
+ FX_CHAR* pstrDest = pstrSource;
+ while (pstrSource < pstrEnd) {
if (*pstrSource != chRemove) {
*pstrDest = *pstrSource;
pstrDest++;
}
pstrSource++;
}
+
*pstrDest = 0;
FX_STRSIZE nCount = (FX_STRSIZE)(pstrSource - pstrDest);
m_pData->m_nDataLength -= nCount;
@@ -799,8 +809,8 @@ void CFX_ByteString::SetAt(FX_STRSIZE nIndex, FX_CHAR ch) {
if (!m_pData) {
return;
}
- FXSYS_assert(nIndex >= 0);
- FXSYS_assert(nIndex < m_pData->m_nDataLength);
+ ASSERT(nIndex >= 0);
+ ASSERT(nIndex < m_pData->m_nDataLength);
ReallocBeforeWrite(m_pData->m_nDataLength);
m_pData->m_String[nIndex] = ch;
}
@@ -810,7 +820,7 @@ CFX_WideString CFX_ByteString::UTF8Decode() const {
for (FX_STRSIZE i = 0; i < GetLength(); i++) {
decoder.Input((uint8_t)m_pData->m_String[i]);
}
- return decoder.GetResult();
+ return CFX_WideString(decoder.GetResult());
}
// static
@@ -822,7 +832,7 @@ CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str,
// static
CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) {
- return CFX_CharMap::GetByteString(0, str);
+ return CFX_CharMap::GetByteString(0, str.AsStringC());
}
int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
@@ -848,11 +858,11 @@ int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
}
return 0;
}
+
void CFX_ByteString::TrimRight(const CFX_ByteStringC& pTargets) {
if (!m_pData || pTargets.IsEmpty()) {
return;
}
- ReallocBeforeWrite(m_pData->m_nDataLength);
FX_STRSIZE pos = GetLength();
if (pos < 1) {
return;
@@ -869,16 +879,20 @@ void CFX_ByteString::TrimRight(const CFX_ByteStringC& pTargets) {
pos--;
}
if (pos < m_pData->m_nDataLength) {
+ ReallocBeforeWrite(m_pData->m_nDataLength);
m_pData->m_String[pos] = 0;
m_pData->m_nDataLength = pos;
}
}
+
void CFX_ByteString::TrimRight(FX_CHAR chTarget) {
TrimRight(CFX_ByteStringC(chTarget));
}
+
void CFX_ByteString::TrimRight() {
TrimRight("\x09\x0a\x0b\x0c\x0d\x20");
}
+
void CFX_ByteString::TrimLeft(const CFX_ByteStringC& pTargets) {
if (!m_pData || pTargets.IsEmpty())
return;
@@ -887,7 +901,6 @@ void CFX_ByteString::TrimLeft(const CFX_ByteStringC& pTargets) {
if (len < 1)
return;
- ReallocBeforeWrite(len);
FX_STRSIZE pos = 0;
while (pos < len) {
FX_STRSIZE i = 0;
@@ -900,40 +913,24 @@ void CFX_ByteString::TrimLeft(const CFX_ByteStringC& pTargets) {
pos++;
}
if (pos) {
+ ReallocBeforeWrite(len);
FX_STRSIZE nDataLength = len - pos;
FXSYS_memmove(m_pData->m_String, m_pData->m_String + pos,
(nDataLength + 1) * sizeof(FX_CHAR));
m_pData->m_nDataLength = nDataLength;
}
}
+
void CFX_ByteString::TrimLeft(FX_CHAR chTarget) {
TrimLeft(CFX_ByteStringC(chTarget));
}
+
void CFX_ByteString::TrimLeft() {
TrimLeft("\x09\x0a\x0b\x0c\x0d\x20");
}
+
uint32_t CFX_ByteString::GetID(FX_STRSIZE start_pos) const {
- return CFX_ByteStringC(*this).GetID(start_pos);
-}
-uint32_t CFX_ByteStringC::GetID(FX_STRSIZE start_pos) const {
- if (m_Length == 0) {
- return 0;
- }
- if (start_pos < 0 || start_pos >= m_Length) {
- return 0;
- }
- uint32_t strid = 0;
- if (start_pos + 4 > m_Length) {
- for (FX_STRSIZE i = 0; i < m_Length - start_pos; i++) {
- strid = strid * 256 + m_Ptr[start_pos + i];
- }
- strid = strid << ((4 - m_Length + start_pos) * 8);
- } else {
- for (int i = 0; i < 4; i++) {
- strid = strid * 256 + m_Ptr[start_pos + i];
- }
- }
- return strid;
+ return AsStringC().GetID(start_pos);
}
FX_STRSIZE FX_ftoa(FX_FLOAT d, FX_CHAR* buf) {
buf[0] = '0';
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring_unittest.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring_unittest.cpp
index 73235ddf5f0..fe98b53b459 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring_unittest.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_bstring_unittest.cpp
@@ -333,6 +333,35 @@ TEST(fxcrt, ByteStringRemove) {
EXPECT_EQ("", empty);
}
+TEST(fxcrt, ByteStringRemoveCopies) {
+ CFX_ByteString freed("FREED");
+ const FX_CHAR* old_buffer = freed.c_str();
+
+ // No change with single reference - no copy.
+ freed.Remove('Q');
+ EXPECT_EQ("FREED", freed);
+ EXPECT_EQ(old_buffer, freed.c_str());
+
+ // Change with single reference - no copy.
+ freed.Remove('E');
+ EXPECT_EQ("FRD", freed);
+ EXPECT_EQ(old_buffer, freed.c_str());
+
+ // No change with multiple references - no copy.
+ CFX_ByteString shared(freed);
+ freed.Remove('Q');
+ EXPECT_EQ("FRD", freed);
+ EXPECT_EQ(old_buffer, freed.c_str());
+ EXPECT_EQ(old_buffer, shared.c_str());
+
+ // Change with multiple references -- must copy.
+ freed.Remove('D');
+ EXPECT_EQ("FR", freed);
+ EXPECT_NE(old_buffer, freed.c_str());
+ EXPECT_EQ("FRD", shared);
+ EXPECT_EQ(old_buffer, shared.c_str());
+}
+
TEST(fxcrt, ByteStringReplace) {
CFX_ByteString fred("FRED");
fred.Replace("FR", "BL");
@@ -505,6 +534,37 @@ TEST(fxcrt, ByteStringTrimRight) {
EXPECT_EQ("", empty);
}
+TEST(fxcrt, ByteStringTrimRightCopies) {
+ {
+ // With a single reference, no copy takes place.
+ CFX_ByteString fred(" FRED ");
+ const FX_CHAR* old_buffer = fred.c_str();
+ fred.TrimRight();
+ EXPECT_EQ(" FRED", fred);
+ EXPECT_EQ(old_buffer, fred.c_str());
+ }
+ {
+ // With multiple references, we must copy.
+ CFX_ByteString fred(" FRED ");
+ CFX_ByteString other_fred = fred;
+ const FX_CHAR* old_buffer = fred.c_str();
+ fred.TrimRight();
+ EXPECT_EQ(" FRED", fred);
+ EXPECT_EQ(" FRED ", other_fred);
+ EXPECT_NE(old_buffer, fred.c_str());
+ }
+ {
+ // With multiple references, but no modifications, no copy.
+ CFX_ByteString fred("FRED");
+ CFX_ByteString other_fred = fred;
+ const FX_CHAR* old_buffer = fred.c_str();
+ fred.TrimRight();
+ EXPECT_EQ("FRED", fred);
+ EXPECT_EQ("FRED", other_fred);
+ EXPECT_EQ(old_buffer, fred.c_str());
+ }
+}
+
TEST(fxcrt, ByteStringTrimLeft) {
CFX_ByteString fred(" FRED ");
fred.TrimLeft();
@@ -533,6 +593,114 @@ TEST(fxcrt, ByteStringTrimLeft) {
EXPECT_EQ("", empty);
}
+TEST(fxcrt, ByteStringTrimLeftCopies) {
+ {
+ // With a single reference, no copy takes place.
+ CFX_ByteString fred(" FRED ");
+ const FX_CHAR* old_buffer = fred.c_str();
+ fred.TrimLeft();
+ EXPECT_EQ("FRED ", fred);
+ EXPECT_EQ(old_buffer, fred.c_str());
+ }
+ {
+ // With multiple references, we must copy.
+ CFX_ByteString fred(" FRED ");
+ CFX_ByteString other_fred = fred;
+ const FX_CHAR* old_buffer = fred.c_str();
+ fred.TrimLeft();
+ EXPECT_EQ("FRED ", fred);
+ EXPECT_EQ(" FRED ", other_fred);
+ EXPECT_NE(old_buffer, fred.c_str());
+ }
+ {
+ // With multiple references, but no modifications, no copy.
+ CFX_ByteString fred("FRED");
+ CFX_ByteString other_fred = fred;
+ const FX_CHAR* old_buffer = fred.c_str();
+ fred.TrimLeft();
+ EXPECT_EQ("FRED", fred);
+ EXPECT_EQ("FRED", other_fred);
+ EXPECT_EQ(old_buffer, fred.c_str());
+ }
+}
+
+TEST(fxcrt, ByteStringReserve) {
+ {
+ CFX_ByteString str;
+ str.Reserve(6);
+ const FX_CHAR* old_buffer = str.c_str();
+ str += "ABCDEF";
+ EXPECT_EQ(old_buffer, str.c_str());
+ str += "Blah Blah Blah Blah Blah Blah";
+ EXPECT_NE(old_buffer, str.c_str());
+ }
+ {
+ CFX_ByteString str("A");
+ str.Reserve(6);
+ const FX_CHAR* old_buffer = str.c_str();
+ str += "BCDEF";
+ EXPECT_EQ(old_buffer, str.c_str());
+ str += "Blah Blah Blah Blah Blah Blah";
+ EXPECT_NE(old_buffer, str.c_str());
+ }
+}
+
+TEST(fxcrt, ByteStringGetBuffer) {
+ {
+ CFX_ByteString str;
+ FX_CHAR* buffer = str.GetBuffer(12);
+ strcpy(buffer, "clams");
+ str.ReleaseBuffer();
+ EXPECT_EQ("clams", str);
+ }
+ {
+ CFX_ByteString str("cl");
+ FX_CHAR* buffer = str.GetBuffer(12);
+ strcpy(buffer + 2, "ams");
+ str.ReleaseBuffer();
+ EXPECT_EQ("clams", str);
+ }
+}
+
+TEST(fxcrt, ByteStringReleaseBuffer) {
+ {
+ CFX_ByteString str;
+ str.Reserve(12);
+ str += "clams";
+ const FX_CHAR* old_buffer = str.c_str();
+ str.ReleaseBuffer(4);
+ EXPECT_EQ(old_buffer, str.c_str());
+ EXPECT_EQ("clam", str);
+ }
+ {
+ CFX_ByteString str("c");
+ str.Reserve(12);
+ str += "lams";
+ const FX_CHAR* old_buffer = str.c_str();
+ str.ReleaseBuffer(4);
+ EXPECT_EQ(old_buffer, str.c_str());
+ EXPECT_EQ("clam", str);
+ }
+ {
+ CFX_ByteString str;
+ str.Reserve(200);
+ str += "clams";
+ const FX_CHAR* old_buffer = str.c_str();
+ str.ReleaseBuffer(4);
+ EXPECT_NE(old_buffer, str.c_str());
+ EXPECT_EQ("clam", str);
+ }
+ {
+ CFX_ByteString str("c");
+ str.Reserve(200);
+ str += "lams";
+ const FX_CHAR* old_buffer = str.c_str();
+ str.ReleaseBuffer(4);
+ EXPECT_NE(old_buffer, str.c_str());
+ EXPECT_EQ("clam", str);
+ }
+}
+
TEST(fxcrt, ByteStringCNotNull) {
CFX_ByteStringC string3("abc");
CFX_ByteStringC string6("abcdef");
@@ -634,6 +802,31 @@ TEST(fxcrt, ByteStringCGetID) {
EXPECT_EQ(0u, longer_string.GetID(-1000000));
}
+TEST(fxcrt, ByteStringCFind) {
+ CFX_ByteStringC null_string;
+ EXPECT_EQ(-1, null_string.Find('a'));
+ EXPECT_EQ(-1, null_string.Find(0));
+
+ CFX_ByteStringC empty_string("");
+ EXPECT_EQ(-1, empty_string.Find('a'));
+ EXPECT_EQ(-1, empty_string.Find(0));
+
+ CFX_ByteStringC single_string("a");
+ EXPECT_EQ(0, single_string.Find('a'));
+ EXPECT_EQ(-1, single_string.Find('b'));
+ EXPECT_EQ(-1, single_string.Find(0));
+
+ CFX_ByteStringC longer_string("abccc");
+ EXPECT_EQ(0, longer_string.Find('a'));
+ EXPECT_EQ(2, longer_string.Find('c'));
+ EXPECT_EQ(-1, longer_string.Find(0));
+
+ CFX_ByteStringC hibyte_string(
+ "ab\x8c"
+ "def");
+ EXPECT_EQ(2, hibyte_string.Find('\x8c'));
+}
+
TEST(fxcrt, ByteStringCMid) {
CFX_ByteStringC null_string;
EXPECT_EQ(null_string, null_string.Mid(0, 1));
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_buffer.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_buffer.cpp
index 9d0397efeb9..2762497e5cf 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_buffer.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_buffer.cpp
@@ -100,10 +100,6 @@ void CFX_BinaryBuf::InsertBlock(FX_STRSIZE pos,
m_DataSize += size;
}
-CFX_ByteStringC CFX_ByteTextBuf::GetByteString() const {
- return CFX_ByteStringC(m_pBuffer.get(), m_DataSize);
-}
-
CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(const CFX_ByteStringC& lpsz) {
AppendBlock(lpsz.raw_str(), lpsz.GetLength());
return *this;
@@ -142,7 +138,7 @@ void CFX_WideTextBuf::AppendChar(FX_WCHAR ch) {
}
CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideStringC& str) {
- AppendBlock(str.raw_str(), str.GetLength() * sizeof(FX_WCHAR));
+ AppendBlock(str.c_str(), str.GetLength() * sizeof(FX_WCHAR));
return *this;
}
@@ -186,11 +182,6 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideTextBuf& buf) {
return *this;
}
-CFX_WideStringC CFX_WideTextBuf::GetWideString() const {
- return CFX_WideStringC((const FX_WCHAR*)m_pBuffer.get(),
- m_DataSize / sizeof(FX_WCHAR));
-}
-
#ifdef PDF_ENABLE_XFA
CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(uint8_t i) {
if (m_pStream) {
@@ -248,7 +239,7 @@ CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const FX_WCHAR* wstr) {
}
CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const CFX_WideString& wstr) {
CFX_ByteString encoded = wstr.UTF16LE_Encode();
- return operator<<(encoded.AsByteStringC());
+ return operator<<(encoded.AsStringC());
}
void CFX_ArchiveSaver::Write(const void* pData, FX_STRSIZE dwSize) {
if (m_pStream) {
@@ -290,7 +281,7 @@ CFX_ArchiveLoader& CFX_ArchiveLoader::operator>>(CFX_ByteString& str) {
}
int len;
operator>>(len);
- str.Empty();
+ str.clear();
if (len <= 0 || m_LoadingPos + len > m_LoadingSize) {
return *this;
}
@@ -423,6 +414,6 @@ int32_t CFX_FileBufferArchive::AppendString(const CFX_ByteStringC& lpsz) {
}
void CFX_FileBufferArchive::AttachFile(IFX_StreamWrite* pFile) {
- FXSYS_assert(pFile);
+ ASSERT(pFile);
m_pFile = pFile;
}
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_gcc.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_gcc.cpp
index c3afe1115b9..a55a4862936 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_gcc.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_gcc.cpp
@@ -133,8 +133,8 @@ uint32_t FXSYS_GetModuleFileName(void* hModule, char* buf, uint32_t bufsize) {
extern "C" {
#endif
FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode) {
- return FXSYS_fopen(CFX_ByteString::FromUnicode(filename),
- CFX_ByteString::FromUnicode(mode));
+ return FXSYS_fopen(CFX_ByteString::FromUnicode(filename).c_str(),
+ CFX_ByteString::FromUnicode(mode).c_str());
}
char* FXSYS_strlwr(char* str) {
if (!str) {
@@ -226,9 +226,8 @@ int FXSYS_WideCharToMultiByte(uint32_t codepage,
int len = 0;
for (int i = 0; i < wlen; i++) {
if (wstr[i] < 0x100) {
- if (buf && len < buflen) {
- buf[len] = (FX_CHAR)wstr[i];
- }
+ if (buf && len < buflen)
+ buf[len] = static_cast<FX_CHAR>(wstr[i]);
len++;
}
}
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_memmgr_unittest.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_memmgr_unittest.cpp
index f69b1325dc1..3ce533012fe 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_memmgr_unittest.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_memmgr_unittest.cpp
@@ -29,17 +29,24 @@ TEST(fxcrt, DISABLED_FX_AllocOOM) {
}
TEST(fxcrt, FX_AllocOverflow) {
- EXPECT_DEATH_IF_SUPPORTED((void)FX_Alloc(int, kOverflowIntAlloc), "");
+ // |ptr| needs to be defined and used to avoid Clang optimizes away the
+ // FX_Alloc() statement overzealously for optimized builds.
+ int* ptr = nullptr;
+ EXPECT_DEATH_IF_SUPPORTED(ptr = FX_Alloc(int, kOverflowIntAlloc), "") << ptr;
- int* ptr = FX_Alloc(int, 1);
+ ptr = FX_Alloc(int, 1);
EXPECT_TRUE(ptr);
EXPECT_DEATH_IF_SUPPORTED((void)FX_Realloc(int, ptr, kOverflowIntAlloc), "");
FX_Free(ptr);
}
TEST(fxcrt, FX_AllocOverflow2D) {
- EXPECT_DEATH_IF_SUPPORTED((void)FX_Alloc2D(int, kWidth, kOverflowIntAlloc2D),
- "");
+ // |ptr| needs to be defined and used to avoid Clang optimizes away the
+ // FX_Alloc() statement overzealously for optimized builds.
+ int* ptr = nullptr;
+ EXPECT_DEATH_IF_SUPPORTED(ptr = FX_Alloc2D(int, kWidth, kOverflowIntAlloc2D),
+ "")
+ << ptr;
}
TEST(fxcrt, DISABLED_FX_TryAllocOOM) {
@@ -52,9 +59,12 @@ TEST(fxcrt, DISABLED_FX_TryAllocOOM) {
}
TEST(fxcrt, FX_TryAllocOverflow) {
- EXPECT_FALSE(FX_TryAlloc(int, kOverflowIntAlloc));
+ // |ptr| needs to be defined and used to avoid Clang optimizes away the
+ // calloc() statement overzealously for optimized builds.
+ int* ptr = (int*)calloc(sizeof(int), kOverflowIntAlloc);
+ EXPECT_FALSE(ptr) << ptr;
- int* ptr = FX_Alloc(int, 1);
+ ptr = FX_Alloc(int, 1);
EXPECT_TRUE(ptr);
EXPECT_FALSE(FX_TryRealloc(int, ptr, kOverflowIntAlloc));
FX_Free(ptr);
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_utf.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_utf.cpp
index e1996999f89..de219b40fd6 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_utf.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_utf.cpp
@@ -74,13 +74,12 @@ void CFX_UTF8Encoder::Input(FX_WCHAR unicode) {
}
}
CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len) {
- FXSYS_assert(pwsStr);
- if (len < 0) {
+ if (len < 0)
len = FXSYS_wcslen(pwsStr);
- }
+
CFX_UTF8Encoder encoder;
- while (len-- > 0) {
+ while (len-- > 0)
encoder.Input(*pwsStr++);
- }
- return encoder.GetResult();
+
+ return CFX_ByteString(encoder.GetResult());
}
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_util.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_util.cpp
index 4374dec7792..abb2b9472a1 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_util.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_util.cpp
@@ -95,21 +95,21 @@ void CFX_PrivateData::ClearAll() {
m_DataList.RemoveAll();
}
void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) {
- if (!FXSYS_memchr(strc.raw_str(), '.', strc.GetLength())) {
+ if (strc.Find('.') == -1) {
bInteger = TRUE;
- int cc = 0, integer = 0;
- const FX_CHAR* str = strc.c_str();
- int len = strc.GetLength();
- FX_BOOL bNegative = FALSE;
- if (str[0] == '+') {
+ int cc = 0;
+ int integer = 0;
+ FX_STRSIZE len = strc.GetLength();
+ bool bNegative = false;
+ if (strc[0] == '+') {
cc++;
- } else if (str[0] == '-') {
- bNegative = TRUE;
+ } else if (strc[0] == '-') {
+ bNegative = true;
cc++;
}
- while (cc < len && std::isdigit(str[cc])) {
+ while (cc < len && std::isdigit(strc[cc])) {
// TODO(dsinclair): This is not the right way to handle overflow.
- integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]);
+ integer = integer * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc));
if (integer < 0)
break;
cc++;
@@ -124,31 +124,30 @@ void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) {
}
}
FX_FLOAT FX_atof(const CFX_ByteStringC& strc) {
- if (strc.GetLength() == 0) {
+ if (strc.IsEmpty())
return 0.0;
- }
+
int cc = 0;
- FX_BOOL bNegative = FALSE;
- const FX_CHAR* str = strc.c_str();
+ bool bNegative = false;
int len = strc.GetLength();
- if (str[0] == '+') {
+ if (strc[0] == '+') {
cc++;
- } else if (str[0] == '-') {
+ } else if (strc[0] == '-') {
bNegative = TRUE;
cc++;
}
while (cc < len) {
- if (str[cc] != '+' && str[cc] != '-') {
+ if (strc[cc] != '+' && strc[cc] != '-') {
break;
}
cc++;
}
FX_FLOAT value = 0;
while (cc < len) {
- if (str[cc] == '.') {
+ if (strc[cc] == '.') {
break;
}
- value = value * 10 + FXSYS_toDecimalDigit(str[cc]);
+ value = value * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc));
cc++;
}
static const FX_FLOAT fraction_scales[] = {
@@ -156,14 +155,13 @@ FX_FLOAT FX_atof(const CFX_ByteStringC& strc) {
0.00001f, 0.000001f, 0.0000001f, 0.00000001f,
0.000000001f, 0.0000000001f, 0.00000000001f};
int scale = 0;
- if (cc < len && str[cc] == '.') {
+ if (cc < len && strc[cc] == '.') {
cc++;
while (cc < len) {
- value += fraction_scales[scale] * FXSYS_toDecimalDigit(str[cc]);
+ value += fraction_scales[scale] * FXSYS_toDecimalDigit(strc.CharAt(cc));
scale++;
- if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) {
+ if (scale == FX_ArraySize(fraction_scales))
break;
- }
cc++;
}
}
@@ -210,9 +208,9 @@ void* FX_OpenFolder(const FX_CHAR* path) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#ifndef _WIN32_WCE
CFindFileDataA* pData = new CFindFileDataA;
- pData->m_Handle =
- FindFirstFileExA(CFX_ByteString(path) + "/*.*", FindExInfoStandard,
- &pData->m_FindData, FindExSearchNameMatch, NULL, 0);
+ pData->m_Handle = FindFirstFileExA((CFX_ByteString(path) + "/*.*").c_str(),
+ FindExInfoStandard, &pData->m_FindData,
+ FindExSearchNameMatch, NULL, 0);
#else
CFindFileDataW* pData = new CFindFileDataW;
pData->m_Handle = FindFirstFileW(CFX_WideString::FromLocal(path) + L"/*.*",
@@ -242,7 +240,7 @@ void* FX_OpenFolder(const FX_WCHAR* path) {
pData->m_bEnd = FALSE;
return pData;
#else
- DIR* dir = opendir(CFX_ByteString::FromUnicode(path));
+ DIR* dir = opendir(CFX_ByteString::FromUnicode(path).c_str());
return dir;
#endif
}
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring.cpp
index 8940c1a37f3..ba86823fe23 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring.cpp
@@ -13,6 +13,9 @@
#include "core/fxcrt/include/fx_ext.h"
#include "third_party/base/numerics/safe_math.h"
+template class CFX_StringDataTemplate<FX_WCHAR>;
+template class CFX_StringCTemplate<FX_WCHAR>;
+
namespace {
#ifndef NDEBUG
@@ -31,173 +34,120 @@ bool IsValidCodePage(uint16_t codepage) {
}
#endif
+const FX_WCHAR* FX_wcsstr(const FX_WCHAR* haystack,
+ int haystack_len,
+ const FX_WCHAR* needle,
+ int needle_len) {
+ if (needle_len > haystack_len || needle_len == 0) {
+ return nullptr;
+ }
+ const FX_WCHAR* end_ptr = haystack + haystack_len - needle_len;
+ while (haystack <= end_ptr) {
+ int i = 0;
+ while (1) {
+ if (haystack[i] != needle[i]) {
+ break;
+ }
+ i++;
+ if (i == needle_len) {
+ return haystack;
+ }
+ }
+ haystack++;
+ }
+ return nullptr;
+}
+
} // namespace
-// static
-CFX_WideString::StringData* CFX_WideString::StringData::Create(int nLen) {
- // TODO(palmer): |nLen| should really be declared as |size_t|, or
- // at least unsigned.
- if (nLen == 0 || nLen < 0) {
- return NULL;
- }
+static_assert(sizeof(CFX_WideString) <= sizeof(FX_WCHAR*),
+ "Strings must not require more space than pointers");
- // Fixed portion of header plus a NUL wide char not in m_nAllocLength.
- int overhead = offsetof(StringData, m_String) + sizeof(FX_WCHAR);
- pdfium::base::CheckedNumeric<int> iSize = nLen;
- iSize *= sizeof(FX_WCHAR);
- iSize += overhead;
-
- // Now round to an 8-byte boundary. We'd expect that this is the minimum
- // granularity of any of the underlying allocators, so there may be cases
- // where we can save a re-alloc when adding a few characters to a string
- // by using this otherwise wasted space.
- iSize += 7;
- int totalSize = iSize.ValueOrDie() & ~7;
- int usableLen = (totalSize - overhead) / sizeof(FX_WCHAR);
- FXSYS_assert(usableLen >= nLen);
-
- void* pData = FX_Alloc(uint8_t, totalSize);
- return new (pData) StringData(nLen, usableLen);
-}
-CFX_WideString::~CFX_WideString() {
- if (m_pData) {
- m_pData->Release();
- }
-}
-CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) {
- if (!stringSrc.m_pData) {
- m_pData = NULL;
- return;
- }
- if (stringSrc.m_pData->m_nRefs >= 0) {
- m_pData = stringSrc.m_pData;
- m_pData->Retain();
- } else {
- m_pData = NULL;
- *this = stringSrc;
- }
-}
-CFX_WideString::CFX_WideString(const FX_WCHAR* lpsz, FX_STRSIZE nLen) {
- if (nLen < 0) {
- nLen = lpsz ? FXSYS_wcslen(lpsz) : 0;
- }
- if (nLen) {
- m_pData = StringData::Create(nLen);
- if (m_pData) {
- FXSYS_memcpy(m_pData->m_String, lpsz, nLen * sizeof(FX_WCHAR));
- }
- } else {
- m_pData = NULL;
- }
+CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) {
+ if (nLen < 0)
+ nLen = pStr ? FXSYS_wcslen(pStr) : 0;
+
+ if (nLen)
+ m_pData.Reset(StringData::Create(pStr, nLen));
}
+
CFX_WideString::CFX_WideString(FX_WCHAR ch) {
- m_pData = StringData::Create(1);
- if (m_pData) {
- m_pData->m_String[0] = ch;
- }
+ m_pData.Reset(StringData::Create(1));
+ m_pData->m_String[0] = ch;
}
-CFX_WideString::CFX_WideString(const CFX_WideStringC& str) {
- if (str.IsEmpty()) {
- m_pData = NULL;
- return;
- }
- m_pData = StringData::Create(str.GetLength());
- if (m_pData) {
- FXSYS_memcpy(m_pData->m_String, str.raw_str(),
- str.GetLength() * sizeof(FX_WCHAR));
+
+CFX_WideString::CFX_WideString(const CFX_WideStringC& stringSrc) {
+ if (!stringSrc.IsEmpty()) {
+ m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength()));
}
}
+
CFX_WideString::CFX_WideString(const CFX_WideStringC& str1,
const CFX_WideStringC& str2) {
- m_pData = NULL;
int nNewLen = str1.GetLength() + str2.GetLength();
- if (nNewLen == 0) {
- return;
- }
- m_pData = StringData::Create(nNewLen);
- if (m_pData) {
- FXSYS_memcpy(m_pData->m_String, str1.raw_str(),
- str1.GetLength() * sizeof(FX_WCHAR));
- FXSYS_memcpy(m_pData->m_String + str1.GetLength(), str2.raw_str(),
- str2.GetLength() * sizeof(FX_WCHAR));
- }
-}
-void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
- if (!m_pData) {
+ if (nNewLen == 0)
return;
- }
- CopyBeforeWrite();
- if (nNewLength == -1) {
- nNewLength = m_pData ? FXSYS_wcslen(m_pData->m_String) : 0;
- }
- if (nNewLength == 0) {
- Empty();
- return;
- }
- FXSYS_assert(nNewLength <= m_pData->m_nAllocLength);
- m_pData->m_nDataLength = nNewLength;
- m_pData->m_String[nNewLength] = 0;
+
+ m_pData.Reset(StringData::Create(nNewLen));
+ m_pData->CopyContents(str1.c_str(), str1.GetLength());
+ m_pData->CopyContentsAt(str1.GetLength(), str2.c_str(), str2.GetLength());
}
-const CFX_WideString& CFX_WideString::operator=(const FX_WCHAR* lpsz) {
- if (!lpsz || lpsz[0] == 0) {
- Empty();
- } else {
- AssignCopy(FXSYS_wcslen(lpsz), lpsz);
- }
+
+CFX_WideString::~CFX_WideString() {}
+
+const CFX_WideString& CFX_WideString::operator=(const FX_WCHAR* pStr) {
+ if (!pStr || !pStr[0])
+ clear();
+ else
+ AssignCopy(pStr, FXSYS_wcslen(pStr));
+
return *this;
}
+
const CFX_WideString& CFX_WideString::operator=(
const CFX_WideStringC& stringSrc) {
- if (stringSrc.IsEmpty()) {
- Empty();
- } else {
- AssignCopy(stringSrc.GetLength(), stringSrc.raw_str());
- }
+ if (stringSrc.IsEmpty())
+ clear();
+ else
+ AssignCopy(stringSrc.c_str(), stringSrc.GetLength());
+
return *this;
}
+
const CFX_WideString& CFX_WideString::operator=(
const CFX_WideString& stringSrc) {
- if (m_pData == stringSrc.m_pData) {
- return *this;
- }
- if (stringSrc.IsEmpty()) {
- Empty();
- } else if ((m_pData && m_pData->m_nRefs < 0) ||
- (stringSrc.m_pData && stringSrc.m_pData->m_nRefs < 0)) {
- AssignCopy(stringSrc.m_pData->m_nDataLength, stringSrc.m_pData->m_String);
- } else {
- Empty();
+ if (m_pData != stringSrc.m_pData)
m_pData = stringSrc.m_pData;
- if (m_pData) {
- m_pData->Retain();
- }
- }
+
return *this;
}
-const CFX_WideString& CFX_WideString::operator+=(FX_WCHAR ch) {
- ConcatInPlace(1, &ch);
+
+const CFX_WideString& CFX_WideString::operator+=(const FX_WCHAR* pStr) {
+ if (pStr)
+ Concat(pStr, FXSYS_wcslen(pStr));
+
return *this;
}
-const CFX_WideString& CFX_WideString::operator+=(const FX_WCHAR* lpsz) {
- if (lpsz) {
- ConcatInPlace(FXSYS_wcslen(lpsz), lpsz);
- }
+
+const CFX_WideString& CFX_WideString::operator+=(FX_WCHAR ch) {
+ Concat(&ch, 1);
return *this;
}
+
const CFX_WideString& CFX_WideString::operator+=(const CFX_WideString& str) {
- if (!str.m_pData) {
- return *this;
- }
- ConcatInPlace(str.m_pData->m_nDataLength, str.m_pData->m_String);
+ if (str.m_pData)
+ Concat(str.m_pData->m_String, str.m_pData->m_nDataLength);
+
return *this;
}
+
const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& str) {
- if (str.IsEmpty()) {
- return *this;
- }
- ConcatInPlace(str.GetLength(), str.raw_str());
+ if (!str.IsEmpty())
+ Concat(str.c_str(), str.GetLength());
+
return *this;
}
+
bool CFX_WideString::operator==(const wchar_t* ptr) const {
if (!m_pData)
return !ptr || !ptr[0];
@@ -208,13 +158,15 @@ bool CFX_WideString::operator==(const wchar_t* ptr) const {
return wcslen(ptr) == static_cast<size_t>(m_pData->m_nDataLength) &&
wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
+
bool CFX_WideString::operator==(const CFX_WideStringC& str) const {
if (!m_pData)
return str.IsEmpty();
- return str.GetLength() == m_pData->m_nDataLength &&
- wmemcmp(str.raw_str(), m_pData->m_String, m_pData->m_nDataLength) == 0;
+ return m_pData->m_nDataLength == str.GetLength() &&
+ wmemcmp(m_pData->m_String, str.c_str(), str.GetLength()) == 0;
}
+
bool CFX_WideString::operator==(const CFX_WideString& other) const {
if (IsEmpty())
return other.IsEmpty();
@@ -226,232 +178,183 @@ bool CFX_WideString::operator==(const CFX_WideString& other) const {
wmemcmp(other.m_pData->m_String, m_pData->m_String,
m_pData->m_nDataLength) == 0;
}
-void CFX_WideString::Empty() {
- if (m_pData) {
- m_pData->Release();
- m_pData = NULL;
- }
+
+void CFX_WideString::AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) {
+ AllocBeforeWrite(nSrcLen);
+ m_pData->CopyContents(pSrcData, nSrcLen);
+ m_pData->m_nDataLength = nSrcLen;
}
-void CFX_WideString::ConcatInPlace(FX_STRSIZE nSrcLen,
- const FX_WCHAR* lpszSrcData) {
- if (nSrcLen == 0 || !lpszSrcData) {
+
+void CFX_WideString::ReallocBeforeWrite(FX_STRSIZE nNewLength) {
+ if (m_pData && m_pData->CanOperateInPlace(nNewLength))
return;
- }
- if (!m_pData) {
- m_pData = StringData::Create(nSrcLen);
- if (m_pData) {
- FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR));
- }
+
+ if (nNewLength <= 0) {
+ clear();
return;
}
- if (m_pData->m_nRefs > 1 ||
- m_pData->m_nDataLength + nSrcLen > m_pData->m_nAllocLength) {
- ConcatCopy(m_pData->m_nDataLength, m_pData->m_String, nSrcLen, lpszSrcData);
+
+ CFX_RetainPtr<StringData> pNewData(StringData::Create(nNewLength));
+ if (m_pData) {
+ FX_STRSIZE nCopyLength = std::min(m_pData->m_nDataLength, nNewLength);
+ pNewData->CopyContents(m_pData->m_String, nCopyLength);
+ pNewData->m_nDataLength = nCopyLength;
} else {
- FXSYS_memcpy(m_pData->m_String + m_pData->m_nDataLength, lpszSrcData,
- nSrcLen * sizeof(FX_WCHAR));
- m_pData->m_nDataLength += nSrcLen;
- m_pData->m_String[m_pData->m_nDataLength] = 0;
+ pNewData->m_nDataLength = 0;
}
+ pNewData->m_String[pNewData->m_nDataLength] = 0;
+ m_pData.Swap(pNewData);
}
-void CFX_WideString::ConcatCopy(FX_STRSIZE nSrc1Len,
- const FX_WCHAR* lpszSrc1Data,
- FX_STRSIZE nSrc2Len,
- const FX_WCHAR* lpszSrc2Data) {
- FX_STRSIZE nNewLen = nSrc1Len + nSrc2Len;
- if (nNewLen <= 0) {
+
+void CFX_WideString::AllocBeforeWrite(FX_STRSIZE nNewLength) {
+ if (m_pData && m_pData->CanOperateInPlace(nNewLength))
return;
- }
- // Don't release until done copying, might be one of the arguments.
- StringData* pOldData = m_pData;
- m_pData = StringData::Create(nNewLen);
- if (m_pData) {
- wmemcpy(m_pData->m_String, lpszSrc1Data, nSrc1Len);
- wmemcpy(m_pData->m_String + nSrc1Len, lpszSrc2Data, nSrc2Len);
- }
- pOldData->Release();
-}
-void CFX_WideString::CopyBeforeWrite() {
- if (!m_pData || m_pData->m_nRefs <= 1) {
+
+ if (nNewLength <= 0) {
+ clear();
return;
}
- StringData* pData = m_pData;
- m_pData->Release();
- FX_STRSIZE nDataLength = pData->m_nDataLength;
- m_pData = StringData::Create(nDataLength);
- if (m_pData) {
- FXSYS_memcpy(m_pData->m_String, pData->m_String,
- (nDataLength + 1) * sizeof(FX_WCHAR));
- }
+
+ m_pData.Reset(StringData::Create(nNewLength));
}
-void CFX_WideString::AllocBeforeWrite(FX_STRSIZE nLen) {
- if (m_pData && m_pData->m_nRefs <= 1 && m_pData->m_nAllocLength >= nLen) {
+
+void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
+ if (!m_pData)
+ return;
+
+ if (nNewLength == -1)
+ nNewLength = FXSYS_wcslen(m_pData->m_String);
+
+ nNewLength = std::min(nNewLength, m_pData->m_nAllocLength);
+ if (nNewLength == 0) {
+ clear();
return;
}
- Empty();
- m_pData = StringData::Create(nLen);
-}
-void CFX_WideString::AssignCopy(FX_STRSIZE nSrcLen,
- const FX_WCHAR* lpszSrcData) {
- AllocBeforeWrite(nSrcLen);
- FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR));
- m_pData->m_nDataLength = nSrcLen;
- m_pData->m_String[nSrcLen] = 0;
-}
-int CFX_WideString::Compare(const FX_WCHAR* lpsz) const {
- if (m_pData)
- return FXSYS_wcscmp(m_pData->m_String, lpsz);
- return (!lpsz || lpsz[0] == 0) ? 0 : -1;
-}
-CFX_ByteString CFX_WideString::UTF8Encode() const {
- return FX_UTF8Encode(*this);
-}
-CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
- if (!m_pData) {
- return CFX_ByteString("\0\0", 2);
- }
- int len = m_pData->m_nDataLength;
- CFX_ByteString result;
- FX_CHAR* buffer = result.GetBuffer(len * 2 + 2);
- for (int i = 0; i < len; i++) {
- buffer[i * 2] = m_pData->m_String[i] & 0xff;
- buffer[i * 2 + 1] = m_pData->m_String[i] >> 8;
+
+ ASSERT(m_pData->m_nRefs == 1);
+ m_pData->m_nDataLength = nNewLength;
+ m_pData->m_String[nNewLength] = 0;
+ if (m_pData->m_nAllocLength - nNewLength >= 32) {
+ // Over arbitrary threshold, so pay the price to relocate. Force copy to
+ // always occur by holding a second reference to the string.
+ CFX_WideString preserve(*this);
+ ReallocBeforeWrite(nNewLength);
}
- buffer[len * 2] = 0;
- buffer[len * 2 + 1] = 0;
- result.ReleaseBuffer(len * 2 + 2);
- return result;
}
void CFX_WideString::Reserve(FX_STRSIZE len) {
GetBuffer(len);
- ReleaseBuffer(GetLength());
}
+
FX_WCHAR* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) {
- if (!m_pData && nMinBufLength == 0) {
- return NULL;
- }
- if (m_pData && m_pData->m_nRefs <= 1 &&
- m_pData->m_nAllocLength >= nMinBufLength) {
- return m_pData->m_String;
- }
if (!m_pData) {
- m_pData = StringData::Create(nMinBufLength);
- if (!m_pData) {
- return NULL;
- }
+ if (nMinBufLength == 0)
+ return nullptr;
+
+ m_pData.Reset(StringData::Create(nMinBufLength));
m_pData->m_nDataLength = 0;
m_pData->m_String[0] = 0;
return m_pData->m_String;
}
- StringData* pOldData = m_pData;
- FX_STRSIZE nOldLen = pOldData->m_nDataLength;
- if (nMinBufLength < nOldLen) {
- nMinBufLength = nOldLen;
- }
- m_pData = StringData::Create(nMinBufLength);
- if (!m_pData) {
- return NULL;
- }
- FXSYS_memcpy(m_pData->m_String, pOldData->m_String,
- (nOldLen + 1) * sizeof(FX_WCHAR));
- m_pData->m_nDataLength = nOldLen;
- pOldData->Release();
- return m_pData->m_String;
-}
-// static
-CFX_WideString CFX_WideString::FromLocal(const CFX_ByteString& str) {
- return FromCodePage(str, 0);
-}
+ if (m_pData->CanOperateInPlace(nMinBufLength))
+ return m_pData->m_String;
-// static
-CFX_WideString CFX_WideString::FromCodePage(const CFX_ByteString& str,
- uint16_t codepage) {
- return CFX_CharMap::GetWideString(codepage, str);
+ nMinBufLength = std::max(nMinBufLength, m_pData->m_nDataLength);
+ if (nMinBufLength == 0)
+ return nullptr;
+
+ CFX_RetainPtr<StringData> pNewData(StringData::Create(nMinBufLength));
+ pNewData->CopyContents(*m_pData);
+ pNewData->m_nDataLength = m_pData->m_nDataLength;
+ m_pData.Swap(pNewData);
+ return m_pData->m_String;
}
-// static
-CFX_WideString CFX_WideString::FromUTF8(const char* str, FX_STRSIZE len) {
- if (!str || 0 == len) {
- return CFX_WideString();
- }
+FX_STRSIZE CFX_WideString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) {
+ if (!m_pData)
+ return 0;
- CFX_UTF8Decoder decoder;
- for (FX_STRSIZE i = 0; i < len; i++) {
- decoder.Input(str[i]);
+ if (nIndex < 0)
+ nIndex = 0;
+
+ FX_STRSIZE nOldLength = m_pData->m_nDataLength;
+ if (nCount > 0 && nIndex < nOldLength) {
+ FX_STRSIZE mLength = nIndex + nCount;
+ if (mLength >= nOldLength) {
+ m_pData->m_nDataLength = nIndex;
+ return m_pData->m_nDataLength;
+ }
+ ReallocBeforeWrite(nOldLength);
+ int nCharsToCopy = nOldLength - mLength + 1;
+ wmemmove(m_pData->m_String + nIndex, m_pData->m_String + mLength,
+ nCharsToCopy);
+ m_pData->m_nDataLength = nOldLength - nCount;
}
- return decoder.GetResult();
+ return m_pData->m_nDataLength;
}
-// static
-CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr,
- FX_STRSIZE wlen) {
- if (!wstr || 0 == wlen) {
- return CFX_WideString();
+void CFX_WideString::Concat(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) {
+ if (!pSrcData || nSrcLen <= 0)
+ return;
+
+ if (!m_pData) {
+ m_pData.Reset(StringData::Create(pSrcData, nSrcLen));
+ return;
}
- CFX_WideString result;
- FX_WCHAR* buf = result.GetBuffer(wlen);
- for (int i = 0; i < wlen; i++) {
- buf[i] = wstr[i];
+ if (m_pData->CanOperateInPlace(m_pData->m_nDataLength + nSrcLen)) {
+ m_pData->CopyContentsAt(m_pData->m_nDataLength, pSrcData, nSrcLen);
+ m_pData->m_nDataLength += nSrcLen;
+ return;
}
- result.ReleaseBuffer(wlen);
- return result;
-}
-FX_STRSIZE CFX_WideString::WStringLength(const unsigned short* str) {
- FX_STRSIZE len = 0;
- if (str)
- while (str[len])
- len++;
- return len;
+ CFX_RetainPtr<StringData> pNewData(
+ StringData::Create(m_pData->m_nDataLength + nSrcLen));
+ pNewData->CopyContents(*m_pData);
+ pNewData->CopyContentsAt(m_pData->m_nDataLength, pSrcData, nSrcLen);
+ m_pData.Swap(pNewData);
}
-void CFX_WideString::AllocCopy(CFX_WideString& dest,
- FX_STRSIZE nCopyLen,
- FX_STRSIZE nCopyIndex) const {
- // |FX_STRSIZE| is currently typedef'd as in |int|. TODO(palmer): It
- // should be a |size_t|, or at least unsigned.
- if (nCopyLen == 0 || nCopyLen < 0) {
- return;
- }
- pdfium::base::CheckedNumeric<FX_STRSIZE> iSize =
- static_cast<FX_STRSIZE>(sizeof(FX_WCHAR));
- iSize *= nCopyLen;
- ASSERT(!dest.m_pData);
- dest.m_pData = StringData::Create(nCopyLen);
- if (dest.m_pData) {
- FXSYS_memcpy(dest.m_pData->m_String, m_pData->m_String + nCopyIndex,
- iSize.ValueOrDie());
- }
+// static
+CFX_ByteString CFX_WideString::UTF8Encode() const {
+ return FX_UTF8Encode(*this);
}
-CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const {
+
+// static
+CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
if (!m_pData) {
- return CFX_WideString();
- }
- if (nCount < 0) {
- nCount = 0;
+ return CFX_ByteString("\0\0", 2);
}
- if (nCount >= m_pData->m_nDataLength) {
- return *this;
+ int len = m_pData->m_nDataLength;
+ CFX_ByteString result;
+ FX_CHAR* buffer = result.GetBuffer(len * 2 + 2);
+ for (int i = 0; i < len; i++) {
+ buffer[i * 2] = m_pData->m_String[i] & 0xff;
+ buffer[i * 2 + 1] = m_pData->m_String[i] >> 8;
}
- CFX_WideString dest;
- AllocCopy(dest, nCount, 0);
- return dest;
+ buffer[len * 2] = 0;
+ buffer[len * 2 + 1] = 0;
+ result.ReleaseBuffer(len * 2 + 2);
+ return result;
}
+
CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst) const {
if (!m_pData)
return CFX_WideString();
return Mid(nFirst, m_pData->m_nDataLength - nFirst);
}
+
CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
if (!m_pData)
return CFX_WideString();
nFirst = std::min(std::max(nFirst, 0), m_pData->m_nDataLength);
nCount = std::min(std::max(nCount, 0), m_pData->m_nDataLength - nFirst);
+ if (nCount == 0)
+ return CFX_WideString();
+
if (nFirst == 0 && nCount == m_pData->m_nDataLength)
return *this;
@@ -459,302 +362,23 @@ CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
AllocCopy(dest, nCount, nFirst);
return dest;
}
-CFX_WideString CFX_WideString::Right(FX_STRSIZE nCount) const {
- if (!m_pData) {
- return CFX_WideString();
- }
- if (nCount < 0) {
- nCount = 0;
- }
- if (nCount >= m_pData->m_nDataLength) {
- return *this;
- }
- CFX_WideString dest;
- AllocCopy(dest, nCount, m_pData->m_nDataLength - nCount);
- return dest;
-}
-int CFX_WideString::CompareNoCase(const FX_WCHAR* lpsz) const {
- if (!m_pData) {
- return (!lpsz || lpsz[0] == 0) ? 0 : -1;
- }
- return FXSYS_wcsicmp(m_pData->m_String, lpsz);
-}
-int CFX_WideString::Compare(const CFX_WideString& str) const {
- if (!m_pData) {
- if (!str.m_pData) {
- return 0;
- }
- return -1;
- }
- if (!str.m_pData) {
- return 1;
- }
- int this_len = m_pData->m_nDataLength;
- int that_len = str.m_pData->m_nDataLength;
- int min_len = this_len < that_len ? this_len : that_len;
- for (int i = 0; i < min_len; i++) {
- if (m_pData->m_String[i] < str.m_pData->m_String[i]) {
- return -1;
- }
- if (m_pData->m_String[i] > str.m_pData->m_String[i]) {
- return 1;
- }
- }
- if (this_len < that_len) {
- return -1;
- }
- if (this_len > that_len) {
- return 1;
- }
- return 0;
-}
-void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) {
- if (!m_pData) {
- return;
- }
- ASSERT(nIndex >= 0);
- ASSERT(nIndex < m_pData->m_nDataLength);
- CopyBeforeWrite();
- m_pData->m_String[nIndex] = ch;
-}
-void CFX_WideString::MakeLower() {
- if (!m_pData) {
- return;
- }
- CopyBeforeWrite();
- if (GetLength() < 1) {
- return;
- }
- FXSYS_wcslwr(m_pData->m_String);
-}
-void CFX_WideString::MakeUpper() {
- if (!m_pData) {
- return;
- }
- CopyBeforeWrite();
- if (GetLength() < 1) {
- return;
- }
- FXSYS_wcsupr(m_pData->m_String);
-}
-FX_STRSIZE CFX_WideString::Find(const FX_WCHAR* lpszSub,
- FX_STRSIZE nStart) const {
- FX_STRSIZE nLength = GetLength();
- if (nLength < 1 || nStart > nLength) {
- return -1;
- }
- const FX_WCHAR* lpsz = FXSYS_wcsstr(m_pData->m_String + nStart, lpszSub);
- return lpsz ? (int)(lpsz - m_pData->m_String) : -1;
-}
-FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const {
- if (!m_pData) {
- return -1;
- }
- FX_STRSIZE nLength = m_pData->m_nDataLength;
- if (nStart >= nLength) {
- return -1;
- }
- const FX_WCHAR* lpsz = FXSYS_wcschr(m_pData->m_String + nStart, ch);
- return (lpsz) ? (int)(lpsz - m_pData->m_String) : -1;
-}
-void CFX_WideString::TrimRight(const FX_WCHAR* lpszTargetList) {
- FXSYS_assert(lpszTargetList);
- if (!m_pData || *lpszTargetList == 0) {
- return;
- }
- CopyBeforeWrite();
- FX_STRSIZE len = GetLength();
- if (len < 1) {
- return;
- }
- FX_STRSIZE pos = len;
- while (pos) {
- if (!FXSYS_wcschr(lpszTargetList, m_pData->m_String[pos - 1])) {
- break;
- }
- pos--;
- }
- if (pos < len) {
- m_pData->m_String[pos] = 0;
- m_pData->m_nDataLength = pos;
- }
-}
-void CFX_WideString::TrimRight(FX_WCHAR chTarget) {
- FX_WCHAR str[2] = {chTarget, 0};
- TrimRight(str);
-}
-void CFX_WideString::TrimRight() {
- TrimRight(L"\x09\x0a\x0b\x0c\x0d\x20");
-}
-void CFX_WideString::TrimLeft(const FX_WCHAR* lpszTargets) {
- FXSYS_assert(lpszTargets);
- if (!m_pData || *lpszTargets == 0) {
- return;
- }
- CopyBeforeWrite();
- if (GetLength() < 1) {
+
+void CFX_WideString::AllocCopy(CFX_WideString& dest,
+ FX_STRSIZE nCopyLen,
+ FX_STRSIZE nCopyIndex) const {
+ if (nCopyLen <= 0)
return;
- }
- const FX_WCHAR* lpsz = m_pData->m_String;
- while (*lpsz != 0) {
- if (!FXSYS_wcschr(lpszTargets, *lpsz)) {
- break;
- }
- lpsz++;
- }
- if (lpsz != m_pData->m_String) {
- int nDataLength =
- m_pData->m_nDataLength - (FX_STRSIZE)(lpsz - m_pData->m_String);
- FXSYS_memmove(m_pData->m_String, lpsz,
- (nDataLength + 1) * sizeof(FX_WCHAR));
- m_pData->m_nDataLength = nDataLength;
- }
-}
-void CFX_WideString::TrimLeft(FX_WCHAR chTarget) {
- FX_WCHAR str[2] = {chTarget, 0};
- TrimLeft(str);
-}
-void CFX_WideString::TrimLeft() {
- TrimLeft(L"\x09\x0a\x0b\x0c\x0d\x20");
-}
-FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld,
- const FX_WCHAR* lpszNew) {
- if (GetLength() < 1) {
- return 0;
- }
- if (!lpszOld) {
- return 0;
- }
- FX_STRSIZE nSourceLen = FXSYS_wcslen(lpszOld);
- if (nSourceLen == 0) {
- return 0;
- }
- FX_STRSIZE nReplacementLen = lpszNew ? FXSYS_wcslen(lpszNew) : 0;
- FX_STRSIZE nCount = 0;
- FX_WCHAR* lpszStart = m_pData->m_String;
- FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength;
- while (lpszStart < lpszEnd) {
- FX_WCHAR* lpszTarget = FXSYS_wcsstr(lpszStart, lpszOld);
- if (!lpszTarget)
- break;
- nCount++;
- lpszStart = lpszTarget + nSourceLen;
- }
- if (nCount > 0) {
- CopyBeforeWrite();
- FX_STRSIZE nOldLength = m_pData->m_nDataLength;
- FX_STRSIZE nNewLength =
- nOldLength + (nReplacementLen - nSourceLen) * nCount;
- if (m_pData->m_nAllocLength < nNewLength || m_pData->m_nRefs > 1) {
- StringData* pOldData = m_pData;
- const FX_WCHAR* pstr = m_pData->m_String;
- m_pData = StringData::Create(nNewLength);
- if (!m_pData) {
- return 0;
- }
- FXSYS_memcpy(m_pData->m_String, pstr,
- pOldData->m_nDataLength * sizeof(FX_WCHAR));
- pOldData->Release();
- }
- lpszStart = m_pData->m_String;
- lpszEnd = m_pData->m_String + std::max(m_pData->m_nDataLength, nNewLength);
- {
- while (lpszStart < lpszEnd) {
- FX_WCHAR* lpszTarget = FXSYS_wcsstr(lpszStart, lpszOld);
- if (!lpszTarget)
- break;
- FX_STRSIZE nBalance =
- nOldLength -
- (FX_STRSIZE)(lpszTarget - m_pData->m_String + nSourceLen);
- FXSYS_memmove(lpszTarget + nReplacementLen, lpszTarget + nSourceLen,
- nBalance * sizeof(FX_WCHAR));
- FXSYS_memcpy(lpszTarget, lpszNew, nReplacementLen * sizeof(FX_WCHAR));
- lpszStart = lpszTarget + nReplacementLen;
- lpszStart[nBalance] = 0;
- nOldLength += (nReplacementLen - nSourceLen);
- }
- }
- ASSERT(m_pData->m_String[nNewLength] == 0);
- m_pData->m_nDataLength = nNewLength;
- }
- return nCount;
-}
-FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, FX_WCHAR ch) {
- CopyBeforeWrite();
- if (nIndex < 0) {
- nIndex = 0;
- }
- FX_STRSIZE nNewLength = GetLength();
- if (nIndex > nNewLength) {
- nIndex = nNewLength;
- }
- nNewLength++;
- if (!m_pData || m_pData->m_nAllocLength < nNewLength) {
- StringData* pOldData = m_pData;
- const FX_WCHAR* pstr = m_pData->m_String;
- m_pData = StringData::Create(nNewLength);
- if (!m_pData) {
- return 0;
- }
- if (pOldData) {
- FXSYS_memmove(m_pData->m_String, pstr,
- (pOldData->m_nDataLength + 1) * sizeof(FX_WCHAR));
- pOldData->Release();
- } else {
- m_pData->m_String[0] = 0;
- }
- }
- FXSYS_memmove(m_pData->m_String + nIndex + 1, m_pData->m_String + nIndex,
- (nNewLength - nIndex) * sizeof(FX_WCHAR));
- m_pData->m_String[nIndex] = ch;
- m_pData->m_nDataLength = nNewLength;
- return nNewLength;
-}
-FX_STRSIZE CFX_WideString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) {
- if (GetLength() < 1) {
- return 0;
- }
- if (nIndex < 0) {
- nIndex = 0;
- }
- FX_STRSIZE nOldLength = m_pData->m_nDataLength;
- if (nCount > 0 && nIndex < nOldLength) {
- CopyBeforeWrite();
- int nBytesToCopy = nOldLength - (nIndex + nCount) + 1;
- FXSYS_memmove(m_pData->m_String + nIndex,
- m_pData->m_String + nIndex + nCount,
- nBytesToCopy * sizeof(FX_WCHAR));
- m_pData->m_nDataLength = nOldLength - nCount;
- }
- return m_pData->m_nDataLength;
-}
-FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) {
- if (!m_pData) {
- return 0;
- }
- CopyBeforeWrite();
- if (GetLength() < 1) {
- return 0;
- }
- FX_WCHAR* pstrSource = m_pData->m_String;
- FX_WCHAR* pstrDest = m_pData->m_String;
- FX_WCHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength;
- while (pstrSource < pstrEnd) {
- if (*pstrSource != chRemove) {
- *pstrDest = *pstrSource;
- pstrDest++;
- }
- pstrSource++;
- }
- *pstrDest = 0;
- FX_STRSIZE nCount = (FX_STRSIZE)(pstrSource - pstrDest);
- m_pData->m_nDataLength -= nCount;
- return nCount;
+
+ CFX_RetainPtr<StringData> pNewData(
+ StringData::Create(m_pData->m_String + nCopyIndex, nCopyLen));
+ dest.m_pData.Swap(pNewData);
}
+
#define FORCE_ANSI 0x10000
#define FORCE_UNICODE 0x20000
#define FORCE_INT64 0x40000
-void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
+
+void CFX_WideString::FormatV(const FX_WCHAR* pFormat, va_list argList) {
va_list argListSave;
#if defined(__ARMCC_VERSION) || \
(!defined(_MSC_VER) && (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || \
@@ -765,71 +389,71 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
argListSave = argList;
#endif
int nMaxLen = 0;
- for (const FX_WCHAR* lpsz = lpszFormat; *lpsz != 0; lpsz++) {
- if (*lpsz != '%' || *(lpsz = lpsz + 1) == '%') {
- nMaxLen += FXSYS_wcslen(lpsz);
+ for (const FX_WCHAR* pStr = pFormat; *pStr != 0; pStr++) {
+ if (*pStr != '%' || *(pStr = pStr + 1) == '%') {
+ nMaxLen += FXSYS_wcslen(pStr);
continue;
}
int nItemLen = 0;
int nWidth = 0;
- for (; *lpsz != 0; lpsz++) {
- if (*lpsz == '#') {
+ for (; *pStr != 0; pStr++) {
+ if (*pStr == '#') {
nMaxLen += 2;
- } else if (*lpsz == '*') {
+ } else if (*pStr == '*') {
nWidth = va_arg(argList, int);
- } else if (*lpsz != '-' && *lpsz != '+' && *lpsz != '0' && *lpsz != ' ') {
+ } else if (*pStr != '-' && *pStr != '+' && *pStr != '0' && *pStr != ' ') {
break;
}
}
if (nWidth == 0) {
- nWidth = FXSYS_wtoi(lpsz);
- while (std::iswdigit(*lpsz))
- ++lpsz;
+ nWidth = FXSYS_wtoi(pStr);
+ while (std::iswdigit(*pStr))
+ ++pStr;
}
if (nWidth < 0 || nWidth > 128 * 1024) {
- lpszFormat = L"Bad width";
+ pFormat = L"Bad width";
nMaxLen = 10;
break;
}
int nPrecision = 0;
- if (*lpsz == '.') {
- lpsz++;
- if (*lpsz == '*') {
+ if (*pStr == '.') {
+ pStr++;
+ if (*pStr == '*') {
nPrecision = va_arg(argList, int);
- lpsz++;
+ pStr++;
} else {
- nPrecision = FXSYS_wtoi(lpsz);
- while (std::iswdigit(*lpsz))
- ++lpsz;
+ nPrecision = FXSYS_wtoi(pStr);
+ while (std::iswdigit(*pStr))
+ ++pStr;
}
}
if (nPrecision < 0 || nPrecision > 128 * 1024) {
- lpszFormat = L"Bad precision";
+ pFormat = L"Bad precision";
nMaxLen = 14;
break;
}
int nModifier = 0;
- if (*lpsz == L'I' && *(lpsz + 1) == L'6' && *(lpsz + 2) == L'4') {
- lpsz += 3;
+ if (*pStr == L'I' && *(pStr + 1) == L'6' && *(pStr + 2) == L'4') {
+ pStr += 3;
nModifier = FORCE_INT64;
} else {
- switch (*lpsz) {
+ switch (*pStr) {
case 'h':
nModifier = FORCE_ANSI;
- lpsz++;
+ pStr++;
break;
case 'l':
nModifier = FORCE_UNICODE;
- lpsz++;
+ pStr++;
break;
case 'F':
case 'N':
case 'L':
- lpsz++;
+ pStr++;
break;
}
}
- switch (*lpsz | nModifier) {
+ switch (*pStr | nModifier) {
case 'c':
case 'C':
nItemLen = 2;
@@ -881,7 +505,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
} break;
case 's' | FORCE_UNICODE:
case 'S' | FORCE_UNICODE: {
- FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*);
+ const FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*);
if (pstrNextArg) {
nItemLen = FXSYS_wcslen(pstrNextArg);
if (nItemLen < 1) {
@@ -900,7 +524,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
nItemLen = nWidth;
}
} else {
- switch (*lpsz) {
+ switch (*pStr) {
case 'd':
case 'i':
case 'u':
@@ -958,17 +582,344 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) {
GetBuffer(nMaxLen);
if (m_pData) {
FXSYS_vswprintf((wchar_t*)m_pData->m_String, nMaxLen + 1,
- (const wchar_t*)lpszFormat, argListSave);
+ (const wchar_t*)pFormat, argListSave);
ReleaseBuffer();
}
va_end(argListSave);
}
-void CFX_WideString::Format(const FX_WCHAR* lpszFormat, ...) {
+
+void CFX_WideString::Format(const FX_WCHAR* pFormat, ...) {
va_list argList;
- va_start(argList, lpszFormat);
- FormatV(lpszFormat, argList);
+ va_start(argList, pFormat);
+ FormatV(pFormat, argList);
va_end(argList);
}
+
+FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, FX_WCHAR ch) {
+ FX_STRSIZE nNewLength = m_pData ? m_pData->m_nDataLength : 0;
+ nIndex = std::max(nIndex, 0);
+ nIndex = std::min(nIndex, nNewLength);
+ nNewLength++;
+
+ ReallocBeforeWrite(nNewLength);
+ wmemmove(m_pData->m_String + nIndex + 1, m_pData->m_String + nIndex,
+ nNewLength - nIndex);
+ m_pData->m_String[nIndex] = ch;
+ m_pData->m_nDataLength = nNewLength;
+ return nNewLength;
+}
+
+CFX_WideString CFX_WideString::Right(FX_STRSIZE nCount) const {
+ if (!m_pData)
+ return CFX_WideString();
+
+ nCount = std::max(nCount, 0);
+ if (nCount >= m_pData->m_nDataLength)
+ return *this;
+
+ CFX_WideString dest;
+ AllocCopy(dest, nCount, m_pData->m_nDataLength - nCount);
+ return dest;
+}
+
+CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const {
+ if (!m_pData)
+ return CFX_WideString();
+
+ nCount = std::max(nCount, 0);
+ if (nCount >= m_pData->m_nDataLength)
+ return *this;
+
+ CFX_WideString dest;
+ AllocCopy(dest, nCount, 0);
+ return dest;
+}
+
+FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const {
+ if (!m_pData)
+ return -1;
+
+ if (nStart < 0 || nStart >= m_pData->m_nDataLength)
+ return -1;
+
+ const FX_WCHAR* pStr =
+ wmemchr(m_pData->m_String + nStart, ch, m_pData->m_nDataLength - nStart);
+ return pStr ? pStr - m_pData->m_String : -1;
+}
+
+FX_STRSIZE CFX_WideString::Find(const CFX_WideStringC& pSub,
+ FX_STRSIZE nStart) const {
+ if (!m_pData)
+ return -1;
+
+ FX_STRSIZE nLength = m_pData->m_nDataLength;
+ if (nStart > nLength)
+ return -1;
+
+ const FX_WCHAR* pStr =
+ FX_wcsstr(m_pData->m_String + nStart, m_pData->m_nDataLength - nStart,
+ pSub.c_str(), pSub.GetLength());
+ return pStr ? (int)(pStr - m_pData->m_String) : -1;
+}
+
+void CFX_WideString::MakeLower() {
+ if (!m_pData)
+ return;
+
+ ReallocBeforeWrite(m_pData->m_nDataLength);
+ FXSYS_wcslwr(m_pData->m_String);
+}
+
+void CFX_WideString::MakeUpper() {
+ if (!m_pData)
+ return;
+
+ ReallocBeforeWrite(m_pData->m_nDataLength);
+ FXSYS_wcsupr(m_pData->m_String);
+}
+
+FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) {
+ if (!m_pData || m_pData->m_nDataLength < 1)
+ return 0;
+
+ FX_WCHAR* pstrSource = m_pData->m_String;
+ FX_WCHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength;
+ while (pstrSource < pstrEnd) {
+ if (*pstrSource == chRemove)
+ break;
+ pstrSource++;
+ }
+ if (pstrSource == pstrEnd)
+ return 0;
+
+ ptrdiff_t copied = pstrSource - m_pData->m_String;
+ ReallocBeforeWrite(m_pData->m_nDataLength);
+ pstrSource = m_pData->m_String + copied;
+ pstrEnd = m_pData->m_String + m_pData->m_nDataLength;
+
+ FX_WCHAR* pstrDest = pstrSource;
+ while (pstrSource < pstrEnd) {
+ if (*pstrSource != chRemove) {
+ *pstrDest = *pstrSource;
+ pstrDest++;
+ }
+ pstrSource++;
+ }
+
+ *pstrDest = 0;
+ FX_STRSIZE nCount = (FX_STRSIZE)(pstrSource - pstrDest);
+ m_pData->m_nDataLength -= nCount;
+ return nCount;
+}
+
+FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld,
+ const CFX_WideStringC& pNew) {
+ if (!m_pData || pOld.IsEmpty())
+ return 0;
+
+ FX_STRSIZE nSourceLen = pOld.GetLength();
+ FX_STRSIZE nReplacementLen = pNew.GetLength();
+ FX_STRSIZE nCount = 0;
+ const FX_WCHAR* pStart = m_pData->m_String;
+ FX_WCHAR* pEnd = m_pData->m_String + m_pData->m_nDataLength;
+ while (1) {
+ const FX_WCHAR* pTarget = FX_wcsstr(pStart, (FX_STRSIZE)(pEnd - pStart),
+ pOld.c_str(), nSourceLen);
+ if (!pTarget)
+ break;
+
+ nCount++;
+ pStart = pTarget + nSourceLen;
+ }
+ if (nCount == 0)
+ return 0;
+
+ FX_STRSIZE nNewLength =
+ m_pData->m_nDataLength + (nReplacementLen - nSourceLen) * nCount;
+
+ if (nNewLength == 0) {
+ clear();
+ return nCount;
+ }
+
+ CFX_RetainPtr<StringData> pNewData(StringData::Create(nNewLength));
+ pStart = m_pData->m_String;
+ FX_WCHAR* pDest = pNewData->m_String;
+ for (FX_STRSIZE i = 0; i < nCount; i++) {
+ const FX_WCHAR* pTarget = FX_wcsstr(pStart, (FX_STRSIZE)(pEnd - pStart),
+ pOld.c_str(), nSourceLen);
+ wmemcpy(pDest, pStart, pTarget - pStart);
+ pDest += pTarget - pStart;
+ wmemcpy(pDest, pNew.c_str(), pNew.GetLength());
+ pDest += pNew.GetLength();
+ pStart = pTarget + nSourceLen;
+ }
+ wmemcpy(pDest, pStart, pEnd - pStart);
+ m_pData.Swap(pNewData);
+ return nCount;
+}
+
+void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) {
+ if (!m_pData) {
+ return;
+ }
+ ASSERT(nIndex >= 0);
+ ASSERT(nIndex < m_pData->m_nDataLength);
+ ReallocBeforeWrite(m_pData->m_nDataLength);
+ m_pData->m_String[nIndex] = ch;
+}
+
+// static
+CFX_WideString CFX_WideString::FromLocal(const CFX_ByteStringC& str) {
+ return FromCodePage(str, 0);
+}
+
+// static
+CFX_WideString CFX_WideString::FromCodePage(const CFX_ByteStringC& str,
+ uint16_t codepage) {
+ return CFX_CharMap::GetWideString(codepage, str);
+}
+
+// static
+CFX_WideString CFX_WideString::FromUTF8(const CFX_ByteStringC& str) {
+ if (str.IsEmpty())
+ return CFX_WideString();
+
+ CFX_UTF8Decoder decoder;
+ for (FX_STRSIZE i = 0; i < str.GetLength(); i++)
+ decoder.Input(str[i]);
+
+ return CFX_WideString(decoder.GetResult());
+}
+
+// static
+CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr,
+ FX_STRSIZE wlen) {
+ if (!wstr || 0 == wlen) {
+ return CFX_WideString();
+ }
+
+ CFX_WideString result;
+ FX_WCHAR* buf = result.GetBuffer(wlen);
+ for (int i = 0; i < wlen; i++) {
+ buf[i] = wstr[i];
+ }
+ result.ReleaseBuffer(wlen);
+ return result;
+}
+
+int CFX_WideString::Compare(const FX_WCHAR* lpsz) const {
+ if (m_pData)
+ return FXSYS_wcscmp(m_pData->m_String, lpsz);
+ return (!lpsz || lpsz[0] == 0) ? 0 : -1;
+}
+
+int CFX_WideString::Compare(const CFX_WideString& str) const {
+ if (!m_pData) {
+ if (!str.m_pData) {
+ return 0;
+ }
+ return -1;
+ }
+ if (!str.m_pData) {
+ return 1;
+ }
+ int this_len = m_pData->m_nDataLength;
+ int that_len = str.m_pData->m_nDataLength;
+ int min_len = this_len < that_len ? this_len : that_len;
+ for (int i = 0; i < min_len; i++) {
+ if (m_pData->m_String[i] < str.m_pData->m_String[i]) {
+ return -1;
+ }
+ if (m_pData->m_String[i] > str.m_pData->m_String[i]) {
+ return 1;
+ }
+ }
+ if (this_len < that_len) {
+ return -1;
+ }
+ if (this_len > that_len) {
+ return 1;
+ }
+ return 0;
+}
+
+int CFX_WideString::CompareNoCase(const FX_WCHAR* lpsz) const {
+ if (!m_pData) {
+ return (!lpsz || lpsz[0] == 0) ? 0 : -1;
+ }
+ return FXSYS_wcsicmp(m_pData->m_String, lpsz);
+}
+
+FX_STRSIZE CFX_WideString::WStringLength(const unsigned short* str) {
+ FX_STRSIZE len = 0;
+ if (str)
+ while (str[len])
+ len++;
+ return len;
+}
+
+void CFX_WideString::TrimRight(const CFX_WideStringC& pTargets) {
+ if (IsEmpty() || pTargets.IsEmpty())
+ return;
+
+ FX_STRSIZE pos = GetLength();
+ while (pos && pTargets.Find(m_pData->m_String[pos - 1]) != -1)
+ pos--;
+
+ if (pos < m_pData->m_nDataLength) {
+ ReallocBeforeWrite(m_pData->m_nDataLength);
+ m_pData->m_String[pos] = 0;
+ m_pData->m_nDataLength = pos;
+ }
+}
+
+void CFX_WideString::TrimRight(FX_WCHAR chTarget) {
+ FX_WCHAR str[2] = {chTarget, 0};
+ TrimRight(str);
+}
+
+void CFX_WideString::TrimRight() {
+ TrimRight(L"\x09\x0a\x0b\x0c\x0d\x20");
+}
+
+void CFX_WideString::TrimLeft(const CFX_WideStringC& pTargets) {
+ if (!m_pData || pTargets.IsEmpty())
+ return;
+
+ FX_STRSIZE len = GetLength();
+ if (len < 1)
+ return;
+
+ FX_STRSIZE pos = 0;
+ while (pos < len) {
+ FX_STRSIZE i = 0;
+ while (i < pTargets.GetLength() &&
+ pTargets.CharAt(i) != m_pData->m_String[pos]) {
+ i++;
+ }
+ if (i == pTargets.GetLength()) {
+ break;
+ }
+ pos++;
+ }
+ if (pos) {
+ ReallocBeforeWrite(len);
+ FX_STRSIZE nDataLength = len - pos;
+ FXSYS_memmove(m_pData->m_String, m_pData->m_String + pos,
+ (nDataLength + 1) * sizeof(FX_WCHAR));
+ m_pData->m_nDataLength = nDataLength;
+ }
+}
+
+void CFX_WideString::TrimLeft(FX_WCHAR chTarget) {
+ FX_WCHAR str[2] = {chTarget, 0};
+ TrimLeft(str);
+}
+
+void CFX_WideString::TrimLeft() {
+ TrimLeft(L"\x09\x0a\x0b\x0c\x0d\x20");
+}
FX_FLOAT FX_wtof(const FX_WCHAR* str, int len) {
if (len == 0) {
return 0.0;
@@ -1002,17 +953,19 @@ FX_FLOAT FX_wtof(const FX_WCHAR* str, int len) {
fraction += (FX_FLOAT)integer;
return bNegative ? -fraction : fraction;
}
+
int CFX_WideString::GetInteger() const {
return m_pData ? FXSYS_wtoi(m_pData->m_String) : 0;
}
+
FX_FLOAT CFX_WideString::GetFloat() const {
return m_pData ? FX_wtof(m_pData->m_String, m_pData->m_nDataLength) : 0.0f;
}
// static
CFX_ByteString CFX_CharMap::GetByteString(uint16_t codepage,
- const CFX_WideString& wstr) {
- FXSYS_assert(IsValidCodePage(codepage));
+ const CFX_WideStringC& wstr) {
+ ASSERT(IsValidCodePage(codepage));
int src_len = wstr.GetLength();
int dest_len = FXSYS_WideCharToMultiByte(codepage, 0, wstr.c_str(), src_len,
nullptr, 0, nullptr, nullptr);
@@ -1028,15 +981,16 @@ CFX_ByteString CFX_CharMap::GetByteString(uint16_t codepage,
// static
CFX_WideString CFX_CharMap::GetWideString(uint16_t codepage,
- const CFX_ByteString& bstr) {
- FXSYS_assert(IsValidCodePage(codepage));
+ const CFX_ByteStringC& bstr) {
+ ASSERT(IsValidCodePage(codepage));
int src_len = bstr.GetLength();
int dest_len =
- FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0);
+ FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0);
CFX_WideString wstr;
if (dest_len) {
FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len);
- FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len);
+ FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf,
+ dest_len);
wstr.ReleaseBuffer(dest_len);
}
return wstr;
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring_unittest.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring_unittest.cpp
index 8f0084619d4..efd958d8a65 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring_unittest.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_basic_wstring_unittest.cpp
@@ -251,26 +251,26 @@ TEST(fxcrt, WideStringOperatorNE) {
TEST(fxcrt, WideStringConcatInPlace) {
CFX_WideString fred;
- fred.ConcatInPlace(4, L"FRED");
+ fred.Concat(L"FRED", 4);
EXPECT_EQ(L"FRED", fred);
- fred.ConcatInPlace(2, L"DY");
+ fred.Concat(L"DY", 2);
EXPECT_EQ(L"FREDDY", fred);
fred.Delete(3, 3);
EXPECT_EQ(L"FRE", fred);
- fred.ConcatInPlace(1, L"D");
+ fred.Concat(L"D", 1);
EXPECT_EQ(L"FRED", fred);
CFX_WideString copy = fred;
- fred.ConcatInPlace(2, L"DY");
+ fred.Concat(L"DY", 2);
EXPECT_EQ(L"FREDDY", fred);
EXPECT_EQ(L"FRED", copy);
// Test invalid arguments.
copy = fred;
- fred.ConcatInPlace(-6, L"freddy");
+ fred.Concat(L"freddy", -6);
CFX_WideString not_aliased(L"xxxxxx");
EXPECT_EQ(L"FREDDY", fred);
EXPECT_EQ(L"xxxxxx", not_aliased);
@@ -294,6 +294,35 @@ TEST(fxcrt, WideStringRemove) {
EXPECT_EQ(L"", empty);
}
+TEST(fxcrt, WideStringRemoveCopies) {
+ CFX_WideString freed(L"FREED");
+ const FX_WCHAR* old_buffer = freed.c_str();
+
+ // No change with single reference - no copy.
+ freed.Remove(L'Q');
+ EXPECT_EQ(L"FREED", freed);
+ EXPECT_EQ(old_buffer, freed.c_str());
+
+ // Change with single reference - no copy.
+ freed.Remove(L'E');
+ EXPECT_EQ(L"FRD", freed);
+ EXPECT_EQ(old_buffer, freed.c_str());
+
+ // No change with multiple references - no copy.
+ CFX_WideString shared(freed);
+ freed.Remove(L'Q');
+ EXPECT_EQ(L"FRD", freed);
+ EXPECT_EQ(old_buffer, freed.c_str());
+ EXPECT_EQ(old_buffer, shared.c_str());
+
+ // Change with multiple references -- must copy.
+ freed.Remove(L'D');
+ EXPECT_EQ(L"FR", freed);
+ EXPECT_NE(old_buffer, freed.c_str());
+ EXPECT_EQ(L"FRD", shared);
+ EXPECT_EQ(old_buffer, shared.c_str());
+}
+
TEST(fxcrt, WideStringReplace) {
CFX_WideString fred(L"FRED");
fred.Replace(L"FR", L"BL");
@@ -472,6 +501,37 @@ TEST(fxcrt, WideStringTrimRight) {
EXPECT_EQ(L"", empty);
}
+TEST(fxcrt, WideStringTrimRightCopies) {
+ {
+ // With a single reference, no copy takes place.
+ CFX_WideString fred(L" FRED ");
+ const FX_WCHAR* old_buffer = fred.c_str();
+ fred.TrimRight();
+ EXPECT_EQ(L" FRED", fred);
+ EXPECT_EQ(old_buffer, fred.c_str());
+ }
+ {
+ // With multiple references, we must copy.
+ CFX_WideString fred(L" FRED ");
+ CFX_WideString other_fred = fred;
+ const FX_WCHAR* old_buffer = fred.c_str();
+ fred.TrimRight();
+ EXPECT_EQ(L" FRED", fred);
+ EXPECT_EQ(L" FRED ", other_fred);
+ EXPECT_NE(old_buffer, fred.c_str());
+ }
+ {
+ // With multiple references, but no modifications, no copy.
+ CFX_WideString fred(L"FRED");
+ CFX_WideString other_fred = fred;
+ const FX_WCHAR* old_buffer = fred.c_str();
+ fred.TrimRight();
+ EXPECT_EQ(L"FRED", fred);
+ EXPECT_EQ(L"FRED", other_fred);
+ EXPECT_EQ(old_buffer, fred.c_str());
+ }
+}
+
TEST(fxcrt, WideStringTrimLeft) {
CFX_WideString fred(L" FRED ");
fred.TrimLeft();
@@ -500,6 +560,114 @@ TEST(fxcrt, WideStringTrimLeft) {
EXPECT_EQ(L"", empty);
}
+TEST(fxcrt, WideStringTrimLeftCopies) {
+ {
+ // With a single reference, no copy takes place.
+ CFX_WideString fred(L" FRED ");
+ const FX_WCHAR* old_buffer = fred.c_str();
+ fred.TrimLeft();
+ EXPECT_EQ(L"FRED ", fred);
+ EXPECT_EQ(old_buffer, fred.c_str());
+ }
+ {
+ // With multiple references, we must copy.
+ CFX_WideString fred(L" FRED ");
+ CFX_WideString other_fred = fred;
+ const FX_WCHAR* old_buffer = fred.c_str();
+ fred.TrimLeft();
+ EXPECT_EQ(L"FRED ", fred);
+ EXPECT_EQ(L" FRED ", other_fred);
+ EXPECT_NE(old_buffer, fred.c_str());
+ }
+ {
+ // With multiple references, but no modifications, no copy.
+ CFX_WideString fred(L"FRED");
+ CFX_WideString other_fred = fred;
+ const FX_WCHAR* old_buffer = fred.c_str();
+ fred.TrimLeft();
+ EXPECT_EQ(L"FRED", fred);
+ EXPECT_EQ(L"FRED", other_fred);
+ EXPECT_EQ(old_buffer, fred.c_str());
+ }
+}
+
+TEST(fxcrt, WideStringReserve) {
+ {
+ CFX_WideString str;
+ str.Reserve(6);
+ const FX_WCHAR* old_buffer = str.c_str();
+ str += L"ABCDEF";
+ EXPECT_EQ(old_buffer, str.c_str());
+ str += L"Blah Blah Blah Blah Blah Blah";
+ EXPECT_NE(old_buffer, str.c_str());
+ }
+ {
+ CFX_WideString str(L"A");
+ str.Reserve(6);
+ const FX_WCHAR* old_buffer = str.c_str();
+ str += L"BCDEF";
+ EXPECT_EQ(old_buffer, str.c_str());
+ str += L"Blah Blah Blah Blah Blah Blah";
+ EXPECT_NE(old_buffer, str.c_str());
+ }
+}
+
+TEST(fxcrt, WideStringGetBuffer) {
+ {
+ CFX_WideString str;
+ FX_WCHAR* buffer = str.GetBuffer(12);
+ wcscpy(buffer, L"clams");
+ str.ReleaseBuffer();
+ EXPECT_EQ(L"clams", str);
+ }
+ {
+ CFX_WideString str(L"cl");
+ FX_WCHAR* buffer = str.GetBuffer(12);
+ wcscpy(buffer + 2, L"ams");
+ str.ReleaseBuffer();
+ EXPECT_EQ(L"clams", str);
+ }
+}
+
+TEST(fxcrt, WideStringReleaseBuffer) {
+ {
+ CFX_WideString str;
+ str.Reserve(12);
+ str += L"clams";
+ const FX_WCHAR* old_buffer = str.c_str();
+ str.ReleaseBuffer(4);
+ EXPECT_EQ(old_buffer, str.c_str());
+ EXPECT_EQ(L"clam", str);
+ }
+ {
+ CFX_WideString str(L"c");
+ str.Reserve(12);
+ str += L"lams";
+ const FX_WCHAR* old_buffer = str.c_str();
+ str.ReleaseBuffer(4);
+ EXPECT_EQ(old_buffer, str.c_str());
+ EXPECT_EQ(L"clam", str);
+ }
+ {
+ CFX_WideString str;
+ str.Reserve(200);
+ str += L"clams";
+ const FX_WCHAR* old_buffer = str.c_str();
+ str.ReleaseBuffer(4);
+ EXPECT_NE(old_buffer, str.c_str());
+ EXPECT_EQ(L"clam", str);
+ }
+ {
+ CFX_WideString str(L"c");
+ str.Reserve(200);
+ str += L"lams";
+ const FX_WCHAR* old_buffer = str.c_str();
+ str.ReleaseBuffer(4);
+ EXPECT_NE(old_buffer, str.c_str());
+ EXPECT_EQ(L"clam", str);
+ }
+}
+
TEST(fxcrt, WideStringUTF16LE_Encode) {
struct UTF16LEEncodeCase {
CFX_WideString ws;
@@ -523,10 +691,10 @@ TEST(fxcrt, WideStringUTF16LE_Encode) {
TEST(fxcrt, WideStringCOperatorSubscript) {
// CFX_WideStringC includes the NUL terminator for non-empty strings.
CFX_WideStringC abc(L"abc");
- EXPECT_EQ(L'a', abc[0]);
- EXPECT_EQ(L'b', abc[1]);
- EXPECT_EQ(L'c', abc[2]);
- EXPECT_EQ(L'\0', abc[3]);
+ EXPECT_EQ(L'a', abc.CharAt(0));
+ EXPECT_EQ(L'b', abc.CharAt(1));
+ EXPECT_EQ(L'c', abc.CharAt(2));
+ EXPECT_EQ(L'\0', abc.CharAt(3));
}
TEST(fxcrt, WideStringCOperatorLT) {
@@ -663,6 +831,31 @@ TEST(fxcrt, WideStringCOperatorNE) {
EXPECT_TRUE(c_string3 != wide_string_c);
}
+TEST(fxcrt, WideStringCFind) {
+ CFX_WideStringC null_string;
+ EXPECT_EQ(-1, null_string.Find(L'a'));
+ EXPECT_EQ(-1, null_string.Find(0));
+
+ CFX_WideStringC empty_string(L"");
+ EXPECT_EQ(-1, empty_string.Find(L'a'));
+ EXPECT_EQ(-1, empty_string.Find(0));
+
+ CFX_WideStringC single_string(L"a");
+ EXPECT_EQ(0, single_string.Find(L'a'));
+ EXPECT_EQ(-1, single_string.Find(L'b'));
+ EXPECT_EQ(-1, single_string.Find(0));
+
+ CFX_WideStringC longer_string(L"abccc");
+ EXPECT_EQ(0, longer_string.Find(L'a'));
+ EXPECT_EQ(2, longer_string.Find(L'c'));
+ EXPECT_EQ(-1, longer_string.Find(0));
+
+ CFX_WideStringC hibyte_string(
+ L"ab\xff08"
+ L"def");
+ EXPECT_EQ(2, hibyte_string.Find(L'\xff08'));
+}
+
TEST(fxcrt, WideStringFormatWidth) {
{
CFX_WideString str;
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_extension.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_extension.cpp
index 7e8029babae..315e33fd7e8 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_extension.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_extension.cpp
@@ -129,18 +129,18 @@ FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) {
FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr,
int32_t iLength,
int32_t* pUsedLen) {
- FXSYS_assert(pcsStr);
+ ASSERT(pcsStr);
if (iLength < 0) {
iLength = (int32_t)FXSYS_strlen(pcsStr);
}
CFX_WideString ws =
- CFX_WideString::FromLocal(CFX_ByteString(pcsStr, iLength));
+ CFX_WideString::FromLocal(CFX_ByteStringC(pcsStr, iLength));
return FXSYS_wcstof(ws.c_str(), iLength, pUsedLen);
}
FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr,
int32_t iLength,
int32_t* pUsedLen) {
- FXSYS_assert(pwsStr);
+ ASSERT(pwsStr);
if (iLength < 0) {
iLength = (int32_t)FXSYS_wcslen(pwsStr);
}
@@ -186,7 +186,7 @@ FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr,
FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr,
const FX_WCHAR* srcStr,
size_t count) {
- FXSYS_assert(dstStr && srcStr && count > 0);
+ ASSERT(dstStr && srcStr && count > 0);
for (size_t i = 0; i < count; ++i)
if ((dstStr[i] = srcStr[i]) == L'\0') {
break;
@@ -194,7 +194,7 @@ FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr,
return dstStr;
}
int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) {
- FXSYS_assert(s1 && s2 && count > 0);
+ ASSERT(s1 && s2 && count > 0);
FX_WCHAR wch1 = 0, wch2 = 0;
while (count-- > 0) {
wch1 = (FX_WCHAR)FXSYS_tolower(*s1++);
@@ -206,7 +206,7 @@ int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) {
return wch1 - wch2;
}
int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) {
- FXSYS_assert(s1 && s2 && count > 0);
+ ASSERT(s1 && s2 && count > 0);
FX_CHAR ch1 = 0, ch2 = 0;
while (count-- > 0) {
ch1 = (FX_CHAR)FXSYS_tolower(*s1++);
@@ -217,34 +217,22 @@ int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) {
}
return ch1 - ch2;
}
-uint32_t FX_HashCode_String_GetA(const FX_CHAR* pStr,
- int32_t iLength,
- FX_BOOL bIgnoreCase) {
- FXSYS_assert(pStr);
- if (iLength < 0) {
- iLength = (int32_t)FXSYS_strlen(pStr);
- }
- const FX_CHAR* pStrEnd = pStr + iLength;
+
+uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase) {
uint32_t dwHashCode = 0;
if (bIgnoreCase) {
- while (pStr < pStrEnd) {
- dwHashCode = 31 * dwHashCode + FXSYS_tolower(*pStr++);
- }
+ for (FX_STRSIZE i = 0; i < str.GetLength(); ++i)
+ dwHashCode = 31 * dwHashCode + FXSYS_tolower(str.CharAt(i));
} else {
- while (pStr < pStrEnd) {
- dwHashCode = 31 * dwHashCode + *pStr++;
- }
+ for (FX_STRSIZE i = 0; i < str.GetLength(); ++i)
+ dwHashCode = 31 * dwHashCode + str.CharAt(i);
}
return dwHashCode;
}
-uint32_t FX_HashCode_String_GetW(const FX_WCHAR* pStr,
- int32_t iLength,
- FX_BOOL bIgnoreCase) {
- FXSYS_assert(pStr);
- if (iLength < 0) {
- iLength = (int32_t)FXSYS_wcslen(pStr);
- }
- const FX_WCHAR* pStrEnd = pStr + iLength;
+
+uint32_t FX_HashCode_GetW(const CFX_WideStringC& str, bool bIgnoreCase) {
+ const FX_WCHAR* pStr = str.c_str();
+ const FX_WCHAR* pStrEnd = pStr + str.GetLength();
uint32_t dwHashCode = 0;
if (bIgnoreCase) {
while (pStr < pStrEnd) {
@@ -270,7 +258,7 @@ void* FX_Random_MT_Start(uint32_t dwSeed) {
return pContext;
}
uint32_t FX_Random_MT_Generate(void* pContext) {
- FXSYS_assert(pContext);
+ ASSERT(pContext);
FX_MTRANDOMCONTEXT* pMTC = static_cast<FX_MTRANDOMCONTEXT*>(pContext);
uint32_t v;
static uint32_t mag[2] = {0, MT_Matrix_A};
@@ -301,7 +289,7 @@ uint32_t FX_Random_MT_Generate(void* pContext) {
return v;
}
void FX_Random_MT_Close(void* pContext) {
- FXSYS_assert(pContext);
+ ASSERT(pContext);
FX_Free(pContext);
}
void FX_Random_GenerateMT(uint32_t* pBuffer, int32_t iCount) {
@@ -327,9 +315,9 @@ void FX_Random_GenerateBase(uint32_t* pBuffer, int32_t iCount) {
::GetSystemTime(&st2);
} while (FXSYS_memcmp(&st1, &st2, sizeof(SYSTEMTIME)) == 0);
uint32_t dwHash1 =
- FX_HashCode_String_GetA((const FX_CHAR*)&st1, sizeof(st1), TRUE);
+ FX_HashCode_GetA(CFX_ByteStringC((uint8_t*)&st1, sizeof(st1)), true);
uint32_t dwHash2 =
- FX_HashCode_String_GetA((const FX_CHAR*)&st2, sizeof(st2), TRUE);
+ FX_HashCode_GetA(CFX_ByteStringC((uint8_t*)&st2, sizeof(st2)), true);
::srand((dwHash1 << 16) | (uint32_t)dwHash2);
#else
time_t tmLast = time(NULL);
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_extension_unittest.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_extension_unittest.cpp
index 7714999bbfa..954e0956edd 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_extension_unittest.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_extension_unittest.cpp
@@ -26,3 +26,17 @@ TEST(fxcrt, FXSYS_isDecimalDigit) {
EXPECT_FALSE(FXSYS_isDecimalDigit('a'));
EXPECT_FALSE(FXSYS_isDecimalDigit(L'a'));
}
+
+TEST(fxcrt, FX_HashCode_Ascii) {
+ EXPECT_EQ(0u, FX_HashCode_GetA("", false));
+ EXPECT_EQ(65u, FX_HashCode_GetA("A", false));
+ EXPECT_EQ(97u, FX_HashCode_GetA("A", true));
+ EXPECT_EQ(31 * 65u + 66u, FX_HashCode_GetA("AB", false));
+}
+
+TEST(fxcrt, FX_HashCode_Wide) {
+ EXPECT_EQ(0u, FX_HashCode_GetW(L"", false));
+ EXPECT_EQ(65u, FX_HashCode_GetW(L"A", false));
+ EXPECT_EQ(97u, FX_HashCode_GetW(L"A", true));
+ EXPECT_EQ(1313 * 65u + 66u, FX_HashCode_GetW(L"AB", false));
+}
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_xml_composer.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_xml_composer.cpp
index 576ff954322..1bad069c342 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_xml_composer.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_xml_composer.cpp
@@ -11,24 +11,18 @@
void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
CFX_ByteStringC& bsSpace,
CFX_ByteStringC& bsName) {
- if (bsFullName.IsEmpty()) {
+ if (bsFullName.IsEmpty())
return;
- }
- int32_t iStart = 0;
- for (; iStart < bsFullName.GetLength(); iStart++) {
- if (bsFullName.GetAt(iStart) == ':') {
- break;
- }
- }
- if (iStart >= bsFullName.GetLength()) {
+
+ FX_STRSIZE iStart = bsFullName.Find(':');
+ if (iStart == -1) {
bsName = bsFullName;
} else {
- bsSpace = CFX_ByteStringC(bsFullName.c_str(), iStart);
- iStart++;
- bsName = CFX_ByteStringC(bsFullName.c_str() + iStart,
- bsFullName.GetLength() - iStart);
+ bsSpace = bsFullName.Mid(0, iStart);
+ bsName = bsFullName.Mid(iStart + 1);
}
}
+
void CXML_Element::SetTag(const CFX_ByteStringC& qSpace,
const CFX_ByteStringC& tagname) {
m_QSpaceName = qSpace;
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_xml_parser.cpp b/chromium/third_party/pdfium/core/fxcrt/fx_xml_parser.cpp
index d59a6b97806..6017bd8fda4 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_xml_parser.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fx_xml_parser.cpp
@@ -132,7 +132,7 @@ void CXML_Parser::GetName(CFX_ByteString& space, CFX_ByteString& name) {
while (m_dwIndex < m_dwBufferSize) {
ch = m_pBuffer[m_dwIndex];
if (ch == ':') {
- space = buf.GetByteString();
+ space = buf.AsStringC();
buf.Clear();
} else if (g_FXCRT_XML_IsNameChar(ch)) {
buf.AppendChar(ch);
@@ -146,7 +146,7 @@ void CXML_Parser::GetName(CFX_ByteString& space, CFX_ByteString& name) {
break;
}
} while (ReadNextBlock());
- name = buf.GetByteString();
+ name = buf.AsStringC();
}
void CXML_Parser::SkipLiterals(const CFX_ByteStringC& str) {
m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
@@ -202,7 +202,7 @@ uint32_t CXML_Parser::GetCharRef() {
case 1:
m_dwIndex++;
if (ch == ';') {
- CFX_ByteStringC ref = buf.GetByteString();
+ CFX_ByteStringC ref = buf.AsStringC();
if (ref == "gt") {
code = '>';
} else if (ref == "lt") {
@@ -371,7 +371,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
}
CXML_Element* pElement = new CXML_Element;
pElement->m_pParent = pParent;
- pElement->SetTag(tag_space.AsByteStringC(), tag_name.AsByteStringC());
+ pElement->SetTag(tag_space.AsStringC(), tag_name.AsStringC());
do {
CFX_ByteString attr_space, attr_name;
while (m_dwIndex < m_dwBufferSize) {
@@ -397,9 +397,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
}
CFX_WideString attr_value;
GetAttrValue(attr_value);
- pElement->m_AttrMap.SetAt(attr_space.AsByteStringC(),
- attr_name.AsByteStringC(),
- attr_value.AsWideStringC());
+ pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value);
}
m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
if (m_dwIndex < m_dwBufferSize || IsEOF()) {
@@ -458,11 +456,11 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
iState = 10;
} else {
content << decoder.GetResult();
- CFX_WideString dataStr = content.GetWideString();
+ CFX_WideString dataStr = content.MakeString();
if (!bCDATA && !m_bSaveSpaceChars) {
dataStr.TrimRight(L" \t\r\n");
}
- InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement);
+ InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement);
content.Clear();
decoder.Clear();
bCDATA = FALSE;
@@ -502,11 +500,11 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
}
} while (ReadNextBlock());
content << decoder.GetResult();
- CFX_WideString dataStr = content.GetWideString();
+ CFX_WideString dataStr = content.MakeString();
if (!m_bSaveSpaceChars) {
dataStr.TrimRight(L" \t\r\n");
}
- InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement);
+ InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement);
content.Clear();
decoder.Clear();
bCDATA = FALSE;
@@ -598,14 +596,13 @@ CFX_ByteString CXML_Element::GetTagName(FX_BOOL bQualified) const {
bsTag += m_TagName;
return bsTag;
}
+
CFX_ByteString CXML_Element::GetNamespace(FX_BOOL bQualified) const {
- if (bQualified) {
- return m_QSpaceName;
- }
- return GetNamespaceURI(m_QSpaceName.AsByteStringC());
+ return bQualified ? m_QSpaceName : GetNamespaceURI(m_QSpaceName);
}
+
CFX_ByteString CXML_Element::GetNamespaceURI(
- const CFX_ByteStringC& qName) const {
+ const CFX_ByteString& qName) const {
const CFX_WideString* pwsSpace;
const CXML_Element* pElement = this;
do {
@@ -634,20 +631,23 @@ void CXML_Element::GetAttrByIndex(int index,
value = item.m_Value;
}
FX_BOOL CXML_Element::HasAttr(const CFX_ByteStringC& name) const {
- CFX_ByteStringC bsSpace, bsName;
+ CFX_ByteStringC bsSpace;
+ CFX_ByteStringC bsName;
FX_XML_SplitQualifiedName(name, bsSpace, bsName);
- return !!m_AttrMap.Lookup(bsSpace, bsName);
+ return !!m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName));
}
FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& name,
CFX_WideString& attribute) const {
- CFX_ByteStringC bsSpace, bsName;
+ CFX_ByteStringC bsSpace;
+ CFX_ByteStringC bsName;
FX_XML_SplitQualifiedName(name, bsSpace, bsName);
return GetAttrValue(bsSpace, bsName, attribute);
}
FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& space,
const CFX_ByteStringC& name,
CFX_WideString& attribute) const {
- const CFX_WideString* pValue = m_AttrMap.Lookup(space, name);
+ const CFX_WideString* pValue =
+ m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name));
if (pValue) {
attribute = *pValue;
return TRUE;
@@ -656,9 +656,11 @@ FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& space,
}
FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& name,
int& attribute) const {
- CFX_ByteStringC bsSpace, bsName;
+ CFX_ByteStringC bsSpace;
+ CFX_ByteStringC bsName;
FX_XML_SplitQualifiedName(name, bsSpace, bsName);
- const CFX_WideString* pwsValue = m_AttrMap.Lookup(bsSpace, bsName);
+ const CFX_WideString* pwsValue =
+ m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName));
if (pwsValue) {
attribute = pwsValue->GetInteger();
return TRUE;
@@ -668,7 +670,8 @@ FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& name,
FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& space,
const CFX_ByteStringC& name,
int& attribute) const {
- const CFX_WideString* pwsValue = m_AttrMap.Lookup(space, name);
+ const CFX_WideString* pwsValue =
+ m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name));
if (pwsValue) {
attribute = pwsValue->GetInteger();
return TRUE;
@@ -684,7 +687,8 @@ FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& name,
FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& space,
const CFX_ByteStringC& name,
FX_FLOAT& attribute) const {
- const CFX_WideString* pValue = m_AttrMap.Lookup(space, name);
+ const CFX_WideString* pValue =
+ m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name));
if (pValue) {
attribute = pValue->GetFloat();
return TRUE;
@@ -755,13 +759,13 @@ uint32_t CXML_Element::FindElement(CXML_Element* pChild) const {
return (uint32_t)-1;
}
-bool CXML_AttrItem::Matches(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name) const {
+bool CXML_AttrItem::Matches(const CFX_ByteString& space,
+ const CFX_ByteString& name) const {
return (space.IsEmpty() || m_QSpaceName == space) && m_AttrName == name;
}
-const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name) const {
+const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteString& space,
+ const CFX_ByteString& name) const {
if (!m_pMap)
return nullptr;
@@ -772,9 +776,9 @@ const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space,
return nullptr;
}
-void CXML_AttrMap::SetAt(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name,
- const CFX_WideStringC& value) {
+void CXML_AttrMap::SetAt(const CFX_ByteString& space,
+ const CFX_ByteString& name,
+ const CFX_WideString& value) {
if (!m_pMap)
m_pMap.reset(new std::vector<CXML_AttrItem>);
@@ -785,7 +789,7 @@ void CXML_AttrMap::SetAt(const CFX_ByteStringC& space,
}
}
- m_pMap->push_back({space, name, value});
+ m_pMap->push_back({space, name, CFX_WideString(value)});
}
int CXML_AttrMap::GetSize() const {
diff --git a/chromium/third_party/pdfium/core/fxcrt/fxcrt_posix.cpp b/chromium/third_party/pdfium/core/fxcrt/fxcrt_posix.cpp
index a18bb69c550..9237acef6bf 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fxcrt_posix.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fxcrt_posix.cpp
@@ -45,7 +45,7 @@ FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName,
}
FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName,
uint32_t dwMode) {
- return Open(FX_UTF8Encode(fileName).AsByteStringC(), dwMode);
+ return Open(FX_UTF8Encode(fileName).AsStringC(), dwMode);
}
void CFXCRT_FileAccess_Posix::Close() {
if (m_nFD < 0) {
diff --git a/chromium/third_party/pdfium/core/fxcrt/fxcrt_windows.cpp b/chromium/third_party/pdfium/core/fxcrt/fxcrt_windows.cpp
index 8c7c0d8176a..eb584ca804c 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fxcrt_windows.cpp
+++ b/chromium/third_party/pdfium/core/fxcrt/fxcrt_windows.cpp
@@ -61,7 +61,7 @@ FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName,
}
uint32_t dwAccess, dwShare, dwCreation;
FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation);
- m_hFile = ::CreateFileW((LPCWSTR)fileName.raw_str(), dwAccess, dwShare, NULL,
+ m_hFile = ::CreateFileW((LPCWSTR)fileName.c_str(), dwAccess, dwShare, NULL,
dwCreation, FILE_ATTRIBUTE_NORMAL, NULL);
if (m_hFile == INVALID_HANDLE_VALUE) {
m_hFile = NULL;
diff --git a/chromium/third_party/pdfium/core/fxcrt/fx_arabic.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_arabic.h
index 694bc510204..2617d1897fb 100644
--- a/chromium/third_party/pdfium/core/fxcrt/fx_arabic.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_arabic.h
@@ -4,29 +4,29 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCRT_FX_ARABIC_H_
-#define CORE_FXCRT_FX_ARABIC_H_
+#ifndef CORE_FXCRT_INCLUDE_FX_ARABIC_H_
+#define CORE_FXCRT_INCLUDE_FX_ARABIC_H_
#include "core/fxcrt/include/fx_arb.h"
-class CFX_ArabicChar : public IFX_ArabicChar {
- public:
- virtual void Release() { delete this; }
- virtual FX_BOOL IsArabicChar(FX_WCHAR wch) const;
- virtual FX_BOOL IsArabicFormChar(FX_WCHAR wch) const;
+#define FX_BIDIMAXLEVEL 61
+#define FX_BidiDirection(a) (FX_IsOdd(a) ? FX_BIDICLASS_R : FX_BIDICLASS_L)
+#define FX_BidiGetDeferredType(a) (((a) >> 4) & 0x0F)
+#define FX_BidiGetResolvedType(a) ((a)&0x0F)
- virtual FX_WCHAR GetFormChar(FX_WCHAR wch,
- FX_WCHAR prev = 0,
- FX_WCHAR next = 0) const;
- virtual FX_WCHAR GetFormChar(const CFX_Char* cur,
- const CFX_Char* prev,
- const CFX_Char* next) const;
+namespace pdfium {
+namespace arabic {
+
+bool IsArabicChar(FX_WCHAR wch);
+bool IsArabicFormChar(FX_WCHAR wch);
+FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev = 0, FX_WCHAR next = 0);
+FX_WCHAR GetFormChar(const CFX_Char* cur,
+ const CFX_Char* prev,
+ const CFX_Char* next);
+
+} // namespace arabic
+} // namespace pdfium
- protected:
- const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
- FX_WCHAR& wChar,
- FX_CHARTYPE& eType) const;
-};
void FX_BidiReverseString(CFX_WideString& wsText,
int32_t iStart,
int32_t iCount);
@@ -34,32 +34,9 @@ void FX_BidiSetDeferredRun(CFX_Int32Array& values,
int32_t iStart,
int32_t iCount,
int32_t iValue);
-#define FX_BCON FX_BIDICLASS_ON
-#define FX_BCL FX_BIDICLASS_L
-#define FX_BCR FX_BIDICLASS_R
-#define FX_BCAN FX_BIDICLASS_AN
-#define FX_BCEN FX_BIDICLASS_EN
-#define FX_BCAL FX_BIDICLASS_AL
-#define FX_BCNSM FX_BIDICLASS_NSM
-#define FX_BCCS FX_BIDICLASS_CS
-#define FX_BCES FX_BIDICLASS_ES
-#define FX_BCET FX_BIDICLASS_ET
-#define FX_BCBN FX_BIDICLASS_BN
-#define FX_BCS FX_BIDICLASS_S
-#define FX_BCWS FX_BIDICLASS_WS
-#define FX_BCB FX_BIDICLASS_B
-#define FX_BCRLO FX_BIDICLASS_RLO
-#define FX_BCRLE FX_BIDICLASS_RLE
-#define FX_BCLRO FX_BIDICLASS_LRO
-#define FX_BCLRE FX_BIDICLASS_LRE
-#define FX_BCPDF FX_BIDICLASS_PDF
-#define FX_BCN FX_BIDICLASS_N
void FX_BidiClassify(const CFX_WideString& wsText,
CFX_Int32Array& classes,
FX_BOOL bWS = FALSE);
-#define FX_BIDIMAXLEVEL 61
-#define FX_BidiGreaterEven(a) (FX_IsOdd(a) ? ((a) + 1) : ((a) + 2))
-#define FX_BidiGreaterOdd(a) (FX_IsOdd(a) ? ((a) + 2) : ((a) + 1))
int32_t FX_BidiResolveExplicit(int32_t iBaseLevel,
int32_t iDirection,
CFX_Int32Array& classes,
@@ -67,7 +44,7 @@ int32_t FX_BidiResolveExplicit(int32_t iBaseLevel,
int32_t iStart,
int32_t iCount,
int32_t iNest = 0);
-#define FX_BidiDirection(a) (FX_IsOdd(a) ? FX_BIDICLASS_R : FX_BIDICLASS_L)
+
enum FX_BIDIWEAKSTATE {
FX_BIDIWEAKSTATE_xa = 0,
FX_BIDIWEAKSTATE_xr,
@@ -110,6 +87,7 @@ enum FX_BIDIWEAKSTATE {
#define FX_BWSls FX_BIDIWEAKSTATE_ls
#define FX_BWSret FX_BIDIWEAKSTATE_ret
#define FX_BWSlet FX_BIDIWEAKSTATE_let
+
enum FX_BIDIWEAKACTION {
FX_BIDIWEAKACTION_IX = 0x100,
FX_BIDIWEAKACTION_XX = 0x0F,
@@ -156,8 +134,7 @@ enum FX_BIDIWEAKACTION {
#define FX_BWAxIL FX_BIDIWEAKACTION_xIL
#define FX_BWAAxR FX_BIDIWEAKACTION_AxR
#define FX_BWALxx FX_BIDIWEAKACTION_Lxx
-#define FX_BidiGetDeferredType(a) (((a) >> 4) & 0x0F)
-#define FX_BidiGetResolvedType(a) ((a)&0x0F)
+
void FX_BidiResolveWeak(int32_t iBaseLevel,
CFX_Int32Array& classes,
CFX_Int32Array& levels);
@@ -208,4 +185,4 @@ void FX_BidiReorder(int32_t iBaseLevel,
CFX_WideString& wsText,
const CFX_Int32Array& levels);
-#endif // CORE_FXCRT_FX_ARABIC_H_
+#endif // CORE_FXCRT_INCLUDE_FX_ARABIC_H_
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_arb.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_arb.h
index 6a0af83150e..6928519a804 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_arb.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_arb.h
@@ -10,8 +10,6 @@
#include "core/fxcrt/include/fx_system.h"
#include "core/fxcrt/include/fx_ucd.h"
-class IFX_ArabicChar;
-
struct FX_ARBFORMTABLE {
uint16_t wIsolated;
uint16_t wFinal;
@@ -40,21 +38,6 @@ enum FX_ARBPOSITION {
FX_ARBPOSITION_Medial,
};
-class IFX_ArabicChar {
- public:
- static IFX_ArabicChar* Create();
- virtual ~IFX_ArabicChar() {}
- virtual void Release() = 0;
- virtual FX_BOOL IsArabicChar(FX_WCHAR wch) const = 0;
- virtual FX_BOOL IsArabicFormChar(FX_WCHAR wch) const = 0;
- virtual FX_WCHAR GetFormChar(FX_WCHAR wch,
- FX_WCHAR prev = 0,
- FX_WCHAR next = 0) const = 0;
- virtual FX_WCHAR GetFormChar(const CFX_Char* cur,
- const CFX_Char* prev,
- const CFX_Char* next) const = 0;
-};
-
void FX_BidiLine(CFX_WideString& wsText, int32_t iBaseLevel = 0);
void FX_BidiLine(CFX_TxtCharArray& chars,
int32_t iCount,
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_basic.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_basic.h
index 2ef11beb277..59d72b8f5ae 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_basic.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_basic.h
@@ -56,10 +56,15 @@ class CFX_BinaryBuf {
class CFX_ByteTextBuf : public CFX_BinaryBuf {
public:
- void AppendChar(int ch) { AppendByte((uint8_t)ch); }
FX_STRSIZE GetLength() const { return m_DataSize; }
- CFX_ByteStringC GetByteString() const;
+ CFX_ByteString MakeString() const {
+ return CFX_ByteString(m_pBuffer.get(), m_DataSize);
+ }
+ CFX_ByteStringC AsStringC() const {
+ return CFX_ByteStringC(m_pBuffer.get(), m_DataSize);
+ }
+ void AppendChar(int ch) { AppendByte(static_cast<uint8_t>(ch)); }
CFX_ByteTextBuf& operator<<(int i);
CFX_ByteTextBuf& operator<<(uint32_t i);
CFX_ByteTextBuf& operator<<(double f);
@@ -67,7 +72,7 @@ class CFX_ByteTextBuf : public CFX_BinaryBuf {
return *this << CFX_ByteStringC(pStr);
}
CFX_ByteTextBuf& operator<<(const CFX_ByteString& str) {
- return *this << str.AsByteStringC();
+ return *this << str.AsStringC();
}
CFX_ByteTextBuf& operator<<(const CFX_ByteStringC& lpsz);
CFX_ByteTextBuf& operator<<(const CFX_ByteTextBuf& buf);
@@ -80,7 +85,15 @@ class CFX_WideTextBuf : public CFX_BinaryBuf {
FX_WCHAR* GetBuffer() const {
return reinterpret_cast<FX_WCHAR*>(m_pBuffer.get());
}
- CFX_WideStringC GetWideString() const;
+
+ CFX_WideStringC AsStringC() const {
+ return CFX_WideStringC(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()),
+ m_DataSize / sizeof(FX_WCHAR));
+ }
+ CFX_WideString MakeString() const {
+ return CFX_WideString(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()),
+ m_DataSize / sizeof(FX_WCHAR));
+ }
void Delete(int start_index, int count) {
CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR),
@@ -186,10 +199,10 @@ class CFX_FileBufferArchive {
class CFX_CharMap {
public:
static CFX_ByteString GetByteString(uint16_t codepage,
- const CFX_WideString& wstr);
+ const CFX_WideStringC& wstr);
static CFX_WideString GetWideString(uint16_t codepage,
- const CFX_ByteString& bstr);
+ const CFX_ByteStringC& bstr);
CFX_CharMap() = delete;
};
@@ -206,7 +219,7 @@ class CFX_UTF8Decoder {
void ClearStatus() { m_PendingBytes = 0; }
- CFX_WideStringC GetResult() const { return m_Buffer.GetWideString(); }
+ CFX_WideStringC GetResult() const { return m_Buffer.AsStringC(); }
protected:
int m_PendingBytes;
@@ -222,7 +235,7 @@ class CFX_UTF8Encoder {
void Input(FX_WCHAR unicode);
void AppendStr(const CFX_ByteStringC& str) { m_Buffer << str; }
- CFX_ByteStringC GetResult() const { return m_Buffer.GetByteString(); }
+ CFX_ByteStringC GetResult() const { return m_Buffer.AsStringC(); }
protected:
CFX_ByteTextBuf m_Buffer;
@@ -231,32 +244,24 @@ class CFX_UTF8Encoder {
class CFX_BasicArray {
protected:
CFX_BasicArray(int unit_size);
-
+ CFX_BasicArray(const CFX_BasicArray&) = delete;
~CFX_BasicArray();
FX_BOOL SetSize(int nNewSize);
-
FX_BOOL Append(const CFX_BasicArray& src);
-
FX_BOOL Copy(const CFX_BasicArray& src);
-
uint8_t* InsertSpaceAt(int nIndex, int nCount);
-
FX_BOOL RemoveAt(int nIndex, int nCount);
-
FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray);
-
const void* GetDataPtr(int index) const;
protected:
uint8_t* m_pData;
-
int m_nSize;
-
int m_nMaxSize;
-
int m_nUnitSize;
};
+
template <class TYPE>
class CFX_ArrayTemplate : public CFX_BasicArray {
public:
@@ -272,7 +277,7 @@ class CFX_ArrayTemplate : public CFX_BasicArray {
const TYPE GetAt(int nIndex) const {
if (nIndex < 0 || nIndex >= m_nSize) {
- return (const TYPE&)(*(volatile const TYPE*)NULL);
+ PDFIUM_IMMEDIATE_CRASH();
}
return ((const TYPE*)m_pData)[nIndex];
}
@@ -287,7 +292,7 @@ class CFX_ArrayTemplate : public CFX_BasicArray {
TYPE& ElementAt(int nIndex) {
if (nIndex < 0 || nIndex >= m_nSize) {
- return *(TYPE*)NULL;
+ PDFIUM_IMMEDIATE_CRASH();
}
return ((TYPE*)m_pData)[nIndex];
}
@@ -384,7 +389,6 @@ typedef CFX_ArrayTemplate<CFX_WideStringC> CFX_WideStringCArray;
typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray;
typedef CFX_ArrayTemplate<int32_t> CFX_Int32Array;
-typedef CFX_ArrayTemplate<void*> CFX_PtrArray;
#endif // PDF_ENABLE_XFA
#ifdef PDF_ENABLE_XFA
@@ -415,7 +419,7 @@ class CFX_ObjectArray : public CFX_BasicArray {
if (!nSize) {
return 0;
}
- FXSYS_assert(nStart > -1 && nStart < nSize);
+ ASSERT(nStart > -1 && nStart < nSize);
if (nCount < 0) {
nCount = nSize;
}
@@ -445,7 +449,7 @@ class CFX_ObjectArray : public CFX_BasicArray {
if (!nSize) {
return 0;
}
- FXSYS_assert(nStart > -1 && nStart < nSize);
+ ASSERT(nStart > -1 && nStart < nSize);
if (nCount < 0) {
nCount = nSize;
}
@@ -468,7 +472,7 @@ class CFX_ObjectArray : public CFX_BasicArray {
int GetSize() const { return m_nSize; }
ObjectClass& operator[](int index) const {
- FXSYS_assert(index < m_nSize);
+ ASSERT(index < m_nSize);
return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
}
@@ -477,7 +481,7 @@ class CFX_ObjectArray : public CFX_BasicArray {
}
void RemoveAt(int index) {
- FXSYS_assert(index < m_nSize);
+ ASSERT(index < m_nSize);
((ObjectClass*)GetDataPtr(index))->~ObjectClass();
CFX_BasicArray::RemoveAt(index, 1);
}
@@ -491,71 +495,6 @@ class CFX_ObjectArray : public CFX_BasicArray {
};
typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray;
typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray;
-class CFX_BaseSegmentedArray {
- public:
- CFX_BaseSegmentedArray(int unit_size = 1,
- int segment_units = 512,
- int index_size = 8);
-
- ~CFX_BaseSegmentedArray();
-
- void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
-
- void* Add();
-
- void* GetAt(int index) const;
-
- void RemoveAll();
-
- void Delete(int index, int count = 1);
-
- int GetSize() const { return m_DataSize; }
-
- int GetSegmentSize() const { return m_SegmentSize; }
-
- int GetUnitSize() const { return m_UnitSize; }
-
- void* Iterate(FX_BOOL (*callback)(void* param, void* pData),
- void* param) const;
-
- private:
- int m_UnitSize;
-
- short m_SegmentSize;
-
- uint8_t m_IndexSize;
-
- uint8_t m_IndexDepth;
-
- int m_DataSize;
-
- void* m_pIndex;
- void** GetIndex(int seg_index) const;
- void* IterateIndex(int level,
- int& start,
- void** pIndex,
- FX_BOOL (*callback)(void* param, void* pData),
- void* param) const;
- void* IterateSegment(const uint8_t* pSegment,
- int count,
- FX_BOOL (*callback)(void* param, void* pData),
- void* param) const;
-};
-template <class ElementType>
-class CFX_SegmentedArray : public CFX_BaseSegmentedArray {
- public:
- CFX_SegmentedArray(int segment_units, int index_size = 8)
- : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size) {
- }
-
- void Add(ElementType data) {
- *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
- }
-
- ElementType& operator[](int index) {
- return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
- }
-};
#endif // PDF_ENABLE_XFA
template <class DataType, int FixedSize>
@@ -879,7 +818,7 @@ class CFX_CountRef {
}
void operator=(void* p) {
- FXSYS_assert(p == 0);
+ ASSERT(p == 0);
if (!m_pObject) {
return;
}
@@ -1055,7 +994,7 @@ class CFX_ListArrayTemplate {
T2& operator[](int32_t nIndex) {
uint8_t* data = m_Data.GetAt(nIndex);
- FXSYS_assert(data);
+ ASSERT(data);
return (T2&)(*(volatile T2*)data);
}
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_coordinates.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_coordinates.h
index a7f0b8d5dc3..ec6b41c8692 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_coordinates.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_coordinates.h
@@ -310,7 +310,6 @@ class CFX_FloatRect {
FX_FLOAT right;
FX_FLOAT top;
};
-using CFX_RectArray = CFX_ArrayTemplate<CFX_FloatRect>;
// LTWH rectangles (y-axis runs downwards).
template <class baseType>
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_ext.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_ext.h
index 68ae2a36512..b6c05ae9bcb 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_ext.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_ext.h
@@ -77,12 +77,8 @@ inline int FXSYS_toDecimalDigit(const FX_WCHAR c) {
return std::iswdigit(c) ? c - L'0' : 0;
}
-uint32_t FX_HashCode_String_GetA(const FX_CHAR* pStr,
- int32_t iLength,
- FX_BOOL bIgnoreCase = FALSE);
-uint32_t FX_HashCode_String_GetW(const FX_WCHAR* pStr,
- int32_t iLength,
- FX_BOOL bIgnoreCase = FALSE);
+uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase);
+uint32_t FX_HashCode_GetW(const CFX_WideStringC& Str, bool bIgnoreCase);
void* FX_Random_MT_Start(uint32_t dwSeed);
@@ -114,7 +110,7 @@ template <class baseType>
class CFX_SSortTemplate {
public:
void ShellSort(baseType* pArray, int32_t iCount) {
- FXSYS_assert(pArray && iCount > 0);
+ ASSERT(pArray && iCount > 0);
int32_t i, j, gap;
baseType v1, v2;
gap = iCount >> 1;
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_safe_types.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_safe_types.h
index 84ea55a6858..f12e74906b6 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_safe_types.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_safe_types.h
@@ -11,7 +11,7 @@
#include "core/fxcrt/include/fx_system.h"
#include "third_party/base/numerics/safe_math.h"
-typedef pdfium::base::CheckedNumeric<uint32_t> FX_SAFE_DWORD;
+typedef pdfium::base::CheckedNumeric<uint32_t> FX_SAFE_UINT32;
typedef pdfium::base::CheckedNumeric<int32_t> FX_SAFE_INT32;
typedef pdfium::base::CheckedNumeric<size_t> FX_SAFE_SIZE_T;
typedef pdfium::base::CheckedNumeric<FX_FILESIZE> FX_SAFE_FILESIZE;
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_stream.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_stream.h
index ba72994f363..a91b59f2856 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_stream.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_stream.h
@@ -79,7 +79,7 @@ class IFX_StreamRead {
virtual size_t ReadBlock(void* buffer, size_t size) = 0;
};
-class IFX_FileRead : IFX_StreamRead {
+class IFX_FileRead : public IFX_StreamRead {
public:
// IFX_StreamRead:
void Release() override = 0;
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_string.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_string.h
index e084f50cfd6..142f9372d08 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_string.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_string.h
@@ -10,144 +10,35 @@
#include <stdint.h> // For intptr_t.
#include <algorithm>
+#include "core/fxcrt/cfx_string_c_template.h"
#include "core/fxcrt/cfx_string_data_template.h"
#include "core/fxcrt/include/cfx_retain_ptr.h"
#include "core/fxcrt/include/fx_memory.h"
#include "core/fxcrt/include/fx_system.h"
-class CFX_BinaryBuf;
class CFX_ByteString;
class CFX_WideString;
-// An immutable string with caller-provided storage which must outlive the
-// string itself.
-class CFX_ByteStringC {
- public:
- typedef FX_CHAR value_type;
-
- CFX_ByteStringC() {
- m_Ptr = NULL;
- m_Length = 0;
- }
-
- CFX_ByteStringC(const uint8_t* ptr, FX_STRSIZE size) {
- m_Ptr = ptr;
- m_Length = size;
- }
-
- CFX_ByteStringC(const FX_CHAR* ptr) {
- m_Ptr = (const uint8_t*)ptr;
- m_Length = ptr ? FXSYS_strlen(ptr) : 0;
- }
-
- // |ch| must be an lvalue that outlives the the CFX_ByteStringC. However,
- // the use of char rvalues are not caught at compile time. They are
- // implicitly promoted to CFX_ByteString (see below) and then the
- // CFX_ByteStringC is constructed from the CFX_ByteString via the alternate
- // constructor below. The CFX_ByteString then typically goes out of scope
- // and |m_Ptr| may be left pointing to invalid memory. Beware.
- // TODO(tsepez): Mark single-argument string constructors as explicit.
- CFX_ByteStringC(FX_CHAR& ch) {
- m_Ptr = (const uint8_t*)&ch;
- m_Length = 1;
- }
-
- CFX_ByteStringC(const FX_CHAR* ptr, FX_STRSIZE len) {
- m_Ptr = (const uint8_t*)ptr;
- m_Length = (len == -1) ? FXSYS_strlen(ptr) : len;
- }
-
- CFX_ByteStringC(const CFX_ByteStringC& src) {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- }
-
- CFX_ByteStringC& operator=(const FX_CHAR* src) {
- m_Ptr = (const uint8_t*)src;
- m_Length = m_Ptr ? FXSYS_strlen(src) : 0;
- return *this;
- }
-
- CFX_ByteStringC& operator=(const CFX_ByteStringC& src) {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- return *this;
- }
-
- CFX_ByteStringC& operator=(const CFX_ByteString& src);
-
- bool operator==(const char* ptr) const {
- return FXSYS_strlen(ptr) == m_Length &&
- FXSYS_memcmp(ptr, m_Ptr, m_Length) == 0;
- }
- bool operator==(const CFX_ByteStringC& other) const {
- return other.m_Length == m_Length &&
- FXSYS_memcmp(other.m_Ptr, m_Ptr, m_Length) == 0;
- }
- bool operator!=(const char* ptr) const { return !(*this == ptr); }
- bool operator!=(const CFX_ByteStringC& other) const {
- return !(*this == other);
- }
-
- uint32_t GetID(FX_STRSIZE start_pos = 0) const;
-
- const uint8_t* raw_str() const { return m_Ptr; }
- const FX_CHAR* c_str() const {
- return reinterpret_cast<const FX_CHAR*>(m_Ptr);
- }
+using CFX_ByteStringC = CFX_StringCTemplate<FX_CHAR>;
+using CFX_WideStringC = CFX_StringCTemplate<FX_WCHAR>;
- FX_STRSIZE GetLength() const { return m_Length; }
- bool IsEmpty() const { return m_Length == 0; }
-
- uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
-
- CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
- if (index < 0) {
- index = 0;
- }
- if (index > m_Length) {
- return CFX_ByteStringC();
- }
- if (count < 0 || count > m_Length - index) {
- count = m_Length - index;
- }
- return CFX_ByteStringC(m_Ptr + index, count);
- }
-
- const uint8_t& operator[](size_t index) const { return m_Ptr[index]; }
-
- bool operator<(const CFX_ByteStringC& that) const {
- int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
- return result < 0 || (result == 0 && m_Length < that.m_Length);
- }
-
- protected:
- const uint8_t* m_Ptr;
- FX_STRSIZE m_Length;
-
- private:
- void* operator new(size_t) throw() { return NULL; }
-};
-inline bool operator==(const char* lhs, const CFX_ByteStringC& rhs) {
- return rhs == lhs;
-}
-inline bool operator!=(const char* lhs, const CFX_ByteStringC& rhs) {
- return rhs != lhs;
-}
#define FXBSTR_ID(c1, c2, c3, c4) \
(((uint32_t)c1 << 24) | ((uint32_t)c2 << 16) | ((uint32_t)c3 << 8) | \
((uint32_t)c4))
+#define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1)
+
// A mutable string with shared buffers using copy-on-write semantics that
// avoids the cost of std::string's iterator stability guarantees.
class CFX_ByteString {
public:
- typedef FX_CHAR value_type;
+ using CharType = FX_CHAR;
CFX_ByteString() {}
CFX_ByteString(const CFX_ByteString& other) : m_pData(other.m_pData) {}
CFX_ByteString(CFX_ByteString&& other) { m_pData.Swap(other.m_pData); }
+ // Deliberately implicit to avoid calling on every string literal.
CFX_ByteString(char ch);
CFX_ByteString(const FX_CHAR* ptr)
: CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
@@ -155,41 +46,30 @@ class CFX_ByteString {
CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len);
CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len);
- CFX_ByteString(const CFX_ByteStringC& bstrc);
+ explicit CFX_ByteString(const CFX_ByteStringC& bstrc);
CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2);
~CFX_ByteString();
- // Deprecated -- use clear().
- void Empty() { m_pData.Reset(); }
void clear() { m_pData.Reset(); }
static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1);
static CFX_ByteString FromUnicode(const CFX_WideString& str);
// Explicit conversion to C-style string.
- // Note: |this| must outlive the use of the result.
+ // Note: Any subsequent modification of |this| will invalidate the result.
const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; }
- // Implicit conversion to C-style string -- deprecated.
- operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; }
-
// Explicit conversion to uint8_t*.
- // Note: |this| must outlive the use of the result.
+ // Note: Any subsequent modification of |this| will invalidate the result.
const uint8_t* raw_str() const {
return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String)
: nullptr;
}
- // Implicit conversion to uint8_t* -- deprecated.
- operator const uint8_t*() const {
- return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String)
- : nullptr;
- }
-
// Explicit conversion to CFX_ByteStringC.
- // Note: |this| must outlive the use of the result.
- CFX_ByteStringC AsByteStringC() const {
+ // Note: Any subsequent modification of |this| will invalidate the result.
+ CFX_ByteStringC AsStringC() const {
return CFX_ByteStringC(raw_str(), GetLength());
}
@@ -218,9 +98,6 @@ class CFX_ByteString {
const CFX_ByteString& operator=(const FX_CHAR* str);
const CFX_ByteString& operator=(const CFX_ByteStringC& bstrc);
const CFX_ByteString& operator=(const CFX_ByteString& stringSrc);
- const CFX_ByteString& operator=(const CFX_BinaryBuf& buf);
-
- void Load(const uint8_t* str, FX_STRSIZE len);
const CFX_ByteString& operator+=(FX_CHAR ch);
const CFX_ByteString& operator+=(const FX_CHAR* str);
@@ -297,12 +174,6 @@ class CFX_ByteString {
friend class fxcrt_ByteStringConcat_Test;
};
-inline CFX_ByteStringC& CFX_ByteStringC::operator=(const CFX_ByteString& src) {
- m_Ptr = (const uint8_t*)src;
- m_Length = src.GetLength();
- return *this;
-}
-
inline bool operator==(const char* lhs, const CFX_ByteString& rhs) {
return rhs == lhs;
}
@@ -336,200 +207,76 @@ inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteStringC& str2) {
}
inline CFX_ByteString operator+(const CFX_ByteString& str1,
const CFX_ByteString& str2) {
- return CFX_ByteString(str1.AsByteStringC(), str2.AsByteStringC());
+ return CFX_ByteString(str1.AsStringC(), str2.AsStringC());
}
inline CFX_ByteString operator+(const CFX_ByteString& str1, FX_CHAR ch) {
- return CFX_ByteString(str1.AsByteStringC(), CFX_ByteStringC(ch));
+ return CFX_ByteString(str1.AsStringC(), CFX_ByteStringC(ch));
}
inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteString& str2) {
- return CFX_ByteString(ch, str2.AsByteStringC());
+ return CFX_ByteString(ch, str2.AsStringC());
}
inline CFX_ByteString operator+(const CFX_ByteString& str1,
const FX_CHAR* str2) {
- return CFX_ByteString(str1.AsByteStringC(), str2);
+ return CFX_ByteString(str1.AsStringC(), str2);
}
inline CFX_ByteString operator+(const FX_CHAR* str1,
const CFX_ByteString& str2) {
- return CFX_ByteString(str1, str2.AsByteStringC());
+ return CFX_ByteString(str1, str2.AsStringC());
}
inline CFX_ByteString operator+(const CFX_ByteString& str1,
const CFX_ByteStringC& str2) {
- return CFX_ByteString(str1.AsByteStringC(), str2);
+ return CFX_ByteString(str1.AsStringC(), str2);
}
inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
const CFX_ByteString& str2) {
- return CFX_ByteString(str1, str2.AsByteStringC());
+ return CFX_ByteString(str1, str2.AsStringC());
}
-class CFX_WideStringC {
- public:
- typedef FX_WCHAR value_type;
-
- CFX_WideStringC() {
- m_Ptr = NULL;
- m_Length = 0;
- }
-
- CFX_WideStringC(const FX_WCHAR* ptr) {
- m_Ptr = ptr;
- m_Length = ptr ? FXSYS_wcslen(ptr) : 0;
- }
-
- CFX_WideStringC(FX_WCHAR& ch) {
- m_Ptr = &ch;
- m_Length = 1;
- }
-
- CFX_WideStringC(const FX_WCHAR* ptr, FX_STRSIZE len) {
- m_Ptr = ptr;
- m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len;
- }
-
- CFX_WideStringC(const CFX_WideStringC& src) {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- }
-
- CFX_WideStringC& operator=(const FX_WCHAR* src) {
- m_Ptr = src;
- m_Length = FXSYS_wcslen(src);
- return *this;
- }
-
- CFX_WideStringC& operator=(const CFX_WideStringC& src) {
- m_Ptr = src.m_Ptr;
- m_Length = src.m_Length;
- return *this;
- }
-
- CFX_WideStringC& operator=(const CFX_WideString& src);
-
- bool operator==(const wchar_t* ptr) const {
- return FXSYS_wcslen(ptr) == m_Length && wmemcmp(ptr, m_Ptr, m_Length) == 0;
- }
- bool operator==(const CFX_WideStringC& str) const {
- return str.m_Length == m_Length && wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0;
- }
- bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
- bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); }
-
- const FX_WCHAR* raw_str() const { return m_Ptr; }
-
- FX_STRSIZE GetLength() const { return m_Length; }
- bool IsEmpty() const { return m_Length == 0; }
-
- FX_WCHAR GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
-
- CFX_WideStringC Left(FX_STRSIZE count) const {
- if (count < 1) {
- return CFX_WideStringC();
- }
- if (count > m_Length) {
- count = m_Length;
- }
- return CFX_WideStringC(m_Ptr, count);
- }
-
- CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
- if (index < 0) {
- index = 0;
- }
- if (index > m_Length) {
- return CFX_WideStringC();
- }
- if (count < 0 || count > m_Length - index) {
- count = m_Length - index;
- }
- return CFX_WideStringC(m_Ptr + index, count);
- }
-
- CFX_WideStringC Right(FX_STRSIZE count) const {
- if (count < 1) {
- return CFX_WideStringC();
- }
- if (count > m_Length) {
- count = m_Length;
- }
- return CFX_WideStringC(m_Ptr + m_Length - count, count);
- }
-
- const FX_WCHAR& operator[](size_t index) const { return m_Ptr[index]; }
-
- bool operator<(const CFX_WideStringC& that) const {
- int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
- return result < 0 || (result == 0 && m_Length < that.m_Length);
- }
-
- protected:
- const FX_WCHAR* m_Ptr;
- FX_STRSIZE m_Length;
-
- private:
- void* operator new(size_t) throw() { return NULL; }
-};
-
-inline bool operator==(const wchar_t* lhs, const CFX_WideStringC& rhs) {
- return rhs == lhs;
-}
-inline bool operator!=(const wchar_t* lhs, const CFX_WideStringC& rhs) {
- return rhs != lhs;
-}
-#define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1)
-
// A mutable string with shared buffers using copy-on-write semantics that
// avoids the cost of std::string's iterator stability guarantees.
class CFX_WideString {
public:
- typedef FX_WCHAR value_type;
-
- CFX_WideString() : m_pData(nullptr) {}
+ using CharType = FX_WCHAR;
- // Copy constructor.
- CFX_WideString(const CFX_WideString& str);
-
- // Move constructor.
- CFX_WideString(CFX_WideString&& other) {
- m_pData = other.m_pData;
- other.m_pData = nullptr;
- }
+ CFX_WideString() {}
+ CFX_WideString(const CFX_WideString& other) : m_pData(other.m_pData) {}
+ CFX_WideString(CFX_WideString&& other) { m_pData.Swap(other.m_pData); }
+ // Deliberately implicit to avoid calling on every string literal.
+ CFX_WideString(FX_WCHAR ch);
CFX_WideString(const FX_WCHAR* ptr)
: CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {}
CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len);
- CFX_WideString(FX_WCHAR ch);
- CFX_WideString(const CFX_WideStringC& str);
+ explicit CFX_WideString(const CFX_WideStringC& str);
CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
~CFX_WideString();
- static CFX_WideString FromLocal(const CFX_ByteString& str);
- static CFX_WideString FromCodePage(const CFX_ByteString& str,
+ static CFX_WideString FromLocal(const CFX_ByteStringC& str);
+ static CFX_WideString FromCodePage(const CFX_ByteStringC& str,
uint16_t codepage);
- static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len);
+ static CFX_WideString FromUTF8(const CFX_ByteStringC& str);
static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len);
static FX_STRSIZE WStringLength(const unsigned short* str);
// Explicit conversion to C-style wide string.
- // Note: |this| must outlive the use of the result.
+ // Note: Any subsequent modification of |this| will invalidate the result.
const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; }
- // Implicit conversion to C-style wide string -- deprecated.
- // Note: |this| must outlive the use of the result.
- operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; }
-
// Explicit conversion to CFX_WideStringC.
- // Note: |this| must outlive the use of the result.
- CFX_WideStringC AsWideStringC() const {
+ // Note: Any subsequent modification of |this| will invalidate the result.
+ CFX_WideStringC AsStringC() const {
return CFX_WideStringC(c_str(), GetLength());
}
- void Empty();
- bool IsEmpty() const { return !GetLength(); }
+ void clear() { m_pData.Reset(); }
+
FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
+ bool IsEmpty() const { return !GetLength(); }
const CFX_WideString& operator=(const FX_WCHAR* str);
const CFX_WideString& operator=(const CFX_WideString& stringSrc);
@@ -587,11 +334,11 @@ class CFX_WideString {
void TrimRight();
void TrimRight(FX_WCHAR chTarget);
- void TrimRight(const FX_WCHAR* lpszTargets);
+ void TrimRight(const CFX_WideStringC& pTargets);
void TrimLeft();
void TrimLeft(FX_WCHAR chTarget);
- void TrimLeft(const FX_WCHAR* lpszTargets);
+ void TrimLeft(const CFX_WideStringC& pTargets);
void Reserve(FX_STRSIZE len);
FX_WCHAR* GetBuffer(FX_STRSIZE len);
@@ -600,62 +347,29 @@ class CFX_WideString {
int GetInteger() const;
FX_FLOAT GetFloat() const;
- FX_STRSIZE Find(const FX_WCHAR* lpszSub, FX_STRSIZE start = 0) const;
+ FX_STRSIZE Find(const CFX_WideStringC& pSub, FX_STRSIZE start = 0) const;
FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const;
- FX_STRSIZE Replace(const FX_WCHAR* lpszOld, const FX_WCHAR* lpszNew);
+ FX_STRSIZE Replace(const CFX_WideStringC& pOld, const CFX_WideStringC& pNew);
FX_STRSIZE Remove(FX_WCHAR ch);
CFX_ByteString UTF8Encode() const;
CFX_ByteString UTF16LE_Encode() const;
protected:
- class StringData {
- public:
- static StringData* Create(int nLen);
- void Retain() { ++m_nRefs; }
- void Release() {
- if (--m_nRefs <= 0)
- FX_Free(this);
- }
-
- intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
- FX_STRSIZE m_nDataLength;
- FX_STRSIZE m_nAllocLength;
- FX_WCHAR m_String[1];
-
- private:
- StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
- : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
- FXSYS_assert(dataLen >= 0);
- FXSYS_assert(allocLen >= 0);
- FXSYS_assert(dataLen <= allocLen);
- m_String[dataLen] = 0;
- }
- ~StringData() = delete;
- };
-
- void CopyBeforeWrite();
+ using StringData = CFX_StringDataTemplate<FX_WCHAR>;
+
+ void ReallocBeforeWrite(FX_STRSIZE nLen);
void AllocBeforeWrite(FX_STRSIZE nLen);
- void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
- void ConcatCopy(FX_STRSIZE nSrc1Len,
- const FX_WCHAR* lpszSrc1Data,
- FX_STRSIZE nSrc2Len,
- const FX_WCHAR* lpszSrc2Data);
- void AssignCopy(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
void AllocCopy(CFX_WideString& dest,
FX_STRSIZE nCopyLen,
FX_STRSIZE nCopyIndex) const;
+ void AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen);
+ void Concat(const FX_WCHAR* lpszSrcData, FX_STRSIZE nSrcLen);
- StringData* m_pData;
+ CFX_RetainPtr<StringData> m_pData;
friend class fxcrt_WideStringConcatInPlace_Test;
};
-inline CFX_WideStringC& CFX_WideStringC::operator=(const CFX_WideString& src) {
- m_Ptr = src.c_str();
- m_Length = src.GetLength();
- return *this;
-}
-
inline CFX_WideString operator+(const CFX_WideStringC& str1,
const CFX_WideStringC& str2) {
return CFX_WideString(str1, str2);
@@ -676,29 +390,29 @@ inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideStringC& str2) {
}
inline CFX_WideString operator+(const CFX_WideString& str1,
const CFX_WideString& str2) {
- return CFX_WideString(str1.AsWideStringC(), str2.AsWideStringC());
+ return CFX_WideString(str1.AsStringC(), str2.AsStringC());
}
inline CFX_WideString operator+(const CFX_WideString& str1, FX_WCHAR ch) {
- return CFX_WideString(str1.AsWideStringC(), CFX_WideStringC(ch));
+ return CFX_WideString(str1.AsStringC(), CFX_WideStringC(ch));
}
inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideString& str2) {
- return CFX_WideString(ch, str2.AsWideStringC());
+ return CFX_WideString(ch, str2.AsStringC());
}
inline CFX_WideString operator+(const CFX_WideString& str1,
const FX_WCHAR* str2) {
- return CFX_WideString(str1.AsWideStringC(), str2);
+ return CFX_WideString(str1.AsStringC(), str2);
}
inline CFX_WideString operator+(const FX_WCHAR* str1,
const CFX_WideString& str2) {
- return CFX_WideString(str1, str2.AsWideStringC());
+ return CFX_WideString(str1, str2.AsStringC());
}
inline CFX_WideString operator+(const CFX_WideString& str1,
const CFX_WideStringC& str2) {
- return CFX_WideString(str1.AsWideStringC(), str2);
+ return CFX_WideString(str1.AsStringC(), str2);
}
inline CFX_WideString operator+(const CFX_WideStringC& str1,
const CFX_WideString& str2) {
- return CFX_WideString(str1, str2.AsWideStringC());
+ return CFX_WideString(str1, str2.AsStringC());
}
inline bool operator==(const wchar_t* lhs, const CFX_WideString& rhs) {
return rhs == lhs;
@@ -715,7 +429,7 @@ inline bool operator!=(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len);
inline CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) {
- return FX_UTF8Encode(wsStr.raw_str(), wsStr.GetLength());
+ return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
}
inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr) {
return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
@@ -723,7 +437,7 @@ inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr) {
FX_FLOAT FX_atof(const CFX_ByteStringC& str);
inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) {
- return FX_atof(FX_UTF8Encode(wsStr.raw_str(), wsStr.GetLength()).c_str());
+ return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str());
}
void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData);
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_system.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_system.h
index 4900634aa5a..61acd73492a 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_system.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_system.h
@@ -95,15 +95,20 @@ static_assert(FALSE == false, "false_needs_to_be_false");
#define NULL 0
#endif
-#define FXSYS_assert assert
#ifndef ASSERT
#ifndef NDEBUG
-#define ASSERT FXSYS_assert
+#define ASSERT assert
#else
#define ASSERT(a)
#endif
#endif
+#if defined(__clang__) || defined(__GNUC__)
+#define PDFIUM_IMMEDIATE_CRASH() __builtin_trap()
+#else
+#define PDFIUM_IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0))
+#endif
+
// M_PI not universally present on all platforms.
#define FX_PI 3.1415926535897932384626433832795f
#define FX_BEZIER 0.5522847498308f
@@ -124,7 +129,6 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap);
#define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE
#define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE
-#define FXSYS_strchr strchr
#define FXSYS_strncmp strncmp
#define FXSYS_strcmp strcmp
#define FXSYS_strcpy strcpy
@@ -160,6 +164,31 @@ FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode);
#define FXSYS_strlen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(strlen(ptr))
#define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr))
+// Overloaded functions for C++ templates
+inline FX_STRSIZE FXSYS_len(const FX_CHAR* ptr) {
+ return FXSYS_strlen(ptr);
+}
+
+inline FX_STRSIZE FXSYS_len(const FX_WCHAR* ptr) {
+ return FXSYS_wcslen(ptr);
+}
+
+inline int FXSYS_cmp(const FX_CHAR* ptr1, const FX_CHAR* ptr2, size_t len) {
+ return memcmp(ptr1, ptr2, len);
+}
+
+inline int FXSYS_cmp(const FX_WCHAR* ptr1, const FX_WCHAR* ptr2, size_t len) {
+ return wmemcmp(ptr1, ptr2, len);
+}
+
+inline const FX_CHAR* FXSYS_chr(const FX_CHAR* ptr, FX_CHAR ch, size_t len) {
+ return reinterpret_cast<const FX_CHAR*>(memchr(ptr, ch, len));
+}
+
+inline const FX_WCHAR* FXSYS_chr(const FX_WCHAR* ptr, FX_WCHAR ch, size_t len) {
+ return wmemchr(ptr, ch, len);
+}
+
extern "C" {
#else
#define FXSYS_strlen(ptr) ((FX_STRSIZE)strlen(ptr))
@@ -167,7 +196,6 @@ extern "C" {
#endif
#define FXSYS_wcscmp wcscmp
-#define FXSYS_wcschr wcschr
#define FXSYS_wcsstr wcsstr
#define FXSYS_wcsncmp wcsncmp
#define FXSYS_vswprintf vswprintf
@@ -177,7 +205,6 @@ extern "C" {
#define FXSYS_memcpy memcpy
#define FXSYS_memmove memmove
#define FXSYS_memset memset
-#define FXSYS_memchr memchr
#define FXSYS_qsort qsort
#define FXSYS_bsearch bsearch
diff --git a/chromium/third_party/pdfium/core/fxcrt/include/fx_xml.h b/chromium/third_party/pdfium/core/fxcrt/include/fx_xml.h
index 3e22883c7fa..8816e2eae18 100644
--- a/chromium/third_party/pdfium/core/fxcrt/include/fx_xml.h
+++ b/chromium/third_party/pdfium/core/fxcrt/include/fx_xml.h
@@ -14,7 +14,7 @@
class CXML_AttrItem {
public:
- bool Matches(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const;
+ bool Matches(const CFX_ByteString& space, const CFX_ByteString& name) const;
CFX_ByteString m_QSpaceName;
CFX_ByteString m_AttrName;
@@ -23,11 +23,11 @@ class CXML_AttrItem {
class CXML_AttrMap {
public:
- const CFX_WideString* Lookup(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name) const;
- void SetAt(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name,
- const CFX_WideStringC& value);
+ const CFX_WideString* Lookup(const CFX_ByteString& space,
+ const CFX_ByteString& name) const;
+ void SetAt(const CFX_ByteString& space,
+ const CFX_ByteString& name,
+ const CFX_WideString& value);
int GetSize() const;
CXML_AttrItem& GetAt(int index) const;
@@ -69,7 +69,7 @@ class CXML_Element {
void Empty();
CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
- CFX_ByteString GetNamespaceURI(const CFX_ByteStringC& qName) const;
+ CFX_ByteString GetNamespaceURI(const CFX_ByteString& qName) const;
CXML_Element* GetParent() const { return m_pParent; }
uint32_t CountAttrs() const { return m_AttrMap.GetSize(); }
void GetAttrByIndex(int index,
diff --git a/chromium/third_party/pdfium/core/fxcrt/xml_int.h b/chromium/third_party/pdfium/core/fxcrt/xml_int.h
index 2dae7b52314..864b4e8789b 100644
--- a/chromium/third_party/pdfium/core/fxcrt/xml_int.h
+++ b/chromium/third_party/pdfium/core/fxcrt/xml_int.h
@@ -49,7 +49,7 @@ class CXML_DataStmAcc : public IFX_BufferRead {
public:
explicit CXML_DataStmAcc(IFX_FileRead* pFileRead)
: m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) {
- FXSYS_assert(m_pFileRead);
+ ASSERT(m_pFileRead);
}
~CXML_DataStmAcc() override { FX_Free(m_pBuffer); }
diff --git a/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp b/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp
index 8bda709c268..98bce9b7c6f 100644
--- a/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp
+++ b/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.cpp
@@ -8,10 +8,10 @@
#include <algorithm>
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "third_party/agg23/agg_conv_dash.h"
#include "third_party/agg23/agg_conv_stroke.h"
#include "third_party/agg23/agg_curves.h"
@@ -1106,7 +1106,7 @@ class CFX_Renderer {
FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
FX_BOOL bDeviceCMYK = pDevice->IsCmykImage();
m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
- ICodec_IccModule* pIccModule = NULL;
+ CCodec_IccModule* pIccModule = NULL;
if (!CFX_GEModule::Get()->GetCodecModule() ||
!CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
pIccTransform = NULL;
@@ -1529,7 +1529,7 @@ FX_BOOL _DibSetPixel(CFX_DIBitmap* pDevice,
FX_BOOL bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color,
@@ -1754,11 +1754,10 @@ FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
FALSE, m_bRgbByteOrder, alpha_flag, pIccTransform,
blend_type);
dest_clip.Offset(-dest_rect.left, -dest_rect.top);
- CFX_ImageStretcher stretcher;
- if (stretcher.Start(&composer, pSource, dest_width, dest_height, dest_clip,
- flags)) {
- stretcher.Continue(NULL);
- }
+ CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height,
+ dest_clip, flags);
+ if (stretcher.Start())
+ stretcher.Continue(nullptr);
return TRUE;
}
@@ -1795,6 +1794,7 @@ void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) {
delete (CFX_ImageRenderer*)pHandle;
}
+#ifndef _SKIA_SUPPORT_
CFX_FxgeDevice::CFX_FxgeDevice() {
m_bOwnedBitmap = FALSE;
}
@@ -1837,3 +1837,4 @@ CFX_FxgeDevice::~CFX_FxgeDevice() {
delete GetBitmap();
}
}
+#endif
diff --git a/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.h b/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.h
index 5bc9283b035..18f8d348ce4 100644
--- a/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.h
+++ b/chromium/third_party/pdfium/core/fxge/agg/fx_agg_driver.h
@@ -7,7 +7,7 @@
#ifndef CORE_FXGE_AGG_FX_AGG_DRIVER_H_
#define CORE_FXGE_AGG_FX_AGG_DRIVER_H_
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "third_party/agg23/agg_clip_liang_barsky.h"
#include "third_party/agg23/agg_path_storage.h"
#include "third_party/agg23/agg_rasterizer_scanline_aa.h"
diff --git a/chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.cpp b/chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.cpp
index bd9b549e992..332bfd0ca27 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.cpp
+++ b/chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.cpp
@@ -12,59 +12,60 @@
#include "core/fxge/android/fpf_skiafont.h"
#include "core/fxge/android/fpf_skiafontmgr.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_freetype.h"
#define FPF_EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em)
CFPF_SkiaFont::CFPF_SkiaFont()
- : m_pFontMgr(NULL),
- m_pFontDes(NULL),
- m_Face(NULL),
+ : m_pFontMgr(nullptr),
+ m_pFontDes(nullptr),
+ m_Face(nullptr),
m_dwStyle(0),
m_uCharset(0),
m_dwRefCount(0) {}
+
CFPF_SkiaFont::~CFPF_SkiaFont() {
- if (m_Face) {
+ if (m_Face)
FXFT_Done_Face(m_Face);
- }
}
+
void CFPF_SkiaFont::Release() {
- if (--m_dwRefCount == 0) {
+ if (--m_dwRefCount == 0)
delete this;
- }
}
-IFPF_Font* CFPF_SkiaFont::Retain() {
+
+CFPF_SkiaFont* CFPF_SkiaFont::Retain() {
m_dwRefCount++;
- return (IFPF_Font*)this;
+ return this;
}
+
FPF_HFONT CFPF_SkiaFont::GetHandle() {
- return NULL;
+ return nullptr;
}
+
CFX_ByteString CFPF_SkiaFont::GetFamilyName() {
- if (!m_Face) {
+ if (!m_Face)
return CFX_ByteString();
- }
return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
}
+
CFX_WideString CFPF_SkiaFont::GetPsName() {
- if (!m_Face) {
+ if (!m_Face)
return CFX_WideString();
- }
return CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m_Face));
}
+
int32_t CFPF_SkiaFont::GetGlyphIndex(FX_WCHAR wUnicode) {
- if (!m_Face) {
+ if (!m_Face)
return wUnicode;
- }
- if (FXFT_Select_Charmap(m_Face, FXFT_ENCODING_UNICODE)) {
+ if (FXFT_Select_Charmap(m_Face, FXFT_ENCODING_UNICODE))
return 0;
- }
return FXFT_Get_Char_Index(m_Face, wUnicode);
}
+
int32_t CFPF_SkiaFont::GetGlyphWidth(int32_t iGlyphIndex) {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
if (FXFT_Load_Glyph(
m_Face, iGlyphIndex,
FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
@@ -73,28 +74,27 @@ int32_t CFPF_SkiaFont::GetGlyphWidth(int32_t iGlyphIndex) {
return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
FXFT_Get_Glyph_HoriAdvance(m_Face));
}
+
int32_t CFPF_SkiaFont::GetAscent() const {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
FXFT_Get_Face_Ascender(m_Face));
}
+
int32_t CFPF_SkiaFont::GetDescent() const {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
FXFT_Get_Face_Descender(m_Face));
}
+
FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox) {
- if (!m_Face) {
+ if (!m_Face)
return FALSE;
- }
if (FXFT_Is_Face_Tricky(m_Face)) {
- if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72)) {
+ if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72))
return FALSE;
- }
if (FXFT_Load_Glyph(m_Face, iGlyphIndex,
FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
@@ -135,6 +135,7 @@ FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox) {
FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face));
return TRUE;
}
+
FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT& rtBBox) {
if (!m_Face) {
return FALSE;
@@ -149,64 +150,68 @@ FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT& rtBBox) {
FXFT_Get_Face_yMax(m_Face));
return TRUE;
}
+
int32_t CFPF_SkiaFont::GetHeight() const {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
FXFT_Get_Face_Height(m_Face));
}
+
int32_t CFPF_SkiaFont::GetItalicAngle() const {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
+
TT_Postscript* ttInfo =
(TT_Postscript*)FT_Get_Sfnt_Table(m_Face, ft_sfnt_post);
- if (ttInfo) {
+ if (ttInfo)
return ttInfo->italicAngle;
- }
return 0;
}
+
uint32_t CFPF_SkiaFont::GetFontData(uint32_t dwTable,
uint8_t* pBuffer,
uint32_t dwSize) {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
+
FT_ULong ulSize = pdfium::base::checked_cast<FT_ULong>(dwSize);
- if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize)) {
+ if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize))
return 0;
- }
return pdfium::base::checked_cast<uint32_t>(ulSize);
}
+
FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
CFPF_SkiaFontDescriptor* pFontDes,
const CFX_ByteStringC& bsFamily,
uint32_t dwStyle,
uint8_t uCharset) {
- if (!pFontMgr || !pFontDes) {
+ if (!pFontMgr || !pFontDes)
return FALSE;
- }
+
switch (pFontDes->GetType()) {
case FPF_SKIAFONTTYPE_Path: {
CFPF_SkiaPathFont* pFont = (CFPF_SkiaPathFont*)pFontDes;
m_Face = pFontMgr->GetFontFace(pFont->m_pPath, pFont->m_iFaceIndex);
- } break;
+ break;
+ }
case FPF_SKIAFONTTYPE_File: {
CFPF_SkiaFileFont* pFont = (CFPF_SkiaFileFont*)pFontDes;
m_Face = pFontMgr->GetFontFace(pFont->m_pFile, pFont->m_iFaceIndex);
- } break;
+ break;
+ }
case FPF_SKIAFONTTYPE_Buffer: {
CFPF_SkiaBufferFont* pFont = (CFPF_SkiaBufferFont*)pFontDes;
m_Face = pFontMgr->GetFontFace((const uint8_t*)pFont->m_pBuffer,
pFont->m_szBuffer, pFont->m_iFaceIndex);
- } break;
+ break;
+ }
default:
return FALSE;
}
- if (!m_Face) {
+ if (!m_Face)
return FALSE;
- }
+
m_dwStyle = dwStyle;
m_uCharset = uCharset;
m_pFontMgr = pFontMgr;
@@ -214,4 +219,5 @@ FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
m_dwRefCount = 1;
return TRUE;
}
-#endif
+
+#endif // _FX_OS_ == _FX_ANDROID_
diff --git a/chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.h b/chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.h
index 9e35c942d34..59172a53859 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.h
+++ b/chromium/third_party/pdfium/core/fxge/android/fpf_skiafont.h
@@ -11,35 +11,35 @@
#if _FX_OS_ == _FX_ANDROID_
-#include "core/include/fxge/fpf.h"
-#include "core/include/fxge/fx_font.h"
+#include "core/fxge/include/fx_font.h"
class CFPF_SkiaFontDescriptor;
class CFPF_SkiaFontMgr;
-class CFPF_SkiaFont : public IFPF_Font {
+
+typedef struct FPF_HFONT_ { void* pData; } * FPF_HFONT;
+
+class CFPF_SkiaFont {
public:
CFPF_SkiaFont();
- ~CFPF_SkiaFont() override;
-
- // IFPF_Font
- void Release() override;
- IFPF_Font* Retain() override;
- FPF_HFONT GetHandle() override;
- CFX_ByteString GetFamilyName() override;
- CFX_WideString GetPsName() override;
- uint32_t GetFontStyle() const override { return m_dwStyle; }
- uint8_t GetCharset() const override { return m_uCharset; }
- int32_t GetGlyphIndex(FX_WCHAR wUnicode) override;
- int32_t GetGlyphWidth(int32_t iGlyphIndex) override;
- int32_t GetAscent() const override;
- int32_t GetDescent() const override;
- FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox) override;
- FX_BOOL GetBBox(FX_RECT& rtBBox) override;
- int32_t GetHeight() const override;
- int32_t GetItalicAngle() const override;
- uint32_t GetFontData(uint32_t dwTable,
- uint8_t* pBuffer,
- uint32_t dwSize) override;
+ ~CFPF_SkiaFont();
+
+ void Release();
+ CFPF_SkiaFont* Retain();
+
+ FPF_HFONT GetHandle();
+ CFX_ByteString GetFamilyName();
+ CFX_WideString GetPsName();
+ uint32_t GetFontStyle() const { return m_dwStyle; }
+ uint8_t GetCharset() const { return m_uCharset; }
+ int32_t GetGlyphIndex(FX_WCHAR wUnicode);
+ int32_t GetGlyphWidth(int32_t iGlyphIndex);
+ int32_t GetAscent() const;
+ int32_t GetDescent() const;
+ FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox);
+ FX_BOOL GetBBox(FX_RECT& rtBBox);
+ int32_t GetHeight() const;
+ int32_t GetItalicAngle() const;
+ uint32_t GetFontData(uint32_t dwTable, uint8_t* pBuffer, uint32_t dwSize);
FX_BOOL InitFont(CFPF_SkiaFontMgr* pFontMgr,
CFPF_SkiaFontDescriptor* pFontDes,
@@ -55,6 +55,7 @@ class CFPF_SkiaFont : public IFPF_Font {
uint8_t m_uCharset;
uint32_t m_dwRefCount;
};
-#endif
+
+#endif // _FX_OS_ == _FX_ANDROID_
#endif // CORE_FXGE_ANDROID_FPF_SKIAFONT_H_
diff --git a/chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.cpp b/chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.cpp
index 7d0d2de9e24..3158f4ca520 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.cpp
+++ b/chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.cpp
@@ -16,7 +16,7 @@
#include "core/fxcrt/include/fx_ext.h"
#include "core/fxge/android/fpf_skiafont.h"
#include "core/fxge/android/fpf_skiafontmgr.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_freetype.h"
#ifdef __cplusplus
extern "C" {
@@ -250,10 +250,10 @@ void CFPF_SkiaFontMgr::LoadSystemFonts() {
void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) {}
void CFPF_SkiaFontMgr::LoadPrivateFont(const CFX_ByteStringC& bsFileName) {}
void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer) {}
-IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
- uint8_t uCharset,
- uint32_t dwStyle,
- uint32_t dwMatch) {
+CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
+ uint8_t uCharset,
+ uint32_t dwStyle,
+ uint32_t dwMatch) {
uint32_t dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
auto it = m_FamilyFonts.find(dwHash);
if (it != m_FamilyFonts.end() && it->second)
diff --git a/chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.h b/chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.h
index 5ed409cccce..be3ea460da9 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.h
+++ b/chromium/third_party/pdfium/core/fxge/android/fpf_skiafontmgr.h
@@ -14,14 +14,15 @@
#include <map>
#include <vector>
-#include "core/include/fxge/fpf.h"
-#include "core/include/fxge/fx_font.h"
+#include "core/fxge/include/fx_font.h"
#define FPF_SKIAFONTTYPE_Unknown 0
#define FPF_SKIAFONTTYPE_Path 1
#define FPF_SKIAFONTTYPE_File 2
#define FPF_SKIAFONTTYPE_Buffer 3
+#define FPF_MATCHFONT_REPLACEANSI 1
+
class CFPF_SkiaFont;
class CFPF_SkiaFontDescriptor {
@@ -88,20 +89,19 @@ class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor {
size_t m_szBuffer;
};
-class CFPF_SkiaFontMgr : public IFPF_FontMgr {
+class CFPF_SkiaFontMgr {
public:
CFPF_SkiaFontMgr();
- ~CFPF_SkiaFontMgr() override;
-
- // IFPF_FontMgr
- void LoadSystemFonts() override;
- void LoadPrivateFont(IFX_FileRead* pFontFile) override;
- void LoadPrivateFont(const CFX_ByteStringC& bsFileName) override;
- void LoadPrivateFont(void* pBuffer, size_t szBuffer) override;
- IFPF_Font* CreateFont(const CFX_ByteStringC& bsFamilyname,
- uint8_t uCharset,
- uint32_t dwStyle,
- uint32_t dwMatch = 0) override;
+ ~CFPF_SkiaFontMgr();
+
+ void LoadSystemFonts();
+ void LoadPrivateFont(IFX_FileRead* pFontFile);
+ void LoadPrivateFont(const CFX_ByteStringC& bsFileName);
+ void LoadPrivateFont(void* pBuffer, size_t szBuffer);
+ CFPF_SkiaFont* CreateFont(const CFX_ByteStringC& bsFamilyname,
+ uint8_t uCharset,
+ uint32_t dwStyle,
+ uint32_t dwMatch = 0);
FX_BOOL InitFTLibrary();
FXFT_Face GetFontFace(IFX_FileRead* pFileRead, int32_t iFaceIndex = 0);
@@ -122,6 +122,6 @@ class CFPF_SkiaFontMgr : public IFPF_FontMgr {
std::map<uint32_t, CFPF_SkiaFont*> m_FamilyFonts;
};
-#endif
+#endif // _FX_OS_ == _FX_ANDROID_
#endif // CORE_FXGE_ANDROID_FPF_SKIAFONTMGR_H_
diff --git a/chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.cpp b/chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.cpp
index 04545248297..f219f124993 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.cpp
+++ b/chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.cpp
@@ -11,28 +11,36 @@
#include "core/fxge/android/fpf_skiafontmgr.h"
#include "core/fxge/android/fpf_skiamodule.h"
-static IFPF_DeviceModule* gs_pPFModule = NULL;
-IFPF_DeviceModule* FPF_GetDeviceModule() {
- if (!gs_pPFModule) {
+namespace {
+
+CFPF_SkiaDeviceModule* gs_pPFModule = nullptr;
+
+} // namespace
+
+CFPF_SkiaDeviceModule* CFPF_GetSkiaDeviceModule() {
+ if (!gs_pPFModule)
gs_pPFModule = new CFPF_SkiaDeviceModule;
- }
return gs_pPFModule;
}
+
CFPF_SkiaDeviceModule::~CFPF_SkiaDeviceModule() {
delete m_pFontMgr;
}
+
void CFPF_SkiaDeviceModule::Destroy() {
- delete (CFPF_SkiaDeviceModule*)gs_pPFModule;
- gs_pPFModule = NULL;
+ delete gs_pPFModule;
+ gs_pPFModule = nullptr;
}
-IFPF_FontMgr* CFPF_SkiaDeviceModule::GetFontMgr() {
+
+CFPF_SkiaFontMgr* CFPF_SkiaDeviceModule::GetFontMgr() {
if (!m_pFontMgr) {
m_pFontMgr = new CFPF_SkiaFontMgr;
if (!m_pFontMgr->InitFTLibrary()) {
delete m_pFontMgr;
- return NULL;
+ return nullptr;
}
}
- return (IFPF_FontMgr*)m_pFontMgr;
+ return m_pFontMgr;
}
-#endif
+
+#endif // _FX_OS_ == _FX_ANDROID_
diff --git a/chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.h b/chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.h
index a95c974b5d8..8ad7549cf10 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.h
+++ b/chromium/third_party/pdfium/core/fxge/android/fpf_skiamodule.h
@@ -7,24 +7,28 @@
#ifndef CORE_FXGE_ANDROID_FPF_SKIAMODULE_H_
#define CORE_FXGE_ANDROID_FPF_SKIAMODULE_H_
+#include "core/fxcrt/include/fx_system.h'"
+
#if _FX_OS_ == _FX_ANDROID_
-#include "core/include/fxge/fpf.h"
+#include "core/fxge/android/fpf_skiafontmgr.h"
class CFPF_SkiaFontMgr;
-class CFPF_SkiaDeviceModule : public IFPF_DeviceModule {
+class CFPF_SkiaDeviceModule {
public:
CFPF_SkiaDeviceModule() : m_pFontMgr(nullptr) {}
- ~CFPF_SkiaDeviceModule() override;
+ ~CFPF_SkiaDeviceModule();
- // IFPF_DeviceModule
- void Destroy() override;
- IFPF_FontMgr* GetFontMgr() override;
+ void Destroy();
+ CFPF_SkiaFontMgr* GetFontMgr();
protected:
CFPF_SkiaFontMgr* m_pFontMgr;
};
-#endif
+
+CFPF_SkiaDeviceModule* CFPF_GetSkiaDeviceModule();
+
+#endif // _FX_OS_ == _FX_ANDROID_
#endif // CORE_FXGE_ANDROID_FPF_SKIAMODULE_H_
diff --git a/chromium/third_party/pdfium/core/fxge/android/fx_android_font.cpp b/chromium/third_party/pdfium/core/fxge/android/fx_android_font.cpp
index d663ac0f4f6..b1606bbd697 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fx_android_font.cpp
+++ b/chromium/third_party/pdfium/core/fxge/android/fx_android_font.cpp
@@ -8,82 +8,86 @@
#if _FX_OS_ == _FX_ANDROID_
+#include "core/fxge/android/fpf_skiafont.h"
+#include "core/fxge/android/fpf_skiafontmgr.h"
#include "core/fxge/android/fx_android_font.h"
-#include "core/include/fxge/fpf.h"
CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(NULL) {}
-FX_BOOL CFX_AndroidFontInfo::Init(IFPF_FontMgr* pFontMgr) {
- if (!pFontMgr) {
+FX_BOOL CFX_AndroidFontInfo::Init(CFPF_SkiaFontMgr* pFontMgr) {
+ if (!pFontMgr)
return FALSE;
- }
+
pFontMgr->LoadSystemFonts();
m_pFontMgr = pFontMgr;
return TRUE;
}
+
FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
return FALSE;
}
+
void* CFX_AndroidFontInfo::MapFont(int weight,
FX_BOOL bItalic,
int charset,
int pitch_family,
const FX_CHAR* face,
int& iExact) {
- if (!m_pFontMgr) {
- return NULL;
- }
+ if (!m_pFontMgr)
+ return nullptr;
+
uint32_t dwStyle = 0;
- if (weight >= 700) {
+ if (weight >= 700)
dwStyle |= FXFONT_BOLD;
- }
- if (bItalic) {
+ if (bItalic)
dwStyle |= FXFONT_ITALIC;
- }
- if (pitch_family & FXFONT_FF_FIXEDPITCH) {
+ if (pitch_family & FXFONT_FF_FIXEDPITCH)
dwStyle |= FXFONT_FIXED_PITCH;
- }
- if (pitch_family & FXFONT_FF_SCRIPT) {
+ if (pitch_family & FXFONT_FF_SCRIPT)
dwStyle |= FXFONT_SCRIPT;
- }
- if (pitch_family & FXFONT_FF_ROMAN) {
+ if (pitch_family & FXFONT_FF_ROMAN)
dwStyle |= FXFONT_SERIF;
- }
return m_pFontMgr->CreateFont(face, charset, dwStyle,
FPF_MATCHFONT_REPLACEANSI);
}
+
void* CFX_AndroidFontInfo::GetFont(const FX_CHAR* face) {
- return NULL;
+ return nullptr;
}
+
uint32_t CFX_AndroidFontInfo::GetFontData(void* hFont,
uint32_t table,
uint8_t* buffer,
uint32_t size) {
- if (!hFont) {
+ if (!hFont)
return 0;
- }
- return ((IFPF_Font*)hFont)->GetFontData(table, buffer, size);
+ return static_cast<CFPF_SkiaFont*>(hFont)->GetFontData(table, buffer, size);
}
+
FX_BOOL CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) {
- if (!hFont) {
+ if (!hFont)
return FALSE;
- }
- name = ((IFPF_Font*)hFont)->GetFamilyName();
+
+ name = static_cast<CFPF_SkiaFont*>(hFont)->GetFamilyName();
return TRUE;
}
+
FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) {
- if (!hFont) {
+ if (!hFont)
return FALSE;
- }
- charset = ((IFPF_Font*)hFont)->GetCharset();
+
+ charset = static_cast<CFPF_SkiaFont*>(hFont)->GetCharset();
return FALSE;
}
+
void CFX_AndroidFontInfo::DeleteFont(void* hFont) {
- if (!hFont) {
+ if (!hFont)
return;
- }
- ((IFPF_Font*)hFont)->Release();
+
+ static_cast<CFPF_SkiaFont*>(hFont)->Release();
}
+
void* CFX_AndroidFontInfo::RetainFont(void* hFont) {
- return NULL;
+ return nullptr;
}
-#endif
+
+#endif // _FX_OS_ == _FX_ANDROID_
diff --git a/chromium/third_party/pdfium/core/fxge/android/fx_android_font.h b/chromium/third_party/pdfium/core/fxge/android/fx_android_font.h
index ee8859185ef..07d5f5852b9 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fx_android_font.h
+++ b/chromium/third_party/pdfium/core/fxge/android/fx_android_font.h
@@ -11,9 +11,9 @@
#if _FX_OS_ == _FX_ANDROID_
-#include "core/include/fxge/fx_font.h"
+#include "core/fxge/include/fx_font.h"
-class IFPF_FontMgr;
+class CFPF_SkiaFontMgr;
class CFX_AndroidFontInfo : public IFX_SystemFontInfo {
public:
@@ -39,11 +39,12 @@ class CFX_AndroidFontInfo : public IFX_SystemFontInfo {
virtual void DeleteFont(void* hFont);
virtual void* RetainFont(void* hFont);
- FX_BOOL Init(IFPF_FontMgr* pFontMgr);
+ FX_BOOL Init(CFPF_SkiaFontMgr* pFontMgr);
protected:
- IFPF_FontMgr* m_pFontMgr;
+ CFPF_SkiaFontMgr* m_pFontMgr;
};
-#endif
+
+#endif // _FX_OS_ == _FX_ANDROID_
#endif // CORE_FXGE_ANDROID_FX_ANDROID_FONT_H_
diff --git a/chromium/third_party/pdfium/core/fxge/android/fx_android_imp.cpp b/chromium/third_party/pdfium/core/fxge/android/fx_android_imp.cpp
index 3fac3706cf3..bbaa2ba27a1 100644
--- a/chromium/third_party/pdfium/core/fxge/android/fx_android_imp.cpp
+++ b/chromium/third_party/pdfium/core/fxge/android/fx_android_imp.cpp
@@ -8,16 +8,16 @@
#if _FX_OS_ == _FX_ANDROID_
+#include "core/fxge/android/fpf_skiamodule.h"
#include "core/fxge/android/fx_android_font.h"
-#include "core/include/fxge/fpf.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
void CFX_GEModule::InitPlatform() {
- IFPF_DeviceModule* pDeviceModule = FPF_GetDeviceModule();
- if (!pDeviceModule) {
+ CFPF_SkiaDeviceModule* pDeviceModule = CFPF_GetSkiaDeviceModule();
+ if (!pDeviceModule)
return;
- }
- IFPF_FontMgr* pFontMgr = pDeviceModule->GetFontMgr();
+
+ CFPF_SkiaFontMgr* pFontMgr = pDeviceModule->GetFontMgr();
if (pFontMgr) {
CFX_AndroidFontInfo* pFontInfo = new CFX_AndroidFontInfo;
pFontInfo->Init(pFontMgr);
@@ -25,10 +25,10 @@ void CFX_GEModule::InitPlatform() {
}
m_pPlatformData = pDeviceModule;
}
+
void CFX_GEModule::DestroyPlatform() {
- if (m_pPlatformData) {
- ((IFPF_DeviceModule*)m_pPlatformData)->Destroy();
- }
+ if (m_pPlatformData)
+ static_cast<IFPF_DeviceModule*>(m_pPlatformData)->Destroy();
}
-#endif
+#endif // _FX_OS_ == _FX_ANDROID_
diff --git a/chromium/third_party/pdfium/core/fxge/apple/apple_int.h b/chromium/third_party/pdfium/core/fxge/apple/apple_int.h
index c6c8f6ac921..02754cc309d 100644
--- a/chromium/third_party/pdfium/core/fxge/apple/apple_int.h
+++ b/chromium/third_party/pdfium/core/fxge/apple/apple_int.h
@@ -11,7 +11,7 @@
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FX_OS_ == _FX_MACOSX_
#include <Carbon/Carbon.h>
diff --git a/chromium/third_party/pdfium/core/fxge/apple/fx_apple_platform.cpp b/chromium/third_party/pdfium/core/fxge/apple/fx_apple_platform.cpp
index b68d50eab32..e45b238cb59 100644
--- a/chromium/third_party/pdfium/core/fxge/apple/fx_apple_platform.cpp
+++ b/chromium/third_party/pdfium/core/fxge/apple/fx_apple_platform.cpp
@@ -5,7 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
@@ -13,8 +13,8 @@
#include "core/fxge/apple/apple_int.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge_apple.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge_apple.h"
void CFX_AggDeviceDriver::InitPlatform() {
CQuartz2D& quartz2d =
diff --git a/chromium/third_party/pdfium/core/fxge/apple/fx_mac_imp.cpp b/chromium/third_party/pdfium/core/fxge/apple/fx_mac_imp.cpp
index db9f802d64c..82b50785650 100644
--- a/chromium/third_party/pdfium/core/fxge/apple/fx_mac_imp.cpp
+++ b/chromium/third_party/pdfium/core/fxge/apple/fx_mac_imp.cpp
@@ -5,7 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxge/apple/apple_int.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FX_OS_ == _FX_MACOSX_
static const struct {
@@ -64,7 +64,7 @@ void* CFX_MacFontInfo::MapFont(int weight,
break;
}
if (iBaseFont < 12) {
- return GetFont(face);
+ return GetFont(face.c_str());
}
auto it = m_FontList.find(face);
if (it != m_FontList.end())
diff --git a/chromium/third_party/pdfium/core/fxge/apple/fx_quartz_device.cpp b/chromium/third_party/pdfium/core/fxge/apple/fx_quartz_device.cpp
index 5386aba2d8a..f3a4428ecce 100644
--- a/chromium/third_party/pdfium/core/fxge/apple/fx_quartz_device.cpp
+++ b/chromium/third_party/pdfium/core/fxge/apple/fx_quartz_device.cpp
@@ -8,12 +8,12 @@
#include "core/fxge/agg/fx_agg_driver.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
#include "core/fxge/apple/apple_int.h"
-#include "core/include/fxge/fx_ge_apple.h"
+#include "core/fxge/include/fx_ge_apple.h"
#ifndef CGFLOAT_IS_DOUBLE
#error Expected CGFLOAT_IS_DOUBLE to be defined by CoreGraphics headers
#endif
diff --git a/chromium/third_party/pdfium/core/fxge/dib/dib_int.h b/chromium/third_party/pdfium/core/fxge/dib/dib_int.h
index 1d2193e9bba..ebb1ddc0ed2 100644
--- a/chromium/third_party/pdfium/core/fxge/dib/dib_int.h
+++ b/chromium/third_party/pdfium/core/fxge/dib/dib_int.h
@@ -10,7 +10,7 @@
#include <stdint.h>
#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
class IFX_ScanlineComposer;
@@ -86,8 +86,8 @@ class CStretchEngine {
int m_SrcWidth, m_SrcHeight;
int m_SrcPitch, m_InterPitch;
int m_ExtraMaskPitch;
- unsigned char* m_pInterBuf;
- unsigned char* m_pExtraAlphaBuf;
+ uint8_t* m_pInterBuf;
+ uint8_t* m_pExtraAlphaBuf;
int m_TransMethod;
int m_Flags;
CWeightTable m_WeightTable;
diff --git a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_composite.cpp b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_composite.cpp
index b10180deae4..18d73d1f256 100644
--- a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_composite.cpp
+++ b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_composite.cpp
@@ -4,9 +4,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxge/dib/dib_int.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
const uint8_t _color_sqrt[256] = {
0x00, 0x03, 0x07, 0x0B, 0x0F, 0x12, 0x16, 0x19, 0x1D, 0x20, 0x23, 0x26,
@@ -287,7 +287,7 @@ void _CompositeRow_Argb2Graya(uint8_t* dest_scan,
const uint8_t* src_alpha_scan,
uint8_t* dst_alpha_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule = nullptr;
+ CCodec_IccModule* pIccModule = nullptr;
if (pIccTransform)
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
@@ -490,7 +490,7 @@ inline void _CompositeRow_Argb2Gray(uint8_t* dest_scan,
const uint8_t* clip_scan,
const uint8_t* src_alpha_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule = NULL;
+ CCodec_IccModule* pIccModule = nullptr;
uint8_t gray;
if (pIccTransform)
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
@@ -586,7 +586,7 @@ inline void _CompositeRow_Rgb2Gray(uint8_t* dest_scan,
int blend_type,
const uint8_t* clip_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule = NULL;
+ CCodec_IccModule* pIccModule = nullptr;
uint8_t gray;
if (pIccTransform) {
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
@@ -636,7 +636,7 @@ void _CompositeRow_Rgb2Graya(uint8_t* dest_scan,
const uint8_t* clip_scan,
uint8_t* dest_alpha_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule = NULL;
+ CCodec_IccModule* pIccModule = nullptr;
if (pIccTransform) {
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
}
@@ -1442,7 +1442,7 @@ void _CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
uint8_t* dp = src_cache_scan;
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_alpha_scan) {
if (dest_alpha_scan) {
@@ -1536,7 +1536,7 @@ void _CompositeRow_Rgb2Argb_Blend_NoClip_Transform(uint8_t* dest_scan,
uint8_t* dest_alpha_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_Bpp == 3) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1562,7 +1562,7 @@ inline void _CompositeRow_Rgb2Argb_Blend_Clip_Transform(
uint8_t* dest_alpha_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_Bpp == 3) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1587,7 +1587,7 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_Clip_Transform(
uint8_t* dest_alpha_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_Bpp == 3) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1611,7 +1611,7 @@ inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip_Transform(
uint8_t* dest_alpha_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_Bpp == 3) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1637,7 +1637,7 @@ inline void _CompositeRow_Argb2Rgb_Blend_Transform(
const uint8_t* src_alpha_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_alpha_scan) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1688,7 +1688,7 @@ inline void _CompositeRow_Argb2Rgb_NoBlend_Transform(
const uint8_t* src_alpha_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_alpha_scan) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1737,7 +1737,7 @@ inline void _CompositeRow_Rgb2Rgb_Blend_NoClip_Transform(
int src_Bpp,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_Bpp == 3) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1762,7 +1762,7 @@ inline void _CompositeRow_Rgb2Rgb_Blend_Clip_Transform(uint8_t* dest_scan,
const uint8_t* clip_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_Bpp == 3) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1786,7 +1786,7 @@ inline void _CompositeRow_Rgb2Rgb_NoBlend_NoClip_Transform(
int src_Bpp,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_Bpp == 3) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -1811,7 +1811,7 @@ inline void _CompositeRow_Rgb2Rgb_NoBlend_Clip_Transform(
const uint8_t* clip_scan,
uint8_t* src_cache_scan,
void* pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (src_Bpp == 3) {
pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan,
@@ -3965,9 +3965,8 @@ inline FX_BOOL _ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format,
int& mask_green,
int& mask_blue,
int& mask_black,
- void* icc_module,
+ CCodec_IccModule* pIccModule,
void* pIccTransform) {
- ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module;
if (alpha_flag >> 8) {
mask_alpha = alpha_flag & 0xff;
mask_red = FXSYS_GetCValue(mask_color);
@@ -4028,9 +4027,8 @@ inline void _ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format,
FXDIB_Format dest_format,
uint32_t*& pDestPalette,
uint32_t* pSrcPalette,
- void* icc_module,
+ CCodec_IccModule* pIccModule,
void* pIccTransform) {
- ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module;
FX_BOOL isSrcCmyk = !!(src_format & 0x0400);
FX_BOOL isDstCmyk = !!(dest_format & 0x0400);
pDestPalette = NULL;
@@ -4186,7 +4184,7 @@ FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format,
m_DestFormat = dest_format;
m_BlendType = blend_type;
m_bRgbByteOrder = bRgbByteOrder;
- ICodec_IccModule* pIccModule = NULL;
+ CCodec_IccModule* pIccModule = nullptr;
if (CFX_GEModule::Get()->GetCodecModule()) {
pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
}
@@ -4803,7 +4801,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left,
if (!IsAlphaMask()) {
if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() &&
CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
pIccModule->TranslateScanline(pIccTransform, &gray, color_p, 1);
} else {
@@ -4877,7 +4875,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left,
return FALSE;
}
if (pIccTransform && CFX_GEModule::Get()->GetCodecModule()) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1);
} else {
diff --git a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_convert.cpp b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_convert.cpp
index d9d5a3b0c0a..da380ee5672 100644
--- a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_convert.cpp
+++ b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_convert.cpp
@@ -4,9 +4,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_dib.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxcodec/include/fx_codec.h"
+#include "core/fxge/include/fx_dib.h"
+#include "core/fxge/include/fx_ge.h"
class CFX_Palette {
public:
@@ -192,7 +192,7 @@ FX_BOOL ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf,
bgr_ptr[4] = FXARGB_G(src_plt[1]);
bgr_ptr[5] = FXARGB_R(src_plt[1]);
}
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
pIccModule->TranslateScanline(pIccTransform, gray, (const uint8_t*)plt, 2);
} else {
@@ -254,7 +254,7 @@ FX_BOOL ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf,
*bgr_ptr++ = FXARGB_R(src_plt[i]);
}
}
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
pIccModule->TranslateScanline(pIccTransform, gray, (const uint8_t*)plt,
256);
@@ -293,7 +293,7 @@ FX_BOOL ConvertBuffer_RgbOrCmyk2Gray(uint8_t* dest_buf,
void* pIccTransform) {
int Bpp = pSrcBitmap->GetBPP() / 8;
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
if (Bpp == 3 || pSrcBitmap->IsCmykImage()) {
for (int row = 0; row < height; row++) {
@@ -401,7 +401,7 @@ FX_BOOL ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf,
}
bgr_ptr = (uint8_t*)plt;
}
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt,
(const uint8_t*)plt, plt_size);
@@ -499,7 +499,7 @@ FX_BOOL ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf,
dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top,
dst_plt);
if (ret && pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
for (int i = 0; i < 256; i++) {
FX_ARGB* plt = dst_plt + i;
@@ -589,7 +589,7 @@ FX_BOOL ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format,
bgr_ptr[5] = FXARGB_R(src_plt[1]);
}
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt,
(const uint8_t*)plt, 2);
@@ -650,7 +650,7 @@ FX_BOOL ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format,
plt[i] = FXCMYK_TODIB(src_plt[i]);
}
}
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
pIccModule->TranslateScanline(pIccTransform, (uint8_t*)plt,
(const uint8_t*)plt, 256);
@@ -688,7 +688,7 @@ FX_BOOL ConvertBuffer_24bppRgb2Rgb24(uint8_t* dest_buf,
int src_top,
void* pIccTransform) {
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
@@ -726,7 +726,7 @@ FX_BOOL ConvertBuffer_32bppRgb2Rgb24(uint8_t* dest_buf,
}
}
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
@@ -745,7 +745,7 @@ FX_BOOL ConvertBuffer_Rgb2Rgb32(uint8_t* dest_buf,
void* pIccTransform) {
int comps = pSrcBitmap->GetBPP() / 8;
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
@@ -782,7 +782,7 @@ FX_BOOL ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf,
int src_top,
void* pIccTransform) {
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
diff --git a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_engine.cpp b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_engine.cpp
index a68583b346e..3bdff23f1e7 100644
--- a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_engine.cpp
+++ b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_engine.cpp
@@ -6,9 +6,31 @@
#include <limits.h>
+#include <algorithm>
+
#include "core/fxge/dib/dib_int.h"
-#include "core/include/fxge/fx_dib.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_dib.h"
+#include "core/fxge/include/fx_ge.h"
+
+namespace {
+
+bool SourceSizeWithinLimit(int width, int height) {
+ const int kMaxProgressiveStretchPixels = 1000000;
+ return !height || width < kMaxProgressiveStretchPixels / height;
+}
+
+FXDIB_Format GetStretchedFormat(const CFX_DIBSource& src) {
+ FXDIB_Format format = src.GetFormat();
+ if (format == FXDIB_1bppMask)
+ return FXDIB_8bppMask;
+ if (format == FXDIB_1bppRgb)
+ return FXDIB_8bppRgb;
+ if (format == FXDIB_8bppRgb && src.GetPalette())
+ return FXDIB_Rgb;
+ return format;
+}
+
+} // namespace
void CWeightTable::Calc(int dest_len,
int dest_min,
@@ -754,48 +776,37 @@ void CStretchEngine::StretchVert() {
m_pDestMaskScanline);
}
}
-CFX_ImageStretcher::CFX_ImageStretcher() {
- m_pScanline = NULL;
- m_pStretchEngine = NULL;
- m_pMaskScanline = NULL;
-}
+
+CFX_ImageStretcher::CFX_ImageStretcher(IFX_ScanlineComposer* pDest,
+ const CFX_DIBSource* pSource,
+ int dest_width,
+ int dest_height,
+ const FX_RECT& bitmap_rect,
+ uint32_t flags)
+ : m_pDest(pDest),
+ m_pSource(pSource),
+ m_Flags(flags),
+ m_bFlipX(FALSE),
+ m_bFlipY(FALSE),
+ m_DestWidth(dest_width),
+ m_DestHeight(dest_height),
+ m_ClipRect(bitmap_rect),
+ m_DestFormat(GetStretchedFormat(*pSource)),
+ m_DestBPP(m_DestFormat & 0xff),
+ m_LineIndex(0) {}
+
CFX_ImageStretcher::~CFX_ImageStretcher() {
- FX_Free(m_pScanline);
- delete m_pStretchEngine;
- FX_Free(m_pMaskScanline);
-}
-FXDIB_Format _GetStretchedFormat(const CFX_DIBSource* pSrc) {
- FXDIB_Format format = pSrc->GetFormat();
- if (format == FXDIB_1bppMask) {
- format = FXDIB_8bppMask;
- } else if (format == FXDIB_1bppRgb) {
- format = FXDIB_8bppRgb;
- } else if (format == FXDIB_8bppRgb) {
- if (pSrc->GetPalette()) {
- format = FXDIB_Rgb;
- }
- }
- return format;
}
-FX_BOOL CFX_ImageStretcher::Start(IFX_ScanlineComposer* pDest,
- const CFX_DIBSource* pSource,
- int dest_width,
- int dest_height,
- const FX_RECT& rect,
- uint32_t flags) {
- m_DestFormat = _GetStretchedFormat(pSource);
- m_DestBPP = m_DestFormat & 0xff;
- m_pDest = pDest;
- m_pSource = pSource;
- m_DestWidth = dest_width;
- m_DestHeight = dest_height;
- m_ClipRect = rect;
- m_Flags = flags;
- if (pSource->GetFormat() == FXDIB_1bppRgb && pSource->GetPalette()) {
+
+FX_BOOL CFX_ImageStretcher::Start() {
+ if (m_DestWidth == 0 || m_DestHeight == 0)
+ return FALSE;
+
+ if (m_pSource->GetFormat() == FXDIB_1bppRgb && m_pSource->GetPalette()) {
FX_ARGB pal[256];
int a0, r0, g0, b0, a1, r1, g1, b1;
- ArgbDecode(pSource->GetPaletteEntry(0), a0, r0, g0, b0);
- ArgbDecode(pSource->GetPaletteEntry(1), a1, r1, g1, b1);
+ ArgbDecode(m_pSource->GetPaletteEntry(0), a0, r0, g0, b0);
+ ArgbDecode(m_pSource->GetPaletteEntry(1), a1, r1, g1, b1);
for (int i = 0; i < 256; i++) {
int a = a0 + (a1 - a0) * i / 255;
int r = r0 + (r1 - r0) * i / 255;
@@ -803,14 +814,16 @@ FX_BOOL CFX_ImageStretcher::Start(IFX_ScanlineComposer* pDest,
int b = b0 + (b1 - b0) * i / 255;
pal[i] = ArgbEncode(a, r, g, b);
}
- if (!pDest->SetInfo(rect.Width(), rect.Height(), m_DestFormat, pal)) {
+ if (!m_pDest->SetInfo(m_ClipRect.Width(), m_ClipRect.Height(), m_DestFormat,
+ pal)) {
return FALSE;
}
- } else if (pSource->GetFormat() == FXDIB_1bppCmyk && pSource->GetPalette()) {
+ } else if (m_pSource->GetFormat() == FXDIB_1bppCmyk &&
+ m_pSource->GetPalette()) {
FX_CMYK pal[256];
int c0, m0, y0, k0, c1, m1, y1, k1;
- CmykDecode(pSource->GetPaletteEntry(0), c0, m0, y0, k0);
- CmykDecode(pSource->GetPaletteEntry(1), c1, m1, y1, k1);
+ CmykDecode(m_pSource->GetPaletteEntry(0), c0, m0, y0, k0);
+ CmykDecode(m_pSource->GetPaletteEntry(1), c1, m1, y1, k1);
for (int i = 0; i < 256; i++) {
int c = c0 + (c1 - c0) * i / 255;
int m = m0 + (m1 - m0) * i / 255;
@@ -818,42 +831,43 @@ FX_BOOL CFX_ImageStretcher::Start(IFX_ScanlineComposer* pDest,
int k = k0 + (k1 - k0) * i / 255;
pal[i] = CmykEncode(c, m, y, k);
}
- if (!pDest->SetInfo(rect.Width(), rect.Height(), m_DestFormat, pal)) {
+ if (!m_pDest->SetInfo(m_ClipRect.Width(), m_ClipRect.Height(), m_DestFormat,
+ pal)) {
return FALSE;
}
- } else if (!pDest->SetInfo(rect.Width(), rect.Height(), m_DestFormat, NULL)) {
+ } else if (!m_pDest->SetInfo(m_ClipRect.Width(), m_ClipRect.Height(),
+ m_DestFormat, nullptr)) {
return FALSE;
}
- if (flags & FXDIB_DOWNSAMPLE) {
+
+ if (m_Flags & FXDIB_DOWNSAMPLE)
return StartQuickStretch();
- }
return StartStretch();
}
+
FX_BOOL CFX_ImageStretcher::Continue(IFX_Pause* pPause) {
- if (m_Flags & FXDIB_DOWNSAMPLE) {
+ if (m_Flags & FXDIB_DOWNSAMPLE)
return ContinueQuickStretch(pPause);
- }
return ContinueStretch(pPause);
}
-#define MAX_PROGRESSIVE_STRETCH_PIXELS 1000000
+
FX_BOOL CFX_ImageStretcher::StartStretch() {
- m_pStretchEngine =
- new CStretchEngine(m_pDest, m_DestFormat, m_DestWidth, m_DestHeight,
- m_ClipRect, m_pSource, m_Flags);
+ m_pStretchEngine.reset(new CStretchEngine(m_pDest, m_DestFormat, m_DestWidth,
+ m_DestHeight, m_ClipRect, m_pSource,
+ m_Flags));
m_pStretchEngine->StartStretchHorz();
- if (m_pSource->GetWidth() * m_pSource->GetHeight() <
- MAX_PROGRESSIVE_STRETCH_PIXELS) {
- m_pStretchEngine->Continue(NULL);
+ if (SourceSizeWithinLimit(m_pSource->GetWidth(), m_pSource->GetHeight())) {
+ m_pStretchEngine->Continue(nullptr);
return FALSE;
}
return TRUE;
}
+
FX_BOOL CFX_ImageStretcher::ContinueStretch(IFX_Pause* pPause) {
return m_pStretchEngine && m_pStretchEngine->Continue(pPause);
}
+
FX_BOOL CFX_ImageStretcher::StartQuickStretch() {
- m_bFlipX = FALSE;
- m_bFlipY = FALSE;
if (m_DestWidth < 0) {
m_bFlipX = TRUE;
m_DestWidth = -m_DestWidth;
@@ -862,31 +876,32 @@ FX_BOOL CFX_ImageStretcher::StartQuickStretch() {
m_bFlipY = TRUE;
m_DestHeight = -m_DestHeight;
}
- m_LineIndex = 0;
uint32_t size = m_ClipRect.Width();
if (size && m_DestBPP > (int)(INT_MAX / size)) {
return FALSE;
}
size *= m_DestBPP;
- m_pScanline = FX_Alloc(uint8_t, (size / 8 + 3) / 4 * 4);
- if (m_pSource->m_pAlphaMask) {
- m_pMaskScanline = FX_Alloc(uint8_t, (m_ClipRect.Width() + 3) / 4 * 4);
- }
- if (m_pSource->GetWidth() * m_pSource->GetHeight() <
- MAX_PROGRESSIVE_STRETCH_PIXELS) {
- ContinueQuickStretch(NULL);
+ m_pScanline.reset(FX_Alloc(uint8_t, (size / 8 + 3) / 4 * 4));
+ if (m_pSource->m_pAlphaMask)
+ m_pMaskScanline.reset(FX_Alloc(uint8_t, (m_ClipRect.Width() + 3) / 4 * 4));
+
+ if (SourceSizeWithinLimit(m_pSource->GetWidth(), m_pSource->GetHeight())) {
+ ContinueQuickStretch(nullptr);
return FALSE;
}
return TRUE;
}
+
FX_BOOL CFX_ImageStretcher::ContinueQuickStretch(IFX_Pause* pPause) {
- if (!m_pScanline) {
+ if (!m_pScanline)
return FALSE;
- }
- int result_width = m_ClipRect.Width(), result_height = m_ClipRect.Height();
+
+ int result_width = m_ClipRect.Width();
+ int result_height = m_ClipRect.Height();
int src_height = m_pSource->GetHeight();
for (; m_LineIndex < result_height; m_LineIndex++) {
- int dest_y, src_y;
+ int dest_y;
+ int src_y;
if (m_bFlipY) {
dest_y = result_height - m_LineIndex - 1;
src_y = (m_DestHeight - (dest_y + m_ClipRect.top) - 1) * src_height /
@@ -895,23 +910,20 @@ FX_BOOL CFX_ImageStretcher::ContinueQuickStretch(IFX_Pause* pPause) {
dest_y = m_LineIndex;
src_y = (dest_y + m_ClipRect.top) * src_height / m_DestHeight;
}
- if (src_y >= src_height) {
- src_y = src_height - 1;
- }
- if (src_y < 0) {
- src_y = 0;
- }
- if (m_pSource->SkipToScanline(src_y, pPause)) {
+ src_y = std::max(std::min(src_y, src_height - 1), 0);
+
+ if (m_pSource->SkipToScanline(src_y, pPause))
return TRUE;
- }
- m_pSource->DownSampleScanline(src_y, m_pScanline, m_DestBPP, m_DestWidth,
- m_bFlipX, m_ClipRect.left, result_width);
+
+ m_pSource->DownSampleScanline(src_y, m_pScanline.get(), m_DestBPP,
+ m_DestWidth, m_bFlipX, m_ClipRect.left,
+ result_width);
if (m_pMaskScanline) {
m_pSource->m_pAlphaMask->DownSampleScanline(
- src_y, m_pMaskScanline, 1, m_DestWidth, m_bFlipX, m_ClipRect.left,
- result_width);
+ src_y, m_pMaskScanline.get(), 1, m_DestWidth, m_bFlipX,
+ m_ClipRect.left, result_width);
}
- m_pDest->ComposeScanline(dest_y, m_pScanline, m_pMaskScanline);
+ m_pDest->ComposeScanline(dest_y, m_pScanline.get(), m_pMaskScanline.get());
}
return FALSE;
}
diff --git a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_main.cpp b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_main.cpp
index 3772459eca1..ad6ee0c4e75 100644
--- a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_main.cpp
+++ b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_main.cpp
@@ -4,13 +4,13 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include <limits.h>
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxge/dib/dib_int.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
uint8_t* dest_buf,
@@ -490,7 +490,7 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left,
uint8_t* color_p = (uint8_t*)&dst_color;
if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() &&
CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1);
} else {
@@ -1591,6 +1591,7 @@ CFX_ImageRenderer::CFX_ImageRenderer() {
CFX_ImageRenderer::~CFX_ImageRenderer() {
delete m_pTransformer;
}
+
FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice,
const CFX_ClipRgn* pClipRgn,
const CFX_DIBSource* pSource,
@@ -1608,9 +1609,9 @@ FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice,
m_ClipBox = pClipRgn ? pClipRgn->GetBox() : FX_RECT(0, 0, pDevice->GetWidth(),
pDevice->GetHeight());
m_ClipBox.Intersect(image_rect);
- if (m_ClipBox.IsEmpty()) {
+ if (m_ClipBox.IsEmpty())
return FALSE;
- }
+
m_pDevice = pDevice;
m_pClipRgn = pClipRgn;
m_MaskColor = mask_color;
@@ -1621,7 +1622,7 @@ FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice,
m_pIccTransform = pIccTransform;
m_bRgbByteOrder = bRgbByteOrder;
m_BlendType = blend_type;
- FX_BOOL ret = TRUE;
+
if ((FXSYS_fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) ||
(FXSYS_fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0)) {
if (FXSYS_fabs(m_Matrix.a) < FXSYS_fabs(m_Matrix.b) / 20 &&
@@ -1636,55 +1637,56 @@ FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice,
m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox,
TRUE, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder,
alpha_flag, pIccTransform, m_BlendType);
- if (!m_Stretcher.Start(&m_Composer, pSource, dest_height, dest_width,
- bitmap_clip, dib_flags)) {
+ m_Stretcher.reset(new CFX_ImageStretcher(&m_Composer, pSource,
+ dest_height, dest_width,
+ bitmap_clip, dib_flags));
+ if (!m_Stretcher->Start())
return FALSE;
- }
+
m_Status = 1;
return TRUE;
}
m_Status = 2;
- m_pTransformer = new CFX_ImageTransformer;
- m_pTransformer->Start(pSource, &m_Matrix, dib_flags, &m_ClipBox);
+ m_pTransformer =
+ new CFX_ImageTransformer(pSource, &m_Matrix, dib_flags, &m_ClipBox);
+ m_pTransformer->Start();
return TRUE;
}
+
int dest_width = image_rect.Width();
- if (m_Matrix.a < 0) {
+ if (m_Matrix.a < 0)
dest_width = -dest_width;
- }
+
int dest_height = image_rect.Height();
- if (m_Matrix.d > 0) {
+ if (m_Matrix.d > 0)
dest_height = -dest_height;
- }
- if (dest_width == 0 || dest_height == 0) {
+
+ if (dest_width == 0 || dest_height == 0)
return FALSE;
- }
+
FX_RECT bitmap_clip = m_ClipBox;
bitmap_clip.Offset(-image_rect.left, -image_rect.top);
m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox,
FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_flag,
pIccTransform, m_BlendType);
m_Status = 1;
- ret = m_Stretcher.Start(&m_Composer, pSource, dest_width, dest_height,
- bitmap_clip, dib_flags);
- return ret;
+ m_Stretcher.reset(new CFX_ImageStretcher(
+ &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags));
+ return m_Stretcher->Start();
}
+
FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) {
- if (m_Status == 1) {
- return m_Stretcher.Continue(pPause);
- }
+ if (m_Status == 1)
+ return m_Stretcher->Continue(pPause);
+
if (m_Status == 2) {
- if (m_pTransformer->Continue(pPause)) {
+ if (m_pTransformer->Continue(pPause))
return TRUE;
- }
- CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (!pBitmap) {
- return FALSE;
- }
- if (!pBitmap->GetBuffer()) {
- delete pBitmap;
+
+ std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap());
+ if (!pBitmap || !pBitmap->GetBuffer())
return FALSE;
- }
+
if (pBitmap->IsAlphaMask()) {
if (m_BitmapAlpha != 255) {
if (m_AlphaFlag >> 8) {
@@ -1695,51 +1697,49 @@ FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) {
m_MaskColor = FXARGB_MUL_ALPHA(m_MaskColor, m_BitmapAlpha);
}
}
- m_pDevice->CompositeMask(m_pTransformer->m_ResultLeft,
- m_pTransformer->m_ResultTop, pBitmap->GetWidth(),
- pBitmap->GetHeight(), pBitmap, m_MaskColor, 0, 0,
- m_BlendType, m_pClipRgn, m_bRgbByteOrder,
- m_AlphaFlag, m_pIccTransform);
+ m_pDevice->CompositeMask(
+ m_pTransformer->result().left, m_pTransformer->result().top,
+ pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap.get(), m_MaskColor,
+ 0, 0, m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_AlphaFlag,
+ m_pIccTransform);
} else {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
- }
m_pDevice->CompositeBitmap(
- m_pTransformer->m_ResultLeft, m_pTransformer->m_ResultTop,
- pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, 0, 0, m_BlendType,
- m_pClipRgn, m_bRgbByteOrder, m_pIccTransform);
+ m_pTransformer->result().left, m_pTransformer->result().top,
+ pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap.get(), 0, 0,
+ m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_pIccTransform);
}
- delete pBitmap;
return FALSE;
}
return FALSE;
}
+
CFX_BitmapStorer::CFX_BitmapStorer() {
- m_pBitmap = NULL;
}
+
CFX_BitmapStorer::~CFX_BitmapStorer() {
- delete m_pBitmap;
}
-CFX_DIBitmap* CFX_BitmapStorer::Detach() {
- CFX_DIBitmap* pBitmap = m_pBitmap;
- m_pBitmap = NULL;
- return pBitmap;
+
+std::unique_ptr<CFX_DIBitmap> CFX_BitmapStorer::Detach() {
+ return std::move(m_pBitmap);
}
-void CFX_BitmapStorer::Replace(CFX_DIBitmap* pBitmap) {
- delete m_pBitmap;
- m_pBitmap = pBitmap;
+
+void CFX_BitmapStorer::Replace(std::unique_ptr<CFX_DIBitmap> pBitmap) {
+ m_pBitmap = std::move(pBitmap);
}
+
void CFX_BitmapStorer::ComposeScanline(int line,
const uint8_t* scanline,
const uint8_t* scan_extra_alpha) {
- uint8_t* dest_buf = (uint8_t*)m_pBitmap->GetScanline(line);
+ uint8_t* dest_buf = const_cast<uint8_t*>(m_pBitmap->GetScanline(line));
uint8_t* dest_alpha_buf =
m_pBitmap->m_pAlphaMask
- ? (uint8_t*)m_pBitmap->m_pAlphaMask->GetScanline(line)
- : NULL;
- if (dest_buf) {
+ ? const_cast<uint8_t*>(m_pBitmap->m_pAlphaMask->GetScanline(line))
+ : nullptr;
+ if (dest_buf)
FXSYS_memcpy(dest_buf, scanline, m_pBitmap->GetPitch());
- }
+
if (dest_alpha_buf) {
FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha,
m_pBitmap->m_pAlphaMask->GetPitch());
@@ -1749,14 +1749,12 @@ FX_BOOL CFX_BitmapStorer::SetInfo(int width,
int height,
FXDIB_Format src_format,
uint32_t* pSrcPalette) {
- m_pBitmap = new CFX_DIBitmap;
+ m_pBitmap.reset(new CFX_DIBitmap);
if (!m_pBitmap->Create(width, height, src_format)) {
- delete m_pBitmap;
- m_pBitmap = NULL;
+ m_pBitmap.reset();
return FALSE;
}
- if (pSrcPalette) {
+ if (pSrcPalette)
m_pBitmap->CopyPalette(pSrcPalette);
- }
return TRUE;
}
diff --git a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_transform.cpp b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_transform.cpp
index 91c65fbbc8e..f9b4250debb 100644
--- a/chromium/third_party/pdfium/core/fxge/dib/fx_dib_transform.cpp
+++ b/chromium/third_party/pdfium/core/fxge/dib/fx_dib_transform.cpp
@@ -6,7 +6,7 @@
#include "core/fxge/dib/dib_int.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
namespace {
@@ -296,154 +296,157 @@ FX_RECT FXDIB_SwapClipBox(FX_RECT& clip,
rect.Normalize();
return rect;
}
+
CFX_DIBitmap* CFX_DIBSource::TransformTo(const CFX_Matrix* pDestMatrix,
int& result_left,
int& result_top,
uint32_t flags,
const FX_RECT* pDestClip) const {
- CFX_ImageTransformer transformer;
- transformer.Start(this, pDestMatrix, flags, pDestClip);
- transformer.Continue(NULL);
- result_left = transformer.m_ResultLeft;
- result_top = transformer.m_ResultTop;
- CFX_DIBitmap* pTransformed = transformer.m_Storer.Detach();
- return pTransformed;
+ CFX_ImageTransformer transformer(this, pDestMatrix, flags, pDestClip);
+ transformer.Start();
+ transformer.Continue(nullptr);
+ result_left = transformer.result().left;
+ result_top = transformer.result().top;
+ return transformer.DetachBitmap().release();
}
+
CFX_DIBitmap* CFX_DIBSource::StretchTo(int dest_width,
int dest_height,
uint32_t flags,
const FX_RECT* pClip) const {
FX_RECT clip_rect(0, 0, FXSYS_abs(dest_width), FXSYS_abs(dest_height));
- if (pClip) {
+ if (pClip)
clip_rect.Intersect(*pClip);
- }
- if (clip_rect.IsEmpty()) {
- return NULL;
- }
- if (dest_width == m_Width && dest_height == m_Height) {
+
+ if (clip_rect.IsEmpty())
+ return nullptr;
+
+ if (dest_width == m_Width && dest_height == m_Height)
return Clone(&clip_rect);
- }
- CFX_ImageStretcher stretcher;
+
CFX_BitmapStorer storer;
- if (stretcher.Start(&storer, this, dest_width, dest_height, clip_rect,
- flags)) {
- stretcher.Continue(NULL);
- }
- return storer.Detach();
-}
-CFX_ImageTransformer::CFX_ImageTransformer() {
- m_Status = 0;
- m_pMatrix = NULL;
+ CFX_ImageStretcher stretcher(&storer, this, dest_width, dest_height,
+ clip_rect, flags);
+ if (stretcher.Start())
+ stretcher.Continue(nullptr);
+ return storer.Detach().release();
}
+
+CFX_ImageTransformer::CFX_ImageTransformer(const CFX_DIBSource* pSrc,
+ const CFX_Matrix* pMatrix,
+ int flags,
+ const FX_RECT* pClip)
+ : m_pSrc(pSrc),
+ m_pMatrix(pMatrix),
+ m_pClip(pClip),
+ m_Flags(flags),
+ m_Status(0) {}
+
CFX_ImageTransformer::~CFX_ImageTransformer() {}
-FX_BOOL CFX_ImageTransformer::Start(const CFX_DIBSource* pSrc,
- const CFX_Matrix* pDestMatrix,
- int flags,
- const FX_RECT* pDestClip) {
- m_pMatrix = (CFX_Matrix*)pDestMatrix;
- CFX_FloatRect unit_rect = pDestMatrix->GetUnitRect();
+
+FX_BOOL CFX_ImageTransformer::Start() {
+ CFX_FloatRect unit_rect = m_pMatrix->GetUnitRect();
FX_RECT result_rect = unit_rect.GetClosestRect();
FX_RECT result_clip = result_rect;
- if (pDestClip) {
- result_clip.Intersect(*pDestClip);
- }
- if (result_clip.IsEmpty()) {
+ if (m_pClip)
+ result_clip.Intersect(*m_pClip);
+
+ if (result_clip.IsEmpty())
return FALSE;
- }
- m_ResultLeft = result_clip.left;
- m_ResultTop = result_clip.top;
- m_ResultWidth = result_clip.Width();
- m_ResultHeight = result_clip.Height();
- m_Flags = flags;
- if (FXSYS_fabs(pDestMatrix->a) < FXSYS_fabs(pDestMatrix->b) / 20 &&
- FXSYS_fabs(pDestMatrix->d) < FXSYS_fabs(pDestMatrix->c) / 20 &&
- FXSYS_fabs(pDestMatrix->a) < 0.5f && FXSYS_fabs(pDestMatrix->d) < 0.5f) {
+
+ m_result = result_clip;
+ if (FXSYS_fabs(m_pMatrix->a) < FXSYS_fabs(m_pMatrix->b) / 20 &&
+ FXSYS_fabs(m_pMatrix->d) < FXSYS_fabs(m_pMatrix->c) / 20 &&
+ FXSYS_fabs(m_pMatrix->a) < 0.5f && FXSYS_fabs(m_pMatrix->d) < 0.5f) {
int dest_width = result_rect.Width();
int dest_height = result_rect.Height();
result_clip.Offset(-result_rect.left, -result_rect.top);
result_clip = FXDIB_SwapClipBox(result_clip, dest_width, dest_height,
- pDestMatrix->c > 0, pDestMatrix->b < 0);
- m_Stretcher.Start(&m_Storer, pSrc, dest_height, dest_width, result_clip,
- flags);
+ m_pMatrix->c > 0, m_pMatrix->b < 0);
+ m_Stretcher.reset(new CFX_ImageStretcher(&m_Storer, m_pSrc, dest_height,
+ dest_width, result_clip, m_Flags));
+ m_Stretcher->Start();
m_Status = 1;
return TRUE;
}
- if (FXSYS_fabs(pDestMatrix->b) < FIX16_005 &&
- FXSYS_fabs(pDestMatrix->c) < FIX16_005) {
- int dest_width = pDestMatrix->a > 0 ? (int)FXSYS_ceil(pDestMatrix->a)
- : (int)FXSYS_floor(pDestMatrix->a);
- int dest_height = pDestMatrix->d > 0 ? (int)-FXSYS_ceil(pDestMatrix->d)
- : (int)-FXSYS_floor(pDestMatrix->d);
+ if (FXSYS_fabs(m_pMatrix->b) < FIX16_005 &&
+ FXSYS_fabs(m_pMatrix->c) < FIX16_005) {
+ int dest_width = m_pMatrix->a > 0 ? (int)FXSYS_ceil(m_pMatrix->a)
+ : (int)FXSYS_floor(m_pMatrix->a);
+ int dest_height = m_pMatrix->d > 0 ? (int)-FXSYS_ceil(m_pMatrix->d)
+ : (int)-FXSYS_floor(m_pMatrix->d);
result_clip.Offset(-result_rect.left, -result_rect.top);
- m_Stretcher.Start(&m_Storer, pSrc, dest_width, dest_height, result_clip,
- flags);
+ m_Stretcher.reset(new CFX_ImageStretcher(
+ &m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags));
+ m_Stretcher->Start();
m_Status = 2;
return TRUE;
}
- int stretch_width =
- (int)FXSYS_ceil(FXSYS_sqrt2(pDestMatrix->a, pDestMatrix->b));
- int stretch_height =
- (int)FXSYS_ceil(FXSYS_sqrt2(pDestMatrix->c, pDestMatrix->d));
+ int stretch_width = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b));
+ int stretch_height = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d));
CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f,
(FX_FLOAT)(stretch_height));
stretch2dest.Concat(
- pDestMatrix->a / stretch_width, pDestMatrix->b / stretch_width,
- pDestMatrix->c / stretch_height, pDestMatrix->d / stretch_height,
- pDestMatrix->e, pDestMatrix->f);
+ m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width,
+ m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height,
+ m_pMatrix->e, m_pMatrix->f);
m_dest2stretch.SetReverse(stretch2dest);
CFX_FloatRect clip_rect_f(result_clip);
clip_rect_f.Transform(&m_dest2stretch);
m_StretchClip = clip_rect_f.GetOutterRect();
m_StretchClip.Intersect(0, 0, stretch_width, stretch_height);
- m_Stretcher.Start(&m_Storer, pSrc, stretch_width, stretch_height,
- m_StretchClip, flags);
+ m_Stretcher.reset(new CFX_ImageStretcher(&m_Storer, m_pSrc, stretch_width,
+ stretch_height, m_StretchClip,
+ m_Flags));
+ m_Stretcher->Start();
m_Status = 3;
return TRUE;
}
FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
if (m_Status == 1) {
- if (m_Stretcher.Continue(pPause)) {
+ if (m_Stretcher->Continue(pPause))
return TRUE;
- }
+
if (m_Storer.GetBitmap()) {
- m_Storer.Replace(
+ std::unique_ptr<CFX_DIBitmap> swapped(
m_Storer.GetBitmap()->SwapXY(m_pMatrix->c > 0, m_pMatrix->b < 0));
+ m_Storer.Replace(std::move(swapped));
}
return FALSE;
}
- if (m_Status == 2) {
- return m_Stretcher.Continue(pPause);
- }
- if (m_Status != 3) {
+
+ if (m_Status == 2)
+ return m_Stretcher->Continue(pPause);
+
+ if (m_Status != 3)
return FALSE;
- }
- if (m_Stretcher.Continue(pPause)) {
+
+ if (m_Stretcher->Continue(pPause))
return TRUE;
- }
+
int stretch_width = m_StretchClip.Width();
int stretch_height = m_StretchClip.Height();
- if (!m_Storer.GetBitmap()) {
+ if (!m_Storer.GetBitmap())
return FALSE;
- }
+
const uint8_t* stretch_buf = m_Storer.GetBitmap()->GetBuffer();
- const uint8_t* stretch_buf_mask = NULL;
- if (m_Storer.GetBitmap()->m_pAlphaMask) {
+ const uint8_t* stretch_buf_mask = nullptr;
+ if (m_Storer.GetBitmap()->m_pAlphaMask)
stretch_buf_mask = m_Storer.GetBitmap()->m_pAlphaMask->GetBuffer();
- }
+
int stretch_pitch = m_Storer.GetBitmap()->GetPitch();
- CFX_DIBitmap* pTransformed = new CFX_DIBitmap;
- FXDIB_Format transformF = GetTransformedFormat(m_Stretcher.m_pSource);
- if (!pTransformed->Create(m_ResultWidth, m_ResultHeight, transformF)) {
- delete pTransformed;
+ std::unique_ptr<CFX_DIBitmap> pTransformed(new CFX_DIBitmap);
+ FXDIB_Format transformF = GetTransformedFormat(m_Stretcher->source());
+ if (!pTransformed->Create(m_result.Width(), m_result.Height(), transformF))
return FALSE;
- }
+
pTransformed->Clear(0);
- if (pTransformed->m_pAlphaMask) {
+ if (pTransformed->m_pAlphaMask)
pTransformed->m_pAlphaMask->Clear(0);
- }
- CFX_Matrix result2stretch(1.0f, 0.0f, 0.0f, 1.0f, (FX_FLOAT)(m_ResultLeft),
- (FX_FLOAT)(m_ResultTop));
+
+ CFX_Matrix result2stretch(1.0f, 0.0f, 0.0f, 1.0f, (FX_FLOAT)(m_result.left),
+ (FX_FLOAT)(m_result.top));
result2stretch.Concat(m_dest2stretch);
result2stretch.TranslateI(-m_StretchClip.left, -m_StretchClip.top);
if (!stretch_buf_mask && pTransformed->m_pAlphaMask) {
@@ -452,10 +455,10 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
int stretch_pitch_mask = m_Storer.GetBitmap()->m_pAlphaMask->GetPitch();
if (!(m_Flags & FXDIB_DOWNSAMPLE) && !(m_Flags & FXDIB_BICUBIC_INTERPOL)) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos_mask =
(uint8_t*)pTransformed->m_pAlphaMask->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -486,10 +489,10 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos_mask =
(uint8_t*)pTransformed->m_pAlphaMask->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -514,10 +517,10 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else {
CPDF_FixedMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos_mask =
(uint8_t*)pTransformed->m_pAlphaMask->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col, src_row;
result2stretch_fix.Transform(col, row, src_col, src_row);
if (src_col >= 0 && src_col <= stretch_width && src_row >= 0 &&
@@ -539,9 +542,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
if (m_Storer.GetBitmap()->IsAlphaMask()) {
if (!(m_Flags & FXDIB_DOWNSAMPLE) && !(m_Flags & FXDIB_BICUBIC_INTERPOL)) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_scan = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -572,9 +575,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_scan = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -598,9 +601,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else {
CPDF_FixedMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_scan = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col, src_row;
result2stretch_fix.Transform(col, row, src_col, src_row);
if (src_col >= 0 && src_col <= stretch_width && src_row >= 0 &&
@@ -643,9 +646,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
if (!(m_Flags & FXDIB_DOWNSAMPLE) &&
!(m_Flags & FXDIB_BICUBIC_INTERPOL)) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -683,9 +686,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -718,9 +721,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else {
CPDF_FixedMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col, src_row;
result2stretch_fix.Transform(col, row, src_col, src_row);
if (src_col >= 0 && src_col <= stretch_width && src_row >= 0 &&
@@ -751,9 +754,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
if (!(m_Flags & FXDIB_DOWNSAMPLE) &&
!(m_Flags & FXDIB_BICUBIC_INTERPOL)) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y, r_pos_k_r = 0;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -827,9 +830,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else if (m_Flags & FXDIB_BICUBIC_INTERPOL) {
CFX_BilinearMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col_l, src_row_l, res_x, res_y, r_pos_k_r = 0;
result2stretch_fix.Transform(col, row, src_col_l, src_row_l, res_x,
res_y);
@@ -898,9 +901,9 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
} else {
CPDF_FixedMatrix result2stretch_fix(result2stretch, 8);
- for (int row = 0; row < m_ResultHeight; row++) {
+ for (int row = 0; row < m_result.Height(); row++) {
uint8_t* dest_pos = (uint8_t*)pTransformed->GetScanline(row);
- for (int col = 0; col < m_ResultWidth; col++) {
+ for (int col = 0; col < m_result.Width(); col++) {
int src_col, src_row;
result2stretch_fix.Transform(col, row, src_col, src_row);
if (src_col >= 0 && src_col <= stretch_width && src_row >= 0 &&
@@ -943,6 +946,10 @@ FX_BOOL CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
}
}
}
- m_Storer.Replace(pTransformed);
+ m_Storer.Replace(std::move(pTransformed));
return FALSE;
}
+
+std::unique_ptr<CFX_DIBitmap> CFX_ImageTransformer::DetachBitmap() {
+ return m_Storer.Detach();
+}
diff --git a/chromium/third_party/pdfium/core/fxge/freetype/fx_freetype.cpp b/chromium/third_party/pdfium/core/fxge/freetype/fx_freetype.cpp
index 2fc60e913e6..f60d0c64d0d 100644
--- a/chromium/third_party/pdfium/core/fxge/freetype/fx_freetype.cpp
+++ b/chromium/third_party/pdfium/core/fxge/freetype/fx_freetype.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_freetype.h"
#include "third_party/freetype/src/psnames/pstables.h"
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_ge.cpp b/chromium/third_party/pdfium/core/fxge/ge/fx_ge.cpp
index 7ae9942dec7..9e45dc74343 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_ge.cpp
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_ge.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "core/fxge/ge/fx_text_int.h"
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_device.cpp b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_device.cpp
index d791859b03e..0d6addab752 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_device.cpp
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_device.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
CFX_RenderDevice::CFX_RenderDevice() {
m_pDeviceDriver = NULL;
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_font.cpp b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_font.cpp
index fab5ea28a9d..144228ff289 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_font.cpp
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_font.cpp
@@ -6,8 +6,8 @@
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge.h"
#define EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em)
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_fontmap.cpp b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_fontmap.cpp
index c6b208c6246..7938e109847 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_fontmap.cpp
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_fontmap.cpp
@@ -10,8 +10,8 @@
#include "core/fxge/fontdata/chromefontdata/chromefontdata.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge.h"
#include "third_party/base/stl_util.h"
#define GET_TT_SHORT(w) (uint16_t)(((w)[0] << 8) | (w)[1])
@@ -317,7 +317,7 @@ CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) {
CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) {
CFX_ByteTextBuf buf;
if (!iLen || iLen <= iIndex) {
- return buf.GetByteString();
+ return buf.MakeString();
}
while (iIndex < iLen) {
if (pStyle[iIndex] == ',') {
@@ -326,7 +326,7 @@ CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) {
buf.AppendChar(pStyle[iIndex]);
++iIndex;
}
- return buf.GetByteString();
+ return buf.MakeString();
}
int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) {
@@ -454,7 +454,8 @@ int CTTFontDesc::ReleaseFace(FXFT_Face face) {
return 0;
}
-CFX_FontMgr::CFX_FontMgr() : m_FTLibrary(nullptr) {
+CFX_FontMgr::CFX_FontMgr()
+ : m_FTLibrary(nullptr), m_FTLibrarySupportsHinting(false) {
m_pBuiltinMapper.reset(new CFX_FontMapper(this));
}
@@ -472,6 +473,9 @@ void CFX_FontMgr::InitFTLibrary() {
if (m_FTLibrary)
return;
FXFT_Init_FreeType(&m_FTLibrary);
+ m_FTLibrarySupportsHinting =
+ FXFT_Library_SetLcdFilter(m_FTLibrary, FT_LCD_FILTER_DEFAULT) !=
+ FT_Err_Unimplemented_Feature;
}
void CFX_FontMgr::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) {
@@ -651,7 +655,6 @@ bool CFX_FontMgr::GetBuiltinFont(size_t index,
CFX_FontMapper::CFX_FontMapper(CFX_FontMgr* mgr)
: m_bListLoaded(FALSE),
m_pFontInfo(nullptr),
- m_pFontEnumerator(nullptr),
m_pFontMgr(mgr) {
m_MMFaces[0] = nullptr;
m_MMFaces[1] = nullptr;
@@ -689,7 +692,7 @@ static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr,
if (string_ptr_length < static_cast<uint32_t>(offset + length)) {
return CFX_ByteString();
}
- return CFX_ByteStringC(string_ptr + offset, length);
+ return CFX_ByteString(string_ptr + offset, length);
}
CFX_ByteString GetNameFromTT(const uint8_t* name_table,
@@ -742,33 +745,32 @@ CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont) {
}
void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
- if (!m_pFontInfo) {
+ if (!m_pFontInfo)
return;
- }
- if (m_CharsetArray.Find((uint32_t)charset) == -1) {
- m_CharsetArray.Add((uint32_t)charset);
- m_FaceArray.push_back(name);
- }
- if (name == m_LastFamily) {
+
+ m_FaceArray.push_back({name, static_cast<uint32_t>(charset)});
+ if (name == m_LastFamily)
return;
- }
- const uint8_t* ptr = name;
+
+ const uint8_t* ptr = name.raw_str();
FX_BOOL bLocalized = FALSE;
- for (int i = 0; i < name.GetLength(); i++)
+ for (int i = 0; i < name.GetLength(); i++) {
if (ptr[i] > 0x80) {
bLocalized = TRUE;
break;
}
+ }
+
if (bLocalized) {
- void* hFont = m_pFontInfo->GetFont(name);
+ void* hFont = m_pFontInfo->GetFont(name.c_str());
if (!hFont) {
int iExact;
- hFont =
- m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name, iExact);
- if (!hFont) {
+ hFont = m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0,
+ name.c_str(), iExact);
+ if (!hFont)
return;
- }
}
+
CFX_ByteString new_name = GetPSNameFromTT(hFont);
if (!new_name.IsEmpty()) {
new_name.Insert(0, ' ');
@@ -779,6 +781,7 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
m_InstalledTTFonts.push_back(name);
m_LastFamily = name;
}
+
void CFX_FontMapper::LoadInstalledFonts() {
if (!m_pFontInfo) {
return;
@@ -797,7 +800,7 @@ CFX_ByteString CFX_FontMapper::MatchInstalledFonts(
LoadInstalledFonts();
int i;
for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) {
- CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i]);
+ CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str());
if (norm1 == norm_name) {
break;
}
@@ -973,7 +976,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
}
if (!style.IsEmpty()) {
int nLen = style.GetLength();
- const FX_CHAR* pStyle = style;
+ const FX_CHAR* pStyle = style.c_str();
int i = 0;
FX_BOOL bFirstItem = TRUE;
CFX_ByteString buf;
@@ -1046,10 +1049,10 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
PitchFamily);
}
family = GetFontFamily(family, nStyle);
- CFX_ByteString match = MatchInstalledFonts(TT_NormalizeName(family));
+ CFX_ByteString match = MatchInstalledFonts(TT_NormalizeName(family.c_str()));
if (match.IsEmpty() && family != SubstName &&
(!bHasComma && (!bHasHypen || (bHasHypen && !bStyleAvail)))) {
- match = MatchInstalledFonts(TT_NormalizeName(SubstName));
+ match = MatchInstalledFonts(TT_NormalizeName(SubstName.c_str()));
}
if (match.IsEmpty() && iBaseFont >= 12) {
if (!bCJK) {
@@ -1105,7 +1108,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
}
iExact = !match.IsEmpty();
void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily,
- family, iExact);
+ family.c_str(), iExact);
if (iExact) {
pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT;
}
@@ -1124,7 +1127,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
weight = old_weight;
}
if (!match.IsEmpty()) {
- hFont = m_pFontInfo->GetFont(match);
+ hFont = m_pFontInfo->GetFont(match.c_str());
if (!hFont) {
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily);
@@ -1156,12 +1159,17 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name,
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily);
}
- int index = m_CharsetArray.Find(Charset);
- if (index < 0) {
+
+ auto it =
+ std::find_if(m_FaceArray.begin(), m_FaceArray.end(),
+ [Charset](const FaceData& face) {
+ return face.charset == static_cast<uint32_t>(Charset);
+ });
+ if (it == m_FaceArray.end()) {
return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
PitchFamily);
}
- hFont = m_pFontInfo->GetFont(m_FaceArray[index]);
+ hFont = m_pFontInfo->GetFont(it->name.c_str());
}
}
pSubstFont->m_ExtHandle = m_pFontInfo->RetainFont(hFont);
@@ -1364,62 +1372,63 @@ CFX_FolderFontInfo::~CFX_FolderFontInfo() {
delete pair.second;
}
}
+
void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) {
- m_PathList.push_back(path);
+ m_PathList.push_back(CFX_ByteString(path));
}
+
void CFX_FolderFontInfo::Release() {
delete this;
}
+
FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
m_pMapper = pMapper;
- for (const auto& path : m_PathList) {
+ for (const auto& path : m_PathList)
ScanPath(path);
- }
return TRUE;
}
void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) {
- void* handle = FX_OpenFolder(path);
- if (!handle) {
+ void* handle = FX_OpenFolder(path.c_str());
+ if (!handle)
return;
- }
+
CFX_ByteString filename;
FX_BOOL bFolder;
while (FX_GetNextFile(handle, filename, bFolder)) {
if (bFolder) {
- if (filename == "." || filename == "..") {
+ if (filename == "." || filename == "..")
continue;
- }
} else {
CFX_ByteString ext = filename.Right(4);
ext.MakeUpper();
- if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC") {
+ if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC")
continue;
- }
}
+
CFX_ByteString fullpath = path;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
fullpath += "\\";
#else
fullpath += "/";
#endif
+
fullpath += filename;
- if (bFolder) {
- ScanPath(fullpath);
- } else {
- ScanFile(fullpath);
- }
+ bFolder ? ScanPath(fullpath) : ScanFile(fullpath);
}
FX_CloseFolder(handle);
}
+
void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) {
- FXSYS_FILE* pFile = FXSYS_fopen(path, "rb");
- if (!pFile) {
+ FXSYS_FILE* pFile = FXSYS_fopen(path.c_str(), "rb");
+ if (!pFile)
return;
- }
+
FXSYS_fseek(pFile, 0, FXSYS_SEEK_END);
+
uint32_t filesize = FXSYS_ftell(pFile);
uint8_t buffer[16];
FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET);
+
size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile);
if (readCnt != 1) {
FXSYS_fclose(pFile);
@@ -1456,35 +1465,37 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
uint32_t offset) {
FXSYS_fseek(pFile, offset, FXSYS_SEEK_SET);
char buffer[16];
- if (!FXSYS_fread(buffer, 12, 1, pFile)) {
+ if (!FXSYS_fread(buffer, 12, 1, pFile))
return;
- }
+
uint32_t nTables = GET_TT_SHORT(buffer + 4);
CFX_ByteString tables = FPDF_ReadStringFromFile(pFile, nTables * 16);
- if (tables.IsEmpty()) {
+ if (tables.IsEmpty())
return;
- }
+
CFX_ByteString names =
- FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65);
- if (names.IsEmpty()) {
+ FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x6e616d65);
+ if (names.IsEmpty())
return;
- }
- CFX_ByteString facename = GetNameFromTT(names, names.GetLength(), 1);
- if (facename.IsEmpty()) {
+
+ CFX_ByteString facename =
+ GetNameFromTT(names.raw_str(), names.GetLength(), 1);
+ if (facename.IsEmpty())
return;
- }
- CFX_ByteString style = GetNameFromTT(names, names.GetLength(), 2);
- if (style != "Regular") {
+
+ CFX_ByteString style = GetNameFromTT(names.raw_str(), names.GetLength(), 2);
+ if (style != "Regular")
facename += " " + style;
- }
+
if (pdfium::ContainsKey(m_FontList, facename))
return;
CFX_FontFaceInfo* pInfo =
new CFX_FontFaceInfo(path, facename, tables, offset, filesize);
- CFX_ByteString os2 = FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32);
+ CFX_ByteString os2 =
+ FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x4f532f32);
if (os2.GetLength() >= 86) {
- const uint8_t* p = (const uint8_t*)os2 + 78;
+ const uint8_t* p = os2.raw_str() + 78;
uint32_t codepages = GET_TT_LONG(p);
if (codepages & (1 << 17)) {
m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET);
@@ -1510,24 +1521,21 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
m_pMapper->AddInstalledFont(facename, FXFONT_ANSI_CHARSET);
pInfo->m_Charsets |= CHARSET_FLAG_ANSI;
pInfo->m_Styles = 0;
- if (style.Find("Bold") > -1) {
+ if (style.Find("Bold") > -1)
pInfo->m_Styles |= FXFONT_BOLD;
- }
- if (style.Find("Italic") > -1 || style.Find("Oblique") > -1) {
+ if (style.Find("Italic") > -1 || style.Find("Oblique") > -1)
pInfo->m_Styles |= FXFONT_ITALIC;
- }
- if (facename.Find("Serif") > -1) {
+ if (facename.Find("Serif") > -1)
pInfo->m_Styles |= FXFONT_SERIF;
- }
+
m_FontList[facename] = pInfo;
}
void* CFX_FolderFontInfo::GetSubstFont(const CFX_ByteString& face) {
for (size_t iBaseFont = 0; iBaseFont < FX_ArraySize(Base14Substs);
iBaseFont++) {
- if (face == Base14Substs[iBaseFont].m_pName) {
+ if (face == Base14Substs[iBaseFont].m_pName)
return GetFont(Base14Substs[iBaseFont].m_pSubstName);
- }
}
return nullptr;
}
@@ -1604,8 +1612,7 @@ uint32_t CFX_FolderFontInfo::GetFontData(void* hFont,
} else {
uint32_t nTables = pFont->m_FontTables.GetLength() / 16;
for (uint32_t i = 0; i < nTables; i++) {
- const uint8_t* p =
- static_cast<const uint8_t*>(pFont->m_FontTables) + i * 16;
+ const uint8_t* p = pFont->m_FontTables.raw_str() + i * 16;
if (GET_TT_LONG(p) == table) {
offset = GET_TT_LONG(p + 8);
datasize = GET_TT_LONG(p + 12);
@@ -1616,7 +1623,7 @@ uint32_t CFX_FolderFontInfo::GetFontData(void* hFont,
if (!datasize || size < datasize)
return datasize;
- FXSYS_FILE* pFile = FXSYS_fopen(pFont->m_FilePath, "rb");
+ FXSYS_FILE* pFile = FXSYS_fopen(pFont->m_FilePath.c_str(), "rb");
if (!pFile)
return 0;
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_linux.cpp b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_linux.cpp
index af731f78da1..0bd67b01bef 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_linux.cpp
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_linux.cpp
@@ -6,7 +6,7 @@
#include "core/fxge/agg/fx_agg_driver.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_
class CFX_LinuxFontInfo : public CFX_FolderFontInfo {
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_path.cpp b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_path.cpp
index 90793c4746f..baa391fef2c 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_path.cpp
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_path.cpp
@@ -5,7 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "third_party/base/numerics/safe_math.h"
CFX_ClipRgn::CFX_ClipRgn(int width, int height) {
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_ps.cpp b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_ps.cpp
index ec8f18e774d..98253336a15 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_ps.cpp
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_ps.cpp
@@ -4,10 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/include/fxcodec/fx_codec.h"
struct PSGlyph {
CFX_Font* m_pFont;
@@ -506,7 +506,7 @@ void CFX_PSRenderer::SetColor(uint32_t color,
}
FX_BOOL bCMYK = FALSE;
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
color = FXGETFLAG_COLORTYPE(alpha_flag) ? FXCMYK_TODIB(color)
: FXARGB_TODIB(color);
@@ -680,7 +680,7 @@ FX_BOOL CFX_PSRenderer::DrawText(int nChars,
buf << pCharPos[i].m_OriginX << " " << pCharPos[i].m_OriginY << " m";
CFX_ByteString hex;
hex.Format("<%02X>", ps_glyphindex);
- buf << hex.AsByteStringC() << "Tj\n";
+ buf << hex.AsStringC() << "Tj\n";
}
buf << "Q\n";
m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize());
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_text.cpp b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_text.cpp
index ce14631f5e2..46edaf7cbe3 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_ge_text.cpp
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_ge_text.cpp
@@ -6,10 +6,10 @@
#include <limits>
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxge/ge/fx_text_int.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge.h"
#ifdef _SKIA_SUPPORT_
#include "third_party/skia/include/core/SkStream.h"
@@ -158,7 +158,7 @@ void _Color2Argb(FX_ARGB& argb,
}
uint8_t bgra[4];
if (pIccTransform) {
- ICodec_IccModule* pIccModule =
+ CCodec_IccModule* pIccModule =
CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
color = FXGETFLAG_COLORTYPE(alpha_flag) ? FXCMYK_TODIB(color)
: FXARGB_TODIB(color);
@@ -194,7 +194,8 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
bool should_call_draw_device_text = true;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
if ((text_flags & FXFONT_CIDFONT) ||
- (pFont->GetPsName().Find(CFX_WideString::FromLocal("+ZJHL")) != -1) ||
+ (pFont->GetPsName().Find(
+ CFX_WideString::FromLocal("+ZJHL").AsStringC()) != -1) ||
(pFont->GetPsName() == CFX_WideString::FromLocal("CNAAJI+cmex10"))) {
should_call_draw_device_text = false;
}
@@ -256,7 +257,14 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
} else {
bClearType = text_flags & FXTEXT_CLEARTYPE;
}
- if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) {
+ if (!CFX_GEModule::Get()->GetFontMgr()->FTLibrarySupportsHinting()) {
+ // Some Freetype implementations (like the one packaged with Fedora) do
+ // not support hinting due to patents 6219025, 6239783, 6307566,
+ // 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest
+ // one expires 10/7/19. This makes LCD antialiasing very ugly, so we
+ // instead fall back on NORMAL antialiasing.
+ anti_alias = FXFT_RENDER_MODE_NORMAL;
+ } else if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) {
anti_alias = FXFT_RENDER_MODE_LCD;
bNormal = TRUE;
} else if (m_bpp < 16) {
@@ -412,7 +420,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars,
}
continue;
}
- FX_BOOL bBGRStripe = text_flags & FXTEXT_BGR_STRIPE;
+ bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE);
ncols /= 3;
int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3;
uint8_t* src_buf = pGlyph->GetBuffer();
@@ -1287,7 +1295,7 @@ void CFX_FaceCache::InitPlatform() {}
CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(
CFX_Font* pFont,
const CFX_Matrix* pMatrix,
- CFX_ByteStringC& FaceGlyphsKey,
+ const CFX_ByteString& FaceGlyphsKey,
uint32_t glyph_index,
FX_BOOL bFontStyle,
int dest_width,
@@ -1358,7 +1366,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont,
dest_width, anti_alias, 3);
}
#endif
- CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
+ CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index,
bFontStyle, dest_width, anti_alias);
@@ -1400,7 +1408,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont,
keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000),
(int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000),
dest_width, anti_alias);
- CFX_ByteStringC FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen);
+ CFX_ByteString FaceGlyphsKey2(keygen.m_Key, keygen.m_KeyLen);
text_flags |= FXTEXT_NO_NATIVETEXT;
return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey2, glyph_index,
bFontStyle, dest_width, anti_alias);
@@ -1579,7 +1587,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont,
if (pFont->IsVertical())
ft_matrix.yx += ft_matrix.yy * skew / 100;
else
- ft_matrix.xy += -ft_matrix.xx * skew / 100;
+ ft_matrix.xy -= ft_matrix.xx * skew / 100;
}
if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) {
pFont->AdjustMMParams(glyph_index, dest_width,
@@ -1849,7 +1857,7 @@ CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) {
if (m_bVertical)
ft_matrix.yx += ft_matrix.yy * skew / 100;
else
- ft_matrix.xy += -ft_matrix.xx * skew / 100;
+ ft_matrix.xy -= ft_matrix.xx * skew / 100;
}
if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) {
AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight);
diff --git a/chromium/third_party/pdfium/core/fxge/ge/fx_text_int.h b/chromium/third_party/pdfium/core/fxge/ge/fx_text_int.h
index 04587c37cb0..c3e9cd7679f 100644
--- a/chromium/third_party/pdfium/core/fxge/ge/fx_text_int.h
+++ b/chromium/third_party/pdfium/core/fxge/ge/fx_text_int.h
@@ -9,8 +9,8 @@
#include <map>
-#include "core/include/fxge/fx_font.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_font.h"
+#include "core/fxge/include/fx_freetype.h"
struct _CFX_UniqueKeyGen {
void Generate(int count, ...);
diff --git a/chromium/third_party/pdfium/core/include/fxge/fx_dib.h b/chromium/third_party/pdfium/core/fxge/include/fx_dib.h
index 09081786ef7..a09f88453f1 100644
--- a/chromium/third_party/pdfium/core/include/fxge/fx_dib.h
+++ b/chromium/third_party/pdfium/core/fxge/include/fx_dib.h
@@ -4,8 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FXGE_FX_DIB_H_
-#define CORE_INCLUDE_FXGE_FX_DIB_H_
+#ifndef CORE_FXGE_INCLUDE_FX_DIB_H_
+#define CORE_FXGE_INCLUDE_FX_DIB_H_
+
+#include <memory>
#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_coordinates.h"
@@ -181,7 +183,6 @@ class CFX_DIBSource {
FX_BOOL bFlipX,
int clip_left,
int clip_width) const = 0;
- virtual void SetDownSampleSize(int width, int height) {}
int GetBPP() const { return m_bpp; }
@@ -557,79 +558,83 @@ class CFX_BitmapStorer : public IFX_ScanlineComposer {
void ComposeScanline(int line,
const uint8_t* scanline,
const uint8_t* scan_extra_alpha) override;
-
FX_BOOL SetInfo(int width,
int height,
FXDIB_Format src_format,
uint32_t* pSrcPalette) override;
- CFX_DIBitmap* GetBitmap() { return m_pBitmap; }
-
- CFX_DIBitmap* Detach();
-
- void Replace(CFX_DIBitmap* pBitmap);
+ CFX_DIBitmap* GetBitmap() { return m_pBitmap.get(); }
+ std::unique_ptr<CFX_DIBitmap> Detach();
+ void Replace(std::unique_ptr<CFX_DIBitmap> pBitmap);
private:
- CFX_DIBitmap* m_pBitmap;
+ std::unique_ptr<CFX_DIBitmap> m_pBitmap;
};
class CFX_ImageStretcher {
public:
- CFX_ImageStretcher();
+ CFX_ImageStretcher(IFX_ScanlineComposer* pDest,
+ const CFX_DIBSource* pSource,
+ int dest_width,
+ int dest_height,
+ const FX_RECT& bitmap_rect,
+ uint32_t flags);
~CFX_ImageStretcher();
- FX_BOOL Start(IFX_ScanlineComposer* pDest,
- const CFX_DIBSource* pBitmap,
- int dest_width,
- int dest_height,
- const FX_RECT& bitmap_rect,
- uint32_t flags);
-
+ FX_BOOL Start();
FX_BOOL Continue(IFX_Pause* pPause);
+
+ const CFX_DIBSource* source() { return m_pSource; }
+
+ private:
FX_BOOL StartQuickStretch();
FX_BOOL StartStretch();
FX_BOOL ContinueQuickStretch(IFX_Pause* pPause);
FX_BOOL ContinueStretch(IFX_Pause* pPause);
- IFX_ScanlineComposer* m_pDest;
- const CFX_DIBSource* m_pSource;
- CStretchEngine* m_pStretchEngine;
- uint32_t m_Flags;
+ IFX_ScanlineComposer* const m_pDest;
+ const CFX_DIBSource* const m_pSource;
+ std::unique_ptr<CStretchEngine> m_pStretchEngine;
+ std::unique_ptr<uint8_t, FxFreeDeleter> m_pScanline;
+ std::unique_ptr<uint8_t, FxFreeDeleter> m_pMaskScanline;
+ const uint32_t m_Flags;
FX_BOOL m_bFlipX;
FX_BOOL m_bFlipY;
int m_DestWidth;
int m_DestHeight;
FX_RECT m_ClipRect;
+ const FXDIB_Format m_DestFormat;
+ const int m_DestBPP;
int m_LineIndex;
- int m_DestBPP;
- uint8_t* m_pScanline;
- uint8_t* m_pMaskScanline;
- FXDIB_Format m_DestFormat;
};
+
class CFX_ImageTransformer {
public:
- CFX_ImageTransformer();
+ CFX_ImageTransformer(const CFX_DIBSource* pSrc,
+ const CFX_Matrix* pMatrix,
+ int flags,
+ const FX_RECT* pClip);
~CFX_ImageTransformer();
- FX_BOOL Start(const CFX_DIBSource* pSrc,
- const CFX_Matrix* pMatrix,
- int flags,
- const FX_RECT* pClip);
-
+ FX_BOOL Start();
FX_BOOL Continue(IFX_Pause* pPause);
- CFX_Matrix* m_pMatrix;
+ const FX_RECT& result() const { return m_result; }
+ std::unique_ptr<CFX_DIBitmap> DetachBitmap();
+
+ private:
+ const CFX_DIBSource* const m_pSrc;
+ const CFX_Matrix* const m_pMatrix;
+ const FX_RECT* const m_pClip;
FX_RECT m_StretchClip;
- int m_ResultLeft;
- int m_ResultTop;
- int m_ResultWidth;
- int m_ResultHeight;
+ FX_RECT m_result;
CFX_Matrix m_dest2stretch;
- CFX_ImageStretcher m_Stretcher;
+ std::unique_ptr<CFX_ImageStretcher> m_Stretcher;
CFX_BitmapStorer m_Storer;
- uint32_t m_Flags;
+ const uint32_t m_Flags;
int m_Status;
};
+
class CFX_ImageRenderer {
public:
CFX_ImageRenderer();
@@ -656,7 +661,7 @@ class CFX_ImageRenderer {
uint32_t m_MaskColor;
CFX_Matrix m_Matrix;
CFX_ImageTransformer* m_pTransformer;
- CFX_ImageStretcher m_Stretcher;
+ std::unique_ptr<CFX_ImageStretcher> m_Stretcher;
CFX_BitmapComposer m_Composer;
int m_Status;
FX_RECT m_ClipBox;
@@ -667,4 +672,4 @@ class CFX_ImageRenderer {
int m_BlendType;
};
-#endif // CORE_INCLUDE_FXGE_FX_DIB_H_
+#endif // CORE_FXGE_INCLUDE_FX_DIB_H_
diff --git a/chromium/third_party/pdfium/core/include/fxge/fx_font.h b/chromium/third_party/pdfium/core/fxge/include/fx_font.h
index 4e2b97e6774..6bc9b2e4c26 100644
--- a/chromium/third_party/pdfium/core/include/fxge/fx_font.h
+++ b/chromium/third_party/pdfium/core/fxge/include/fx_font.h
@@ -4,16 +4,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FXGE_FX_FONT_H_
-#define CORE_INCLUDE_FXGE_FX_FONT_H_
+#ifndef CORE_FXGE_INCLUDE_FX_FONT_H_
+#define CORE_FXGE_INCLUDE_FX_FONT_H_
#include <map>
#include <memory>
#include <vector>
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
-#include "core/include/fxge/fx_freetype.h"
+#include "core/fxge/include/fx_dib.h"
+#include "core/fxge/include/fx_freetype.h"
typedef struct FT_FaceRec_* FXFT_Face;
typedef void* FXFT_Library;
@@ -280,30 +280,13 @@ class CFX_FontMgr {
bool GetBuiltinFont(size_t index, const uint8_t** pFontData, uint32_t* size);
CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); }
FXFT_Library GetFTLibrary() const { return m_FTLibrary; }
+ bool FTLibrarySupportsHinting() const { return m_FTLibrarySupportsHinting; }
private:
std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper;
std::map<CFX_ByteString, CTTFontDesc*> m_FaceMap;
FXFT_Library m_FTLibrary;
-};
-
-class IFX_FontEnumerator {
- public:
- virtual void HitFont() = 0;
-
- virtual void Finish() = 0;
-
- protected:
- virtual ~IFX_FontEnumerator() {}
-};
-
-class IFX_AdditionalFontEnum {
- public:
- virtual int CountFiles() = 0;
- virtual IFX_FileStream* GetFontFile(int index) = 0;
-
- protected:
- virtual ~IFX_AdditionalFontEnum() {}
+ bool m_FTLibrarySupportsHinting;
};
class CFX_FontMapper {
@@ -315,11 +298,7 @@ class CFX_FontMapper {
IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; }
void AddInstalledFont(const CFX_ByteString& name, int charset);
void LoadInstalledFonts();
- std::vector<CFX_ByteString> m_InstalledTTFonts;
- void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) {
- m_pFontEnumerator = pFontEnumerator;
- }
- IFX_FontEnumerator* GetFontEnumerator() const { return m_pFontEnumerator; }
+
FXFT_Face FindSubstFont(const CFX_ByteString& face_name,
FX_BOOL bTrueType,
uint32_t flags,
@@ -335,7 +314,11 @@ class CFX_FontMapper {
#endif // PDF_ENABLE_XFA
FX_BOOL IsBuiltinFace(const FXFT_Face face) const;
int GetFaceSize() const;
- CFX_ByteString GetFaceName(int index) const { return m_FaceArray[index]; }
+ CFX_ByteString GetFaceName(int index) const {
+ return m_FaceArray[index].name;
+ }
+
+ std::vector<CFX_ByteString> m_InstalledTTFonts;
private:
static const size_t MM_FACE_COUNT = 2;
@@ -349,14 +332,17 @@ class CFX_FontMapper {
int weight,
int picthfamily);
+ struct FaceData {
+ CFX_ByteString name;
+ uint32_t charset;
+ };
+
FX_BOOL m_bListLoaded;
FXFT_Face m_MMFaces[MM_FACE_COUNT];
CFX_ByteString m_LastFamily;
- CFX_ArrayTemplate<uint32_t> m_CharsetArray;
- std::vector<CFX_ByteString> m_FaceArray;
+ std::vector<FaceData> m_FaceArray;
IFX_SystemFontInfo* m_pFontInfo;
FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT];
- IFX_FontEnumerator* m_pFontEnumerator;
CFX_FontMgr* const m_pFontMgr;
};
@@ -517,7 +503,7 @@ class CFX_FaceCache {
int anti_alias);
CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont,
const CFX_Matrix* pMatrix,
- CFX_ByteStringC& FaceGlyphsKey,
+ const CFX_ByteString& FaceGlyphsKey,
uint32_t glyph_index,
FX_BOOL bFontStyle,
int dest_width,
@@ -548,19 +534,10 @@ FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos,
FX_FLOAT retinaScaleX = 1.0f,
FX_FLOAT retinaScaleY = 1.0f);
-class IFX_GSUBTable {
- public:
- static IFX_GSUBTable* Create(CFX_Font* pFont);
- virtual FX_BOOL GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum) = 0;
-
- protected:
- virtual ~IFX_GSUBTable() {}
-};
-
CFX_ByteString GetNameFromTT(const uint8_t* name_table,
uint32_t name_table_size,
uint32_t name);
int PDF_GetStandardFontName(CFX_ByteString* name);
-#endif // CORE_INCLUDE_FXGE_FX_FONT_H_
+#endif // CORE_FXGE_INCLUDE_FX_FONT_H_
diff --git a/chromium/third_party/pdfium/core/include/fxge/fx_freetype.h b/chromium/third_party/pdfium/core/fxge/include/fx_freetype.h
index 6920d86aca5..533974dc2e6 100644
--- a/chromium/third_party/pdfium/core/include/fxge/fx_freetype.h
+++ b/chromium/third_party/pdfium/core/fxge/include/fx_freetype.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FXGE_FX_FREETYPE_H_
-#define CORE_INCLUDE_FXGE_FX_FREETYPE_H_
+#ifndef CORE_FXGE_INCLUDE_FX_FREETYPE_H_
+#define CORE_FXGE_INCLUDE_FX_FREETYPE_H_
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -177,4 +177,4 @@ void FXFT_adobe_name_from_unicode(char* name, wchar_t unicode);
};
#endif
-#endif // CORE_INCLUDE_FXGE_FX_FREETYPE_H_
+#endif // CORE_FXGE_INCLUDE_FX_FREETYPE_H_
diff --git a/chromium/third_party/pdfium/core/include/fxge/fx_ge.h b/chromium/third_party/pdfium/core/fxge/include/fx_ge.h
index 3eb9303a804..3c25e8ddd4d 100644
--- a/chromium/third_party/pdfium/core/include/fxge/fx_ge.h
+++ b/chromium/third_party/pdfium/core/fxge/include/fx_ge.h
@@ -4,11 +4,11 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FXGE_FX_GE_H_
-#define CORE_INCLUDE_FXGE_FX_GE_H_
+#ifndef CORE_FXGE_INCLUDE_FX_GE_H_
+#define CORE_FXGE_INCLUDE_FX_GE_H_
-#include "core/include/fxge/fx_dib.h"
-#include "core/include/fxge/fx_font.h"
+#include "core/fxge/include/fx_dib.h"
+#include "core/fxge/include/fx_font.h"
class CFX_Font;
class CFX_FontMgr;
@@ -170,13 +170,10 @@ class CFX_PathData {
class CFX_GraphStateData {
public:
CFX_GraphStateData();
-
CFX_GraphStateData(const CFX_GraphStateData& src);
-
~CFX_GraphStateData();
void Copy(const CFX_GraphStateData& src);
-
void SetDashCount(int count);
typedef enum { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 } LineCap;
@@ -437,33 +434,13 @@ class CFX_FxgeDevice : public CFX_RenderDevice {
int dither_bits = 0,
CFX_DIBitmap* pOriDevice = NULL);
- protected:
- bool m_bOwnedBitmap;
-};
-
-class CFX_SkiaDevice : public CFX_RenderDevice {
- public:
- CFX_SkiaDevice();
- ~CFX_SkiaDevice() override;
-
- FX_BOOL Attach(CFX_DIBitmap* pBitmap,
- int dither_bits = 0,
- FX_BOOL bRgbByteOrder = FALSE,
- CFX_DIBitmap* pOriDevice = NULL,
- FX_BOOL bGroupKnockout = FALSE);
-
- FX_BOOL AttachRecorder(SkPictureRecorder* recorder);
-
- FX_BOOL Create(int width,
- int height,
- FXDIB_Format format,
- int dither_bits = 0,
- CFX_DIBitmap* pOriDevice = NULL);
-
+#ifdef _SKIA_SUPPORT_
+ bool AttachRecorder(SkPictureRecorder* recorder);
SkPictureRecorder* CreateRecorder(int size_x, int size_y);
+#endif
protected:
- FX_BOOL m_bOwnedBitmap;
+ bool m_bOwnedBitmap;
};
class IFX_RenderDeviceDriver {
@@ -603,8 +580,9 @@ class IFX_RenderDeviceDriver {
virtual int GetDriverType() const { return 0; }
virtual void ClearDriver() {}
- virtual FX_BOOL DrawShading(CPDF_ShadingPattern* pPattern,
- CFX_Matrix* pMatrix,
+ virtual FX_BOOL DrawShading(const CPDF_ShadingPattern* pPattern,
+ const CFX_Matrix* pMatrix,
+ const FX_RECT& clip_rect,
int alpha,
FX_BOOL bAlphaMode) {
return false;
@@ -730,4 +708,4 @@ class CFX_PSRenderer {
void WritePSBinary(const uint8_t* data, int len);
};
-#endif // CORE_INCLUDE_FXGE_FX_GE_H_
+#endif // CORE_FXGE_INCLUDE_FX_GE_H_
diff --git a/chromium/third_party/pdfium/core/include/fxge/fx_ge_apple.h b/chromium/third_party/pdfium/core/fxge/include/fx_ge_apple.h
index 16298581b3a..57acef653ca 100644
--- a/chromium/third_party/pdfium/core/include/fxge/fx_ge_apple.h
+++ b/chromium/third_party/pdfium/core/fxge/include/fx_ge_apple.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FXGE_FX_GE_APPLE_H_
-#define CORE_INCLUDE_FXGE_FX_GE_APPLE_H_
+#ifndef CORE_FXGE_INCLUDE_FX_GE_APPLE_H_
+#define CORE_FXGE_INCLUDE_FX_GE_APPLE_H_
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
class CFX_QuartzDevice : public CFX_RenderDevice {
@@ -24,4 +24,4 @@ class CFX_QuartzDevice : public CFX_RenderDevice {
};
#endif
-#endif // CORE_INCLUDE_FXGE_FX_GE_APPLE_H_
+#endif // CORE_FXGE_INCLUDE_FX_GE_APPLE_H_
diff --git a/chromium/third_party/pdfium/core/include/fxge/fx_ge_win32.h b/chromium/third_party/pdfium/core/fxge/include/fx_ge_win32.h
index f1864590c54..b4337c117cd 100644
--- a/chromium/third_party/pdfium/core/include/fxge/fx_ge_win32.h
+++ b/chromium/third_party/pdfium/core/fxge/include/fx_ge_win32.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_INCLUDE_FXGE_FX_GE_WIN32_H_
-#define CORE_INCLUDE_FXGE_FX_GE_WIN32_H_
+#ifndef CORE_FXGE_INCLUDE_FX_GE_WIN32_H_
+#define CORE_FXGE_INCLUDE_FX_GE_WIN32_H_
#ifdef _WIN32
#ifndef _WINDOWS_
@@ -95,4 +95,4 @@ class CFX_WinBitmapDevice : public CFX_RenderDevice {
};
#endif
-#endif // CORE_INCLUDE_FXGE_FX_GE_WIN32_H_
+#endif // CORE_FXGE_INCLUDE_FX_GE_WIN32_H_
diff --git a/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.cpp b/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.cpp
index 86d71d485b1..7f47d855c91 100644
--- a/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.cpp
+++ b/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.cpp
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if defined(_SKIA_SUPPORT_)
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
-#include "core/fxge/agg/fx_agg_driver.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fxge/skia/fx_skia_device.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -178,6 +178,90 @@ bool AddColors(const CPDF_Function* pFunc, SkTDArray<SkColor>* skColors) {
return true;
}
+uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits) {
+ ASSERT(0 < nbits && nbits <= 32);
+ const uint8_t* dataPtr = &pData[bitpos / 8];
+ int bitShift;
+ int bitMask;
+ int dstShift;
+ int bitCount = bitpos & 0x07;
+ if (nbits < 8 && nbits + bitCount <= 8) {
+ bitShift = 8 - nbits - bitCount;
+ bitMask = (1 << nbits) - 1;
+ dstShift = 0;
+ } else {
+ bitShift = 0;
+ int bitOffset = 8 - bitCount;
+ bitMask = (1 << SkTMin(bitOffset, nbits)) - 1;
+ dstShift = nbits - bitOffset;
+ }
+ uint32_t result = (uint32_t)(*dataPtr++ >> bitShift & bitMask) << dstShift;
+ while (dstShift >= 8) {
+ dstShift -= 8;
+ result |= *dataPtr++ << dstShift;
+ }
+ if (dstShift > 0) {
+ bitShift = 8 - dstShift;
+ bitMask = (1 << dstShift) - 1;
+ result |= *dataPtr++ >> bitShift & bitMask;
+ }
+ return result;
+}
+
+uint8_t FloatToByte(FX_FLOAT f) {
+ ASSERT(0 <= f && f <= 1);
+ return (uint8_t)(f * 255.99f);
+}
+
+bool AddSamples(const CPDF_Function* pFunc,
+ SkTDArray<SkColor>* skColors,
+ SkTDArray<SkScalar>* skPos) {
+ if (pFunc->CountInputs() != 1)
+ return false;
+ if (pFunc->CountOutputs() != 3) // expect rgb
+ return false;
+ ASSERT(CPDF_Function::Type::kType0Sampled == pFunc->GetType());
+ const CPDF_SampledFunc* sampledFunc =
+ static_cast<const CPDF_SampledFunc*>(pFunc);
+ if (!sampledFunc->m_pEncodeInfo)
+ return false;
+ const CPDF_SampledFunc::SampleEncodeInfo& encodeInfo =
+ sampledFunc->m_pEncodeInfo[0];
+ if (encodeInfo.encode_min != 0)
+ return false;
+ if (encodeInfo.encode_max != encodeInfo.sizes - 1)
+ return false;
+ uint32_t sampleSize = sampledFunc->m_nBitsPerSample;
+ uint32_t sampleCount = encodeInfo.sizes;
+ if (sampleCount != 1 << sampleSize)
+ return false;
+ if (sampledFunc->m_pSampleStream->GetSize() <
+ sampleCount * 3 * sampleSize / 8) {
+ return false;
+ }
+ FX_FLOAT colorsMin[3];
+ FX_FLOAT colorsMax[3];
+ for (int i = 0; i < 3; ++i) {
+ colorsMin[i] = sampledFunc->GetRange(i * 2);
+ colorsMax[i] = sampledFunc->GetRange(i * 2 + 1);
+ }
+ const uint8_t* pSampleData = sampledFunc->m_pSampleStream->GetData();
+ for (uint32_t i = 0; i < sampleCount; ++i) {
+ FX_FLOAT floatColors[3];
+ for (uint32_t j = 0; j < 3; ++j) {
+ int sample = GetBits32(pSampleData, (i * 3 + j) * sampleSize, sampleSize);
+ FX_FLOAT interp = (FX_FLOAT)sample / (sampleCount - 1);
+ floatColors[j] = colorsMin[j] + (colorsMax[j] - colorsMin[j]) * interp;
+ }
+ SkColor color =
+ SkPackARGB32(0xFF, FloatToByte(floatColors[0]),
+ FloatToByte(floatColors[1]), FloatToByte(floatColors[2]));
+ skColors->push(color);
+ skPos->push((FX_FLOAT)i / (sampleCount - 1));
+ }
+ return true;
+}
+
bool AddStitching(const CPDF_Function* pFunc,
SkTDArray<SkColor>* skColors,
SkTDArray<SkScalar>* skPos) {
@@ -203,6 +287,201 @@ bool AddStitching(const CPDF_Function* pFunc,
return true;
}
+void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap,
+ int dest_left,
+ int dest_top,
+ int width,
+ int height,
+ const CFX_DIBSource* pSrcBitmap,
+ int src_left,
+ int src_top) {
+ if (!pBitmap)
+ return;
+ pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
+ pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(),
+ src_left, src_top, NULL);
+ if (width == 0 || height == 0)
+ return;
+ int Bpp = pBitmap->GetBPP() / 8;
+ FXDIB_Format dest_format = pBitmap->GetFormat();
+ FXDIB_Format src_format = pSrcBitmap->GetFormat();
+ int pitch = pBitmap->GetPitch();
+ uint8_t* buffer = pBitmap->GetBuffer();
+ if (dest_format == src_format) {
+ for (int row = 0; row < height; row++) {
+ uint8_t* dest_scan = buffer + (dest_top + row) * pitch + dest_left * Bpp;
+ uint8_t* src_scan =
+ (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
+ if (Bpp == 4) {
+ for (int col = 0; col < width; col++) {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_scan[3], src_scan[0],
+ src_scan[1], src_scan[2]));
+ dest_scan += 4;
+ src_scan += 4;
+ }
+ } else {
+ for (int col = 0; col < width; col++) {
+ *dest_scan++ = src_scan[2];
+ *dest_scan++ = src_scan[1];
+ *dest_scan++ = src_scan[0];
+ src_scan += 3;
+ }
+ }
+ }
+ return;
+ }
+ uint8_t* dest_buf = buffer + dest_top * pitch + dest_left * Bpp;
+ if (dest_format == FXDIB_Rgb) {
+ if (src_format == FXDIB_Rgb32) {
+ for (int row = 0; row < height; row++) {
+ uint8_t* dest_scan = dest_buf + row * pitch;
+ uint8_t* src_scan =
+ (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
+ for (int col = 0; col < width; col++) {
+ *dest_scan++ = src_scan[2];
+ *dest_scan++ = src_scan[1];
+ *dest_scan++ = src_scan[0];
+ src_scan += 4;
+ }
+ }
+ } else {
+ ASSERT(FALSE);
+ }
+ } else if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) {
+ if (src_format == FXDIB_Rgb) {
+ for (int row = 0; row < height; row++) {
+ uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch);
+ uint8_t* src_scan =
+ (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
+ if (src_format == FXDIB_Argb) {
+ for (int col = 0; col < width; col++) {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, FX_GAMMA(src_scan[0]),
+ FX_GAMMA(src_scan[1]),
+ FX_GAMMA(src_scan[2])));
+ dest_scan += 4;
+ src_scan += 3;
+ }
+ } else {
+ for (int col = 0; col < width; col++) {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
+ src_scan[2]));
+ dest_scan += 4;
+ src_scan += 3;
+ }
+ }
+ }
+ } else if (src_format == FXDIB_Rgb32) {
+ ASSERT(dest_format == FXDIB_Argb);
+ for (int row = 0; row < height; row++) {
+ uint8_t* dest_scan = dest_buf + row * pitch;
+ uint8_t* src_scan =
+ (uint8_t*)(pSrcBitmap->GetScanline(src_top + row) + src_left * 4);
+ for (int col = 0; col < width; col++) {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
+ src_scan[2]));
+ src_scan += 4;
+ dest_scan += 4;
+ }
+ }
+ }
+ } else {
+ ASSERT(FALSE);
+ }
+}
+
+// see https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
+SkScalar LineSide(const SkPoint line[2], const SkPoint& pt) {
+ return (line[1].fY - line[0].fY) * pt.fX - (line[1].fX - line[0].fX) * pt.fY +
+ line[1].fX * line[0].fY - line[1].fY * line[0].fX;
+}
+
+SkPoint IntersectSides(const SkPoint& parallelPt,
+ const SkVector& paraRay,
+ const SkPoint& perpendicularPt) {
+ SkVector perpRay = {paraRay.fY, -paraRay.fX};
+ SkScalar denom = perpRay.fY * paraRay.fX - paraRay.fY * perpRay.fX;
+ if (!denom) {
+ SkPoint zeroPt = {0, 0};
+ return zeroPt;
+ }
+ SkVector ab0 = parallelPt - perpendicularPt;
+ SkScalar numerA = ab0.fY * perpRay.fX - perpRay.fY * ab0.fX;
+ numerA /= denom;
+ SkPoint result = {parallelPt.fX + paraRay.fX * numerA,
+ parallelPt.fY + paraRay.fY * numerA};
+ return result;
+}
+
+void ClipAngledGradient(const SkPoint pts[2],
+ SkPoint rectPts[4],
+ bool clipStart,
+ bool clipEnd,
+ SkPath* clip) {
+ // find the corners furthest from the gradient perpendiculars
+ SkScalar minPerpDist = SK_ScalarMax;
+ SkScalar maxPerpDist = SK_ScalarMin;
+ int minPerpPtIndex = -1;
+ int maxPerpPtIndex = -1;
+ SkVector slope = pts[1] - pts[0];
+ SkPoint startPerp[2] = {pts[0], {pts[0].fX + slope.fY, pts[0].fY - slope.fX}};
+ SkPoint endPerp[2] = {pts[1], {pts[1].fX + slope.fY, pts[1].fY - slope.fX}};
+ for (int i = 0; i < 4; ++i) {
+ SkScalar sDist = LineSide(startPerp, rectPts[i]);
+ SkScalar eDist = LineSide(endPerp, rectPts[i]);
+ if (sDist * eDist <= 0) // if the signs are different,
+ continue; // the point is inside the gradient
+ if (sDist < 0) {
+ SkScalar smaller = SkTMin(sDist, eDist);
+ if (minPerpDist > smaller) {
+ minPerpDist = smaller;
+ minPerpPtIndex = i;
+ }
+ } else {
+ SkScalar larger = SkTMax(sDist, eDist);
+ if (maxPerpDist < larger) {
+ maxPerpDist = larger;
+ maxPerpPtIndex = i;
+ }
+ }
+ }
+ if (minPerpPtIndex < 0 && maxPerpPtIndex < 0) // nothing's outside
+ return;
+ // determine if negative distances are before start or after end
+ SkPoint beforeStart = {pts[0].fX * 2 - pts[1].fX, pts[0].fY * 2 - pts[1].fY};
+ bool beforeNeg = LineSide(startPerp, beforeStart) < 0;
+ const SkPoint& startEdgePt =
+ clipStart ? pts[0] : beforeNeg ? rectPts[minPerpPtIndex]
+ : rectPts[maxPerpPtIndex];
+ const SkPoint& endEdgePt = clipEnd ? pts[1] : beforeNeg
+ ? rectPts[maxPerpPtIndex]
+ : rectPts[minPerpPtIndex];
+ // find the corners that bound the gradient
+ SkScalar minDist = SK_ScalarMax;
+ SkScalar maxDist = SK_ScalarMin;
+ int minBounds = -1;
+ int maxBounds = -1;
+ for (int i = 0; i < 4; ++i) {
+ SkScalar dist = LineSide(pts, rectPts[i]);
+ if (minDist > dist) {
+ minDist = dist;
+ minBounds = i;
+ }
+ if (maxDist < dist) {
+ maxDist = dist;
+ maxBounds = i;
+ }
+ }
+ ASSERT(minBounds >= 0);
+ ASSERT(maxBounds != minBounds && maxBounds >= 0);
+ // construct a clip parallel to the gradient that goes through
+ // rectPts[minBounds] and rectPts[maxBounds] and perpendicular to the
+ // gradient that goes through startEdgePt, endEdgePt.
+ clip->moveTo(IntersectSides(rectPts[minBounds], slope, startEdgePt));
+ clip->lineTo(IntersectSides(rectPts[minBounds], slope, endEdgePt));
+ clip->lineTo(IntersectSides(rectPts[maxBounds], slope, endEdgePt));
+ clip->lineTo(IntersectSides(rectPts[maxBounds], slope, startEdgePt));
+}
+
} // namespace
// convert a stroking path to scanlines
@@ -275,40 +554,48 @@ CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap,
FX_BOOL bRgbByteOrder,
CFX_DIBitmap* pOriDevice,
FX_BOOL bGroupKnockout)
- : m_pRecorder(nullptr) {
- m_pAggDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrder,
- pOriDevice, bGroupKnockout);
+ : m_pBitmap(pBitmap),
+ m_pOriDevice(pOriDevice),
+ m_pRecorder(nullptr),
+ m_ditherBits(dither_bits),
+ m_bRgbByteOrder(bRgbByteOrder),
+ m_bGroupKnockout(bGroupKnockout) {
SkBitmap skBitmap;
- const CFX_DIBitmap* bitmap = m_pAggDriver->GetBitmap();
SkImageInfo imageInfo =
- SkImageInfo::Make(bitmap->GetWidth(), bitmap->GetHeight(),
+ SkImageInfo::Make(pBitmap->GetWidth(), pBitmap->GetHeight(),
kN32_SkColorType, kOpaque_SkAlphaType);
- skBitmap.installPixels(imageInfo, bitmap->GetBuffer(), bitmap->GetPitch(),
+ skBitmap.installPixels(imageInfo, pBitmap->GetBuffer(), pBitmap->GetPitch(),
nullptr, /* to do : set color table */
nullptr, nullptr);
m_pCanvas = new SkCanvas(skBitmap);
- m_ditherBits = dither_bits;
+ if (m_bGroupKnockout)
+ SkDebugf(""); // FIXME(caryclark) suppress 'm_bGroupKnockout is unused'
}
CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(int size_x, int size_y)
- : m_pRecorder(new SkPictureRecorder) {
- m_pAggDriver = nullptr;
+ : m_pBitmap(nullptr),
+ m_pOriDevice(nullptr),
+ m_pRecorder(new SkPictureRecorder),
+ m_ditherBits(0),
+ m_bRgbByteOrder(FALSE),
+ m_bGroupKnockout(FALSE) {
m_pRecorder->beginRecording(SkIntToScalar(size_x), SkIntToScalar(size_y));
m_pCanvas = m_pRecorder->getRecordingCanvas();
- m_ditherBits = 0;
}
CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(SkPictureRecorder* recorder)
- : m_pRecorder(recorder) {
- m_pAggDriver = nullptr;
+ : m_pBitmap(nullptr),
+ m_pOriDevice(nullptr),
+ m_pRecorder(recorder),
+ m_ditherBits(0),
+ m_bRgbByteOrder(FALSE),
+ m_bGroupKnockout(FALSE) {
m_pCanvas = m_pRecorder->getRecordingCanvas();
- m_ditherBits = 0;
}
CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() {
if (!m_pRecorder)
delete m_pCanvas;
- delete m_pAggDriver;
}
FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars,
@@ -438,7 +725,11 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawPath(
SkIRect rect;
rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH),
GetDeviceCaps(FXDC_PIXEL_HEIGHT));
- SkMatrix skMatrix = ToSkMatrix(*pObject2Device);
+ SkMatrix skMatrix;
+ if (pObject2Device)
+ skMatrix = ToSkMatrix(*pObject2Device);
+ else
+ skMatrix.setIdentity();
SkPaint skPaint;
skPaint.setAntiAlias(true);
int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag)
@@ -497,11 +788,17 @@ FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect,
return TRUE;
}
-FX_BOOL CFX_SkiaDeviceDriver::DrawShading(CPDF_ShadingPattern* pPattern,
- CFX_Matrix* pMatrix,
+FX_BOOL CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern,
+ const CFX_Matrix* pMatrix,
+ const FX_RECT& clip_rect,
int alpha,
FX_BOOL bAlphaMode) {
- CPDF_Function** pFuncs = pPattern->m_pFunctions;
+ if (kAxialShading != pPattern->m_ShadingType &&
+ kRadialShading != pPattern->m_ShadingType) {
+ // TODO(caryclark) more types
+ return false;
+ }
+ CPDF_Function* const* pFuncs = pPattern->m_pFunctions;
int nFuncs = pPattern->m_nFuncs;
if (nFuncs != 1) // TODO(caryclark) remove this restriction
return false;
@@ -509,23 +806,8 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawShading(CPDF_ShadingPattern* pPattern,
CPDF_Array* pCoords = pDict->GetArrayBy("Coords");
if (!pCoords)
return true;
- FX_FLOAT start_x = pCoords->GetNumberAt(0);
- FX_FLOAT start_y = pCoords->GetNumberAt(1);
- FX_FLOAT end_x = pCoords->GetNumberAt(2);
- FX_FLOAT end_y = pCoords->GetNumberAt(3);
- FX_FLOAT t_min = 0;
- FX_FLOAT t_max = 1;
- CPDF_Array* pArray = pDict->GetArrayBy("Domain");
- if (pArray) {
- t_min = pArray->GetNumberAt(0);
- t_max = pArray->GetNumberAt(1);
- }
- FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE;
- pArray = pDict->GetArrayBy("Extend");
- if (pArray) {
- bStartExtend = pArray->GetIntegerAt(0);
- bEndExtend = pArray->GetIntegerAt(1);
- }
+ // TODO(caryclark) Respect Domain[0], Domain[1]. (Don't know what they do
+ // yet.)
SkTDArray<SkColor> skColors;
SkTDArray<SkScalar> skPos;
for (int j = 0; j < nFuncs; j++) {
@@ -533,6 +815,14 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawShading(CPDF_ShadingPattern* pPattern,
if (!pFunc)
continue;
switch (pFunc->GetType()) {
+ case CPDF_Function::Type::kType0Sampled:
+ /* TODO(caryclark)
+ Type 0 Sampled Functions in PostScript can also have an Order integer
+ in the dictionary. PDFium doesn't appear to check for this anywhere.
+ */
+ if (!AddSamples(pFunc, &skColors, &skPos))
+ return false;
+ break;
case CPDF_Function::Type::kType2ExpotentialInterpolation:
if (!AddColors(pFunc, &skColors))
return false;
@@ -547,17 +837,90 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawShading(CPDF_ShadingPattern* pPattern,
return false;
}
}
- SkMatrix skMatrix = ToSkMatrix(*pMatrix);
- SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}};
+ CPDF_Array* pArray = pDict->GetArrayBy("Extend");
+ bool clipStart = !pArray || !pArray->GetIntegerAt(0);
+ bool clipEnd = !pArray || !pArray->GetIntegerAt(1);
SkPaint paint;
paint.setAntiAlias(true);
- paint.setShader(SkGradientShader::MakeLinear(pts, skColors.begin(),
- skPos.begin(), skColors.count(),
- SkShader::kClamp_TileMode));
paint.setAlpha(alpha);
+ SkMatrix skMatrix = ToSkMatrix(*pMatrix);
+ SkRect skRect = SkRect::MakeLTRB(clip_rect.left, clip_rect.top,
+ clip_rect.right, clip_rect.bottom);
+ SkPath skClip;
+ SkPath skPath;
+ if (kAxialShading == pPattern->m_ShadingType) {
+ FX_FLOAT start_x = pCoords->GetNumberAt(0);
+ FX_FLOAT start_y = pCoords->GetNumberAt(1);
+ FX_FLOAT end_x = pCoords->GetNumberAt(2);
+ FX_FLOAT end_y = pCoords->GetNumberAt(3);
+ SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}};
+ skMatrix.mapPoints(pts, SK_ARRAY_COUNT(pts));
+ paint.setShader(SkGradientShader::MakeLinear(
+ pts, skColors.begin(), skPos.begin(), skColors.count(),
+ SkShader::kClamp_TileMode));
+ if (clipStart || clipEnd) {
+ // if the gradient is horizontal or vertical, modify the draw rectangle
+ if (pts[0].fX == pts[1].fX) { // vertical
+ if (pts[0].fY > pts[1].fY) {
+ SkTSwap(pts[0].fY, pts[1].fY);
+ SkTSwap(clipStart, clipEnd);
+ }
+ if (clipStart)
+ skRect.fTop = SkTMax(skRect.fTop, pts[0].fY);
+ if (clipEnd)
+ skRect.fBottom = SkTMin(skRect.fBottom, pts[1].fY);
+ } else if (pts[0].fY == pts[1].fY) { // horizontal
+ if (pts[0].fX > pts[1].fX) {
+ SkTSwap(pts[0].fX, pts[1].fX);
+ SkTSwap(clipStart, clipEnd);
+ }
+ if (clipStart)
+ skRect.fLeft = SkTMax(skRect.fLeft, pts[0].fX);
+ if (clipEnd)
+ skRect.fRight = SkTMin(skRect.fRight, pts[1].fX);
+ } else { // if the gradient is angled and contained by the rect, clip
+ SkPoint rectPts[4] = {{skRect.fLeft, skRect.fTop},
+ {skRect.fRight, skRect.fTop},
+ {skRect.fRight, skRect.fBottom},
+ {skRect.fLeft, skRect.fBottom}};
+ ClipAngledGradient(pts, rectPts, clipStart, clipEnd, &skClip);
+ }
+ }
+ skPath.addRect(skRect);
+ skMatrix.setIdentity();
+ } else {
+ ASSERT(kRadialShading == pPattern->m_ShadingType);
+ FX_FLOAT start_x = pCoords->GetNumberAt(0);
+ FX_FLOAT start_y = pCoords->GetNumberAt(1);
+ FX_FLOAT start_r = pCoords->GetNumberAt(2);
+ FX_FLOAT end_x = pCoords->GetNumberAt(3);
+ FX_FLOAT end_y = pCoords->GetNumberAt(4);
+ FX_FLOAT end_r = pCoords->GetNumberAt(5);
+ SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}};
+
+ paint.setShader(SkGradientShader::MakeTwoPointConical(
+ pts[0], start_r, pts[1], end_r, skColors.begin(), skPos.begin(),
+ skColors.count(), SkShader::kClamp_TileMode));
+ if (clipStart || clipEnd) {
+ if (clipStart && start_r)
+ skClip.addCircle(pts[0].fX, pts[0].fY, start_r);
+ if (clipEnd)
+ skClip.addCircle(pts[1].fX, pts[1].fY, end_r, SkPath::kCCW_Direction);
+ else
+ skClip.setFillType(SkPath::kInverseWinding_FillType);
+ skClip.transform(skMatrix);
+ }
+ SkMatrix inverse;
+ if (!skMatrix.invert(&inverse))
+ return false;
+ skPath.addRect(skRect);
+ skPath.transform(inverse);
+ }
m_pCanvas->save();
+ if (!skClip.isEmpty())
+ m_pCanvas->clipPath(skClip);
m_pCanvas->concat(skMatrix);
- m_pCanvas->drawRect(SkRect::MakeWH(1, 1), paint);
+ m_pCanvas->drawPath(skPath, paint);
m_pCanvas->restore();
return true;
}
@@ -577,8 +940,45 @@ FX_BOOL CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap,
int top,
void* pIccTransform,
FX_BOOL bDEdge) {
- return m_pAggDriver &&
- m_pAggDriver->GetDIBits(pBitmap, left, top, pIccTransform, bDEdge);
+ if (!m_pBitmap || !m_pBitmap->GetBuffer())
+ return TRUE;
+ if (bDEdge) {
+ if (m_bRgbByteOrder) {
+ RgbByteOrderTransferBitmap(pBitmap, 0, 0, pBitmap->GetWidth(),
+ pBitmap->GetHeight(), m_pBitmap, left, top);
+ } else {
+ return pBitmap->TransferBitmap(0, 0, pBitmap->GetWidth(),
+ pBitmap->GetHeight(), m_pBitmap, left, top,
+ pIccTransform);
+ }
+ return TRUE;
+ }
+ FX_RECT rect(left, top, left + pBitmap->GetWidth(),
+ top + pBitmap->GetHeight());
+ CFX_DIBitmap* pBack;
+ if (m_pOriDevice) {
+ pBack = m_pOriDevice->Clone(&rect);
+ if (!pBack)
+ return TRUE;
+ pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(),
+ m_pBitmap, 0, 0);
+ } else {
+ pBack = m_pBitmap->Clone(&rect);
+ if (!pBack)
+ return TRUE;
+ }
+ FX_BOOL bRet = TRUE;
+ left = left >= 0 ? 0 : left;
+ top = top >= 0 ? 0 : top;
+ if (m_bRgbByteOrder) {
+ RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(),
+ pBack, left, top);
+ } else {
+ bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack,
+ left, top, pIccTransform);
+ }
+ delete pBack;
+ return bRet;
}
FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
@@ -589,9 +989,17 @@ FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
int blend_type,
int alpha_flag,
void* pIccTransform) {
- return m_pAggDriver &&
- m_pAggDriver->SetDIBits(pBitmap, argb, pSrcRect, left, top, blend_type,
- alpha_flag, pIccTransform);
+ if (!m_pBitmap || !m_pBitmap->GetBuffer())
+ return TRUE;
+ if (pBitmap->IsAlphaMask()) {
+ return m_pBitmap->CompositeMask(
+ left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb,
+ pSrcRect->left, pSrcRect->top, blend_type, nullptr, m_bRgbByteOrder,
+ alpha_flag, pIccTransform);
+ }
+ return m_pBitmap->CompositeBitmap(
+ left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left,
+ pSrcRect->top, blend_type, nullptr, m_bRgbByteOrder, pIccTransform);
}
FX_BOOL CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
@@ -605,10 +1013,29 @@ FX_BOOL CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
int alpha_flag,
void* pIccTransform,
int blend_type) {
- return m_pAggDriver &&
- m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top,
- dest_width, dest_height, pClipRect, flags,
- alpha_flag, pIccTransform, blend_type);
+ if (!m_pBitmap->GetBuffer())
+ return TRUE;
+ if (dest_width == pSource->GetWidth() &&
+ dest_height == pSource->GetHeight()) {
+ FX_RECT rect(0, 0, dest_width, dest_height);
+ return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type,
+ alpha_flag, pIccTransform);
+ }
+ FX_RECT dest_rect(dest_left, dest_top, dest_left + dest_width,
+ dest_top + dest_height);
+ dest_rect.Normalize();
+ FX_RECT dest_clip = dest_rect;
+ dest_clip.Intersect(*pClipRect);
+ CFX_BitmapComposer composer;
+ composer.Compose(m_pBitmap, nullptr, 255, argb, dest_clip, FALSE, FALSE,
+ FALSE, m_bRgbByteOrder, alpha_flag, pIccTransform,
+ blend_type);
+ dest_clip.Offset(-dest_rect.left, -dest_rect.top);
+ CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height,
+ dest_clip, flags);
+ if (stretcher.Start())
+ stretcher.Continue(nullptr);
+ return TRUE;
}
FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
@@ -644,6 +1071,9 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
rowBytes = width;
colorType = SkColorType::kGray_8_SkColorType;
} break;
+ case 8:
+ colorType = SkColorType::kGray_8_SkColorType;
+ break;
case 24: {
dst32Storage.reset(FX_Alloc2D(uint32_t, width, height));
uint32_t* dst32Pixels = dst32Storage.get();
@@ -698,63 +1128,66 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
}
FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) {
- return m_pAggDriver && m_pAggDriver->ContinueDIBits(pHandle, pPause);
+ if (!m_pBitmap->GetBuffer())
+ return TRUE;
+ return ((CFX_ImageRenderer*)pHandle)->Continue(pPause);
}
void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) {
- if (m_pAggDriver)
- m_pAggDriver->CancelDIBits(pHandle);
+ if (!m_pBitmap->GetBuffer())
+ return;
+ delete (CFX_ImageRenderer*)pHandle;
}
-CFX_SkiaDevice::CFX_SkiaDevice() {
+CFX_FxgeDevice::CFX_FxgeDevice() {
m_bOwnedBitmap = FALSE;
}
-SkPictureRecorder* CFX_SkiaDevice::CreateRecorder(int size_x, int size_y) {
+SkPictureRecorder* CFX_FxgeDevice::CreateRecorder(int size_x, int size_y) {
CFX_SkiaDeviceDriver* skDriver = new CFX_SkiaDeviceDriver(size_x, size_y);
SetDeviceDriver(skDriver);
return skDriver->GetRecorder();
}
-FX_BOOL CFX_SkiaDevice::Attach(CFX_DIBitmap* pBitmap,
- int dither_bits,
- FX_BOOL bRgbByteOrder,
- CFX_DIBitmap* pOriDevice,
- FX_BOOL bGroupKnockout) {
+bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap,
+ int dither_bits,
+ bool bRgbByteOrder,
+ CFX_DIBitmap* pOriDevice,
+ bool bGroupKnockout) {
if (!pBitmap)
- return FALSE;
+ return false;
SetBitmap(pBitmap);
SetDeviceDriver(new CFX_SkiaDeviceDriver(pBitmap, dither_bits, bRgbByteOrder,
pOriDevice, bGroupKnockout));
- return TRUE;
+ return true;
}
-FX_BOOL CFX_SkiaDevice::AttachRecorder(SkPictureRecorder* recorder) {
+bool CFX_FxgeDevice::AttachRecorder(SkPictureRecorder* recorder) {
if (!recorder)
- return FALSE;
+ return false;
SetDeviceDriver(new CFX_SkiaDeviceDriver(recorder));
- return TRUE;
+ return true;
}
-FX_BOOL CFX_SkiaDevice::Create(int width,
- int height,
- FXDIB_Format format,
- int dither_bits,
- CFX_DIBitmap* pOriDevice) {
+bool CFX_FxgeDevice::Create(int width,
+ int height,
+ FXDIB_Format format,
+ int dither_bits,
+ CFX_DIBitmap* pOriDevice) {
m_bOwnedBitmap = TRUE;
CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
if (!pBitmap->Create(width, height, format)) {
delete pBitmap;
- return FALSE;
+ return false;
}
SetBitmap(pBitmap);
CFX_SkiaDeviceDriver* pDriver =
new CFX_SkiaDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE);
SetDeviceDriver(pDriver);
- return TRUE;
+ return true;
}
-CFX_SkiaDevice::~CFX_SkiaDevice() {
+CFX_FxgeDevice::~CFX_FxgeDevice() {
if (m_bOwnedBitmap && GetBitmap())
delete GetBitmap();
}
diff --git a/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.h b/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.h
index afc505da6e2..ef66b94ae26 100644
--- a/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.h
+++ b/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device.h
@@ -84,7 +84,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
void* pIccTransform = NULL,
FX_BOOL bDEdge = FALSE) override;
- CFX_DIBitmap* GetBackDrop() override { return m_pAggDriver->GetBackDrop(); }
+ CFX_DIBitmap* GetBackDrop() override { return m_pOriDevice; }
FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
uint32_t color,
@@ -128,22 +128,26 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
int alpha_flag = 0,
void* pIccTransform = NULL) override;
- FX_BOOL DrawShading(CPDF_ShadingPattern* pPattern,
- CFX_Matrix* pMatrix,
+ FX_BOOL DrawShading(const CPDF_ShadingPattern* pPattern,
+ const CFX_Matrix* pMatrix,
+ const FX_RECT& clip_rect,
int alpha,
FX_BOOL bAlphaMode) override;
- virtual uint8_t* GetBuffer() const { return m_pAggDriver->GetBuffer(); }
+ virtual uint8_t* GetBuffer() const { return m_pBitmap->GetBuffer(); }
void PaintStroke(SkPaint* spaint,
const CFX_GraphStateData* pGraphState,
const SkMatrix& matrix);
SkPictureRecorder* GetRecorder() const { return m_pRecorder; }
private:
- CFX_AggDeviceDriver* m_pAggDriver;
+ CFX_DIBitmap* m_pBitmap;
+ CFX_DIBitmap* m_pOriDevice;
SkCanvas* m_pCanvas;
SkPictureRecorder* const m_pRecorder;
int m_ditherBits;
+ FX_BOOL m_bRgbByteOrder;
+ FX_BOOL m_bGroupKnockout;
};
#endif // defined(_SKIA_SUPPORT_)
diff --git a/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device_unittest.cpp b/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device_unittest.cpp
new file mode 100644
index 00000000000..57a4ec140b5
--- /dev/null
+++ b/chromium/third_party/pdfium/core/fxge/skia/fx_skia_device_unittest.cpp
@@ -0,0 +1,31 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/fxge/skia/fx_skia_device.cpp"
+#include "testing/fx_string_testhelpers.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+uint32_t _GetBits32(const uint8_t* pData, int bitpos, int nbits) {
+ int result = 0;
+ for (int i = 0; i < nbits; i++)
+ if (pData[(bitpos + i) / 8] & (1 << (7 - (bitpos + i) % 8))) {
+ result |= 1 << (nbits - i - 1);
+ }
+ return result;
+}
+
+} // namespace
+
+TEST(fxge, GetBits32) {
+ unsigned char data[] = {0xDE, 0x3F, 0xB1, 0x7C, 0x12, 0x9A, 0x04, 0x56};
+ for (int nbits = 1; nbits <= 32; ++nbits) {
+ for (int bitpos = 0; bitpos < (int)sizeof(data) * 8 - nbits; ++bitpos) {
+ uint32_t ref = _GetBits32(data, bitpos, nbits);
+ uint32_t test = GetBits32(data, bitpos, nbits);
+ EXPECT_TRUE(ref == test);
+ }
+ }
+}
diff --git a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_device.cpp b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_device.cpp
index ed57a02c23e..f8057e7d5d1 100644
--- a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_device.cpp
+++ b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_device.cpp
@@ -4,19 +4,19 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
#include <crtdbg.h>
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxge/agg/fx_agg_driver.h"
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/ge/fx_text_int.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge_win32.h"
#include "core/fxge/win32/dwrite_int.h"
#include "core/fxge/win32/win32_int.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge_win32.h"
#include "third_party/base/stl_util.h"
class CFX_Win32FallbackFontInfo final : public CFX_FolderFontInfo {
@@ -147,9 +147,6 @@ static int CALLBACK FontEnumProc(const LOGFONTA* plf,
uint32_t FontType,
LPARAM lParam) {
CFX_Win32FontInfo* pFontInfo = (CFX_Win32FontInfo*)lParam;
- if (pFontInfo->m_pMapper->GetFontEnumerator()) {
- pFontInfo->m_pMapper->GetFontEnumerator()->HitFont();
- }
pFontInfo->AddInstalledFont(plf, FontType);
return 1;
}
@@ -162,9 +159,6 @@ FX_BOOL CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) {
lf.lfPitchAndFamily = 0;
EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t) this,
0);
- if (pMapper->GetFontEnumerator()) {
- pMapper->GetFontEnumerator()->Finish();
- }
return TRUE;
}
static const struct {
@@ -356,7 +350,7 @@ void* CFX_Win32FontInfo::MapFont(int weight,
}
HFONT hFont =
::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset,
- OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face);
+ OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face.c_str());
char facebuf[100];
HFONT hOldFont = (HFONT)::SelectObject(m_hDC, hFont);
::GetTextFaceA(m_hDC, 100, facebuf);
@@ -399,8 +393,9 @@ void* CFX_Win32FontInfo::MapFont(int weight,
}
break;
}
- hFont = ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset,
- OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face);
+ hFont =
+ ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset,
+ OUT_TT_ONLY_PRECIS, 0, 0, subst_pitch_family, face.c_str());
return hFont;
}
void CFX_Win32FontInfo::DeleteFont(void* hFont) {
@@ -460,7 +455,7 @@ IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) {
if (path_len > 0 && path_len < MAX_PATH) {
CFX_ByteString fonts_path(windows_path);
fonts_path += "\\Fonts";
- pInfoFallback->AddPath(fonts_path.AsByteStringC());
+ pInfoFallback->AddPath(fonts_path.AsStringC());
}
return pInfoFallback;
}
diff --git a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_dib.cpp b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_dib.cpp
index cc627dbab03..eefa991eebd 100644
--- a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_dib.cpp
+++ b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_dib.cpp
@@ -4,13 +4,13 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
#include <windows.h>
+#include "core/fxge/include/fx_ge_win32.h"
#include "core/fxge/win32/win32_int.h"
-#include "core/include/fxge/fx_ge_win32.h"
CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) {
CFX_ByteString result;
diff --git a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_dwrite.cpp b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_dwrite.cpp
index f95b5eb4a35..aa6ba9c8b97 100644
--- a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_dwrite.cpp
+++ b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_dwrite.cpp
@@ -4,13 +4,13 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
#include <dwrite.h>
+#include "core/fxge/include/fx_ge_win32.h"
#include "core/fxge/win32/dwrite_int.h"
-#include "core/include/fxge/fx_ge_win32.h"
typedef HRESULT(__stdcall* FuncType_DWriteCreateFactory)(
__in DWRITE_FACTORY_TYPE,
diff --git a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_gdipext.cpp b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_gdipext.cpp
index b9c2190041a..eb24410900e 100644
--- a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_gdipext.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
#include <windows.h>
@@ -17,8 +17,8 @@ using std::max;
#include <gdiplus.h>
+#include "core/fxge/include/fx_ge_win32.h"
#include "core/fxge/win32/win32_int.h"
-#include "core/include/fxge/fx_ge_win32.h"
using namespace Gdiplus; // NOLINT
using namespace Gdiplus::DllExports; // NOLINT
@@ -673,7 +673,7 @@ static void OutputImage(GpGraphics* pGraphics,
CGdiplusExt::CGdiplusExt() {
m_hModule = NULL;
m_GdiModule = NULL;
- for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
+ for (size_t i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
m_Functions[i] = NULL;
}
m_pGdiAddFontMemResourceEx = NULL;
@@ -686,11 +686,11 @@ void CGdiplusExt::Load() {
strPlusPath += buf;
strPlusPath += "\\";
strPlusPath += "GDIPLUS.DLL";
- m_hModule = LoadLibraryA(strPlusPath);
+ m_hModule = LoadLibraryA(strPlusPath.c_str());
if (!m_hModule) {
return;
}
- for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
+ for (size_t i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);
if (!m_Functions[i]) {
m_hModule = NULL;
diff --git a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_print.cpp b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_print.cpp
index cb5ce771a3c..d0359138de1 100644
--- a/chromium/third_party/pdfium/core/fxge/win32/fx_win32_print.cpp
+++ b/chromium/third_party/pdfium/core/fxge/win32/fx_win32_print.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
@@ -12,9 +12,9 @@
#include "core/fxge/dib/dib_int.h"
#include "core/fxge/ge/fx_text_int.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge_win32.h"
#include "core/fxge/win32/win32_int.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge_win32.h"
#define SIZETHRESHOLD 1000
#define OUTPUTPSLEN 4096
diff --git a/chromium/third_party/pdfium/core/fxge/win32/win32_int.h b/chromium/third_party/pdfium/core/fxge/win32/win32_int.h
index 18996afc5c6..79166908177 100644
--- a/chromium/third_party/pdfium/core/fxge/win32/win32_int.h
+++ b/chromium/third_party/pdfium/core/fxge/win32/win32_int.h
@@ -7,8 +7,8 @@
#ifndef CORE_FXGE_WIN32_WIN32_INT_H_
#define CORE_FXGE_WIN32_WIN32_INT_H_
+#include "core/fxge/include/fx_ge.h"
#include "core/fxge/win32/dwrite_int.h"
-#include "core/include/fxge/fx_ge.h"
struct WINDIB_Open_Args_;
class CGdiplusExt {
diff --git a/chromium/third_party/pdfium/core/include/fxcodec/fx_codec.h b/chromium/third_party/pdfium/core/include/fxcodec/fx_codec.h
deleted file mode 100644
index a674eb72909..00000000000
--- a/chromium/third_party/pdfium/core/include/fxcodec/fx_codec.h
+++ /dev/null
@@ -1,566 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_H_
-#define CORE_INCLUDE_FXCODEC_FX_CODEC_H_
-
-#include <map>
-#include <memory>
-#include <vector>
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "core/fxcrt/include/fx_coordinates.h" // For FX_RECT.
-#include "core/include/fxcodec/fx_codec_def.h"
-
-class CFX_DIBSource;
-class CJPX_Decoder;
-class CPDF_ColorSpace;
-class CPDF_StreamAcc;
-class ICodec_BasicModule;
-class ICodec_FaxModule;
-class ICodec_FlateModule;
-class ICodec_IccModule;
-class ICodec_Jbig2Encoder;
-class ICodec_Jbig2Module;
-class ICodec_JpegModule;
-class ICodec_JpxModule;
-class ICodec_ScanlineDecoder;
-
-#ifdef PDF_ENABLE_XFA
-class ICodec_BmpModule;
-class ICodec_GifModule;
-class ICodec_PngModule;
-class ICodec_ProgressiveDecoder;
-class ICodec_TiffModule;
-#endif // PDF_ENABLE_XFA
-
-#ifdef PDF_ENABLE_XFA
-class CFX_DIBAttribute {
- public:
- CFX_DIBAttribute();
- ~CFX_DIBAttribute();
-
- int32_t m_nXDPI;
- int32_t m_nYDPI;
- FX_FLOAT m_fAspectRatio;
- uint16_t m_wDPIUnit;
- CFX_ByteString m_strAuthor;
- uint8_t m_strTime[20];
- int32_t m_nGifLeft;
- int32_t m_nGifTop;
- uint32_t* m_pGifLocalPalette;
- uint32_t m_nGifLocalPalNum;
- int32_t m_nBmpCompressType;
- std::map<uint32_t, void*> m_Exif;
-};
-#endif // PDF_ENABLE_XFA
-
-class CCodec_ModuleMgr {
- public:
- CCodec_ModuleMgr();
-
- ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
- ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
- ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
- ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); }
- ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
- ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); }
- ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); }
-
-#ifdef PDF_ENABLE_XFA
- ICodec_ProgressiveDecoder* CreateProgressiveDecoder();
- ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
- ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
- ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
- ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
-#endif // PDF_ENABLE_XFA
-
- protected:
- std::unique_ptr<ICodec_BasicModule> m_pBasicModule;
- std::unique_ptr<ICodec_FaxModule> m_pFaxModule;
- std::unique_ptr<ICodec_JpegModule> m_pJpegModule;
- std::unique_ptr<ICodec_JpxModule> m_pJpxModule;
- std::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module;
- std::unique_ptr<ICodec_IccModule> m_pIccModule;
-#ifdef PDF_ENABLE_XFA
- std::unique_ptr<ICodec_PngModule> m_pPngModule;
- std::unique_ptr<ICodec_GifModule> m_pGifModule;
- std::unique_ptr<ICodec_BmpModule> m_pBmpModule;
- std::unique_ptr<ICodec_TiffModule> m_pTiffModule;
-#endif // PDF_ENABLE_XFA
- std::unique_ptr<ICodec_FlateModule> m_pFlateModule;
-};
-class ICodec_BasicModule {
- public:
- virtual ~ICodec_BasicModule() {}
- virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
- virtual FX_BOOL A85Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
- virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- int bpc) = 0;
-};
-
-class ICodec_ScanlineDecoder {
- public:
- virtual ~ICodec_ScanlineDecoder() {}
-
- virtual uint32_t GetSrcOffset() = 0;
-
- virtual void DownScale(int dest_width, int dest_height) = 0;
-
- virtual const uint8_t* GetScanline(int line) = 0;
-
- virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) = 0;
-
- virtual int GetWidth() = 0;
-
- virtual int GetHeight() = 0;
-
- virtual int CountComps() = 0;
-
- virtual int GetBPC() = 0;
-
- virtual FX_BOOL IsColorTransformed() = 0;
-
- virtual void ClearImageData() = 0;
-};
-
-class ICodec_FlateModule {
- public:
- virtual ~ICodec_FlateModule() {}
- virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- int bpc,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns) = 0;
- virtual uint32_t FlateOrLZWDecode(FX_BOOL bLZW,
- const uint8_t* src_buf,
- uint32_t src_size,
- FX_BOOL bEarlyChange,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint32_t estimated_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- uint32_t src_size,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- uint32_t src_size,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
-};
-class ICodec_FaxModule {
- public:
- virtual ~ICodec_FaxModule() {}
-
- virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int K,
- FX_BOOL EndOfLine,
- FX_BOOL EncodedByteAlign,
- FX_BOOL BlackIs1,
- int Columns,
- int Rows) = 0;
-
- virtual FX_BOOL Encode(const uint8_t* src_buf,
- int width,
- int height,
- int pitch,
- uint8_t*& dest_buf,
- uint32_t& dest_size) = 0;
-};
-class ICodec_JpegModule {
- public:
- virtual ~ICodec_JpegModule() {}
-
- virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- int nComps,
- FX_BOOL ColorTransform) = 0;
-
- virtual FX_BOOL LoadInfo(const uint8_t* src_buf,
- uint32_t src_size,
- int& width,
- int& height,
- int& num_components,
- int& bits_per_components,
- FX_BOOL& color_transform,
- uint8_t** icc_buf_ptr = NULL,
- uint32_t* icc_length = NULL) = 0;
-
- virtual FX_BOOL Encode(const class CFX_DIBSource* pSource,
- uint8_t*& dest_buf,
- FX_STRSIZE& dest_size,
- int quality = 75,
- const uint8_t* icc_buf = NULL,
- uint32_t icc_length = 0) = 0;
-
- virtual void* Start() = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) = 0;
-
-#ifdef PDF_ENABLE_XFA
- virtual int ReadHeader(void* pContext,
- int* width,
- int* height,
- int* nComps,
- CFX_DIBAttribute* pAttribute) = 0;
-#else // PDF_ENABLE_XFA
- virtual int ReadHeader(void* pContext,
- int* width,
- int* height,
- int* nComps) = 0;
-#endif // PDF_ENABLE_XFA
-
- virtual int StartScanline(void* pContext, int down_scale) = 0;
-
- virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0;
-
- virtual uint32_t GetAvailInput(void* pContext,
- uint8_t** avail_buf_ptr = NULL) = 0;
-};
-
-class ICodec_JpxModule {
- public:
- virtual ~ICodec_JpxModule() {}
-
- virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
- uint32_t src_size,
- CPDF_ColorSpace* cs) = 0;
-
- virtual void GetImageInfo(CJPX_Decoder* pDecoder,
- uint32_t* width,
- uint32_t* height,
- uint32_t* components) = 0;
-
- virtual bool Decode(CJPX_Decoder* pDecoder,
- uint8_t* dest_data,
- int pitch,
- const std::vector<uint8_t>& offsets) = 0;
-
- virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0;
-};
-#ifdef PDF_ENABLE_XFA
-class ICodec_PngModule {
- public:
- virtual ~ICodec_PngModule() {}
-
- virtual void* Start(void* pModule) = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual FX_BOOL Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size,
- CFX_DIBAttribute* pAttribute) = 0;
-
- FX_BOOL (*ReadHeaderCallback)(void* pModule,
- int width,
- int height,
- int bpc,
- int pass,
- int* color_type,
- double* gamma);
-
- FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf);
-
- void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line);
-};
-class ICodec_GifModule {
- public:
- virtual ~ICodec_GifModule() {}
-
- virtual void* Start(void* pModule) = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual uint32_t GetAvailInput(void* pContext,
- uint8_t** avail_buf_ptr = NULL) = 0;
-
- virtual void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) = 0;
-
- virtual int32_t ReadHeader(void* pContext,
- int* width,
- int* height,
- int* pal_num,
- void** pal_pp,
- int* bg_index,
- CFX_DIBAttribute* pAttribute) = 0;
-
- virtual int32_t LoadFrameInfo(void* pContext, int* frame_num) = 0;
-
- void (*RecordCurrentPositionCallback)(void* pModule, uint32_t& cur_pos);
-
- uint8_t* (*AskLocalPaletteBufCallback)(void* pModule,
- int32_t frame_num,
- int32_t pal_size);
-
- virtual int32_t LoadFrame(void* pContext,
- int frame_num,
- CFX_DIBAttribute* pAttribute) = 0;
-
- FX_BOOL (*InputRecordPositionBufCallback)(void* pModule,
- uint32_t rcd_pos,
- const FX_RECT& img_rc,
- int32_t pal_num,
- void* pal_ptr,
- int32_t delay_time,
- FX_BOOL user_input,
- int32_t trans_index,
- int32_t disposal_method,
- FX_BOOL interlace);
-
- void (*ReadScanlineCallback)(void* pModule,
- int32_t row_num,
- uint8_t* row_buf);
-};
-class ICodec_BmpModule {
- public:
- virtual ~ICodec_BmpModule() {}
-
- virtual void* Start(void* pModule) = 0;
-
- virtual void Finish(void* pContext) = 0;
-
- virtual uint32_t GetAvailInput(void* pContext,
- uint8_t** avail_buf_ptr = NULL) = 0;
-
- virtual void Input(void* pContext,
- const uint8_t* src_buf,
- uint32_t src_size) = 0;
-
- virtual int32_t ReadHeader(void* pContext,
- int32_t* width,
- int32_t* height,
- FX_BOOL* tb_flag,
- int32_t* components,
- int* pal_num,
- uint32_t** pal_pp,
- CFX_DIBAttribute* pAttribute) = 0;
-
- virtual int32_t LoadImage(void* pContext) = 0;
-
- FX_BOOL (*InputImagePositionBufCallback)(void* pModule, uint32_t rcd_pos);
-
- void (*ReadScanlineCallback)(void* pModule,
- int32_t row_num,
- uint8_t* row_buf);
-};
-class ICodec_TiffModule {
- public:
- virtual ~ICodec_TiffModule() {}
-
- virtual void* CreateDecoder(IFX_FileRead* file_ptr) = 0;
-
- virtual void GetFrames(void* ctx, int32_t& frames) = 0;
-
- virtual FX_BOOL LoadFrameInfo(void* ctx,
- int32_t frame,
- uint32_t& width,
- uint32_t& height,
- uint32_t& comps,
- uint32_t& bpc,
- CFX_DIBAttribute* pAttribute) = 0;
-
- virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0;
-
- virtual void DestroyDecoder(void* ctx) = 0;
-};
-#endif
-
-class ICodec_Jbig2Module {
- public:
- virtual ~ICodec_Jbig2Module() {}
-
- virtual void* CreateJbig2Context() = 0;
-
- virtual FXCODEC_STATUS StartDecode(void* pJbig2Context,
- CFX_PrivateData* pPrivateData,
- uint32_t width,
- uint32_t height,
- CPDF_StreamAcc* src_stream,
- CPDF_StreamAcc* global_stream,
- uint8_t* dest_buf,
- uint32_t dest_pitch,
- IFX_Pause* pPause) = 0;
-
- virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content,
- IFX_Pause* pPause) = 0;
- virtual void DestroyJbig2Context(void* pJbig2Content) = 0;
-};
-#ifdef PDF_ENABLE_XFA
-class ICodec_ProgressiveDecoder {
- public:
- virtual ~ICodec_ProgressiveDecoder() {}
-
- virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile,
- FXCODEC_IMAGE_TYPE imageType,
- CFX_DIBAttribute* pAttribute) = 0;
-
- virtual FXCODEC_IMAGE_TYPE GetType() const = 0;
- virtual int32_t GetWidth() const = 0;
- virtual int32_t GetHeight() const = 0;
- virtual int32_t GetNumComponents() const = 0;
- virtual int32_t GetBPC() const = 0;
-
- virtual void SetClipBox(FX_RECT* clip) = 0;
-
- virtual FXCODEC_STATUS GetFrames(int32_t& frames,
- IFX_Pause* pPause = NULL) = 0;
-
- virtual FXCODEC_STATUS StartDecode(class CFX_DIBitmap* pDIBitmap,
- int32_t start_x,
- int32_t start_y,
- int32_t size_x,
- int32_t size_y,
- int32_t frames = 0,
- FX_BOOL bInterpol = TRUE) = 0;
-
- virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = NULL) = 0;
-};
-#endif // PDF_ENABLE_XFA
-class ICodec_Jbig2Encoder {
- public:
- virtual ~ICodec_Jbig2Encoder() {}
-};
-
-class ICodec_IccModule {
- public:
- enum IccCS {
- IccCS_Unknown = 0,
- IccCS_XYZ,
- IccCS_Lab,
- IccCS_Luv,
- IccCS_YCbCr,
- IccCS_Yxy,
- IccCS_Hsv,
- IccCS_Hls,
- IccCS_Gray,
- IccCS_Rgb,
- IccCS_Cmyk,
- IccCS_Cmy
- };
-
- struct IccParam {
- uint32_t Version;
- IccCS ColorSpace;
- uint32_t dwProfileType;
- uint32_t dwFormat;
- uint8_t* pProfileData;
- uint32_t dwProfileSize;
- double Gamma;
- };
-
- virtual ~ICodec_IccModule() {}
-
- virtual IccCS GetProfileCS(const uint8_t* pProfileData,
- unsigned int dwProfileSize) = 0;
-
- virtual IccCS GetProfileCS(IFX_FileRead* pFile) = 0;
-
- virtual void* CreateTransform(
- ICodec_IccModule::IccParam* pInputParam,
- ICodec_IccModule::IccParam* pOutputParam,
- ICodec_IccModule::IccParam* pProofParam = NULL,
- uint32_t dwIntent = Icc_INTENT_PERCEPTUAL,
- uint32_t dwFlag = Icc_FLAGS_DEFAULT,
- uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
- uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING) = 0;
-
- virtual void* CreateTransform_sRGB(
- const uint8_t* pProfileData,
- uint32_t dwProfileSize,
- uint32_t& nComponents,
- int32_t intent = 0,
- uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT) = 0;
-
- virtual void* CreateTransform_CMYK(
- const uint8_t* pSrcProfileData,
- uint32_t dwSrcProfileSize,
- uint32_t& nSrcComponents,
- const uint8_t* pDstProfileData,
- uint32_t dwDstProfileSize,
- int32_t intent = 0,
- uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT,
- uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) = 0;
-
- virtual void DestroyTransform(void* pTransform) = 0;
-
- virtual void Translate(void* pTransform,
- FX_FLOAT* pSrcValues,
- FX_FLOAT* pDestValues) = 0;
-
- virtual void TranslateScanline(void* pTransform,
- uint8_t* pDest,
- const uint8_t* pSrc,
- int pixels) = 0;
- virtual void SetComponents(uint32_t nComponents) = 0;
-};
-
-void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels);
-void sRGB_to_AdobeCMYK(FX_FLOAT R,
- FX_FLOAT G,
- FX_FLOAT B,
- FX_FLOAT& c,
- FX_FLOAT& m,
- FX_FLOAT& y,
- FX_FLOAT& k);
-void AdobeCMYK_to_sRGB(FX_FLOAT c,
- FX_FLOAT m,
- FX_FLOAT y,
- FX_FLOAT k,
- FX_FLOAT& R,
- FX_FLOAT& G,
- FX_FLOAT& B);
-void AdobeCMYK_to_sRGB1(uint8_t c,
- uint8_t m,
- uint8_t y,
- uint8_t k,
- uint8_t& R,
- uint8_t& G,
- uint8_t& B);
-FX_BOOL MD5ComputeID(const void* buf, uint32_t dwSize, uint8_t ID[16]);
-void FaxG4Decode(const uint8_t* src_buf,
- uint32_t src_size,
- int* pbitpos,
- uint8_t* dest_buf,
- int width,
- int height,
- int pitch);
-
-#endif // CORE_INCLUDE_FXCODEC_FX_CODEC_H_
diff --git a/chromium/third_party/pdfium/core/include/fxge/fpf.h b/chromium/third_party/pdfium/core/include/fxge/fpf.h
deleted file mode 100644
index bc42a2dd95d..00000000000
--- a/chromium/third_party/pdfium/core/include/fxge/fpf.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_INCLUDE_FXGE_FPF_H_
-#define CORE_INCLUDE_FXGE_FPF_H_
-
-#include "core/fxcrt/include/fx_coordinates.h"
-
-class IFPF_FontMgr;
-
-class IFPF_DeviceModule {
- public:
- virtual ~IFPF_DeviceModule() {}
- virtual void Destroy() = 0;
- virtual IFPF_FontMgr* GetFontMgr() = 0;
-};
-
-IFPF_DeviceModule* FPF_GetDeviceModule();
-
-#define FPF_MATCHFONT_REPLACEANSI 1
-
-typedef struct FPF_HFONT_ { void* pData; } * FPF_HFONT;
-
-class IFPF_Font {
- public:
- virtual void Release() = 0;
- virtual IFPF_Font* Retain() = 0;
- virtual FPF_HFONT GetHandle() = 0;
- virtual CFX_ByteString GetFamilyName() = 0;
- virtual CFX_WideString GetPsName() = 0;
- virtual uint32_t GetFontStyle() const = 0;
- virtual uint8_t GetCharset() const = 0;
-
- virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode) = 0;
- virtual int32_t GetGlyphWidth(int32_t iGlyphIndex) = 0;
-
- virtual int32_t GetAscent() const = 0;
- virtual int32_t GetDescent() const = 0;
-
- virtual FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox) = 0;
- virtual FX_BOOL GetBBox(FX_RECT& rtBBox) = 0;
-
- virtual int32_t GetHeight() const = 0;
- virtual int32_t GetItalicAngle() const = 0;
- virtual uint32_t GetFontData(uint32_t dwTable,
- uint8_t* pBuffer,
- uint32_t dwSize) = 0;
-
- protected:
- virtual ~IFPF_Font() {}
-};
-
-class IFPF_FontMgr {
- public:
- virtual ~IFPF_FontMgr() {}
- virtual void LoadSystemFonts() = 0;
- virtual void LoadPrivateFont(IFX_FileRead* pFontFile) = 0;
- virtual void LoadPrivateFont(const CFX_ByteStringC& bsFileName) = 0;
- virtual void LoadPrivateFont(void* pBuffer, size_t szBuffer) = 0;
-
- virtual IFPF_Font* CreateFont(const CFX_ByteStringC& bsFamilyname,
- uint8_t charset,
- uint32_t dwStyle,
- uint32_t dwMatch = 0) = 0;
-};
-
-#endif // CORE_INCLUDE_FXGE_FPF_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/DEPS b/chromium/third_party/pdfium/fpdfsdk/DEPS
index 1383f25c356..463991d9051 100644
--- a/chromium/third_party/pdfium/fpdfsdk/DEPS
+++ b/chromium/third_party/pdfium/fpdfsdk/DEPS
@@ -1,14 +1,17 @@
include_rules = [
- '+core/include',
'+core/fpdftext/include',
'+core/fpdfapi/include',
'+core/fpdfapi/fpdf_edit/include',
'+core/fpdfapi/fpdf_page/include',
'+core/fpdfapi/fpdf_parser/include',
'+core/fpdfapi/fpdf_render/include',
+ '+core/fpdfdoc/include',
+ '+core/fxcodec/include',
'+core/fxcrt/include',
+ '+core/fxge/include',
'+public',
'+v8',
- '+xfa/include',
+ '+xfa/fwl/core/include',
+ '+xfa/fxfa/include',
'+xfa/fxgraphics/include',
]
diff --git a/chromium/third_party/pdfium/fpdfsdk/cfx_systemhandler.cpp b/chromium/third_party/pdfium/fpdfsdk/cfx_systemhandler.cpp
new file mode 100644
index 00000000000..c5f53341e18
--- /dev/null
+++ b/chromium/third_party/pdfium/fpdfsdk/cfx_systemhandler.cpp
@@ -0,0 +1,138 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fpdfsdk/cfx_systemhandler.h"
+
+#include "fpdfsdk/formfiller/cffl_formfiller.h"
+#include "fpdfsdk/include/fsdk_mgr.h"
+
+namespace {
+
+int CharSet2CP(int charset) {
+ if (charset == 128)
+ return 932;
+ if (charset == 134)
+ return 936;
+ if (charset == 129)
+ return 949;
+ if (charset == 136)
+ return 950;
+ return 0;
+}
+
+} // namespace
+
+void CFX_SystemHandler::SetCursor(int32_t nCursorType) {
+ m_pEnv->FFI_SetCursor(nCursorType);
+}
+
+void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect) {
+ CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd;
+ CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView();
+ UnderlyingPageType* pPage = pSDKAnnot->GetUnderlyingPage();
+ if (!pPage || !pPageView)
+ return;
+
+ CFX_Matrix page2device;
+ pPageView->GetCurrentMatrix(page2device);
+ CFX_Matrix device2page;
+ device2page.SetReverse(page2device);
+ FX_FLOAT left, top, right, bottom;
+ device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top);
+ device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right,
+ bottom);
+ CFX_FloatRect rcPDF(left, bottom, right, top);
+ rcPDF.Normalize();
+
+ m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right,
+ rcPDF.bottom);
+}
+
+void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller,
+ CFX_FloatRect& rect) {
+ CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller;
+ if (!pFFL)
+ return;
+
+ CFX_FloatPoint leftbottom = CFX_FloatPoint(rect.left, rect.bottom);
+ CFX_FloatPoint righttop = CFX_FloatPoint(rect.right, rect.top);
+ CFX_FloatPoint ptA = pFFL->PWLtoFFL(leftbottom);
+ CFX_FloatPoint ptB = pFFL->PWLtoFFL(righttop);
+ CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot();
+ UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage();
+ ASSERT(pPage);
+
+ m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y);
+}
+
+bool CFX_SystemHandler::IsSelectionImplemented() const {
+ if (m_pEnv) {
+ FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo();
+ if (pInfo && pInfo->FFI_OutputSelectedRect)
+ return true;
+ }
+ return false;
+}
+
+bool CFX_SystemHandler::FindNativeTrueTypeFont(int32_t nCharset,
+ CFX_ByteString sFontFaceName) {
+ CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
+ if (!pFontMgr)
+ return false;
+
+ CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
+ if (!pFontMapper)
+ return false;
+
+ if (pFontMapper->m_InstalledTTFonts.empty())
+ pFontMapper->LoadInstalledFonts();
+
+ for (const auto& font : pFontMapper->m_InstalledTTFonts) {
+ if (font.Compare(sFontFaceName.AsStringC()))
+ return true;
+ }
+
+ return false;
+}
+
+CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(
+ CPDF_Document* pDoc,
+ CFX_ByteString sFontFaceName,
+ uint8_t nCharset) {
+ if (!pDoc)
+ return nullptr;
+
+ CFX_Font* pFXFont = new CFX_Font();
+ pFXFont->LoadSubst(sFontFaceName, TRUE, 0, 0, 0, CharSet2CP(nCharset), FALSE);
+ CPDF_Font* pFont = pDoc->AddFont(pFXFont, nCharset, FALSE);
+ delete pFXFont;
+ return pFont;
+}
+
+int32_t CFX_SystemHandler::SetTimer(int32_t uElapse,
+ TimerCallback lpTimerFunc) {
+ return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc);
+}
+
+void CFX_SystemHandler::KillTimer(int32_t nID) {
+ m_pEnv->FFI_KillTimer(nID);
+}
+
+FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() {
+ return m_pEnv->FFI_GetLocalTime();
+}
+
+bool CFX_SystemHandler::IsSHIFTKeyDown(uint32_t nFlag) const {
+ return !!m_pEnv->FFI_IsSHIFTKeyDown(nFlag);
+}
+
+bool CFX_SystemHandler::IsCTRLKeyDown(uint32_t nFlag) const {
+ return !!m_pEnv->FFI_IsCTRLKeyDown(nFlag);
+}
+
+bool CFX_SystemHandler::IsALTKeyDown(uint32_t nFlag) const {
+ return !!m_pEnv->FFI_IsALTKeyDown(nFlag);
+}
diff --git a/chromium/third_party/pdfium/fpdfsdk/cfx_systemhandler.h b/chromium/third_party/pdfium/fpdfsdk/cfx_systemhandler.h
new file mode 100644
index 00000000000..e77120adef9
--- /dev/null
+++ b/chromium/third_party/pdfium/fpdfsdk/cfx_systemhandler.h
@@ -0,0 +1,82 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FPDFSDK_CFX_SYSTEMHANDLER_H_
+#define FPDFSDK_CFX_SYSTEMHANDLER_H_
+
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxcrt/include/fx_system.h"
+
+using FX_HWND = void*;
+using FX_HMENU = void*;
+using TimerCallback = void (*)(int32_t idEvent);
+
+struct FX_SYSTEMTIME {
+ FX_SYSTEMTIME()
+ : wYear(0),
+ wMonth(0),
+ wDayOfWeek(0),
+ wDay(0),
+ wHour(0),
+ wMinute(0),
+ wSecond(0),
+ wMilliseconds(0) {}
+
+ uint16_t wYear;
+ uint16_t wMonth;
+ uint16_t wDayOfWeek;
+ uint16_t wDay;
+ uint16_t wHour;
+ uint16_t wMinute;
+ uint16_t wSecond;
+ uint16_t wMilliseconds;
+};
+
+// Cursor style. These must match the values in public/fpdf_formfill.h
+#define FXCT_ARROW 0
+#define FXCT_NESW 1
+#define FXCT_NWSE 2
+#define FXCT_VBEAM 3
+#define FXCT_HBEAM 4
+#define FXCT_HAND 5
+
+class CPDF_Document;
+class CPDF_Font;
+class CPDFDoc_Environment;
+
+class CFX_SystemHandler {
+ public:
+ explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv)
+ : m_pEnv(pEnv), m_nCharSet(-1) {}
+ ~CFX_SystemHandler() {}
+
+ void InvalidateRect(FX_HWND hWnd, FX_RECT rect);
+ void OutputSelectedRect(void* pFormFiller, CFX_FloatRect& rect);
+ bool IsSelectionImplemented() const;
+
+ void SetCursor(int32_t nCursorType);
+
+ bool FindNativeTrueTypeFont(int32_t nCharset, CFX_ByteString sFontFaceName);
+ CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc,
+ CFX_ByteString sFontFaceName,
+ uint8_t nCharset);
+ int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc);
+ void KillTimer(int32_t nID);
+ bool IsSHIFTKeyDown(uint32_t nFlag) const;
+ bool IsCTRLKeyDown(uint32_t nFlag) const;
+ bool IsALTKeyDown(uint32_t nFlag) const;
+
+ FX_SYSTEMTIME GetLocalTime();
+
+ int32_t GetCharSet() const { return m_nCharSet; }
+ void SetCharSet(int32_t nCharSet) { m_nCharSet = nCharSet; }
+
+ private:
+ CPDFDoc_Environment* const m_pEnv;
+ int m_nCharSet;
+};
+
+#endif // FPDFSDK_CFX_SYSTEMHANDLER_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.cpp b/chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.cpp
index 1ecf7d4de44..4c74d5a242a 100644
--- a/chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -14,7 +14,7 @@
#include "fpdfsdk/include/fsdk_baseannot.h"
CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot,
- IFX_SystemHandler* pSystemHandler)
+ CFX_SystemHandler* pSystemHandler)
: CPWL_FontMap(pSystemHandler),
m_pDocument(NULL),
m_pAnnotDict(NULL),
@@ -159,15 +159,15 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
}
// to avoid checkbox and radiobutton
- CPDF_Object* pObject = pAPDict->GetObjectBy(m_sAPType.AsByteStringC());
+ CPDF_Object* pObject = pAPDict->GetObjectBy(m_sAPType);
if (ToDictionary(pObject))
return;
- CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType.AsByteStringC());
+ CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType);
if (!pStream) {
pStream = new CPDF_Stream(NULL, 0, NULL);
int32_t objnum = m_pDocument->AddIndirectObject(pStream);
- pAPDict->SetAtReference(m_sAPType.AsByteStringC(), m_pDocument, objnum);
+ pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
@@ -191,8 +191,8 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList);
pStreamResList->SetAtReference("Font", m_pDocument, objnum);
}
- if (!pStreamResFontList->KeyExist(sAlias.AsByteStringC()))
- pStreamResFontList->SetAtReference(sAlias.AsByteStringC(), m_pDocument,
+ if (!pStreamResFontList->KeyExist(sAlias))
+ pStreamResFontList->SetAtReference(sAlias, m_pDocument,
pFont->GetFontDict());
}
}
@@ -221,14 +221,14 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
CPDF_Dictionary* pFontDict = NULL;
if (!sDA.IsEmpty()) {
- CPDF_SimpleParser syntax(sDA.AsByteStringC());
+ CPDF_SimpleParser syntax(sDA.AsStringC());
syntax.FindTagParamFromStart("Tf", 2);
- CFX_ByteString sFontName = syntax.GetWord();
+ CFX_ByteString sFontName(syntax.GetWord());
sAlias = PDF_NameDecode(sFontName).Mid(1);
if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR"))
if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
- pFontDict = pDRFontDict->GetDictBy(sAlias.AsByteStringC());
+ pFontDict = pDRFontDict->GetDictBy(sAlias);
if (!pFontDict)
if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP"))
@@ -237,14 +237,14 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
pNormalDict->GetDictBy("Resources"))
if (CPDF_Dictionary* pResFontDict =
pNormalResDict->GetDictBy("Font"))
- pFontDict = pResFontDict->GetDictBy(sAlias.AsByteStringC());
+ pFontDict = pResFontDict->GetDictBy(sAlias);
if (bWidget) {
if (!pFontDict) {
if (pAcroFormDict) {
if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR"))
if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font"))
- pFontDict = pDRFontDict->GetDictBy(sAlias.AsByteStringC());
+ pFontDict = pDRFontDict->GetDictBy(sAlias);
}
}
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.h b/chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.h
index ac5f2ced8a5..c0e569a0d3f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.h
+++ b/chromium/third_party/pdfium/fpdfsdk/formfiller/cba_fontmap.h
@@ -14,7 +14,7 @@ class CPDFSDK_Annot;
class CBA_FontMap : public CPWL_FontMap {
public:
- CBA_FontMap(CPDFSDK_Annot* pAnnot, IFX_SystemHandler* pSystemHandler);
+ CBA_FontMap(CPDFSDK_Annot* pAnnot, CFX_SystemHandler* pSystemHandler);
~CBA_FontMap() override;
void SetDefaultFont(CPDF_Font* pFont, const CFX_ByteString& sFontName);
diff --git a/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.cpp b/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.cpp
index 9ca8f054934..8ee6da387d3 100644
--- a/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -323,32 +323,23 @@ PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() {
cp.fFontSize = m_pWidget->GetFontSize();
cp.dwBorderWidth = m_pWidget->GetBorderWidth();
- int nBorderStyle = m_pWidget->GetBorderStyle();
-
- switch (nBorderStyle) {
- case BBS_SOLID:
- cp.nBorderStyle = PBS_SOLID;
- break;
- case BBS_DASH:
- cp.nBorderStyle = PBS_DASH;
+ cp.nBorderStyle = m_pWidget->GetBorderStyle();
+ switch (cp.nBorderStyle) {
+ case BorderStyle::DASH:
cp.sDash = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- cp.nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
cp.dwBorderWidth *= 2;
break;
- case BBS_INSET:
- cp.nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
cp.dwBorderWidth *= 2;
break;
- case BBS_UNDERLINE:
- cp.nBorderStyle = PBS_UNDERLINED;
+ default:
break;
}
- if (cp.fFontSize <= 0) {
+ if (cp.fFontSize <= 0)
dwCreateFlags |= PWS_AUTOFONTSIZE;
- }
cp.dwFlags = dwCreateFlags;
cp.pSystemHandler = m_pApp->GetSysHandler();
@@ -603,7 +594,7 @@ CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView,
void CFFL_FormFiller::TimerProc() {}
-IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const {
+CFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const {
return m_pApp->GetSysHandler();
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.h b/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.h
index 9e9f4becf48..73609572569 100644
--- a/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.h
+++ b/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_formfiller.h
@@ -83,7 +83,7 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
// CPWL_TimerHandler
void TimerProc() override;
- IFX_SystemHandler* GetSystemHandler() const override;
+ CFX_SystemHandler* GetSystemHandler() const override;
// IPWL_Provider
CFX_Matrix GetWindowMatrix(void* pAttachedData) override;
diff --git a/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_listbox.cpp b/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_listbox.cpp
index b668b67edb0..dc4f07d0d20 100644
--- a/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -111,40 +111,25 @@ FX_BOOL CFFL_ListBox::IsDataChanged(CPDFSDK_PageView* pPageView) {
}
void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView) {
- ASSERT(m_pWidget);
-
- if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE)) {
- CFX_IntArray aOldSelect, aNewSelect;
-
- {
- for (int i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) {
- if (m_pWidget->IsOptionSelected(i)) {
- aOldSelect.Add(i);
- }
- }
- }
-
- int32_t nNewTopIndex = pListBox->GetTopVisibleIndex();
-
- m_pWidget->ClearSelection(FALSE);
+ CPWL_ListBox* pListBox =
+ static_cast<CPWL_ListBox*>(GetPDFWindow(pPageView, FALSE));
+ if (!pListBox)
+ return;
- if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
- for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) {
- if (pListBox->IsItemSelected(i)) {
- m_pWidget->SetOptionSelection(i, TRUE, FALSE);
- aNewSelect.Add(i);
- }
- }
- } else {
- m_pWidget->SetOptionSelection(pListBox->GetCurSel(), TRUE, FALSE);
- aNewSelect.Add(pListBox->GetCurSel());
+ int32_t nNewTopIndex = pListBox->GetTopVisibleIndex();
+ m_pWidget->ClearSelection(FALSE);
+ if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
+ for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) {
+ if (pListBox->IsItemSelected(i))
+ m_pWidget->SetOptionSelection(i, TRUE, FALSE);
}
-
- m_pWidget->SetTopVisibleIndex(nNewTopIndex);
- m_pWidget->ResetFieldAppearance(TRUE);
- m_pWidget->UpdateField();
- SetChangeMark();
+ } else {
+ m_pWidget->SetOptionSelection(pListBox->GetCurSel(), TRUE, FALSE);
}
+ m_pWidget->SetTopVisibleIndex(nNewTopIndex);
+ m_pWidget->ResetFieldAppearance(TRUE);
+ m_pWidget->UpdateField();
+ SetChangeMark();
}
void CFFL_ListBox::GetActionData(CPDFSDK_PageView* pPageView,
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdf_ext.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdf_ext.cpp
index a1009c5cdf4..8a45a13e120 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdf_ext.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdf_ext.cpp
@@ -13,7 +13,7 @@
#include "fpdfsdk/include/fsdk_define.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
#endif // PDF_ENABLE_XFA
#define FPDFSDK_UNSUPPORT_CALL 100
@@ -105,7 +105,7 @@ FX_BOOL CheckSharedForm(const CXML_Element* pElement, CFX_ByteString cbName) {
if (space == "xmlns" && name == "adhocwf" &&
value == L"http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/") {
CXML_Element* pVersion =
- pElement->GetElement("adhocwf", cbName.AsByteStringC());
+ pElement->GetElement("adhocwf", cbName.AsStringC());
if (!pVersion)
continue;
CFX_WideString wsContent = pVersion->GetContent(0);
@@ -163,8 +163,7 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) {
CPDF_Dictionary* pJSDict = pNameDict->GetDictBy("JavaScript");
CPDF_Array* pArray = pJSDict ? pJSDict->GetArrayBy("Names") : NULL;
if (pArray) {
- int nCount = pArray->GetCount();
- for (int i = 0; i < nCount; i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
CFX_ByteString cbStr = pArray->GetStringAt(i);
if (cbStr.Compare("com.adobe.acrobat.SharedReview.Register") == 0) {
FPDF_UnSupportError(FPDF_UNSP_DOC_SHAREDREVIEW);
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdf_flatten.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdf_flatten.cpp
index bbd5ad3dd3d..fe81246a0b5 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdf_flatten.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdf_flatten.cpp
@@ -45,9 +45,8 @@ FX_BOOL IsValiableRect(CFX_FloatRect rect, CFX_FloatRect rcPage) {
void GetContentsRect(CPDF_Document* pDoc,
CPDF_Dictionary* pDict,
CPDF_RectArray* pRectArray) {
- std::unique_ptr<CPDF_Page> pPDFPage(new CPDF_Page);
- pPDFPage->Load(pDoc, pDict, FALSE);
- pPDFPage->ParseContent(nullptr);
+ std::unique_ptr<CPDF_Page> pPDFPage(new CPDF_Page(pDoc, pDict, false));
+ pPDFPage->ParseContent();
for (auto& pPageObject : *pPDFPage->GetPageObjectList()) {
if (!pPageObject)
@@ -201,7 +200,7 @@ void SetPageContents(CFX_ByteString key,
CFX_ByteString sStream;
sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str());
- pNewContents->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE,
+ pNewContents->SetData(sStream.raw_str(), sStream.GetLength(), FALSE,
FALSE);
}
return;
@@ -220,8 +219,7 @@ void SetPageContents(CFX_ByteString key,
CFX_ByteString sBody =
CFX_ByteString((const FX_CHAR*)acc.GetData(), acc.GetSize());
sStream = sStream + sBody + "\nQ";
- pContents->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE,
- FALSE);
+ pContents->SetData(sStream.raw_str(), sStream.GetLength(), FALSE, FALSE);
pContentsArray->AddReference(pDocument, dwObjNum);
break;
}
@@ -247,8 +245,7 @@ void SetPageContents(CFX_ByteString key,
CFX_ByteString sStream;
sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str());
- pNewContents->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE,
- FALSE);
+ pNewContents->SetData(sStream.raw_str(), sStream.GetLength(), FALSE, FALSE);
}
}
@@ -395,7 +392,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
char sExtend[5] = {};
FXSYS_itoa(iKey, sExtend, 10);
key = CFX_ByteString("FFT") + CFX_ByteString(sExtend);
- if (!pPageXObject->KeyExist(key.AsByteStringC()))
+ if (!pPageXObject->KeyExist(key))
break;
}
}
@@ -405,7 +402,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
CPDF_Dictionary* pNewXORes = NULL;
if (!key.IsEmpty()) {
- pPageXObject->SetAtReference(key.AsByteStringC(), pDocument, dwObjNum);
+ pPageXObject->SetAtReference(key, pDocument, dwObjNum);
CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict();
pNewXORes = new CPDF_Dictionary;
pNewOXbjectDic->SetAt("Resources", pNewXORes);
@@ -437,7 +434,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
continue;
if (!sAnnotState.IsEmpty()) {
- pAPStream = pAPDic->GetStreamBy(sAnnotState.AsByteStringC());
+ pAPStream = pAPDic->GetStreamBy(sAnnotState);
} else {
auto it = pAPDic->begin();
if (it != pAPDic->end()) {
@@ -486,7 +483,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
CFX_ByteString sFormName;
sFormName.Format("F%d", i);
uint32_t dwObjNum = pDocument->AddIndirectObject(pObj);
- pXObject->SetAtReference(sFormName.AsByteStringC(), pDocument, dwObjNum);
+ pXObject->SetAtReference(sFormName, pDocument, dwObjNum);
CPDF_StreamAcc acc;
acc.LoadAllData(pNewXObject);
@@ -508,9 +505,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f,
sFormName.c_str());
sStream += sTemp;
-
- pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE,
- FALSE);
+ pNewXObject->SetData(sStream.raw_str(), sStream.GetLength(), FALSE, FALSE);
}
pPageDict->RemoveAt("Annots");
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdf_progressive.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdf_progressive.cpp
index 1450f8e74b2..d42d954bb9f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdf_progressive.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdf_progressive.cpp
@@ -41,21 +41,12 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
CRenderContext* pContext = new CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
-#ifdef _SKIA_SUPPORT_
- pContext->m_pDevice = new CFX_SkiaDevice;
- if (flags & FPDF_REVERSE_BYTE_ORDER)
- ((CFX_SkiaDevice*)pContext->m_pDevice)
- ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
- else
- ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
-#else
pContext->m_pDevice = new CFX_FxgeDevice;
if (flags & FPDF_REVERSE_BYTE_ORDER)
((CFX_FxgeDevice*)pContext->m_pDevice)
->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
else
((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
-#endif
IFSDK_PAUSE_Adapter IPauseAdapter(pause);
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdf_searchex.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdf_searchex.cpp
index ab2baf529c2..9c987f2691a 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdf_searchex.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdf_searchex.cpp
@@ -6,11 +6,12 @@
#include "public/fpdf_searchex.h"
-#include "core/fpdftext/include/ipdf_textpage.h"
+#include "core/fpdftext/include/cpdf_textpage.h"
DLLEXPORT int STDCALL
FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex) {
if (!text_page)
return -1;
- return ((IPDF_TextPage*)text_page)->CharIndexFromTextIndex(nTextIndex);
+ return static_cast<CPDF_TextPage*>(text_page)
+ ->CharIndexFromTextIndex(nTextIndex);
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdf_sysfontinfo.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdf_sysfontinfo.cpp
index 7fe4b08e469..d5ee7d186fa 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -152,7 +152,7 @@ static unsigned long DefaultGetFaceName(struct _FPDF_SYSFONTINFO* pThis,
return 0;
if (name.GetLength() >= (long)buf_size)
return name.GetLength() + 1;
- FXSYS_strcpy(buffer, name);
+ FXSYS_strcpy(buffer, name.c_str());
return name.GetLength() + 1;
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdf_transformpage.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdf_transformpage.cpp
index d47cb02b1d3..5fe6e4ebccf 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdf_transformpage.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdf_transformpage.cpp
@@ -20,36 +20,34 @@
namespace {
void SetBoundingBox(CPDF_Page* page,
- const CFX_ByteStringC& key,
+ const CFX_ByteString& key,
float left,
float bottom,
float right,
float top) {
- CPDF_Dictionary* pPageDict = page->m_pFormDict;
CPDF_Array* pBoundingBoxArray = new CPDF_Array;
pBoundingBoxArray->Add(new CPDF_Number(left));
pBoundingBoxArray->Add(new CPDF_Number(bottom));
pBoundingBoxArray->Add(new CPDF_Number(right));
pBoundingBoxArray->Add(new CPDF_Number(top));
- pPageDict->SetAt(key, pBoundingBoxArray);
+ page->m_pFormDict->SetAt(key, pBoundingBoxArray);
}
-FPDF_BOOL GetBoundingBox(CPDF_Page* page,
- const CFX_ByteStringC& key,
- float* left,
- float* bottom,
- float* right,
- float* top) {
- CPDF_Dictionary* pPageDict = page->m_pFormDict;
- CPDF_Array* pArray = pPageDict->GetArrayBy(key);
+bool GetBoundingBox(CPDF_Page* page,
+ const CFX_ByteString& key,
+ float* left,
+ float* bottom,
+ float* right,
+ float* top) {
+ CPDF_Array* pArray = page->m_pFormDict->GetArrayBy(key);
if (!pArray)
- return FALSE;
+ return false;
*left = pArray->GetFloatAt(0);
*bottom = pArray->GetFloatAt(1);
*right = pArray->GetFloatAt(2);
*top = pArray->GetFloatAt(3);
- return TRUE;
+ return true;
}
} // namespace
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfdoc.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfdoc.cpp
index c9030e50350..7473cb06711 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfdoc.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfdoc.cpp
@@ -286,14 +286,14 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page,
CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayBy("Annots");
if (!pAnnots)
return FALSE;
- for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) {
+ for (size_t i = *startPos; i < pAnnots->GetCount(); i++) {
CPDF_Dictionary* pDict =
ToDictionary(static_cast<CPDF_Object*>(pAnnots->GetDirectObjectAt(i)));
if (!pDict)
continue;
if (pDict->GetStringBy("Subtype") == "Link") {
- *startPos = i + 1;
- *linkAnnot = (FPDF_LINK)pDict;
+ *startPos = static_cast<int>(i + 1);
+ *linkAnnot = static_cast<FPDF_LINK>(pDict);
return TRUE;
}
}
@@ -322,7 +322,7 @@ DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) {
CPDF_Array* pArray = pAnnotDict->GetArrayBy("QuadPoints");
if (!pArray)
return 0;
- return pArray->GetCount() / 8;
+ return static_cast<int>(pArray->GetCount() / 8);
}
DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot,
@@ -334,8 +334,9 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot,
ToDictionary(static_cast<CPDF_Object*>(linkAnnot));
CPDF_Array* pArray = pAnnotDict->GetArrayBy("QuadPoints");
if (pArray) {
- if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount() / 8 ||
- ((quadIndex * 8 + 7) >= (int)pArray->GetCount()))
+ if (quadIndex < 0 ||
+ static_cast<size_t>(quadIndex) >= pArray->GetCount() / 8 ||
+ (static_cast<size_t>(quadIndex * 8 + 7) >= pArray->GetCount()))
return FALSE;
quadPoints->x1 = pArray->GetNumberAt(quadIndex * 8);
quadPoints->y1 = pArray->GetNumberAt(quadIndex * 8 + 1);
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfdoc_embeddertest.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfdoc_embeddertest.cpp
index 855235858b2..2450b6aea61 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfdoc_embeddertest.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfdoc_embeddertest.cpp
@@ -6,6 +6,7 @@
#include "core/fxcrt/include/fx_string.h"
#include "public/fpdf_doc.h"
+#include "public/fpdf_edit.h"
#include "public/fpdfview.h"
#include "testing/embedder_test.h"
#include "testing/fx_string_testhelpers.h"
@@ -138,3 +139,10 @@ TEST_F(FPDFDocEmbeddertest, FindBookmarks_bug420) {
GetFPDFWideString(L"anything");
EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), title.get()));
}
+
+TEST_F(FPDFDocEmbeddertest, DeletePage) {
+ EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ EXPECT_EQ(1, FPDF_GetPageCount(document()));
+ FPDFPage_Delete(document(), 0);
+ EXPECT_EQ(0, FPDF_GetPageCount(document()));
+}
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfdoc_unittest.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfdoc_unittest.cpp
index bf94aefa6eb..eb04de69711 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfdoc_unittest.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfdoc_unittest.cpp
@@ -13,17 +13,19 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
#endif // PDF_ENABLE_XFA
class CPDF_TestDocument : public CPDF_Document {
public:
+ CPDF_TestDocument() : CPDF_Document(nullptr) {}
+
void SetRoot(CPDF_Dictionary* root) { m_pRootDict = root; }
CPDF_IndirectObjectHolder* GetHolder() { return this; }
};
@@ -58,7 +60,6 @@ class PDFDocTest : public testing::Test {
CPDF_ModuleMgr::Create();
CPDF_ModuleMgr* module_mgr = CPDF_ModuleMgr::Get();
module_mgr->InitPageModule();
- module_mgr->InitRenderModule();
m_pDoc.reset(new CPDF_TestPdfDocument());
m_pIndirectObjs = m_pDoc->GetHolder();
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfedit_embeddertest.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfedit_embeddertest.cpp
index 480ef51dbd0..720dcdec019 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -11,50 +11,60 @@
class FPDFEditEmbeddertest : public EmbedderTest, public TestSaver {};
+namespace {
+const char kExpectedPDF[] =
+ "%PDF-1.7\r\n"
+ "%\xA1\xB3\xC5\xD7\r\n"
+ "1 0 obj\r\n"
+ "<</Pages 2 0 R /Type/Catalog>>\r\n"
+ "endobj\r\n"
+ "2 0 obj\r\n"
+ "<</Count 1/Kids\\[ 4 0 R \\]/Type/Pages>>\r\n"
+ "endobj\r\n"
+ "3 0 obj\r\n"
+ "<</CreationDate\\(D:.*\\)/Creator\\(PDFium\\)>>\r\n"
+ "endobj\r\n"
+ "4 0 obj\r\n"
+ "<</Contents 5 0 R /MediaBox\\[ 0 0 640 480\\]"
+ "/Parent 2 0 R /Resources<<>>/Rotate 0/Type/Page"
+ ">>\r\n"
+ "endobj\r\n"
+ "5 0 obj\r\n"
+ "<</Filter/FlateDecode/Length 8>>stream\r\n"
+ // Character '_' is matching '\0' (see comment below).
+ "x\x9C\x3____\x1\r\n"
+ "endstream\r\n"
+ "endobj\r\n"
+ "xref\r\n"
+ "0 6\r\n"
+ "0000000000 65535 f\r\n"
+ "0000000017 00000 n\r\n"
+ "0000000066 00000 n\r\n"
+ "0000000122 00000 n\r\n"
+ "0000000192 00000 n\r\n"
+ "0000000301 00000 n\r\n"
+ "trailer\r\n"
+ "<<\r\n"
+ "/Root 1 0 R\r\n"
+ "/Info 3 0 R\r\n"
+ "/Size 6/ID\\[<.*><.*>\\]>>\r\n"
+ "startxref\r\n"
+ "379\r\n"
+ "%%EOF\r\n";
+} // namespace
+
TEST_F(FPDFEditEmbeddertest, EmptyCreation) {
EXPECT_TRUE(CreateEmptyDocument());
FPDF_PAGE page = FPDFPage_New(document(), 1, 640.0, 480.0);
EXPECT_NE(nullptr, page);
EXPECT_TRUE(FPDFPage_GenerateContent(page));
EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
- EXPECT_THAT(GetString(),
- testing::MatchesRegex(
- "%PDF-1.7\r\n"
- "%\xA1\xB3\xC5\xD7\r\n"
- "1 0 obj\r\n"
- "<</Pages 2 0 R /Type/Catalog>>\r\n"
- "endobj\r\n"
- "2 0 obj\r\n"
- "<</Count 1/Kids\\[ 4 0 R \\]/Type/Pages>>\r\n"
- "endobj\r\n"
- "3 0 obj\r\n"
- "<</CreationDate\\(D:.*\\)/Creator\\(PDFium\\)>>\r\n"
- "endobj\r\n"
- "4 0 obj\r\n"
- "<</Contents 5 0 R /MediaBox\\[ 0 0 640 480\\]"
- "/Parent 2 0 R /Resources<<>>/Rotate 0/Type/Page"
- ">>\r\n"
- "endobj\r\n"
- "5 0 obj\r\n"
- "<</Filter/FlateDecode/Length 8>>stream\r\n"
- "x\x9C\x3\0\0\0\0\x1\r\n"
- "endstream\r\n"
- "endobj\r\n"
- "xref\r\n"
- "0 6\r\n"
- "0000000000 65535 f\r\n"
- "0000000017 00000 n\r\n"
- "0000000066 00000 n\r\n"
- "0000000122 00000 n\r\n"
- "0000000192 00000 n\r\n"
- "0000000301 00000 n\r\n"
- "trailer\r\n"
- "<<\r\n"
- "/Root 1 0 R\r\n"
- "/Info 3 0 R\r\n"
- "/Size 6/ID\\[<.*><.*>\\]>>\r\n"
- "startxref\r\n"
- "379\r\n"
- "%%EOF\r\n"));
+
+ // The MatchesRegexp doesn't support embedded NUL ('\0') characters. They are
+ // replaced by '_' for the purpose of the test.
+ std::string result = GetString();
+ std::replace(result.begin(), result.end(), '\0', '_');
+ EXPECT_THAT(result, testing::MatchesRegex(
+ std::string(kExpectedPDF, sizeof(kExpectedPDF))));
FPDFPage_Delete(document(), 1);
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfeditpage.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfeditpage.cpp
index 25ace0e039b..576d9fb7785 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfeditpage.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfeditpage.cpp
@@ -24,9 +24,9 @@
#include "third_party/base/stl_util.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
#endif // PDF_ENABLE_XFA
#if _FX_OS_ == _FX_ANDROID_
@@ -36,7 +36,7 @@
#endif
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() {
- CPDF_Document* pDoc = new CPDF_Document;
+ CPDF_Document* pDoc = new CPDF_Document(nullptr);
pDoc->CreateNewDoc();
time_t currentTime;
@@ -100,9 +100,8 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
new CPDFXFA_Page((CPDFXFA_Document*)document, page_index);
pPage->LoadPDFPage(pPageDict);
#else // PDF_ENABLE_XFA
- CPDF_Page* pPage = new CPDF_Page;
- pPage->Load(pDoc, pPageDict);
- pPage->ParseContent(nullptr);
+ CPDF_Page* pPage = new CPDF_Page(pDoc, pPageDict, true);
+ pPage->ParseContent();
#endif // PDF_ENABLE_XFA
return pPage;
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfformfill.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfformfill.cpp
index 26bc30e07cb..f949da1019d 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfformfill.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfformfill.cpp
@@ -18,13 +18,13 @@
#include "third_party/base/stl_util.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#endif // PDF_ENABLE_XFA
namespace {
@@ -91,10 +91,9 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
if (!pWidgetHandler)
return -1;
- std::unique_ptr<IXFA_WidgetIterator, ReleaseDeleter<IXFA_WidgetIterator>>
- pWidgetIterator(pPageView->CreateWidgetIterator(
- XFA_TRAVERSEWAY_Form,
- XFA_WIDGETFILTER_Viewable | XFA_WIDGETFILTER_AllType));
+ std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator(
+ pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form,
+ XFA_WidgetStatus_Viewable));
if (!pWidgetIterator)
return -1;
@@ -342,11 +341,9 @@ static void FFLCommon(FPDF_FORMHANDLE hHandle,
FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
+ std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
#ifdef _SKIA_SUPPORT_
- std::unique_ptr<CFX_SkiaDevice> pDevice(new CFX_SkiaDevice());
pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder));
-#else
- std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
#endif
pDevice->Attach((CFX_DIBitmap*)bitmap);
pDevice->SaveState();
@@ -597,8 +594,7 @@ FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle,
uint32_t real_size = len < *size ? len : *size;
if (real_size > 0)
- FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(*sSuggestWords)[index],
- real_size);
+ FXSYS_memcpy((void*)bsText, (*sSuggestWords)[index].c_str(), real_size);
*size = real_size;
return TRUE;
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfppo.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfppo.cpp
index 21d8c7d9aeb..97fd390cb3c 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfppo.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfppo.cpp
@@ -32,7 +32,7 @@ class CPDF_PageOrganizer {
CPDF_Document* pDestPDFDoc,
int nIndex);
CPDF_Object* PageDictGetInheritableTag(CPDF_Dictionary* pDict,
- CFX_ByteString nSrctag);
+ const CFX_ByteString& bsSrctag);
FX_BOOL UpdateReference(CPDF_Object* pObj,
CPDF_Document* pDoc,
ObjectNumberMap* pObjNumberMap);
@@ -110,9 +110,9 @@ FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc,
const CFX_ByteString& cbSrcKeyStr = it.first;
CPDF_Object* pObj = it.second;
if (cbSrcKeyStr.Compare(("Type")) && cbSrcKeyStr.Compare(("Parent"))) {
- if (pCurPageDict->KeyExist(cbSrcKeyStr.AsByteStringC()))
- pCurPageDict->RemoveAt(cbSrcKeyStr.AsByteStringC());
- pCurPageDict->SetAt(cbSrcKeyStr.AsByteStringC(), pObj->Clone());
+ if (pCurPageDict->KeyExist(cbSrcKeyStr))
+ pCurPageDict->RemoveAt(cbSrcKeyStr);
+ pCurPageDict->SetAt(cbSrcKeyStr, pObj->Clone());
}
}
@@ -175,8 +175,8 @@ FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc,
CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
CPDF_Dictionary* pDict,
- CFX_ByteString nSrctag) {
- if (!pDict || nSrctag.IsEmpty())
+ const CFX_ByteString& bsSrcTag) {
+ if (!pDict || bsSrcTag.IsEmpty())
return nullptr;
if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type"))
return nullptr;
@@ -191,12 +191,12 @@ CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
if (!pp)
return nullptr;
- if (pDict->KeyExist((const char*)nSrctag))
- return pDict->GetObjectBy((const char*)nSrctag);
+ if (pDict->KeyExist(bsSrcTag))
+ return pDict->GetObjectBy(bsSrcTag);
while (pp) {
- if (pp->KeyExist((const char*)nSrctag))
- return pp->GetObjectBy((const char*)nSrctag);
+ if (pp->KeyExist(bsSrcTag))
+ return pp->GetObjectBy(bsSrcTag);
if (!pp->KeyExist("Parent"))
break;
pp = ToDictionary(pp->GetObjectBy("Parent")->GetDirect());
@@ -223,13 +223,14 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
const CFX_ByteString& key = it->first;
CPDF_Object* pNextObj = it->second;
++it;
- if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") ||
- !FXSYS_strcmp(key, "First")) {
+ if (!FXSYS_strcmp(key.c_str(), "Parent") ||
+ !FXSYS_strcmp(key.c_str(), "Prev") ||
+ !FXSYS_strcmp(key.c_str(), "First")) {
continue;
}
if (pNextObj) {
if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
- pDict->RemoveAt(key.AsByteStringC());
+ pDict->RemoveAt(key);
} else {
return FALSE;
}
@@ -238,8 +239,7 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
}
case CPDF_Object::ARRAY: {
CPDF_Array* pArray = pObj->AsArray();
- uint32_t count = pArray->GetCount();
- for (uint32_t i = 0; i < count; ++i) {
+ for (size_t i = 0; i < pArray->GetCount(); ++i) {
CPDF_Object* pNextObj = pArray->GetObjectAt(i);
if (!pNextObj)
return FALSE;
@@ -291,11 +291,11 @@ uint32_t CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
if (CPDF_Dictionary* pDictClone = pClone->AsDictionary()) {
if (pDictClone->KeyExist("Type")) {
CFX_ByteString strType = pDictClone->GetStringBy("Type");
- if (!FXSYS_stricmp(strType, "Pages")) {
+ if (!FXSYS_stricmp(strType.c_str(), "Pages")) {
pDictClone->Release();
return 4;
}
- if (!FXSYS_stricmp(strType, "Page")) {
+ if (!FXSYS_stricmp(strType.c_str(), "Page")) {
pDictClone->Release();
return 0;
}
@@ -331,12 +331,12 @@ FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring,
cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom);
int nMid = cbMidRange.Find('-');
if (nMid == -1) {
- long lPageNum = atol(cbMidRange);
+ long lPageNum = atol(cbMidRange.c_str());
if (lPageNum <= 0 || lPageNum > nCount)
return FALSE;
pageArray->push_back((uint16_t)lPageNum);
} else {
- int nStartPageNum = atol(cbMidRange.Mid(0, nMid));
+ int nStartPageNum = atol(cbMidRange.Mid(0, nMid).c_str());
if (nStartPageNum == 0)
return FALSE;
@@ -345,7 +345,7 @@ FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring,
if (nEnd == 0)
return FALSE;
- int nEndPageNum = atol(cbMidRange.Mid(nMid, nEnd));
+ int nEndPageNum = atol(cbMidRange.Mid(nMid, nEnd).c_str());
if (nStartPageNum < 0 || nStartPageNum > nEndPageNum ||
nEndPageNum > nCount) {
return FALSE;
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfsave.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfsave.cpp
index 11a22ac8547..c67db816a99 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfsave.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfsave.cpp
@@ -19,14 +19,14 @@
#include "public/fpdf_edit.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
#include "public/fpdf_formfill.h"
-#include "xfa/include/fxfa/xfa_checksum.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/include/xfa_checksum.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
#endif
#if _FX_OS_ == _FX_ANDROID_
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdftext.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdftext.cpp
index 24b592a88be..1596fd25849 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdftext.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdftext.cpp
@@ -7,25 +7,44 @@
#include "public/fpdf_text.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
-#include "core/fpdftext/include/ipdf_linkextract.h"
-#include "core/fpdftext/include/ipdf_textpage.h"
-#include "core/fpdftext/include/ipdf_textpagefind.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
+#include "core/fpdftext/include/cpdf_linkextract.h"
+#include "core/fpdftext/include/cpdf_textpage.h"
+#include "core/fpdftext/include/cpdf_textpagefind.h"
#include "fpdfsdk/include/fsdk_define.h"
+#include "third_party/base/numerics/safe_conversions.h"
+#include "third_party/base/stl_util.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
#endif // PDF_ENABLE_XFA
#ifdef _WIN32
#include <tchar.h>
#endif
+namespace {
+
+CPDF_TextPage* CPDFTextPageFromFPDFTextPage(FPDF_TEXTPAGE text_page) {
+ return static_cast<CPDF_TextPage*>(text_page);
+}
+
+CPDF_TextPageFind* CPDFTextPageFindFromFPDFSchHandle(FPDF_SCHHANDLE handle) {
+ return static_cast<CPDF_TextPageFind*>(handle);
+}
+
+CPDF_LinkExtract* CPDFLinkExtractFromFPDFPageLink(FPDF_PAGELINK link) {
+ return static_cast<CPDF_LinkExtract*>(link);
+}
+
+} // namespace
+
DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) {
CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
if (!pPDFPage)
return nullptr;
+
#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
CPDFXFA_Document* pDoc = pPage->GetDocument();
@@ -33,18 +52,23 @@ DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) {
#else // PDF_ENABLE_XFA
CPDF_ViewerPreferences viewRef(pPDFPage->m_pDocument);
#endif // PDF_ENABLE_XFA
- IPDF_TextPage* textpage =
- IPDF_TextPage::CreateTextPage(pPDFPage, viewRef.IsDirectionR2L());
+
+ CPDF_TextPage* textpage = new CPDF_TextPage(
+ pPDFPage, viewRef.IsDirectionR2L() ? FPDFText_Direction::Right
+ : FPDFText_Direction::Left);
textpage->ParseTextPage();
return textpage;
}
+
DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page) {
- delete (IPDF_TextPage*)text_page;
+ delete CPDFTextPageFromFPDFTextPage(text_page);
}
+
DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page) {
if (!text_page)
return -1;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
return textpage->CountChars();
}
@@ -52,8 +76,8 @@ DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page,
int index) {
if (!text_page)
return 0;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
if (index < 0 || index >= textpage->CountChars())
return 0;
@@ -66,7 +90,7 @@ DLLEXPORT double STDCALL FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
int index) {
if (!text_page)
return 0;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
if (index < 0 || index >= textpage->CountChars())
return 0;
@@ -84,7 +108,7 @@ DLLEXPORT void STDCALL FPDFText_GetCharBox(FPDF_TEXTPAGE text_page,
double* top) {
if (!text_page)
return;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
if (index < 0 || index >= textpage->CountChars())
return;
@@ -104,7 +128,8 @@ DLLEXPORT int STDCALL FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page,
double yTolerance) {
if (!text_page)
return -3;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
return textpage->GetIndexAtPos((FX_FLOAT)x, (FX_FLOAT)y, (FX_FLOAT)xTolerance,
(FX_FLOAT)yTolerance);
}
@@ -115,8 +140,8 @@ DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page,
unsigned short* result) {
if (!text_page)
return 0;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
if (start >= textpage->CountChars())
return 0;
@@ -137,9 +162,11 @@ DLLEXPORT int STDCALL FPDFText_CountRects(FPDF_TEXTPAGE text_page,
int count) {
if (!text_page)
return 0;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
return textpage->CountRects(start, count);
}
+
DLLEXPORT void STDCALL FPDFText_GetRect(FPDF_TEXTPAGE text_page,
int rect_index,
double* left,
@@ -148,7 +175,8 @@ DLLEXPORT void STDCALL FPDFText_GetRect(FPDF_TEXTPAGE text_page,
double* bottom) {
if (!text_page)
return;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
CFX_FloatRect rect;
textpage->GetRect(rect_index, rect.left, rect.top, rect.right, rect.bottom);
*left = rect.left;
@@ -166,14 +194,14 @@ DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page,
int buflen) {
if (!text_page)
return 0;
- IPDF_TextPage* textpage = (IPDF_TextPage*)text_page;
+
+ CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
CFX_FloatRect rect((FX_FLOAT)left, (FX_FLOAT)bottom, (FX_FLOAT)right,
(FX_FLOAT)top);
CFX_WideString str = textpage->GetTextByRect(rect);
- if (buflen <= 0 || !buffer) {
+ if (buflen <= 0 || !buffer)
return str.GetLength();
- }
CFX_ByteString cbUTF16Str = str.UTF16LE_Encode();
int len = cbUTF16Str.GetLength() / sizeof(unsigned short);
@@ -192,91 +220,107 @@ DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page,
unsigned long flags,
int start_index) {
if (!text_page)
- return NULL;
- IPDF_TextPageFind* textpageFind = NULL;
- textpageFind = IPDF_TextPageFind::CreatePageFind((IPDF_TextPage*)text_page);
+ return nullptr;
+
+ CPDF_TextPageFind* textpageFind =
+ new CPDF_TextPageFind(CPDFTextPageFromFPDFTextPage(text_page));
FX_STRSIZE len = CFX_WideString::WStringLength(findwhat);
textpageFind->FindFirst(CFX_WideString::FromUTF16LE(findwhat, len), flags,
start_index);
return textpageFind;
}
+
DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle) {
if (!handle)
return FALSE;
- IPDF_TextPageFind* textpageFind = (IPDF_TextPageFind*)handle;
+
+ CPDF_TextPageFind* textpageFind = CPDFTextPageFindFromFPDFSchHandle(handle);
return textpageFind->FindNext();
}
+
DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindPrev(FPDF_SCHHANDLE handle) {
if (!handle)
return FALSE;
- IPDF_TextPageFind* textpageFind = (IPDF_TextPageFind*)handle;
+
+ CPDF_TextPageFind* textpageFind = CPDFTextPageFindFromFPDFSchHandle(handle);
return textpageFind->FindPrev();
}
+
DLLEXPORT int STDCALL FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle) {
if (!handle)
return 0;
- IPDF_TextPageFind* textpageFind = (IPDF_TextPageFind*)handle;
+
+ CPDF_TextPageFind* textpageFind = CPDFTextPageFindFromFPDFSchHandle(handle);
return textpageFind->GetCurOrder();
}
+
DLLEXPORT int STDCALL FPDFText_GetSchCount(FPDF_SCHHANDLE handle) {
if (!handle)
return 0;
- IPDF_TextPageFind* textpageFind = (IPDF_TextPageFind*)handle;
+
+ CPDF_TextPageFind* textpageFind = CPDFTextPageFindFromFPDFSchHandle(handle);
return textpageFind->GetMatchedCount();
}
+
DLLEXPORT void STDCALL FPDFText_FindClose(FPDF_SCHHANDLE handle) {
if (!handle)
return;
- IPDF_TextPageFind* textpageFind = (IPDF_TextPageFind*)handle;
+
+ CPDF_TextPageFind* textpageFind = CPDFTextPageFindFromFPDFSchHandle(handle);
delete textpageFind;
- handle = NULL;
+ handle = nullptr;
}
// web link
DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page) {
if (!text_page)
- return NULL;
- IPDF_LinkExtract* pageLink = NULL;
- pageLink = IPDF_LinkExtract::CreateLinkExtract();
- pageLink->ExtractLinks((IPDF_TextPage*)text_page);
+ return nullptr;
+
+ CPDF_LinkExtract* pageLink =
+ new CPDF_LinkExtract(CPDFTextPageFromFPDFTextPage(text_page));
+ pageLink->ExtractLinks();
return pageLink;
}
+
DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page) {
if (!link_page)
return 0;
- IPDF_LinkExtract* pageLink = (IPDF_LinkExtract*)link_page;
- return pageLink->CountLinks();
+
+ CPDF_LinkExtract* pageLink = CPDFLinkExtractFromFPDFPageLink(link_page);
+ return pdfium::base::checked_cast<int>(pageLink->CountLinks());
}
+
DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page,
int link_index,
unsigned short* buffer,
int buflen) {
- if (!link_page)
- return 0;
- IPDF_LinkExtract* pageLink = (IPDF_LinkExtract*)link_page;
- CFX_WideString url = pageLink->GetURL(link_index);
-
- CFX_ByteString cbUTF16URL = url.UTF16LE_Encode();
- int len = cbUTF16URL.GetLength() / sizeof(unsigned short);
+ CFX_WideString wsUrl(L"");
+ if (link_page && link_index >= 0) {
+ CPDF_LinkExtract* pageLink = CPDFLinkExtractFromFPDFPageLink(link_page);
+ wsUrl = pageLink->GetURL(link_index);
+ }
+ CFX_ByteString cbUTF16URL = wsUrl.UTF16LE_Encode();
+ int required = cbUTF16URL.GetLength() / sizeof(unsigned short);
if (!buffer || buflen <= 0)
- return len;
- int size = len < buflen ? len : buflen;
+ return required;
+
+ int size = std::min(required, buflen);
if (size > 0) {
- FXSYS_memcpy(buffer, cbUTF16URL.GetBuffer(size * sizeof(unsigned short)),
- size * sizeof(unsigned short));
- cbUTF16URL.ReleaseBuffer(size * sizeof(unsigned short));
+ int buf_size = size * sizeof(unsigned short);
+ FXSYS_memcpy(buffer, cbUTF16URL.GetBuffer(buf_size), buf_size);
}
return size;
}
+
DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page,
int link_index) {
- if (!link_page)
+ if (!link_page || link_index < 0)
return 0;
- IPDF_LinkExtract* pageLink = (IPDF_LinkExtract*)link_page;
- CFX_RectArray rectArray;
- pageLink->GetRects(link_index, rectArray);
- return rectArray.GetSize();
+
+ CPDF_LinkExtract* pageLink = CPDFLinkExtractFromFPDFPageLink(link_page);
+ return pdfium::CollectionSize<int>(pageLink->GetRects(link_index));
}
+
DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page,
int link_index,
int rect_index,
@@ -284,19 +328,20 @@ DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page,
double* top,
double* right,
double* bottom) {
- if (!link_page)
+ if (!link_page || link_index < 0 || rect_index < 0)
return;
- IPDF_LinkExtract* pageLink = (IPDF_LinkExtract*)link_page;
- CFX_RectArray rectArray;
- pageLink->GetRects(link_index, rectArray);
- if (rect_index >= 0 && rect_index < rectArray.GetSize()) {
- CFX_FloatRect rect = rectArray.GetAt(rect_index);
- *left = rect.left;
- *right = rect.right;
- *top = rect.top;
- *bottom = rect.bottom;
- }
+
+ CPDF_LinkExtract* pageLink = CPDFLinkExtractFromFPDFPageLink(link_page);
+ std::vector<CFX_FloatRect> rectArray = pageLink->GetRects(link_index);
+ if (rect_index >= pdfium::CollectionSize<int>(rectArray))
+ return;
+
+ *left = rectArray[rect_index].left;
+ *right = rectArray[rect_index].right;
+ *top = rectArray[rect_index].top;
+ *bottom = rectArray[rect_index].bottom;
}
+
DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) {
- delete (IPDF_LinkExtract*)link_page;
+ delete CPDFLinkExtractFromFPDFPageLink(link_page);
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp
index e5a53da7399..020ff8df6d5 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfview.cpp
@@ -13,8 +13,8 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcrt/include/fx_safe_types.h"
-#include "core/include/fxcodec/fx_codec.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
#include "fpdfsdk/include/fsdk_rendercontext.h"
@@ -24,10 +24,10 @@
#include "third_party/base/numerics/safe_conversions_impl.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
#include "public/fpdf_formfill.h"
#endif // PDF_ENABLE_XFA
@@ -244,7 +244,7 @@ FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* cfg) {
CPDF_ModuleMgr* pModuleMgr = CPDF_ModuleMgr::Get();
pModuleMgr->SetCodecModule(g_pCodecModule);
pModuleMgr->InitPageModule();
- pModuleMgr->InitRenderModule();
+
#ifdef PDF_ENABLE_XFA
CPDFXFA_App::GetInstance()->Initialize(
(cfg && cfg->version >= 2)
@@ -256,6 +256,7 @@ FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* cfg) {
pModuleMgr->LoadEmbeddedCNS1CMaps();
pModuleMgr->LoadEmbeddedKorea1CMaps();
#endif // PDF_ENABLE_XFA
+
if (cfg && cfg->version >= 2)
IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate);
}
@@ -463,7 +464,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
// header).
DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) {
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
- if (!pDoc)
+ if (!pDoc || !pDoc->GetParser())
#ifndef PDF_ENABLE_XFA
return 0;
#else // PDF_ENABLE_XFA
@@ -476,7 +477,7 @@ DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) {
DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document) {
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
- if (!pDoc)
+ if (!pDoc || !pDoc->GetParser())
return -1;
CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict();
@@ -502,10 +503,10 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
#else // PDF_ENABLE_XFA
CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
if (!pDict)
- return NULL;
- CPDF_Page* pPage = new CPDF_Page;
- pPage->Load(pDoc, pDict);
- pPage->ParseContent(nullptr);
+ return nullptr;
+
+ CPDF_Page* pPage = new CPDF_Page(pDoc, pDict, true);
+ pPage->ParseContent();
return pPage;
#endif // PDF_ENABLE_XFA
}
@@ -548,13 +549,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
pBitmap = new CFX_DIBitmap;
pBitmap->Create(size_x, size_y, FXDIB_Argb);
pBitmap->Clear(0x00ffffff);
-#ifdef _SKIA_SUPPORT_
- pContext->m_pDevice = new CFX_SkiaDevice;
- ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap);
-#else
pContext->m_pDevice = new CFX_FxgeDevice;
((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap);
-#endif
} else {
pContext->m_pDevice = new CFX_WindowsDevice(dc);
}
@@ -647,15 +643,6 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
return;
CRenderContext* pContext = new CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
-#ifdef _SKIA_SUPPORT_
- pContext->m_pDevice = new CFX_SkiaDevice();
-
- if (flags & FPDF_REVERSE_BYTE_ORDER)
- ((CFX_SkiaDevice*)pContext->m_pDevice)
- ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
- else
- ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
-#else
pContext->m_pDevice = new CFX_FxgeDevice;
if (flags & FPDF_REVERSE_BYTE_ORDER)
@@ -663,7 +650,6 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
else
((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
-#endif
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
rotate, flags, TRUE, NULL);
@@ -681,7 +667,7 @@ DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
return nullptr;
std::unique_ptr<CRenderContext> pContext(new CRenderContext);
pPage->SetPrivateData((void*)1, pContext.get(), DropContext);
- CFX_SkiaDevice* skDevice = new CFX_SkiaDevice();
+ CFX_FxgeDevice* skDevice = new CFX_FxgeDevice;
FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y);
pContext->m_pDevice = skDevice;
@@ -834,11 +820,7 @@ DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
FPDF_DWORD color) {
if (!bitmap)
return;
-#ifdef _SKIA_SUPPORT_
- CFX_SkiaDevice device;
-#else
CFX_FxgeDevice device;
-#endif
device.Attach((CFX_DIBitmap*)bitmap);
if (!((CFX_DIBitmap*)bitmap)->HasAlpha())
color |= 0xFF000000;
@@ -958,8 +940,8 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
if (!pDict)
return FALSE;
- CPDF_Page page;
- page.Load(pDoc, pDict);
+
+ CPDF_Page page(pDoc, pDict, true);
*width = page.GetPageWidth();
*height = page.GetPageHeight();
#endif // PDF_ENABLE_XFA
@@ -1044,7 +1026,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
}
#ifdef PDF_ENABLE_XFA
-FPDF_RESULT FPDF_BStr_Init(FPDF_BSTR* str) {
+DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str) {
if (!str)
return -1;
@@ -1052,7 +1034,9 @@ FPDF_RESULT FPDF_BStr_Init(FPDF_BSTR* str) {
return 0;
}
-FPDF_RESULT FPDF_BStr_Set(FPDF_BSTR* str, FPDF_LPCSTR bstr, int length) {
+DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
+ FPDF_LPCSTR bstr,
+ int length) {
if (!str)
return -1;
if (!bstr || !length)
@@ -1084,7 +1068,7 @@ FPDF_RESULT FPDF_BStr_Set(FPDF_BSTR* str, FPDF_LPCSTR bstr, int length) {
return 0;
}
-FPDF_RESULT FPDF_BStr_Clear(FPDF_BSTR* str) {
+DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str) {
if (!str)
return -1;
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfview_embeddertest.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfview_embeddertest.cpp
index 10fe3aa8222..80b39b5b9cb 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfview_embeddertest.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfview_embeddertest.cpp
@@ -29,6 +29,36 @@ TEST_F(FPDFViewEmbeddertest, Document) {
EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document()));
}
+// See bug 465.
+TEST_F(FPDFViewEmbeddertest, EmptyDocument) {
+ EXPECT_TRUE(CreateEmptyDocument());
+
+ {
+ int version = 42;
+ EXPECT_FALSE(FPDF_GetFileVersion(document(), &version));
+ EXPECT_EQ(0, version);
+ }
+
+ {
+#ifndef PDF_ENABLE_XFA
+ const unsigned long kExpected = 0;
+#else
+ const unsigned long kExpected = static_cast<uint32_t>(-1);
+#endif
+ EXPECT_EQ(kExpected, FPDF_GetDocPermissions(document()));
+ }
+
+ EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document()));
+
+ EXPECT_EQ(0, FPDF_GetPageCount(document()));
+
+ EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document()));
+ EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document()));
+ EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document()));
+
+ EXPECT_EQ(0u, FPDF_CountNamedDests(document()));
+}
+
TEST_F(FPDFViewEmbeddertest, Page) {
EXPECT_TRUE(OpenDocument("about_blank.pdf"));
FPDF_PAGE page = LoadPage(0);
@@ -56,7 +86,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = 2000000; // Absurdly large, check not used for this case.
dest = FPDF_GetNamedDest(document(), 0, nullptr, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(12u, buffer_size);
+ EXPECT_EQ(12, buffer_size);
// Try to retrieve the first item with too small a buffer.
buffer_size = 10;
@@ -69,7 +99,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = 12;
dest = FPDF_GetNamedDest(document(), 0, fixed_buffer, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(12u, buffer_size);
+ EXPECT_EQ(12, buffer_size);
EXPECT_EQ(std::string("F\0i\0r\0s\0t\0\0\0", 12),
std::string(fixed_buffer, buffer_size));
@@ -78,7 +108,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 1, fixed_buffer, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(10u, buffer_size);
+ EXPECT_EQ(10, buffer_size);
EXPECT_EQ(std::string("N\0e\0x\0t\0\0\0", 10),
std::string(fixed_buffer, buffer_size));
@@ -104,7 +134,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 4, fixed_buffer, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(30u, buffer_size);
+ EXPECT_EQ(30, buffer_size);
EXPECT_EQ(std::string("F\0i\0r\0s\0t\0A\0l\0t\0e\0r\0n\0a\0t\0e\0\0\0", 30),
std::string(fixed_buffer, buffer_size));
@@ -114,7 +144,7 @@ TEST_F(FPDFViewEmbeddertest, NamedDests) {
buffer_size = sizeof(fixed_buffer);
dest = FPDF_GetNamedDest(document(), 5, fixed_buffer, &buffer_size);
EXPECT_NE(nullptr, dest);
- EXPECT_EQ(28u, buffer_size);
+ EXPECT_EQ(28, buffer_size);
EXPECT_EQ(std::string("L\0a\0s\0t\0A\0l\0t\0e\0r\0n\0a\0t\0e\0\0\0", 28),
std::string(fixed_buffer, buffer_size));
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp
index 46a3d53b30a..e91bdf16997 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp
@@ -4,15 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
#include "public/fpdf_formfill.h"
#include "xfa/fxbarcode/include/BC_Library.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_fontmgr.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_fontmgr.h"
CPDFXFA_App* CPDFXFA_App::g_pApp = NULL;
@@ -131,8 +131,8 @@ void CPDFXFA_App::Beep(uint32_t dwType) {
}
}
-int32_t CPDFXFA_App::MsgBox(const CFX_WideStringC& wsMessage,
- const CFX_WideStringC& wsTitle,
+int32_t CPDFXFA_App::MsgBox(const CFX_WideString& wsMessage,
+ const CFX_WideString& wsTitle,
uint32_t dwIconType,
uint32_t dwButtonType) {
CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
@@ -169,7 +169,7 @@ int32_t CPDFXFA_App::MsgBox(const CFX_WideStringC& wsMessage,
iButtonType |= 3;
break;
}
- int32_t iRet = pEnv->JS_appAlert(wsMessage.raw_str(), wsTitle.raw_str(),
+ int32_t iRet = pEnv->JS_appAlert(wsMessage.c_str(), wsTitle.c_str(),
iButtonType, iconType);
switch (iRet) {
case 1:
@@ -184,18 +184,18 @@ int32_t CPDFXFA_App::MsgBox(const CFX_WideStringC& wsMessage,
return XFA_IDYes;
}
-void CPDFXFA_App::Response(CFX_WideString& wsAnswer,
- const CFX_WideStringC& wsQuestion,
- const CFX_WideStringC& wsTitle,
- const CFX_WideStringC& wsDefaultAnswer,
- FX_BOOL bMark) {
+CFX_WideString CPDFXFA_App::Response(const CFX_WideString& wsQuestion,
+ const CFX_WideString& wsTitle,
+ const CFX_WideString& wsDefaultAnswer,
+ FX_BOOL bMark) {
+ CFX_WideString wsAnswer;
CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
if (pEnv) {
int nLength = 2048;
char* pBuff = new char[nLength];
- nLength = pEnv->JS_appResponse(wsQuestion.raw_str(), wsTitle.raw_str(),
- wsDefaultAnswer.raw_str(), NULL, bMark,
- pBuff, nLength);
+ nLength = pEnv->JS_appResponse(wsQuestion.c_str(), wsTitle.c_str(),
+ wsDefaultAnswer.c_str(), NULL, bMark, pBuff,
+ nLength);
if (nLength > 0) {
nLength = nLength > 2046 ? 2046 : nLength;
pBuff[nLength] = 0;
@@ -206,6 +206,7 @@ void CPDFXFA_App::Response(CFX_WideString& wsAnswer,
}
delete[] pBuff;
}
+ return wsAnswer;
}
int32_t CPDFXFA_App::GetCurDocumentInBatch() {
@@ -225,39 +226,34 @@ int32_t CPDFXFA_App::GetDocumentCountInBatch() {
return 0;
}
-IFX_FileRead* CPDFXFA_App::DownloadURL(const CFX_WideStringC& wsURL) {
+IFX_FileRead* CPDFXFA_App::DownloadURL(const CFX_WideString& wsURL) {
CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv) {
- return pEnv->FFI_DownloadFromURL(wsURL.raw_str());
- }
- return NULL;
+ return pEnv ? pEnv->FFI_DownloadFromURL(wsURL.c_str()) : nullptr;
}
-FX_BOOL CPDFXFA_App::PostRequestURL(const CFX_WideStringC& wsURL,
- const CFX_WideStringC& wsData,
- const CFX_WideStringC& wsContentType,
- const CFX_WideStringC& wsEncode,
- const CFX_WideStringC& wsHeader,
+FX_BOOL CPDFXFA_App::PostRequestURL(const CFX_WideString& wsURL,
+ const CFX_WideString& wsData,
+ const CFX_WideString& wsContentType,
+ const CFX_WideString& wsEncode,
+ const CFX_WideString& wsHeader,
CFX_WideString& wsResponse) {
CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv) {
- wsResponse = pEnv->FFI_PostRequestURL(
- wsURL.raw_str(), wsData.raw_str(), wsContentType.raw_str(),
- wsEncode.raw_str(), wsHeader.raw_str());
- return TRUE;
- }
- return FALSE;
+ if (!pEnv)
+ return FALSE;
+
+ wsResponse = pEnv->FFI_PostRequestURL(wsURL.c_str(), wsData.c_str(),
+ wsContentType.c_str(), wsEncode.c_str(),
+ wsHeader.c_str());
+ return TRUE;
}
-FX_BOOL CPDFXFA_App::PutRequestURL(const CFX_WideStringC& wsURL,
- const CFX_WideStringC& wsData,
- const CFX_WideStringC& wsEncode) {
+FX_BOOL CPDFXFA_App::PutRequestURL(const CFX_WideString& wsURL,
+ const CFX_WideString& wsData,
+ const CFX_WideString& wsEncode) {
CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
- if (pEnv) {
- return pEnv->FFI_PutRequestURL(wsURL.raw_str(), wsData.raw_str(),
- wsEncode.raw_str());
- }
- return FALSE;
+ return pEnv &&
+ pEnv->FFI_PutRequestURL(wsURL.c_str(), wsData.c_str(),
+ wsEncode.c_str());
}
void CPDFXFA_App::LoadString(int32_t iStringID, CFX_WideString& wsString) {
@@ -514,13 +510,6 @@ void CPDFXFA_App::LoadString(int32_t iStringID, CFX_WideString& wsString) {
}
}
-FX_BOOL CPDFXFA_App::ShowFileDialog(const CFX_WideStringC& wsTitle,
- const CFX_WideStringC& wsFilter,
- CFX_WideStringArray& wsPathArr,
- FX_BOOL bOpen) {
- return FALSE;
-}
-
IFWL_AdapterTimerMgr* CPDFXFA_App::GetTimerMgr() {
CXFA_FWLAdapterTimerMgr* pAdapter = NULL;
CPDFDoc_Environment* pEnv = m_pEnvList.GetAt(0);
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index bb8793f1a7c..7a9d0746240 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
@@ -4,23 +4,24 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
#include "fpdfsdk/javascript/ijs_runtime.h"
#include "public/fpdf_formfill.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#define IDS_XFA_Validate_Input \
"At least one required field was empty. Please fill in the required " \
@@ -38,7 +39,6 @@
#ifndef _WIN32
extern void SetLastError(int err);
-
extern int GetLastError();
#endif
@@ -154,21 +154,23 @@ int CPDFXFA_Document::GetPageCount() {
CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) {
if (page_index < 0)
return nullptr;
+
CPDFXFA_Page* pPage = nullptr;
int nCount = m_XFAPageList.GetSize();
if (nCount > 0 && page_index < nCount) {
pPage = m_XFAPageList.GetAt(page_index);
if (pPage)
- pPage->AddRef();
+ pPage->Retain();
} else {
m_nPageCount = GetPageCount();
m_XFAPageList.SetSize(m_nPageCount);
}
if (pPage)
return pPage;
+
pPage = new CPDFXFA_Page(this, page_index);
if (!pPage->LoadPage()) {
- delete pPage;
+ pPage->Release();
return nullptr;
}
m_XFAPageList.SetAt(page_index, pPage);
@@ -177,13 +179,13 @@ CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) {
CPDFXFA_Page* CPDFXFA_Document::GetPage(CXFA_FFPageView* pPage) {
if (!pPage)
- return NULL;
+ return nullptr;
if (!m_pXFADoc)
- return NULL;
+ return nullptr;
if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
- return NULL;
+ return nullptr;
int nSize = m_XFAPageList.GetSize();
for (int i = 0; i < nSize; i++) {
@@ -194,10 +196,16 @@ CPDFXFA_Page* CPDFXFA_Document::GetPage(CXFA_FFPageView* pPage) {
return pTempPage;
}
- return NULL;
+ return nullptr;
}
void CPDFXFA_Document::DeletePage(int page_index) {
+ // Delete from the document first because, if GetPage was never called for
+ // this |page_index| then |m_XFAPageList| may have size < |page_index| even
+ // if it's a valid page in the document.
+ if (m_pPDFDoc)
+ m_pPDFDoc->DeletePage(page_index);
+
if (page_index < 0 || page_index >= m_XFAPageList.GetSize())
return;
@@ -346,7 +354,7 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget,
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
if (!pEnv)
return FALSE;
- FS_RECTF pageViewRect;
+ FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f};
pEnv->FFI_GetPageViewRect(pPage, pageViewRect);
CFX_FloatRect rcAnchor;
@@ -508,8 +516,6 @@ void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView,
m_pSDKDoc->RemovePageView(pPage);
CXFA_FFPageView* pXFAPageView = pXFADocView->GetPageView(iPageIter);
pPage->SetXFAPageView(pXFAPageView);
- if (pXFAPageView)
- pXFAPageView->LoadPageView(nullptr);
}
int flag = (nNewCount < m_nPageCount) ? FXFA_PAGEVIEWEVENT_POSTREMOVED
@@ -521,16 +527,25 @@ void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView,
}
}
-void CPDFXFA_Document::WidgetEvent(CXFA_FFWidget* hWidget,
- CXFA_WidgetAcc* pWidgetData,
- uint32_t dwEvent,
- void* pParam,
- void* pAdditional) {
+void CPDFXFA_Document::WidgetPostAdd(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData) {
if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget)
return;
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- if (!pEnv)
+ CXFA_FFPageView* pPageView = hWidget->GetPageView();
+ if (!pPageView)
+ return;
+
+ CPDFXFA_Page* pXFAPage = GetPage(pPageView);
+ if (!pXFAPage)
+ return;
+
+ m_pSDKDoc->GetPageView(pXFAPage)->AddAnnot(hWidget);
+}
+
+void CPDFXFA_Document::WidgetPreRemove(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData) {
+ if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget)
return;
CXFA_FFPageView* pPageView = hWidget->GetPageView();
@@ -542,13 +557,8 @@ void CPDFXFA_Document::WidgetEvent(CXFA_FFWidget* hWidget,
return;
CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage);
- if (dwEvent == XFA_WIDGETEVENT_PostAdded) {
- pSdkPageView->AddAnnot(hWidget);
- } else if (dwEvent == XFA_WIDGETEVENT_PreRemoved) {
- CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget);
- if (pAnnot)
- pSdkPageView->DeleteAnnot(pAnnot);
- }
+ if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget))
+ pSdkPageView->DeleteAnnot(pAnnot);
}
int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) {
@@ -610,34 +620,33 @@ void CPDFXFA_Document::GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) {
wsTitle = wsTitle.FromLocal(csTitle.GetBuffer(csTitle.GetLength()));
csTitle.ReleaseBuffer(csTitle.GetLength());
}
+
void CPDFXFA_Document::SetTitle(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsTitle) {
- if (hDoc != m_pXFADoc)
+ const CFX_WideString& wsTitle) {
+ if (hDoc != m_pXFADoc || !m_pPDFDoc)
return;
- if (m_pPDFDoc == NULL)
- return;
- CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo();
- if (pInfoDict == NULL)
- return;
- pInfoDict->SetAt("Title", new CPDF_String(wsTitle));
+ if (CPDF_Dictionary* pInfoDict = m_pPDFDoc->GetInfo())
+ pInfoDict->SetAt("Title", new CPDF_String(wsTitle));
}
+
void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFilePath,
+ const CFX_WideString& wsFilePath,
FX_BOOL bXDP) {
if (hDoc != m_pXFADoc)
return;
+
if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
return;
+
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- if (pEnv == NULL)
+ if (!pEnv)
return;
- int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
- CFX_ByteString bs = CFX_WideString(wsFilePath).UTF16LE_Encode();
+ int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML;
+ CFX_ByteString bs = wsFilePath.UTF16LE_Encode();
if (wsFilePath.IsEmpty()) {
- if (!pEnv->GetFormFillInfo() ||
- pEnv->GetFormFillInfo()->m_pJsPlatform == NULL)
+ if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform)
return;
CFX_WideString filepath = pEnv->JS_fieldBrowse();
bs = filepath.UTF16LE_Encode();
@@ -647,16 +656,14 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML,
(FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb");
bs.ReleaseBuffer(len * sizeof(unsigned short));
-
- if (pFileHandler == NULL)
+ if (!pFileHandler)
return;
CFPDF_FileStream fileWrite(pFileHandler);
-
CFX_ByteString content;
if (fileType == FXFA_SAVEAS_XML) {
content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
- fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(),
+ fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
content.GetLength());
CFX_WideStringC data(L"data");
if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) {
@@ -699,13 +706,13 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
} else {
if (i == size - 1) {
CFX_WideString wPath = CFX_WideString::FromUTF16LE(
- (unsigned short*)(const FX_CHAR*)bs,
+ reinterpret_cast<const unsigned short*>(bs.c_str()),
bs.GetLength() / sizeof(unsigned short));
CFX_ByteString bPath = wPath.UTF8Encode();
- CFX_ByteString szFormat =
+ const char* szFormat =
"\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
- content.Format(szFormat, (char*)(const FX_CHAR*)bPath);
- fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(),
+ content.Format(szFormat, bPath.c_str());
+ fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
content.GetLength());
}
@@ -723,10 +730,10 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
}
}
void CPDFXFA_Document::ImportData(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFilePath) {}
+ const CFX_WideString& wsFilePath) {}
void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& bsURL,
+ const CFX_WideString& bsURL,
FX_BOOL bAppend) {
if (hDoc != m_pXFADoc)
return;
@@ -738,7 +745,7 @@ void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc,
if (pEnv == NULL)
return;
- CFX_WideStringC str(bsURL.raw_str());
+ CFX_WideStringC str(bsURL.c_str());
pEnv->FFI_GotoURL(this, str, bAppend);
}
@@ -955,9 +962,9 @@ FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
if (fileType == FXFA_SAVEAS_XML) {
CFX_WideString ws;
ws.FromLocal("data");
- CFX_ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
- fileStream.WriteBlock((const FX_CHAR*)content, 0, content.GetLength());
- m_pXFADoc->SavePackage(ws.AsWideStringC(), &fileStream);
+ const char* content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+ fileStream.WriteBlock(content, 0, strlen(content));
+ m_pXFADoc->SavePackage(ws.AsStringC(), &fileStream);
} else if (fileType == FXFA_SAVEAS_XDP) {
if (flag == 0)
flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
@@ -1018,11 +1025,11 @@ FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
if (pPrePDFObj->GetString() == "form") {
CFX_WideString ws;
ws.FromLocal("form");
- m_pXFADoc->SavePackage(ws.AsWideStringC(), &fileStream);
+ m_pXFADoc->SavePackage(ws.AsStringC(), &fileStream);
} else if (pPrePDFObj->GetString() == "datasets") {
CFX_WideString ws;
ws.FromLocal("datasets");
- m_pXFADoc->SavePackage(ws.AsWideStringC(), &fileStream);
+ m_pXFADoc->SavePackage(ws.AsStringC(), &fileStream);
} else {
// PDF,creator.
}
@@ -1136,7 +1143,7 @@ FX_BOOL CPDFXFA_Document::_SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) {
return FALSE;
CFX_WideStringC csURLC;
submit.GetSubmitTarget(csURLC);
- CFX_WideString csURL = csURLC;
+ CFX_WideString csURL(csURLC);
if (csURL.IsEmpty()) {
CFX_WideString ws;
ws.FromLocal("Submit cancelled.");
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp
index dc4185af2d0..8dbbf4e07c2 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp
@@ -4,70 +4,51 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index)
- : m_pPDFPage(NULL),
- m_pXFAPageView(NULL),
- m_iPageIndex(page_index),
+ : m_pXFAPageView(nullptr),
m_pDocument(pDoc),
+ m_iPageIndex(page_index),
m_iRef(1) {}
CPDFXFA_Page::~CPDFXFA_Page() {
- if (m_pPDFPage)
- delete m_pPDFPage;
- m_pPDFPage = NULL;
- m_pXFAPageView = NULL;
-}
-
-void CPDFXFA_Page::Release() {
- m_iRef--;
- if (m_iRef > 0)
- return;
-
if (m_pDocument)
m_pDocument->RemovePage(this);
-
- delete this;
}
FX_BOOL CPDFXFA_Page::LoadPDFPage() {
if (!m_pDocument)
return FALSE;
+
CPDF_Document* pPDFDoc = m_pDocument->GetPDFDoc();
- if (pPDFDoc) {
- CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex);
- if (pDict == NULL)
- return FALSE;
- if (m_pPDFPage) {
- if (m_pPDFPage->m_pFormDict == pDict)
- return TRUE;
+ if (!pPDFDoc)
+ return FALSE;
- delete m_pPDFPage;
- m_pPDFPage = NULL;
- }
+ CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex);
+ if (!pDict)
+ return FALSE;
- m_pPDFPage = new CPDF_Page;
- m_pPDFPage->Load(pPDFDoc, pDict);
- m_pPDFPage->ParseContent(nullptr);
- return TRUE;
+ if (!m_pPDFPage || m_pPDFPage->m_pFormDict != pDict) {
+ m_pPDFPage.reset(new CPDF_Page(pPDFDoc, pDict, true));
+ m_pPDFPage->ParseContent();
}
-
- return FALSE;
+ return TRUE;
}
FX_BOOL CPDFXFA_Page::LoadXFAPageView() {
if (!m_pDocument)
return FALSE;
+
CXFA_FFDoc* pXFADoc = m_pDocument->GetXFADoc();
if (!pXFADoc)
return FALSE;
@@ -80,11 +61,7 @@ FX_BOOL CPDFXFA_Page::LoadXFAPageView() {
if (!pPageView)
return FALSE;
- if (m_pXFAPageView == pPageView)
- return TRUE;
-
m_pXFAPageView = pPageView;
- (void)m_pXFAPageView->LoadPageView(nullptr);
return TRUE;
}
@@ -110,17 +87,12 @@ FX_BOOL CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) {
if (!m_pDocument || m_iPageIndex < 0 || !pageDict)
return FALSE;
- if (m_pPDFPage)
- delete m_pPDFPage;
-
- m_pPDFPage = new CPDF_Page();
- m_pPDFPage->Load(m_pDocument->GetPDFDoc(), pageDict);
- m_pPDFPage->ParseContent(nullptr);
-
+ m_pPDFPage.reset(new CPDF_Page(m_pDocument->GetPDFDoc(), pageDict, true));
+ m_pPDFPage->ParseContent();
return TRUE;
}
-FX_FLOAT CPDFXFA_Page::GetPageWidth() {
+FX_FLOAT CPDFXFA_Page::GetPageWidth() const {
if (!m_pPDFPage && !m_pXFAPageView)
return 0.0f;
@@ -145,7 +117,7 @@ FX_FLOAT CPDFXFA_Page::GetPageWidth() {
return 0.0f;
}
-FX_FLOAT CPDFXFA_Page::GetPageHeight() {
+FX_FLOAT CPDFXFA_Page::GetPageHeight() const {
if (!m_pPDFPage && !m_pXFAPageView)
return 0.0f;
diff --git a/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp
index 49efceb8e41..b6deaef17b7 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
#include <vector>
@@ -13,24 +13,24 @@
std::vector<CFWL_TimerInfo*>* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr;
-FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer,
- uint32_t dwElapse,
- FWL_HTIMER& hTimer,
- FX_BOOL bImmediately) {
+FWL_Error CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer,
+ uint32_t dwElapse,
+ FWL_HTIMER& hTimer,
+ FX_BOOL bImmediately) {
if (!m_pEnv)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
int32_t id_event = m_pEnv->FFI_SetTimer(dwElapse, TimerProc);
if (!s_TimerArray)
s_TimerArray = new std::vector<CFWL_TimerInfo*>;
s_TimerArray->push_back(new CFWL_TimerInfo(id_event, pTimer));
hTimer = reinterpret_cast<FWL_HTIMER>(s_TimerArray->back());
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) {
+FWL_Error CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) {
if (!hTimer || !m_pEnv)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
CFWL_TimerInfo* pInfo = reinterpret_cast<CFWL_TimerInfo*>(hTimer);
m_pEnv->FFI_KillTimer(pInfo->idEvent);
@@ -41,7 +41,7 @@ FWL_ERR CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) {
delete pInfo;
}
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
// static
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/DEPS b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/DEPS
index f207778cb2a..f207778cb2a 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/DEPS
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/DEPS
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_app.h
index ed626716f7e..3a61ef40c39 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_app.h
@@ -4,10 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_APP_H_
-#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_APP_H_
+#ifndef FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_APP_H_
+#define FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_APP_H_
-#include "xfa/include/fxfa/fxfa.h"
+#include "xfa/fxfa/include/fxfa.h"
class CPDFDoc_Environment;
class IFXJS_Runtime;
@@ -51,35 +51,30 @@ class CPDFXFA_App : public IXFA_AppProvider {
}
void Beep(uint32_t dwType) override;
- int32_t MsgBox(const CFX_WideStringC& wsMessage,
- const CFX_WideStringC& wsTitle,
+ int32_t MsgBox(const CFX_WideString& wsMessage,
+ const CFX_WideString& wsTitle,
uint32_t dwIconType,
uint32_t dwButtonType) override;
- void Response(CFX_WideString& wsAnswer,
- const CFX_WideStringC& wsQuestion,
- const CFX_WideStringC& wsTitle,
- const CFX_WideStringC& wsDefaultAnswer,
- FX_BOOL bMark) override;
+ CFX_WideString Response(const CFX_WideString& wsQuestion,
+ const CFX_WideString& wsTitle,
+ const CFX_WideString& wsDefaultAnswer,
+ FX_BOOL bMark) override;
int32_t GetDocumentCountInBatch() override;
int32_t GetCurDocumentInBatch() override;
- IFX_FileRead* DownloadURL(const CFX_WideStringC& wsURL) override;
- FX_BOOL PostRequestURL(const CFX_WideStringC& wsURL,
- const CFX_WideStringC& wsData,
- const CFX_WideStringC& wsContentType,
- const CFX_WideStringC& wsEncode,
- const CFX_WideStringC& wsHeader,
+ IFX_FileRead* DownloadURL(const CFX_WideString& wsURL) override;
+ FX_BOOL PostRequestURL(const CFX_WideString& wsURL,
+ const CFX_WideString& wsData,
+ const CFX_WideString& wsContentType,
+ const CFX_WideString& wsEncode,
+ const CFX_WideString& wsHeader,
CFX_WideString& wsResponse) override;
- FX_BOOL PutRequestURL(const CFX_WideStringC& wsURL,
- const CFX_WideStringC& wsData,
- const CFX_WideStringC& wsEncode) override;
+ FX_BOOL PutRequestURL(const CFX_WideString& wsURL,
+ const CFX_WideString& wsData,
+ const CFX_WideString& wsEncode) override;
void LoadString(int32_t iStringID, CFX_WideString& wsString) override;
- FX_BOOL ShowFileDialog(const CFX_WideStringC& wsTitle,
- const CFX_WideStringC& wsFilter,
- CFX_WideStringArray& wsPathArr,
- FX_BOOL bOpen) override;
IFWL_AdapterTimerMgr* GetTimerMgr() override;
CFX_ArrayTemplate<CPDFDoc_Environment*> m_pEnvList;
@@ -95,4 +90,4 @@ class CPDFXFA_App : public IXFA_AppProvider {
bool m_bOwnedRuntime;
};
-#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_APP_H_
+#endif // FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_APP_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h
index dc09c8b6566..d54b77abeaa 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h
@@ -4,15 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_DOC_H_
-#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_DOC_H_
+#ifndef FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_
+#define FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_
#include <vector>
#include "public/fpdfview.h"
-#include "xfa/include/fxfa/fxfa.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdochandler.h"
+#include "xfa/fxfa/include/fxfa.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdochandler.h"
class CPDFXFA_App;
class CPDFXFA_Document;
@@ -70,12 +70,10 @@ class CPDFXFA_Document : public IXFA_DocProvider {
// dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing
virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags);
- // dwEvent refer to XFA_WIDGETEVENT_XXX
- virtual void WidgetEvent(CXFA_FFWidget* hWidget,
- CXFA_WidgetAcc* pWidgetData,
- uint32_t dwEvent,
- void* pParam = NULL,
- void* pAdditional = NULL);
+ virtual void WidgetPostAdd(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData);
+ virtual void WidgetPreRemove(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData);
// return true if render it.
virtual FX_BOOL RenderCustomWidget(CXFA_FFWidget* hWidget,
@@ -92,13 +90,13 @@ class CPDFXFA_Document : public IXFA_DocProvider {
virtual FX_BOOL IsCalculationsEnabled(CXFA_FFDoc* hDoc);
virtual void SetCalculationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled);
virtual void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle);
- virtual void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideStringC& wsTitle);
+ virtual void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle);
virtual void ExportData(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFilePath,
+ const CFX_WideString& wsFilePath,
FX_BOOL bXDP = TRUE);
- virtual void ImportData(CXFA_FFDoc* hDoc, const CFX_WideStringC& wsFilePath);
+ virtual void ImportData(CXFA_FFDoc* hDoc, const CFX_WideString& wsFilePath);
virtual void GotoURL(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& bsURL,
+ const CFX_WideString& bsURL,
FX_BOOL bAppend = TRUE);
virtual FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc);
virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled);
@@ -235,4 +233,4 @@ class CPDFXFA_Document : public IXFA_DocProvider {
int m_nPageCount;
};
-#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_DOC_H_
+#endif // FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_DOC_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_page.h
index 20da040a237..2e08f580ed1 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_page.h
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_page.h
@@ -4,8 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_PAGE_H_
-#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_PAGE_H_
+#ifndef FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_PAGE_H_
+#define FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_PAGE_H_
+
+#include <memory>
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
@@ -19,22 +21,26 @@ class CXFA_FFPageView;
class CPDFXFA_Page {
public:
CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index);
- ~CPDFXFA_Page();
- void Release();
- void AddRef() { m_iRef++; }
+ void Retain() { m_iRef++; }
+ void Release() {
+ if (--m_iRef <= 0)
+ delete this;
+ }
+
FX_BOOL LoadPage();
FX_BOOL LoadPDFPage(CPDF_Dictionary* pageDict);
- CPDFXFA_Document* GetDocument() { return m_pDocument; }
- int GetPageIndex() { return m_iPageIndex; }
- CPDF_Page* GetPDFPage() { return m_pPDFPage; }
- CXFA_FFPageView* GetXFAPageView() { return m_pXFAPageView; }
+ CPDFXFA_Document* GetDocument() const { return m_pDocument; }
+ int GetPageIndex() const { return m_iPageIndex; }
+ CPDF_Page* GetPDFPage() const { return m_pPDFPage.get(); }
+ CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; }
+
void SetXFAPageView(CXFA_FFPageView* pPageView) {
m_pXFAPageView = pPageView;
}
- FX_FLOAT GetPageWidth();
- FX_FLOAT GetPageHeight();
+ FX_FLOAT GetPageWidth() const;
+ FX_FLOAT GetPageHeight() const;
void DeviceToPage(int start_x,
int start_y,
@@ -63,15 +69,18 @@ class CPDFXFA_Page {
int iRotate) const;
protected:
+ // Refcounted class.
+ ~CPDFXFA_Page();
+
FX_BOOL LoadPDFPage();
FX_BOOL LoadXFAPageView();
private:
- CPDF_Page* m_pPDFPage;
+ std::unique_ptr<CPDF_Page> m_pPDFPage;
CXFA_FFPageView* m_pXFAPageView;
- int m_iPageIndex;
- CPDFXFA_Document* m_pDocument;
+ CPDFXFA_Document* const m_pDocument;
+ const int m_iPageIndex;
int m_iRef;
};
-#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_PAGE_H_
+#endif // FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_PAGE_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h
index e0c508baa51..dce9a742291 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
+++ b/chromium/third_party/pdfium/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h
@@ -4,12 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_
-#define FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_
+#ifndef FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_UTIL_H_
+#define FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_UTIL_H_
#include <vector>
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
#include "xfa/fwl/core/include/ifwl_adaptertimermgr.h"
#define JS_STR_VIEWERTYPE_STANDARD L"Exchange"
@@ -22,11 +22,11 @@ struct CFWL_TimerInfo;
class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr {
public:
CXFA_FWLAdapterTimerMgr(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv) {}
- virtual FWL_ERR Start(IFWL_Timer* pTimer,
- uint32_t dwElapse,
- FWL_HTIMER& hTimer,
- FX_BOOL bImmediately = TRUE);
- virtual FWL_ERR Stop(FWL_HTIMER hTimer);
+ virtual FWL_Error Start(IFWL_Timer* pTimer,
+ uint32_t dwElapse,
+ FWL_HTIMER& hTimer,
+ FX_BOOL bImmediately = TRUE);
+ virtual FWL_Error Stop(FWL_HTIMER hTimer);
protected:
static void TimerProc(int32_t idEvent);
@@ -44,4 +44,4 @@ struct CFWL_TimerInfo {
IFWL_Timer* pTimer;
};
-#endif // FPDFSDK_INCLUDE_FPDFXFA_FPDFXFA_UTIL_H_
+#endif // FPDFSDK_FPDFXFA_INCLUDE_FPDFXFA_UTIL_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/fsdk_actionhandler.cpp b/chromium/third_party/pdfium/fpdfsdk/fsdk_actionhandler.cpp
index ebcaf354ada..912bc40c7fa 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fsdk_actionhandler.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fsdk_actionhandler.cpp
@@ -439,7 +439,7 @@ void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
if (pMyArray) {
pPosAry = new float[pMyArray->GetCount()];
int j = 0;
- for (int i = 2; i < (int)pMyArray->GetCount(); i++) {
+ for (size_t i = 2; i < pMyArray->GetCount(); i++) {
pPosAry[j++] = pMyArray->GetFloatAt(i);
}
sizeOfAry = j;
@@ -470,7 +470,7 @@ void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument,
ASSERT(action.GetDict());
CFX_ByteString csName = action.GetNamedAction();
- pDocument->GetEnv()->FFI_ExecuteNamedAction(csName);
+ pDocument->GetEnv()->FFI_ExecuteNamedAction(csName.c_str());
}
void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument,
diff --git a/chromium/third_party/pdfium/fpdfsdk/fsdk_annothandler.cpp b/chromium/third_party/pdfium/fpdfsdk/fsdk_annothandler.cpp
index 5afe8e493b8..cbcb53e1691 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fsdk_annothandler.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fsdk_annothandler.cpp
@@ -16,11 +16,12 @@
#include "fpdfsdk/include/fsdk_mgr.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
+#include "xfa/fwl/core/include/fwl_widgethit.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
#endif // PDF_ENABLE_XFA
CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) {
@@ -375,22 +376,20 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
return pNext;
}
// for xfa annots
- IXFA_WidgetIterator* pWidgetIterator =
+ std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator(
pPage->GetXFAPageView()->CreateWidgetIterator(
- XFA_TRAVERSEWAY_Tranvalse, XFA_WIDGETFILTER_Visible |
- XFA_WIDGETFILTER_Viewable |
- XFA_WIDGETFILTER_Field);
- if (pWidgetIterator == NULL)
- return NULL;
+ XFA_TRAVERSEWAY_Tranvalse, XFA_WidgetStatus_Visible |
+ XFA_WidgetStatus_Viewable |
+ XFA_WidgetStatus_Focused));
+ if (!pWidgetIterator)
+ return nullptr;
if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget())
pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget());
- CXFA_FFWidget* hNextFocus = NULL;
- hNextFocus =
+ CXFA_FFWidget* hNextFocus =
bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious();
if (!hNextFocus && pSDKAnnot)
hNextFocus = pWidgetIterator->MoveToFirst();
- pWidgetIterator->Release();
return pPageView->GetAnnotByXFAWidget(hNextFocus);
#else // PDF_ENABLE_XFA
CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", "");
@@ -723,14 +722,6 @@ FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
}
#ifdef PDF_ENABLE_XFA
-#define FWL_WGTHITTEST_Unknown 0
-#define FWL_WGTHITTEST_Client 1 // arrow
-#define FWL_WGTHITTEST_Titlebar 11 // caption
-#define FWL_WGTHITTEST_HScrollBar 15
-#define FWL_WGTHITTEST_VScrollBar 16
-#define FWL_WGTHITTEST_Border 17
-#define FWL_WGTHITTEST_Edit 19
-#define FWL_WGTHITTEST_HyperLink 20
CPDFSDK_XFAAnnotHandler::CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp)
: m_pApp(pApp) {}
@@ -789,9 +780,9 @@ CFX_FloatRect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
CFX_RectF rcBBox;
XFA_ELEMENT eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType();
if (eType == XFA_ELEMENT_Signature)
- pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WIDGETSTATUS_Visible, TRUE);
+ pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_Visible, TRUE);
else
- pAnnot->GetXFAWidget()->GetBBox(rcBBox, 0);
+ pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_None);
CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
rcBBox.top + rcBBox.height);
@@ -825,9 +816,9 @@ FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
if (!pWidgetHandler)
return FALSE;
- uint32_t dwHitTest =
+ FWL_WidgetHit dwHitTest =
pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y);
- return (dwHitTest != FWL_WGTHITTEST_Unknown);
+ return dwHitTest != FWL_WidgetHit::Unknown;
}
void CPDFSDK_XFAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
diff --git a/chromium/third_party/pdfium/fpdfsdk/fsdk_baseannot.cpp b/chromium/third_party/pdfium/fpdfsdk/fsdk_baseannot.cpp
index 249fd83fc8a..e2ee6f7c73f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fsdk_baseannot.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fsdk_baseannot.cpp
@@ -16,22 +16,27 @@
#include "fpdfsdk/include/fsdk_mgr.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
#endif // PDF_ENABLE_XFA
+namespace {
+
+const float kMinWidth = 1.0f;
+const float kMinHeight = 1.0f;
+
int gAfxGetTimeZoneInSeconds(int8_t tzhour, uint8_t tzminute) {
return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60);
}
-FX_BOOL _gAfxIsLeapYear(int16_t year) {
+bool gAfxIsLeapYear(int16_t year) {
return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)));
}
-uint16_t _gAfxGetYearDays(int16_t year) {
- return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365);
+uint16_t gAfxGetYearDays(int16_t year) {
+ return (gAfxIsLeapYear(year) ? 366 : 365);
}
-uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) {
+uint8_t gAfxGetMonthDays(int16_t year, uint8_t month) {
uint8_t mDays;
switch (month) {
case 1:
@@ -52,7 +57,7 @@ uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) {
break;
case 2:
- if (_gAfxIsLeapYear(year) == TRUE)
+ if (gAfxIsLeapYear(year))
mDays = 29;
else
mDays = 28;
@@ -66,6 +71,8 @@ uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) {
return mDays;
}
+} // namespace
+
CPDFSDK_DateTime::CPDFSDK_DateTime() {
ResetDateTime();
}
@@ -406,24 +413,24 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) {
yy = y;
if (((uint16_t)m * 100 + d) > 300)
yy++;
- ydays = _gAfxGetYearDays(yy);
+ ydays = gAfxGetYearDays(yy);
while (ldays >= ydays) {
y++;
ldays -= ydays;
yy++;
- mdays = _gAfxGetMonthDays(y, m);
+ mdays = gAfxGetMonthDays(y, m);
if (d > mdays) {
m++;
d -= mdays;
}
- ydays = _gAfxGetYearDays(yy);
+ ydays = gAfxGetYearDays(yy);
}
- mdays = _gAfxGetMonthDays(y, m) - d + 1;
+ mdays = gAfxGetMonthDays(y, m) - d + 1;
while (ldays >= mdays) {
ldays -= mdays;
m++;
d = 1;
- mdays = _gAfxGetMonthDays(y, m);
+ mdays = gAfxGetMonthDays(y, m);
}
d += ldays;
} else {
@@ -431,22 +438,22 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) {
yy = y;
if (((uint16_t)m * 100 + d) < 300)
yy--;
- ydays = _gAfxGetYearDays(yy);
+ ydays = gAfxGetYearDays(yy);
while (ldays >= ydays) {
y--;
ldays -= ydays;
yy--;
- mdays = _gAfxGetMonthDays(y, m);
+ mdays = gAfxGetMonthDays(y, m);
if (d > mdays) {
m++;
d -= mdays;
}
- ydays = _gAfxGetYearDays(yy);
+ ydays = gAfxGetYearDays(yy);
}
while (ldays >= d) {
ldays -= d;
m--;
- mdays = _gAfxGetMonthDays(y, m);
+ mdays = gAfxGetMonthDays(y, m);
d = mdays;
}
d -= ldays;
@@ -677,7 +684,7 @@ int CPDFSDK_BAAnnot::GetBorderWidth() const {
return 1;
}
-void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle) {
+void CPDFSDK_BAAnnot::SetBorderStyle(BorderStyle nStyle) {
CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS");
if (!pBSDict) {
pBSDict = new CPDF_Dictionary;
@@ -685,38 +692,40 @@ void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle) {
}
switch (nStyle) {
- case BBS_SOLID:
+ case BorderStyle::SOLID:
pBSDict->SetAtName("S", "S");
break;
- case BBS_DASH:
+ case BorderStyle::DASH:
pBSDict->SetAtName("S", "D");
break;
- case BBS_BEVELED:
+ case BorderStyle::BEVELED:
pBSDict->SetAtName("S", "B");
break;
- case BBS_INSET:
+ case BorderStyle::INSET:
pBSDict->SetAtName("S", "I");
break;
- case BBS_UNDERLINE:
+ case BorderStyle::UNDERLINE:
pBSDict->SetAtName("S", "U");
break;
+ default:
+ break;
}
}
-int CPDFSDK_BAAnnot::GetBorderStyle() const {
+BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const {
CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS");
if (pBSDict) {
CFX_ByteString sBorderStyle = pBSDict->GetStringBy("S", "S");
if (sBorderStyle == "S")
- return BBS_SOLID;
+ return BorderStyle::SOLID;
if (sBorderStyle == "D")
- return BBS_DASH;
+ return BorderStyle::DASH;
if (sBorderStyle == "B")
- return BBS_BEVELED;
+ return BorderStyle::BEVELED;
if (sBorderStyle == "I")
- return BBS_INSET;
+ return BorderStyle::INSET;
if (sBorderStyle == "U")
- return BBS_UNDERLINE;
+ return BorderStyle::UNDERLINE;
}
CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border");
@@ -724,46 +733,11 @@ int CPDFSDK_BAAnnot::GetBorderStyle() const {
if (pBorder->GetCount() >= 4) {
CPDF_Array* pDP = pBorder->GetArrayAt(3);
if (pDP && pDP->GetCount() > 0)
- return BBS_DASH;
+ return BorderStyle::DASH;
}
}
- return BBS_SOLID;
-}
-
-void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array) {
- CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS");
- if (!pBSDict) {
- pBSDict = new CPDF_Dictionary;
- m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
- }
-
- CPDF_Array* pArray = new CPDF_Array;
- for (int i = 0, sz = array.GetSize(); i < sz; i++) {
- pArray->AddInteger(array[i]);
- }
-
- pBSDict->SetAt("D", pArray);
-}
-
-void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const {
- CPDF_Array* pDash = NULL;
-
- CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border");
- if (pBorder) {
- pDash = pBorder->GetArrayAt(3);
- } else {
- CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS");
- if (pBSDict) {
- pDash = pBSDict->GetArrayBy("D");
- }
- }
-
- if (pDash) {
- for (int i = 0, sz = pDash->GetCount(); i < sz; i++) {
- array.Add(pDash->GetIntegerAt(i));
- }
- }
+ return BorderStyle::SOLID;
}
void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) {
@@ -780,7 +754,7 @@ void CPDFSDK_BAAnnot::RemoveColor() {
FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const {
if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArrayBy("C")) {
- int nCount = pEntry->GetCount();
+ size_t nCount = pEntry->GetCount();
if (nCount == 1) {
FX_FLOAT g = pEntry->GetNumberAt(0) * 255;
@@ -831,22 +805,22 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
if (sAPState.IsEmpty()) {
pParentDict = pAPDict;
- pStream = pAPDict->GetStreamBy(sAPType.AsByteStringC());
+ pStream = pAPDict->GetStreamBy(sAPType);
} else {
- CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictBy(sAPType.AsByteStringC());
+ CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictBy(sAPType);
if (!pAPTypeDict) {
pAPTypeDict = new CPDF_Dictionary;
- pAPDict->SetAt(sAPType.AsByteStringC(), pAPTypeDict);
+ pAPDict->SetAt(sAPType, pAPTypeDict);
}
pParentDict = pAPTypeDict;
- pStream = pAPTypeDict->GetStreamBy(sAPState.AsByteStringC());
+ pStream = pAPTypeDict->GetStreamBy(sAPState);
}
if (!pStream) {
pStream = new CPDF_Stream(nullptr, 0, nullptr);
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
int32_t objnum = pDoc->AddIndirectObject(pStream);
- pParentDict->SetAtReference(sAPType.AsByteStringC(), pDoc, objnum);
+ pParentDict->SetAtReference(sAPType, pDoc, objnum);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
@@ -867,15 +841,12 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
FALSE);
}
-#define BA_ANNOT_MINWIDTH 1
-#define BA_ANNOT_MINHEIGHT 1
-
FX_FLOAT CPDFSDK_Annot::GetMinWidth() const {
- return BA_ANNOT_MINWIDTH;
+ return kMinWidth;
}
FX_FLOAT CPDFSDK_Annot::GetMinHeight() const {
- return BA_ANNOT_MINHEIGHT;
+ return kMinHeight;
}
FX_BOOL CPDFSDK_BAAnnot::CreateFormFiller() {
diff --git a/chromium/third_party/pdfium/fpdfsdk/fsdk_baseform.cpp b/chromium/third_party/pdfium/fpdfsdk/fsdk_baseform.cpp
index 3dad62472f0..4e5c9f0065a 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fsdk_baseform.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fsdk_baseform.cpp
@@ -7,6 +7,7 @@
#include "fpdfsdk/include/fsdk_baseform.h"
#include <algorithm>
+#include <map>
#include <memory>
#include <vector>
@@ -25,9 +26,9 @@
#include "fpdfsdk/pdfwindow/PWL_Utils.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#endif // PDF_ENABLE_XFA
CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot,
@@ -64,7 +65,7 @@ CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const {
}
if (!sName.IsEmpty())
- m_hMixXFAWidget = pDocView->GetWidgetByName(sName.AsWideStringC());
+ m_hMixXFAWidget = pDocView->GetWidgetByName(sName);
}
}
return m_hMixXFAWidget;
@@ -80,7 +81,7 @@ CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() {
if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) {
CFX_WideString sName = GetName();
if (!sName.IsEmpty())
- return pDocView->GetWidgetByName(sName.AsWideStringC());
+ return pDocView->GetWidgetByName(sName);
}
}
@@ -461,7 +462,7 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
case FIELDTYPE_CHECKBOX:
case FIELDTYPE_RADIOBUTTON:
if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) {
- return !!pSubDict->GetStreamBy(GetAppState().AsByteStringC());
+ return !!pSubDict->GetStreamBy(GetAppState());
}
return FALSE;
}
@@ -718,7 +719,7 @@ void CPDFSDK_Widget::ResetAppearance(FX_BOOL bValueChanged) {
case FIELDTYPE_COMBOBOX: {
FX_BOOL bFormated = FALSE;
CFX_WideString sValue = OnFormat(bFormated);
- ResetAppearance(bFormated ? sValue : nullptr, TRUE);
+ ResetAppearance(bFormated ? sValue.c_str() : nullptr, TRUE);
} break;
default:
ResetAppearance(nullptr, FALSE);
@@ -879,32 +880,25 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
CPWL_Dash dsBorder(3, 0, 0);
CPWL_Color crLeftTop, crRightBottom;
- switch (GetBorderStyle()) {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
+ BorderStyle nBorderStyle = GetBorderStyle();
+ switch (nBorderStyle) {
+ case BorderStyle::DASH:
dsBorder = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
default:
- nBorderStyle = PBS_SOLID;
break;
}
@@ -1021,15 +1015,19 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
}
switch (nBorderStyle) {
- case PBS_BEVELED: {
+ case BorderStyle::BEVELED: {
CPWL_Color crTemp = crLeftTop;
crLeftTop = crRightBottom;
crRightBottom = crTemp;
- } break;
- case PBS_INSET:
+ break;
+ }
+ case BorderStyle::INSET: {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
break;
+ }
+ default:
+ break;
}
font_map.SetAPType("D");
@@ -1067,32 +1065,25 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() {
crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
CPWL_Dash dsBorder(3, 0, 0);
CPWL_Color crLeftTop, crRightBottom;
- switch (GetBorderStyle()) {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
+ BorderStyle nBorderStyle = GetBorderStyle();
+ switch (nBorderStyle) {
+ case BorderStyle::DASH:
dsBorder = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
default:
- nBorderStyle = PBS_SOLID;
break;
}
@@ -1142,15 +1133,19 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() {
CFX_ByteString csAP_N_OFF = csAP_N_ON;
switch (nBorderStyle) {
- case PBS_BEVELED: {
+ case BorderStyle::BEVELED: {
CPWL_Color crTemp = crLeftTop;
crLeftTop = crRightBottom;
crRightBottom = crTemp;
- } break;
- case PBS_INSET:
+ break;
+ }
+ case BorderStyle::INSET: {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
break;
+ }
+ default:
+ break;
}
CFX_ByteString csAP_D_ON =
@@ -1193,32 +1188,25 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() {
crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
CPWL_Dash dsBorder(3, 0, 0);
CPWL_Color crLeftTop, crRightBottom;
- switch (GetBorderStyle()) {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
+ BorderStyle nBorderStyle = GetBorderStyle();
+ switch (nBorderStyle) {
+ case BorderStyle::DASH:
dsBorder = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
default:
- nBorderStyle = PBS_SOLID;
break;
}
@@ -1265,10 +1253,10 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() {
CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f);
if (nStyle == PCS_CIRCLE) {
- if (nBorderStyle == PBS_BEVELED) {
+ if (nBorderStyle == BorderStyle::BEVELED) {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::SubstractColor(crBackground, 0.25f);
- } else if (nBorderStyle == PBS_INSET) {
+ } else if (nBorderStyle == BorderStyle::INSET) {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5f);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75f);
}
@@ -1287,26 +1275,30 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() {
CFX_ByteString csAP_N_OFF = csAP_N_ON;
switch (nBorderStyle) {
- case PBS_BEVELED: {
+ case BorderStyle::BEVELED: {
CPWL_Color crTemp = crLeftTop;
crLeftTop = crRightBottom;
crRightBottom = crTemp;
- } break;
- case PBS_INSET:
+ break;
+ }
+ case BorderStyle::INSET: {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
break;
+ }
+ default:
+ break;
}
CFX_ByteString csAP_D_ON;
if (nStyle == PCS_CIRCLE) {
CPWL_Color crBK = CPWL_Utils::SubstractColor(crBackground, 0.25f);
- if (nBorderStyle == PBS_BEVELED) {
+ if (nBorderStyle == BorderStyle::BEVELED) {
crLeftTop = CPWL_Utils::SubstractColor(crBackground, 0.25f);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
crBK = crBackground;
- } else if (nBorderStyle == PBS_INSET) {
+ } else if (nBorderStyle == BorderStyle::INSET) {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
}
@@ -1351,66 +1343,65 @@ void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) {
rcButton.left = rcButton.right - 13;
rcButton.Normalize();
- if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
- pEdit->EnableRefresh(FALSE);
+ IFX_Edit* pEdit = IFX_Edit::NewEdit();
+ pEdit->EnableRefresh(FALSE);
- CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
- CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap font_map(this, pEnv->GetSysHandler());
- pEdit->SetFontMap(&font_map);
-
- CFX_FloatRect rcEdit = rcClient;
- rcEdit.right = rcButton.left;
- rcEdit.Normalize();
+ CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
+ CPDFDoc_Environment* pEnv = pDoc->GetEnv();
+ CBA_FontMap font_map(this, pEnv->GetSysHandler());
+ pEdit->SetFontMap(&font_map);
- pEdit->SetPlateRect(rcEdit);
- pEdit->SetAlignmentV(1);
+ CFX_FloatRect rcEdit = rcClient;
+ rcEdit.right = rcButton.left;
+ rcEdit.Normalize();
- FX_FLOAT fFontSize = GetFontSize();
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
+ pEdit->SetPlateRect(rcEdit);
+ pEdit->SetAlignmentV(1);
- pEdit->Initialize();
+ FX_FLOAT fFontSize = GetFontSize();
+ if (IsFloatZero(fFontSize))
+ pEdit->SetAutoFontSize(TRUE);
+ else
+ pEdit->SetFontSize(fFontSize);
- if (sValue) {
- pEdit->SetText(sValue);
- } else {
- int32_t nCurSel = pField->GetSelectedIndex(0);
+ pEdit->Initialize();
- if (nCurSel < 0)
- pEdit->SetText(pField->GetValue().c_str());
- else
- pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str());
- }
+ if (sValue) {
+ pEdit->SetText(sValue);
+ } else {
+ int32_t nCurSel = pField->GetSelectedIndex(0);
- CFX_FloatRect rcContent = pEdit->GetContentRect();
+ if (nCurSel < 0)
+ pEdit->SetText(pField->GetValue().c_str());
+ else
+ pEdit->SetText(pField->GetOptionLabel(nCurSel).c_str());
+ }
- CFX_ByteString sEdit =
- CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
- if (sEdit.GetLength() > 0) {
- sBody << "/Tx BMC\n"
- << "q\n";
- if (rcContent.Width() > rcEdit.Width() ||
- rcContent.Height() > rcEdit.Height()) {
- sBody << rcEdit.left << " " << rcEdit.bottom << " " << rcEdit.Width()
- << " " << rcEdit.Height() << " re\nW\nn\n";
- }
+ CFX_FloatRect rcContent = pEdit->GetContentRect();
- CPWL_Color crText = GetTextPWLColor();
- sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit
- << "ET\n"
- << "Q\nEMC\n";
+ CFX_ByteString sEdit =
+ CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
+ if (sEdit.GetLength() > 0) {
+ sBody << "/Tx BMC\n"
+ << "q\n";
+ if (rcContent.Width() > rcEdit.Width() ||
+ rcContent.Height() > rcEdit.Height()) {
+ sBody << rcEdit.left << " " << rcEdit.bottom << " " << rcEdit.Width()
+ << " " << rcEdit.Height() << " re\nW\nn\n";
}
- IFX_Edit::DelEdit(pEdit);
+ CPWL_Color crText = GetTextPWLColor();
+ sBody << "BT\n"
+ << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"
+ << "Q\nEMC\n";
}
+ IFX_Edit::DelEdit(pEdit);
+
sBody << CPWL_Utils::GetDropButtonAppStream(rcButton);
CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() +
- sLines.GetByteString() + sBody.GetByteString();
+ sLines.AsStringC() + sBody.AsStringC();
WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
}
@@ -1421,85 +1412,84 @@ void CPDFSDK_Widget::ResetAppearance_ListBox() {
CFX_FloatRect rcClient = GetClientRect();
CFX_ByteTextBuf sBody, sLines;
- if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
- pEdit->EnableRefresh(FALSE);
+ IFX_Edit* pEdit = IFX_Edit::NewEdit();
+ pEdit->EnableRefresh(FALSE);
- CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
- CPDFDoc_Environment* pEnv = pDoc->GetEnv();
+ CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
+ CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap font_map(this, pEnv->GetSysHandler());
- pEdit->SetFontMap(&font_map);
+ CBA_FontMap font_map(this, pEnv->GetSysHandler());
+ pEdit->SetFontMap(&font_map);
- pEdit->SetPlateRect(
- CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f));
+ pEdit->SetPlateRect(CFX_FloatRect(rcClient.left, 0.0f, rcClient.right, 0.0f));
- FX_FLOAT fFontSize = GetFontSize();
+ FX_FLOAT fFontSize = GetFontSize();
- if (IsFloatZero(fFontSize))
- pEdit->SetFontSize(12.0f);
- else
- pEdit->SetFontSize(fFontSize);
+ pEdit->SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize);
- pEdit->Initialize();
+ pEdit->Initialize();
- CFX_ByteTextBuf sList;
- FX_FLOAT fy = rcClient.top;
+ CFX_ByteTextBuf sList;
+ FX_FLOAT fy = rcClient.top;
- int32_t nTop = pField->GetTopVisibleIndex();
- int32_t nCount = pField->CountOptions();
- int32_t nSelCount = pField->CountSelectedItems();
+ int32_t nTop = pField->GetTopVisibleIndex();
+ int32_t nCount = pField->CountOptions();
+ int32_t nSelCount = pField->CountSelectedItems();
- for (int32_t i = nTop; i < nCount; i++) {
- FX_BOOL bSelected = FALSE;
- for (int32_t j = 0; j < nSelCount; j++) {
- if (pField->GetSelectedIndex(j) == i) {
- bSelected = TRUE;
- break;
- }
+ for (int32_t i = nTop; i < nCount; ++i) {
+ bool bSelected = false;
+ for (int32_t j = 0; j < nSelCount; ++j) {
+ if (pField->GetSelectedIndex(j) == i) {
+ bSelected = true;
+ break;
}
+ }
- pEdit->SetText(pField->GetOptionLabel(i).c_str());
-
- CFX_FloatRect rcContent = pEdit->GetContentRect();
- FX_FLOAT fItemHeight = rcContent.Height();
-
- if (bSelected) {
- CFX_FloatRect rcItem =
- CFX_FloatRect(rcClient.left, fy - fItemHeight, rcClient.right, fy);
- sList << "q\n" << CPWL_Utils::GetColorAppStream(
- CPWL_Color(COLORTYPE_RGB, 0, 51.0f / 255.0f,
- 113.0f / 255.0f),
- TRUE)
- << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width()
- << " " << rcItem.Height() << " re f\n"
- << "Q\n";
-
- sList << "BT\n" << CPWL_Utils::GetColorAppStream(
- CPWL_Color(COLORTYPE_GRAY, 1), TRUE)
- << CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, fy))
- << "ET\n";
- } else {
- CPWL_Color crText = GetTextPWLColor();
- sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
- << CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, fy))
- << "ET\n";
- }
+ pEdit->SetText(pField->GetOptionLabel(i).c_str());
- fy -= fItemHeight;
+ CFX_FloatRect rcContent = pEdit->GetContentRect();
+ FX_FLOAT fItemHeight = rcContent.Height();
+
+ if (bSelected) {
+ CFX_FloatRect rcItem =
+ CFX_FloatRect(rcClient.left, fy - fItemHeight, rcClient.right, fy);
+ sList << "q\n"
+ << CPWL_Utils::GetColorAppStream(
+ CPWL_Color(COLORTYPE_RGB, 0, 51.0f / 255.0f,
+ 113.0f / 255.0f),
+ TRUE)
+ << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width()
+ << " " << rcItem.Height() << " re f\n"
+ << "Q\n";
+
+ sList << "BT\n"
+ << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1),
+ TRUE)
+ << CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, fy))
+ << "ET\n";
+ } else {
+ CPWL_Color crText = GetTextPWLColor();
+ sList << "BT\n"
+ << CPWL_Utils::GetColorAppStream(crText, TRUE)
+ << CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, fy))
+ << "ET\n";
}
- if (sList.GetSize() > 0) {
- sBody << "/Tx BMC\n"
- << "q\n" << rcClient.left << " " << rcClient.bottom << " "
- << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n";
- sBody << sList << "Q\nEMC\n";
- }
+ fy -= fItemHeight;
+ }
- IFX_Edit::DelEdit(pEdit);
+ if (sList.GetSize() > 0) {
+ sBody << "/Tx BMC\n"
+ << "q\n"
+ << rcClient.left << " " << rcClient.bottom << " " << rcClient.Width()
+ << " " << rcClient.Height() << " re\nW\nn\n";
+ sBody << sList << "Q\nEMC\n";
}
+ IFX_Edit::DelEdit(pEdit);
+
CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() +
- sLines.GetByteString() + sBody.GetByteString();
+ sLines.AsStringC() + sBody.AsStringC();
WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
}
@@ -1509,146 +1499,151 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
CPDF_FormField* pField = pControl->GetField();
CFX_ByteTextBuf sBody, sLines;
- if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
- pEdit->EnableRefresh(FALSE);
+ IFX_Edit* pEdit = IFX_Edit::NewEdit();
+ pEdit->EnableRefresh(FALSE);
- CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
- CPDFDoc_Environment* pEnv = pDoc->GetEnv();
+ CPDFSDK_Document* pDoc = m_pInterForm->GetDocument();
+ CPDFDoc_Environment* pEnv = pDoc->GetEnv();
- CBA_FontMap font_map(this, pEnv->GetSysHandler());
- pEdit->SetFontMap(&font_map);
+ CBA_FontMap font_map(this, pEnv->GetSysHandler());
+ pEdit->SetFontMap(&font_map);
- CFX_FloatRect rcClient = GetClientRect();
- pEdit->SetPlateRect(rcClient);
- pEdit->SetAlignmentH(pControl->GetControlAlignment());
+ CFX_FloatRect rcClient = GetClientRect();
+ pEdit->SetPlateRect(rcClient);
+ pEdit->SetAlignmentH(pControl->GetControlAlignment());
- uint32_t dwFieldFlags = pField->GetFieldFlags();
- FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1;
+ uint32_t dwFieldFlags = pField->GetFieldFlags();
+ FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1;
- if (bMultiLine) {
- pEdit->SetMultiLine(TRUE);
- pEdit->SetAutoReturn(TRUE);
- } else {
- pEdit->SetAlignmentV(1);
- }
+ if (bMultiLine) {
+ pEdit->SetMultiLine(TRUE);
+ pEdit->SetAutoReturn(TRUE);
+ } else {
+ pEdit->SetAlignmentV(1);
+ }
- uint16_t subWord = 0;
- if ((dwFieldFlags >> 13) & 1) {
- subWord = '*';
- pEdit->SetPasswordChar(subWord);
- }
+ uint16_t subWord = 0;
+ if ((dwFieldFlags >> 13) & 1) {
+ subWord = '*';
+ pEdit->SetPasswordChar(subWord);
+ }
- int nMaxLen = pField->GetMaxLen();
- FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1;
- FX_FLOAT fFontSize = GetFontSize();
+ int nMaxLen = pField->GetMaxLen();
+ FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1;
+ FX_FLOAT fFontSize = GetFontSize();
#ifdef PDF_ENABLE_XFA
- CFX_WideString sValueTmp;
- if (!sValue && GetMixXFAWidget()) {
- sValueTmp = GetValue(TRUE);
- sValue = sValueTmp;
- }
+ CFX_WideString sValueTmp;
+ if (!sValue && GetMixXFAWidget()) {
+ sValueTmp = GetValue(TRUE);
+ sValue = sValueTmp.c_str();
+ }
#endif // PDF_ENABLE_XFA
- if (nMaxLen > 0) {
- if (bCharArray) {
- pEdit->SetCharArray(nMaxLen);
+ if (nMaxLen > 0) {
+ if (bCharArray) {
+ pEdit->SetCharArray(nMaxLen);
- if (IsFloatZero(fFontSize)) {
- fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(
- font_map.GetPDFFont(0), rcClient, nMaxLen);
- }
- } else {
- if (sValue)
- nMaxLen = wcslen((const wchar_t*)sValue);
- pEdit->SetLimitChar(nMaxLen);
+ if (IsFloatZero(fFontSize)) {
+ fFontSize = CPWL_Edit::GetCharArrayAutoFontSize(font_map.GetPDFFont(0),
+ rcClient, nMaxLen);
}
+ } else {
+ if (sValue)
+ nMaxLen = wcslen((const wchar_t*)sValue);
+ pEdit->SetLimitChar(nMaxLen);
}
+ }
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
+ if (IsFloatZero(fFontSize))
+ pEdit->SetAutoFontSize(TRUE);
+ else
+ pEdit->SetFontSize(fFontSize);
- pEdit->Initialize();
+ pEdit->Initialize();
- if (sValue)
- pEdit->SetText(sValue);
- else
- pEdit->SetText(pField->GetValue().c_str());
+ if (sValue)
+ pEdit->SetText(sValue);
+ else
+ pEdit->SetText(pField->GetValue().c_str());
- CFX_FloatRect rcContent = pEdit->GetContentRect();
+ CFX_FloatRect rcContent = pEdit->GetContentRect();
- CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(
- pEdit, CFX_FloatPoint(0.0f, 0.0f), NULL, !bCharArray, subWord);
+ CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(
+ pEdit, CFX_FloatPoint(0.0f, 0.0f), NULL, !bCharArray, subWord);
- if (sEdit.GetLength() > 0) {
- sBody << "/Tx BMC\n"
- << "q\n";
- if (rcContent.Width() > rcClient.Width() ||
- rcContent.Height() > rcClient.Height()) {
- sBody << rcClient.left << " " << rcClient.bottom << " "
- << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n";
- }
- CPWL_Color crText = GetTextPWLColor();
- sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit
- << "ET\n"
- << "Q\nEMC\n";
+ if (sEdit.GetLength() > 0) {
+ sBody << "/Tx BMC\n"
+ << "q\n";
+ if (rcContent.Width() > rcClient.Width() ||
+ rcContent.Height() > rcClient.Height()) {
+ sBody << rcClient.left << " " << rcClient.bottom << " "
+ << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n";
}
-
- if (bCharArray) {
- switch (GetBorderStyle()) {
- case BBS_SOLID: {
- CFX_ByteString sColor =
- CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE);
- if (sColor.GetLength() > 0) {
- sLines << "q\n" << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE)
- << " 2 J 0 j\n";
-
- for (int32_t i = 1; i < nMaxLen; i++) {
- sLines << rcClient.left +
- ((rcClient.right - rcClient.left) / nMaxLen) * i
- << " " << rcClient.bottom << " m\n"
- << rcClient.left +
- ((rcClient.right - rcClient.left) / nMaxLen) * i
- << " " << rcClient.top << " l S\n";
- }
-
- sLines << "Q\n";
+ CPWL_Color crText = GetTextPWLColor();
+ sBody << "BT\n"
+ << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"
+ << "Q\nEMC\n";
+ }
+
+ if (bCharArray) {
+ switch (GetBorderStyle()) {
+ case BorderStyle::SOLID: {
+ CFX_ByteString sColor =
+ CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE);
+ if (sColor.GetLength() > 0) {
+ sLines << "q\n"
+ << GetBorderWidth() << " w\n"
+ << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE)
+ << " 2 J 0 j\n";
+
+ for (int32_t i = 1; i < nMaxLen; ++i) {
+ sLines << rcClient.left +
+ ((rcClient.right - rcClient.left) / nMaxLen) * i
+ << " " << rcClient.bottom << " m\n"
+ << rcClient.left +
+ ((rcClient.right - rcClient.left) / nMaxLen) * i
+ << " " << rcClient.top << " l S\n";
}
- } break;
- case BBS_DASH: {
- CFX_ByteString sColor =
- CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE);
- if (sColor.GetLength() > 0) {
- CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0);
-
- sLines << "q\n" << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE)
- << "[" << dsBorder.nDash << " " << dsBorder.nGap << "] "
- << dsBorder.nPhase << " d\n";
-
- for (int32_t i = 1; i < nMaxLen; i++) {
- sLines << rcClient.left +
- ((rcClient.right - rcClient.left) / nMaxLen) * i
- << " " << rcClient.bottom << " m\n"
- << rcClient.left +
- ((rcClient.right - rcClient.left) / nMaxLen) * i
- << " " << rcClient.top << " l S\n";
- }
- sLines << "Q\n";
+ sLines << "Q\n";
+ }
+ break;
+ }
+ case BorderStyle::DASH: {
+ CFX_ByteString sColor =
+ CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE);
+ if (sColor.GetLength() > 0) {
+ CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0);
+
+ sLines << "q\n"
+ << GetBorderWidth() << " w\n"
+ << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE)
+ << "[" << dsBorder.nDash << " " << dsBorder.nGap << "] "
+ << dsBorder.nPhase << " d\n";
+
+ for (int32_t i = 1; i < nMaxLen; ++i) {
+ sLines << rcClient.left +
+ ((rcClient.right - rcClient.left) / nMaxLen) * i
+ << " " << rcClient.bottom << " m\n"
+ << rcClient.left +
+ ((rcClient.right - rcClient.left) / nMaxLen) * i
+ << " " << rcClient.top << " l S\n";
}
- } break;
+
+ sLines << "Q\n";
+ }
+ break;
}
+ default:
+ break;
}
-
- IFX_Edit::DelEdit(pEdit);
}
+ IFX_Edit::DelEdit(pEdit);
+
CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() +
- sLines.GetByteString() + sBody.GetByteString();
+ sLines.AsStringC() + sBody.AsStringC();
WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP);
}
@@ -1656,10 +1651,12 @@ CFX_FloatRect CPDFSDK_Widget::GetClientRect() const {
CFX_FloatRect rcWindow = GetRotatedRect();
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
switch (GetBorderStyle()) {
- case BBS_BEVELED:
- case BBS_INSET:
+ case BorderStyle::BEVELED:
+ case BorderStyle::INSET:
fBorderWidth *= 2.0f;
break;
+ default:
+ break;
}
return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth);
@@ -1702,31 +1699,24 @@ CFX_ByteString CPDFSDK_Widget::GetBorderAppStream() const {
CPWL_Color crLeftTop, crRightBottom;
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
CPWL_Dash dsBorder(3, 0, 0);
- switch (GetBorderStyle()) {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
+ BorderStyle nBorderStyle = GetBorderStyle();
+ switch (nBorderStyle) {
+ case BorderStyle::DASH:
dsBorder = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
default:
- nBorderStyle = PBS_SOLID;
break;
}
@@ -1808,7 +1798,7 @@ void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType,
ASSERT(pDoc);
CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP");
- CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType.AsByteStringC());
+ CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType);
CPDF_Dictionary* pStreamDict = pStream->GetDict();
CFX_ByteString sImageAlias = "IMG";
@@ -1826,15 +1816,14 @@ void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType,
if (pStreamResList) {
CPDF_Dictionary* pXObject = new CPDF_Dictionary;
- pXObject->SetAtReference(sImageAlias.AsByteStringC(), pDoc, pImage);
+ pXObject->SetAtReference(sImageAlias, pDoc, pImage);
pStreamResList->SetAt("XObject", pXObject);
}
}
void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) {
- if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) {
- pAPDict->RemoveAt(sAPType.AsByteStringC());
- }
+ if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"))
+ pAPDict->RemoveAt(sAPType);
}
FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
@@ -1998,7 +1987,7 @@ CPDFSDK_InterForm::~CPDFSDK_InterForm() {
m_pInterForm = nullptr;
m_Map.clear();
#ifdef PDF_ENABLE_XFA
- m_XFAMap.RemoveAll();
+ m_XFAMap.clear();
#endif // PDF_ENABLE_XFA
}
@@ -2115,18 +2104,19 @@ FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const {
#ifdef PDF_ENABLE_XFA
void CPDFSDK_InterForm::AddXFAMap(CXFA_FFWidget* hWidget,
CPDFSDK_XFAWidget* pWidget) {
- m_XFAMap.SetAt(hWidget, pWidget);
+ ASSERT(hWidget);
+ m_XFAMap[hWidget] = pWidget;
}
void CPDFSDK_InterForm::RemoveXFAMap(CXFA_FFWidget* hWidget) {
- m_XFAMap.RemoveKey(hWidget);
+ ASSERT(hWidget);
+ m_XFAMap.erase(hWidget);
}
CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(CXFA_FFWidget* hWidget) {
- CPDFSDK_XFAWidget* pWidget = NULL;
- m_XFAMap.Lookup(hWidget, pWidget);
-
- return pWidget;
+ ASSERT(hWidget);
+ auto it = m_XFAMap.find(hWidget);
+ return it != m_XFAMap.end() ? it->second : nullptr;
}
void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) {
@@ -2448,21 +2438,15 @@ FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(
bool bIncludeOrExclude,
CFX_ByteTextBuf& textBuf) {
std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF(
- m_pDocument->GetPath().AsWideStringC(), fields, bIncludeOrExclude));
+ m_pDocument->GetPath().AsStringC(), fields, bIncludeOrExclude));
return pFDF ? pFDF->WriteBuf(textBuf) : FALSE;
}
#ifdef PDF_ENABLE_XFA
void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField,
FX_BOOL bSynchronizeElse) {
- int x = 0;
- if (m_FieldSynchronizeMap.Lookup(pFormField, x))
- return;
-
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
- ASSERT(pFormCtrl);
- ASSERT(m_pInterForm);
if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) {
pWidget->Synchronize(bSynchronizeElse);
}
@@ -2486,8 +2470,7 @@ FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination,
CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
CFX_WideString wsPDFFilePath = m_pDocument->GetPath();
- CFDF_Document* pFDFDoc =
- m_pInterForm->ExportToFDF(wsPDFFilePath.AsWideStringC());
+ CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC());
if (!pFDFDoc)
return FALSE;
@@ -2517,7 +2500,7 @@ FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination,
FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) {
CFDF_Document* pFDF =
- m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsWideStringC());
+ m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsStringC());
if (!pFDF)
return FALSE;
diff --git a/chromium/third_party/pdfium/fpdfsdk/fsdk_mgr.cpp b/chromium/third_party/pdfium/fpdfsdk/fsdk_mgr.cpp
index cc228eb8b9d..40a891ca1e1 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fsdk_mgr.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fsdk_mgr.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
+#include "core/fxcrt/include/cfx_retain_ptr.h"
#include "fpdfsdk/formfiller/cffl_formfiller.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/javascript/ijs_runtime.h"
@@ -19,12 +20,12 @@
#include "third_party/base/stl_util.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h"
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
+#include "xfa/fxfa/include/xfa_rendercontext.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
-#include "xfa/include/fxfa/xfa_rendercontext.h"
#endif // PDF_ENABLE_XFA
#if _FX_OS_ == _FX_ANDROID_
@@ -33,194 +34,11 @@
#include <ctime>
#endif
-namespace {
-
-int CharSet2CP(int charset) {
- if (charset == 128)
- return 932;
- if (charset == 134)
- return 936;
- if (charset == 129)
- return 949;
- if (charset == 136)
- return 950;
- return 0;
-}
-
-} // namespace
-
FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) {
return reinterpret_cast<FPDF_WIDESTRING>(
bsUTF16LE->GetBuffer(bsUTF16LE->GetLength()));
}
-class CFX_SystemHandler : public IFX_SystemHandler {
- public:
- explicit CFX_SystemHandler(CPDFDoc_Environment* pEnv)
- : m_pEnv(pEnv), m_nCharSet(-1) {}
- ~CFX_SystemHandler() override {}
-
- public:
- // IFX_SystemHandler
- void InvalidateRect(FX_HWND hWnd, FX_RECT rect) override;
- void OutputSelectedRect(void* pFormFiller, CFX_FloatRect& rect) override;
- FX_BOOL IsSelectionImplemented() override;
- CFX_WideString GetClipboardText(FX_HWND hWnd) override { return L""; }
- FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString str) override {
- return FALSE;
- }
- void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t& y) override {}
- void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t& y) override {}
- void SetCursor(int32_t nCursorType) override;
- FX_HMENU CreatePopupMenu() override { return NULL; }
- FX_BOOL AppendMenuItem(FX_HMENU hMenu,
- int32_t nIDNewItem,
- CFX_WideString str) override {
- return FALSE;
- }
- FX_BOOL EnableMenuItem(FX_HMENU hMenu,
- int32_t nIDItem,
- FX_BOOL bEnabled) override {
- return FALSE;
- }
- int32_t TrackPopupMenu(FX_HMENU hMenu,
- int32_t x,
- int32_t y,
- FX_HWND hParent) override {
- return -1;
- }
- void DestroyMenu(FX_HMENU hMenu) override {}
- CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset) override;
- FX_BOOL FindNativeTrueTypeFont(int32_t nCharset,
- CFX_ByteString sFontFaceName) override;
- CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc,
- CFX_ByteString sFontFaceName,
- uint8_t nCharset) override;
- int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) override;
- void KillTimer(int32_t nID) override;
- FX_BOOL IsSHIFTKeyDown(uint32_t nFlag) override {
- return m_pEnv->FFI_IsSHIFTKeyDown(nFlag);
- }
- FX_BOOL IsCTRLKeyDown(uint32_t nFlag) override {
- return m_pEnv->FFI_IsCTRLKeyDown(nFlag);
- }
- FX_BOOL IsALTKeyDown(uint32_t nFlag) override {
- return m_pEnv->FFI_IsALTKeyDown(nFlag);
- }
- FX_BOOL IsINSERTKeyDown(uint32_t nFlag) override {
- return m_pEnv->FFI_IsINSERTKeyDown(nFlag);
- }
- FX_SYSTEMTIME GetLocalTime() override;
- int32_t GetCharSet() override { return m_nCharSet; }
- void SetCharSet(int32_t nCharSet) override { m_nCharSet = nCharSet; }
-
- private:
- CPDFDoc_Environment* m_pEnv;
- int m_nCharSet;
-};
-
-void CFX_SystemHandler::SetCursor(int32_t nCursorType) {
- m_pEnv->FFI_SetCursor(nCursorType);
-}
-
-void CFX_SystemHandler::InvalidateRect(FX_HWND hWnd, FX_RECT rect) {
- CPDFSDK_Annot* pSDKAnnot = (CPDFSDK_Annot*)hWnd;
- CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView();
- UnderlyingPageType* pPage = pSDKAnnot->GetUnderlyingPage();
- if (!pPage || !pPageView)
- return;
- CFX_Matrix page2device;
- pPageView->GetCurrentMatrix(page2device);
- CFX_Matrix device2page;
- device2page.SetReverse(page2device);
- FX_FLOAT left, top, right, bottom;
- device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top);
- device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right,
- bottom);
- CFX_FloatRect rcPDF(left, bottom, right, top);
- rcPDF.Normalize();
-
- m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right,
- rcPDF.bottom);
-}
-void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller,
- CFX_FloatRect& rect) {
- CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller;
- if (pFFL) {
- CFX_FloatPoint leftbottom = CFX_FloatPoint(rect.left, rect.bottom);
- CFX_FloatPoint righttop = CFX_FloatPoint(rect.right, rect.top);
- CFX_FloatPoint ptA = pFFL->PWLtoFFL(leftbottom);
- CFX_FloatPoint ptB = pFFL->PWLtoFFL(righttop);
- CPDFSDK_Annot* pAnnot = pFFL->GetSDKAnnot();
- UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage();
- ASSERT(pPage);
- m_pEnv->FFI_OutputSelectedRect(pPage, ptA.x, ptB.y, ptB.x, ptA.y);
- }
-}
-
-FX_BOOL CFX_SystemHandler::IsSelectionImplemented() {
- if (m_pEnv) {
- FPDF_FORMFILLINFO* pInfo = m_pEnv->GetFormFillInfo();
- if (pInfo && pInfo->FFI_OutputSelectedRect)
- return TRUE;
- }
- return FALSE;
-}
-
-CFX_ByteString CFX_SystemHandler::GetNativeTrueTypeFont(int32_t nCharset) {
- return "";
-}
-
-FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(
- int32_t nCharset,
- CFX_ByteString sFontFaceName) {
- CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
- if (!pFontMgr)
- return FALSE;
-
- CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
- if (!pFontMapper)
- return FALSE;
-
- if (pFontMapper->m_InstalledTTFonts.empty())
- pFontMapper->LoadInstalledFonts();
-
- for (const auto& font : pFontMapper->m_InstalledTTFonts) {
- if (font.Compare(sFontFaceName.AsByteStringC()))
- return TRUE;
- }
-
- return FALSE;
-}
-
-CPDF_Font* CFX_SystemHandler::AddNativeTrueTypeFontToPDF(
- CPDF_Document* pDoc,
- CFX_ByteString sFontFaceName,
- uint8_t nCharset) {
- if (pDoc) {
- CFX_Font* pFXFont = new CFX_Font();
- pFXFont->LoadSubst(sFontFaceName, TRUE, 0, 0, 0, CharSet2CP(nCharset),
- FALSE);
- CPDF_Font* pFont = pDoc->AddFont(pFXFont, nCharset, FALSE);
- delete pFXFont;
- return pFont;
- }
-
- return NULL;
-}
-
-int32_t CFX_SystemHandler::SetTimer(int32_t uElapse,
- TimerCallback lpTimerFunc) {
- return m_pEnv->FFI_SetTimer(uElapse, lpTimerFunc);
-}
-void CFX_SystemHandler::KillTimer(int32_t nID) {
- m_pEnv->FFI_KillTimer(nID);
-}
-
-FX_SYSTEMTIME CFX_SystemHandler::GetLocalTime() {
- return m_pEnv->FFI_GetLocalTime();
-}
-
CPDFDoc_Environment::CPDFDoc_Environment(UnderlyingDocumentType* pDoc,
FPDF_FORMFILLINFO* pFFinfo)
: m_pInfo(pFFinfo), m_pSDKDoc(NULL), m_pUnderlyingDoc(pDoc) {
@@ -296,7 +114,7 @@ CFX_WideString CPDFDoc_Environment::JS_fieldBrowse() {
if (nActualLen <= 0 || nActualLen > nRequiredLen)
return CFX_WideString();
- return CFX_WideString::FromLocal(CFX_ByteString(pBuff.get(), nActualLen));
+ return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen));
}
CFX_WideString CPDFDoc_Environment::JS_docGetFilePath() {
@@ -316,7 +134,7 @@ CFX_WideString CPDFDoc_Environment::JS_docGetFilePath() {
if (nActualLen <= 0 || nActualLen > nRequiredLen)
return CFX_WideString();
- return CFX_WideString::FromLocal(CFX_ByteString(pBuff.get(), nActualLen));
+ return CFX_WideString::FromLocal(CFX_ByteStringC(pBuff.get(), nActualLen));
}
void CPDFDoc_Environment::JS_docSubmitForm(void* formData,
@@ -476,7 +294,7 @@ void CPDFSDK_Document::ProcJavascriptFun() {
CPDF_Action jsAction = docJS.GetJSAction(i, csJSName);
if (m_pEnv->GetActionHander())
m_pEnv->GetActionHander()->DoAction_JavaScript(
- jsAction, CFX_WideString::FromLocal(csJSName), this);
+ jsAction, CFX_WideString::FromLocal(csJSName.AsStringC()), this);
}
}
@@ -840,7 +658,8 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CXFA_FFWidget* pPDFAnnot) {
#endif // PDF_ENABLE_XFA
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) {
- return pDict ? AddAnnot(pDict->GetStringBy("Subtype"), pDict) : nullptr;
+ return pDict ? AddAnnot(pDict->GetStringBy("Subtype").c_str(), pDict)
+ : nullptr;
}
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,
@@ -1084,15 +903,14 @@ void CPDFSDK_PageView::LoadFXAnnots() {
SetLock(TRUE);
#ifdef PDF_ENABLE_XFA
- m_page->AddRef();
+ CFX_RetainPtr<CPDFXFA_Page> protector(m_page);
if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
CXFA_FFPageView* pageView = m_page->GetXFAPageView();
- IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator(
- XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible |
- XFA_WIDGETFILTER_Viewable |
- XFA_WIDGETFILTER_AllType);
+ std::unique_ptr<IXFA_WidgetIterator> pWidgetHander(
+ pageView->CreateWidgetIterator(
+ XFA_TRAVERSEWAY_Form,
+ XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable));
if (!pWidgetHander) {
- m_page->Release();
SetLock(FALSE);
return;
}
@@ -1101,11 +919,9 @@ void CPDFSDK_PageView::LoadFXAnnots() {
CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pXFAAnnot, this);
if (!pAnnot)
continue;
-
m_fxAnnotArray.push_back(pAnnot);
pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
}
- pWidgetHander->Release();
} else {
CPDF_Page* pPage = m_page->GetPDFPage();
ASSERT(pPage);
@@ -1127,7 +943,6 @@ void CPDFSDK_PageView::LoadFXAnnots() {
pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
}
}
- m_page->Release();
#else // PDF_ENABLE_XFA
for (size_t i = 0; i < nCount; ++i) {
CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
@@ -1157,12 +972,10 @@ void CPDFSDK_PageView::ClearFXAnnots() {
SetLock(FALSE);
}
-void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) {
- for (int i = 0; i < rects.GetSize(); i++) {
- CFX_FloatRect rc = rects.GetAt(i);
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+void CPDFSDK_PageView::UpdateRects(const std::vector<CFX_FloatRect>& rects) {
+ CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+ for (const auto& rc : rects)
pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.bottom);
- }
}
void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) {
diff --git a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_ap.cpp b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_ap.cpp
index 48c6876a742..563acb65b5f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_ap.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_ap.cpp
@@ -8,8 +8,8 @@
#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
#include "core/fpdfdoc/include/cpvt_word.h"
#include "core/fpdfdoc/include/ipvt_fontmap.h"
-#include "fpdfsdk/include/fxedit/fx_edit.h"
-#include "fpdfsdk/include/fxedit/fxet_edit.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fxet_edit.h"
CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
int32_t nFontIndex,
@@ -48,15 +48,12 @@ static CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
int32_t nFontIndex,
FX_FLOAT fFontSize) {
CFX_ByteTextBuf sRet;
-
if (pFontMap) {
CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
-
if (sFontAlias.GetLength() > 0 && fFontSize > 0)
sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
}
-
- return sRet.GetByteString();
+ return sRet.MakeString();
}
CFX_ByteString IFX_Edit::GetEditAppearanceStream(
@@ -70,91 +67,90 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream(
CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
int32_t nCurFontIndex = -1;
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
-
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- if (bContinuous) {
- if (place.LineCmp(oldplace) != 0) {
- if (sWords.GetSize() > 0) {
- sEditStream << GetWordRenderString(sWords.GetByteString());
- sWords.Clear();
- }
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y);
- } else {
- CPVT_Line line;
- pIterator->GetLine(line);
- ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
- line.ptLine.y + ptOffset.y);
- }
+ CPVT_WordPlace oldplace;
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
- ptOld = ptNew;
- }
- }
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (word.nFontIndex != nCurFontIndex) {
- if (sWords.GetSize() > 0) {
- sEditStream << GetWordRenderString(sWords.GetByteString());
- sWords.Clear();
- }
- sEditStream << GetFontSetString(pEdit->GetFontMap(),
- word.nFontIndex, word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
-
- sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex,
- word.Word, SubWord);
+ if (bContinuous) {
+ if (place.LineCmp(oldplace) != 0) {
+ if (sWords.GetSize() > 0) {
+ sEditStream << GetWordRenderString(sWords.MakeString());
+ sWords.Clear();
}
- oldplace = place;
- } else {
CPVT_Word word;
if (pIterator->GetWord(word)) {
ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
word.ptWord.y + ptOffset.y);
+ } else {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+ ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
+ line.ptLine.y + ptOffset.y);
+ }
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
- << " Td\n";
- ptOld = ptNew;
- }
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+
+ ptOld = ptNew;
+ }
+ }
- if (word.nFontIndex != nCurFontIndex) {
- sEditStream << GetFontSetString(pEdit->GetFontMap(),
- word.nFontIndex, word.fFontSize);
- nCurFontIndex = word.nFontIndex;
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (word.nFontIndex != nCurFontIndex) {
+ if (sWords.GetSize() > 0) {
+ sEditStream << GetWordRenderString(sWords.MakeString());
+ sWords.Clear();
}
+ sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
+ word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
+ }
+
+ sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex,
+ word.Word, SubWord);
+ }
- sEditStream << GetWordRenderString(GetPDFWordString(
- pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord));
+ oldplace = place;
+ } else {
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y);
+
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+ ptOld = ptNew;
}
+
+ if (word.nFontIndex != nCurFontIndex) {
+ sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
+ word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
+ }
+
+ sEditStream << GetWordRenderString(GetPDFWordString(
+ pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord));
}
}
+ }
- if (sWords.GetSize() > 0) {
- sEditStream << GetWordRenderString(sWords.GetByteString());
- sWords.Clear();
- }
+ if (sWords.GetSize() > 0) {
+ sEditStream << GetWordRenderString(sWords.MakeString());
+ sWords.Clear();
}
CFX_ByteTextBuf sAppStream;
@@ -172,7 +168,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream(
sAppStream << sEditStream;
}
- return sAppStream.GetByteString();
+ return sAppStream.MakeString();
}
CFX_ByteString IFX_Edit::GetSelectAppearanceStream(
@@ -182,25 +178,24 @@ CFX_ByteString IFX_Edit::GetSelectAppearanceStream(
CFX_ByteTextBuf sRet;
if (pRange && pRange->IsExist()) {
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- pIterator->SetAt(pRange->BeginPos);
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ pIterator->SetAt(pRange->BeginPos);
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word) && pIterator->GetLine(line)) {
- sRet << word.ptWord.x + ptOffset.x << " "
- << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " "
- << line.fLineAscent - line.fLineDescent << " re\nf\n";
- }
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word) && pIterator->GetLine(line)) {
+ sRet << word.ptWord.x + ptOffset.x << " "
+ << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " "
+ << line.fLineAscent - line.fLineDescent << " re\nf\n";
}
}
}
- return sRet.GetByteString();
+ return sRet.MakeString();
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_edit.cpp b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_edit.cpp
index f275248ac26..d2abb176eb7 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_edit.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/include/fxedit/fxet_edit.h"
+#include "fpdfsdk/fxedit/include/fxet_edit.h"
#include <algorithm>
@@ -13,7 +13,11 @@
#include "core/fpdfdoc/include/cpvt_word.h"
#include "core/fpdfdoc/include/ipvt_fontmap.h"
-#define FX_EDIT_UNDO_MAXITEM 10000
+namespace {
+
+const int kEditUndoMaxItems = 10000;
+
+} // namespace
CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit,
CPDF_VariableText::Iterator* pVTIterator)
@@ -219,7 +223,7 @@ void CFX_Edit_Refresh::Analyse(int32_t nAlignment) {
rcResult.left = rcResult.right - fWidthDiff;
} else {
rcResult.left = rcResult.right;
- rcResult.right += (-fWidthDiff);
+ rcResult.right -= fWidthDiff;
}
}
m_RefreshRects.Add(rcResult);
@@ -744,18 +748,17 @@ void CFXEU_SetWordProps::Undo() {
CFX_Edit::CFX_Edit(CPDF_VariableText* pVT)
: m_pVT(pVT),
- m_pNotify(NULL),
- m_pOprNotify(NULL),
- m_pVTProvide(NULL),
+ m_pNotify(nullptr),
+ m_pOprNotify(nullptr),
m_wpCaret(-1, -1, -1),
m_wpOldCaret(-1, -1, -1),
m_SelState(),
m_ptScrollPos(0, 0),
m_ptRefreshScrollPos(0, 0),
m_bEnableScroll(FALSE),
- m_pIterator(NULL),
+ m_pIterator(nullptr),
m_ptCaret(0.0f, 0.0f),
- m_Undo(FX_EDIT_UNDO_MAXITEM),
+ m_Undo(kEditUndoMaxItems),
m_nAlignment(0),
m_bNotifyFlag(FALSE),
m_bEnableOverflow(FALSE),
@@ -764,15 +767,11 @@ CFX_Edit::CFX_Edit(CPDF_VariableText* pVT)
m_bEnableUndo(TRUE),
m_bNotify(TRUE),
m_bOprNotify(FALSE),
- m_pGroupUndoItem(NULL) {
+ m_pGroupUndoItem(nullptr) {
ASSERT(pVT);
}
CFX_Edit::~CFX_Edit() {
- delete m_pVTProvide;
- m_pVTProvide = NULL;
- delete m_pIterator;
- m_pIterator = NULL;
ASSERT(!m_pGroupUndoItem);
}
@@ -783,12 +782,8 @@ void CFX_Edit::Initialize() {
}
void CFX_Edit::SetFontMap(IPVT_FontMap* pFontMap) {
- delete m_pVTProvide;
- m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap));
-}
-
-void CFX_Edit::SetVTProvider(CPDF_VariableText::Provider* pProvider) {
- m_pVT->SetProvider(pProvider);
+ m_pVTProvider.reset(new CFX_Edit_Provider(pFontMap));
+ m_pVT->SetProvider(m_pVTProvider.get());
}
void CFX_Edit::SetNotify(IFX_Edit_Notify* pNotify) {
@@ -801,9 +796,8 @@ void CFX_Edit::SetOprNotify(IFX_Edit_OprNotify* pOprNotify) {
IFX_Edit_Iterator* CFX_Edit::GetIterator() {
if (!m_pIterator)
- m_pIterator = new CFX_Edit_Iterator(this, m_pVT->GetIterator());
-
- return m_pIterator;
+ m_pIterator.reset(new CFX_Edit_Iterator(this, m_pVT->GetIterator()));
+ return m_pIterator.get();
}
CPDF_VariableText* CFX_Edit::GetVariableText() {
@@ -811,10 +805,7 @@ CPDF_VariableText* CFX_Edit::GetVariableText() {
}
IPVT_FontMap* CFX_Edit::GetFontMap() {
- if (m_pVTProvide)
- return m_pVTProvide->GetFontMap();
-
- return NULL;
+ return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr;
}
void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect, FX_BOOL bPaint) {
@@ -980,33 +971,24 @@ CPVT_WordPlace CFX_Edit::GetCaretWordPlace() const {
CFX_WideString CFX_Edit::GetText() const {
CFX_WideString swRet;
- if (m_pVT->IsValid()) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- FX_BOOL bRich = m_pVT->IsRichText();
+ if (!m_pVT->IsValid())
+ return swRet;
- pIterator->SetAt(0);
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(0);
- CPVT_Word wordinfo;
- CPVT_WordPlace oldplace = pIterator->GetAt();
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
+ CPVT_Word wordinfo;
+ CPVT_WordPlace oldplace = pIterator->GetAt();
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
- if (pIterator->GetWord(wordinfo)) {
- if (bRich) {
- swRet += wordinfo.Word;
- } else {
- swRet += wordinfo.Word;
- }
- }
+ if (pIterator->GetWord(wordinfo))
+ swRet += wordinfo.Word;
- if (oldplace.SecCmp(place) != 0) {
- swRet += 0x0D;
- swRet += 0x0A;
- }
+ if (oldplace.SecCmp(place) != 0)
+ swRet += L"\r\n";
- oldplace = place;
- }
- }
+ oldplace = place;
}
return swRet;
@@ -1015,38 +997,29 @@ CFX_WideString CFX_Edit::GetText() const {
CFX_WideString CFX_Edit::GetRangeText(const CPVT_WordRange& range) const {
CFX_WideString swRet;
- if (m_pVT->IsValid()) {
- FX_BOOL bRich = m_pVT->IsRichText();
+ if (!m_pVT->IsValid())
+ return swRet;
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- CPVT_WordRange wrTemp = range;
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ CPVT_WordRange wrTemp = range;
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
- CPVT_Word wordinfo;
- CPVT_WordPlace oldplace = wrTemp.BeginPos;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0)
- break;
+ CPVT_Word wordinfo;
+ CPVT_WordPlace oldplace = wrTemp.BeginPos;
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)
+ break;
- if (pIterator->GetWord(wordinfo)) {
- if (bRich) {
- swRet += wordinfo.Word;
- } else {
- swRet += wordinfo.Word;
- }
- }
+ if (pIterator->GetWord(wordinfo))
+ swRet += wordinfo.Word;
- if (oldplace.SecCmp(place) != 0) {
- swRet += 0x0D;
- swRet += 0x0A;
- }
+ if (oldplace.SecCmp(place) != 0)
+ swRet += L"\r\n";
- oldplace = place;
- }
- }
+ oldplace = place;
}
return swRet;
@@ -1061,15 +1034,14 @@ int32_t CFX_Edit::GetTotalWords() const {
}
int32_t CFX_Edit::GetTotalLines() const {
- int32_t nLines = 0;
+ int32_t nLines = 1;
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- pIterator->SetAt(0);
- while (pIterator->NextLine())
- nLines++;
- }
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(0);
+ while (pIterator->NextLine())
+ ++nLines;
- return nLines + 1;
+ return nLines;
}
CPVT_WordRange CFX_Edit::GetSelectWordRange() const {
@@ -1190,39 +1162,37 @@ FX_BOOL CFX_Edit::SetRichTextAlignment(int32_t nAlignment) {
FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps,
const CPVT_SecProps* pSecProps,
const CPVT_WordProps* pWordProps) {
- FX_BOOL bSet = FALSE;
- FX_BOOL bSet1, bSet2;
- if (m_pVT->IsValid() && m_pVT->IsRichText()) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
+ if (!m_pVT->IsValid() || !m_pVT->IsRichText())
+ return FALSE;
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
- BeginGroupUndo(L"");
- bSet = SetSecProps(eProps, wrTemp.BeginPos, pSecProps, pWordProps, wrTemp,
- TRUE);
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0)
- break;
- bSet1 = SetSecProps(eProps, place, pSecProps, pWordProps, wrTemp, TRUE);
- bSet2 = SetWordProps(eProps, place, pWordProps, wrTemp, TRUE);
-
- if (!bSet)
- bSet = (bSet1 || bSet2);
- }
+ BeginGroupUndo(L"");
+ FX_BOOL bSet =
+ SetSecProps(eProps, wrTemp.BeginPos, pSecProps, pWordProps, wrTemp, TRUE);
- EndGroupUndo();
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)
+ break;
+ FX_BOOL bSet1 =
+ SetSecProps(eProps, place, pSecProps, pWordProps, wrTemp, TRUE);
+ FX_BOOL bSet2 = SetWordProps(eProps, place, pWordProps, wrTemp, TRUE);
- if (bSet) {
- PaintSetProps(eProps, wrTemp);
- }
- }
+ if (!bSet)
+ bSet = (bSet1 || bSet2);
}
+ EndGroupUndo();
+
+ if (bSet)
+ PaintSetProps(eProps, wrTemp);
+
return bSet;
}
@@ -1268,321 +1238,308 @@ FX_BOOL CFX_Edit::SetSecProps(EDIT_PROPS_E eProps,
const CPVT_WordProps* pWordProps,
const CPVT_WordRange& wr,
FX_BOOL bAddUndo) {
- if (m_pVT->IsValid() && m_pVT->IsRichText()) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- FX_BOOL bSet = FALSE;
- CPVT_Section secinfo;
- CPVT_Section OldSecinfo;
-
- CPVT_WordPlace oldplace = pIterator->GetAt();
+ if (!m_pVT->IsValid() || !m_pVT->IsRichText())
+ return FALSE;
- if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT ||
- eProps == EP_ALIGNMENT) {
- if (pSecProps) {
- pIterator->SetAt(place);
- if (pIterator->GetSection(secinfo)) {
- if (bAddUndo)
- OldSecinfo = secinfo;
-
- switch (eProps) {
- case EP_LINELEADING:
- if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineLeading,
- pSecProps->fLineLeading)) {
- secinfo.SecProps.fLineLeading = pSecProps->fLineLeading;
- bSet = TRUE;
- }
- break;
- case EP_LINEINDENT:
- if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineIndent,
- pSecProps->fLineIndent)) {
- secinfo.SecProps.fLineIndent = pSecProps->fLineIndent;
- bSet = TRUE;
- }
- break;
- case EP_ALIGNMENT:
- if (secinfo.SecProps.nAlignment != pSecProps->nAlignment) {
- secinfo.SecProps.nAlignment = pSecProps->nAlignment;
- bSet = TRUE;
- }
- break;
- default:
- break;
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ FX_BOOL bSet = FALSE;
+ CPVT_Section secinfo;
+ CPVT_Section OldSecinfo;
+
+ CPVT_WordPlace oldplace = pIterator->GetAt();
+
+ if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT ||
+ eProps == EP_ALIGNMENT) {
+ if (pSecProps) {
+ pIterator->SetAt(place);
+ if (pIterator->GetSection(secinfo)) {
+ if (bAddUndo)
+ OldSecinfo = secinfo;
+
+ switch (eProps) {
+ case EP_LINELEADING:
+ if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineLeading,
+ pSecProps->fLineLeading)) {
+ secinfo.SecProps.fLineLeading = pSecProps->fLineLeading;
+ bSet = TRUE;
}
- }
- }
- } else {
- if (pWordProps && place == m_pVT->GetSectionBeginPlace(place)) {
- pIterator->SetAt(place);
- if (pIterator->GetSection(secinfo)) {
- if (bAddUndo)
- OldSecinfo = secinfo;
-
- switch (eProps) {
- case EP_FONTINDEX:
- if (secinfo.WordProps.nFontIndex != pWordProps->nFontIndex) {
- secinfo.WordProps.nFontIndex = pWordProps->nFontIndex;
- bSet = TRUE;
- }
- break;
- case EP_FONTSIZE:
- if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fFontSize,
- pWordProps->fFontSize)) {
- secinfo.WordProps.fFontSize = pWordProps->fFontSize;
- bSet = TRUE;
- }
- break;
- case EP_WORDCOLOR:
- if (secinfo.WordProps.dwWordColor != pWordProps->dwWordColor) {
- secinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
- bSet = TRUE;
- }
- break;
- case EP_SCRIPTTYPE:
- if (secinfo.WordProps.nScriptType != pWordProps->nScriptType) {
- secinfo.WordProps.nScriptType = pWordProps->nScriptType;
- bSet = TRUE;
- }
- break;
- case EP_CHARSPACE:
- if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fCharSpace,
- pWordProps->fCharSpace)) {
- secinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
- bSet = TRUE;
- }
- break;
- case EP_HORZSCALE:
- if (secinfo.WordProps.nHorzScale != pWordProps->nHorzScale) {
- secinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
- bSet = TRUE;
- }
- break;
- case EP_UNDERLINE:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) {
- if ((secinfo.WordProps.nWordStyle &
- PVTWORD_STYLE_UNDERLINE) == 0) {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- } else {
- if ((secinfo.WordProps.nWordStyle &
- PVTWORD_STYLE_UNDERLINE) != 0) {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- break;
- case EP_CROSSOUT:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) ==
- 0) {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- } else {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) !=
- 0) {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- break;
- case EP_BOLD:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) ==
- 0) {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- } else {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) !=
- 0) {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- break;
- case EP_ITALIC:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) ==
- 0) {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- } else {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) !=
- 0) {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- break;
- default:
- break;
+ break;
+ case EP_LINEINDENT:
+ if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineIndent,
+ pSecProps->fLineIndent)) {
+ secinfo.SecProps.fLineIndent = pSecProps->fLineIndent;
+ bSet = TRUE;
}
- }
- }
- }
-
- if (bSet) {
- pIterator->SetSection(secinfo);
-
- if (bAddUndo && m_bEnableUndo) {
- AddEditUndoItem(new CFXEU_SetSecProps(
- this, place, eProps, OldSecinfo.SecProps, OldSecinfo.WordProps,
- secinfo.SecProps, secinfo.WordProps, wr));
+ break;
+ case EP_ALIGNMENT:
+ if (secinfo.SecProps.nAlignment != pSecProps->nAlignment) {
+ secinfo.SecProps.nAlignment = pSecProps->nAlignment;
+ bSet = TRUE;
+ }
+ break;
+ default:
+ break;
}
}
-
- pIterator->SetAt(oldplace);
-
- return bSet;
}
- }
-
- return FALSE;
-}
-
-FX_BOOL CFX_Edit::SetWordProps(EDIT_PROPS_E eProps,
- const CPVT_WordPlace& place,
- const CPVT_WordProps* pWordProps,
- const CPVT_WordRange& wr,
- FX_BOOL bAddUndo) {
- if (m_pVT->IsValid() && m_pVT->IsRichText()) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- FX_BOOL bSet = FALSE;
- CPVT_Word wordinfo;
- CPVT_Word OldWordinfo;
-
- CPVT_WordPlace oldplace = pIterator->GetAt();
-
- if (pWordProps) {
- pIterator->SetAt(place);
- if (pIterator->GetWord(wordinfo)) {
- if (bAddUndo)
- OldWordinfo = wordinfo;
-
- switch (eProps) {
- case EP_FONTINDEX:
- if (wordinfo.WordProps.nFontIndex != pWordProps->nFontIndex) {
- if (IPVT_FontMap* pFontMap = GetFontMap()) {
- wordinfo.WordProps.nFontIndex = pFontMap->GetWordFontIndex(
- wordinfo.Word, wordinfo.nCharset, pWordProps->nFontIndex);
- }
+ } else {
+ if (pWordProps && place == m_pVT->GetSectionBeginPlace(place)) {
+ pIterator->SetAt(place);
+ if (pIterator->GetSection(secinfo)) {
+ if (bAddUndo)
+ OldSecinfo = secinfo;
+
+ switch (eProps) {
+ case EP_FONTINDEX:
+ if (secinfo.WordProps.nFontIndex != pWordProps->nFontIndex) {
+ secinfo.WordProps.nFontIndex = pWordProps->nFontIndex;
+ bSet = TRUE;
+ }
+ break;
+ case EP_FONTSIZE:
+ if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fFontSize,
+ pWordProps->fFontSize)) {
+ secinfo.WordProps.fFontSize = pWordProps->fFontSize;
+ bSet = TRUE;
+ }
+ break;
+ case EP_WORDCOLOR:
+ if (secinfo.WordProps.dwWordColor != pWordProps->dwWordColor) {
+ secinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
+ bSet = TRUE;
+ }
+ break;
+ case EP_SCRIPTTYPE:
+ if (secinfo.WordProps.nScriptType != pWordProps->nScriptType) {
+ secinfo.WordProps.nScriptType = pWordProps->nScriptType;
+ bSet = TRUE;
+ }
+ break;
+ case EP_CHARSPACE:
+ if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fCharSpace,
+ pWordProps->fCharSpace)) {
+ secinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
+ bSet = TRUE;
+ }
+ break;
+ case EP_HORZSCALE:
+ if (secinfo.WordProps.nHorzScale != pWordProps->nHorzScale) {
+ secinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
+ bSet = TRUE;
+ }
+ break;
+ case EP_UNDERLINE:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) ==
+ 0) {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
bSet = TRUE;
}
- break;
- case EP_FONTSIZE:
- if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fFontSize,
- pWordProps->fFontSize)) {
- wordinfo.WordProps.fFontSize = pWordProps->fFontSize;
+ } else {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) !=
+ 0) {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
bSet = TRUE;
}
- break;
- case EP_WORDCOLOR:
- if (wordinfo.WordProps.dwWordColor != pWordProps->dwWordColor) {
- wordinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
+ }
+ break;
+ case EP_CROSSOUT:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) ==
+ 0) {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
bSet = TRUE;
}
- break;
- case EP_SCRIPTTYPE:
- if (wordinfo.WordProps.nScriptType != pWordProps->nScriptType) {
- wordinfo.WordProps.nScriptType = pWordProps->nScriptType;
+ } else {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) !=
+ 0) {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
bSet = TRUE;
}
- break;
- case EP_CHARSPACE:
- if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fCharSpace,
- pWordProps->fCharSpace)) {
- wordinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
+ }
+ break;
+ case EP_BOLD:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0) {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
bSet = TRUE;
}
- break;
- case EP_HORZSCALE:
- if (wordinfo.WordProps.nHorzScale != pWordProps->nHorzScale) {
- wordinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
+ } else {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0) {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
bSet = TRUE;
}
- break;
- case EP_UNDERLINE:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) ==
- 0) {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- } else {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) !=
- 0) {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- break;
- case EP_CROSSOUT:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) ==
- 0) {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- } else {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) !=
- 0) {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- break;
- case EP_BOLD:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0) {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- } else {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0) {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
+ }
+ break;
+ case EP_ITALIC:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0) {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
}
- break;
- case EP_ITALIC:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) ==
- 0) {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- } else {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) !=
- 0) {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
+ } else {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0) {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
}
- break;
- default:
- break;
- }
+ }
+ break;
+ default:
+ break;
}
}
+ }
+ }
- if (bSet) {
- pIterator->SetWord(wordinfo);
+ if (bSet) {
+ pIterator->SetSection(secinfo);
- if (bAddUndo && m_bEnableUndo) {
- AddEditUndoItem(new CFXEU_SetWordProps(this, place, eProps,
- OldWordinfo.WordProps,
- wordinfo.WordProps, wr));
- }
+ if (bAddUndo && m_bEnableUndo) {
+ AddEditUndoItem(new CFXEU_SetSecProps(
+ this, place, eProps, OldSecinfo.SecProps, OldSecinfo.WordProps,
+ secinfo.SecProps, secinfo.WordProps, wr));
+ }
+ }
+
+ pIterator->SetAt(oldplace);
+
+ return bSet;
+}
+
+FX_BOOL CFX_Edit::SetWordProps(EDIT_PROPS_E eProps,
+ const CPVT_WordPlace& place,
+ const CPVT_WordProps* pWordProps,
+ const CPVT_WordRange& wr,
+ FX_BOOL bAddUndo) {
+ if (!m_pVT->IsValid() || !m_pVT->IsRichText())
+ return FALSE;
+
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ FX_BOOL bSet = FALSE;
+ CPVT_Word wordinfo;
+ CPVT_Word OldWordinfo;
+
+ CPVT_WordPlace oldplace = pIterator->GetAt();
+
+ if (pWordProps) {
+ pIterator->SetAt(place);
+ if (pIterator->GetWord(wordinfo)) {
+ if (bAddUndo)
+ OldWordinfo = wordinfo;
+
+ switch (eProps) {
+ case EP_FONTINDEX:
+ if (wordinfo.WordProps.nFontIndex != pWordProps->nFontIndex) {
+ if (IPVT_FontMap* pFontMap = GetFontMap()) {
+ wordinfo.WordProps.nFontIndex = pFontMap->GetWordFontIndex(
+ wordinfo.Word, wordinfo.nCharset, pWordProps->nFontIndex);
+ }
+ bSet = TRUE;
+ }
+ break;
+ case EP_FONTSIZE:
+ if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fFontSize,
+ pWordProps->fFontSize)) {
+ wordinfo.WordProps.fFontSize = pWordProps->fFontSize;
+ bSet = TRUE;
+ }
+ break;
+ case EP_WORDCOLOR:
+ if (wordinfo.WordProps.dwWordColor != pWordProps->dwWordColor) {
+ wordinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
+ bSet = TRUE;
+ }
+ break;
+ case EP_SCRIPTTYPE:
+ if (wordinfo.WordProps.nScriptType != pWordProps->nScriptType) {
+ wordinfo.WordProps.nScriptType = pWordProps->nScriptType;
+ bSet = TRUE;
+ }
+ break;
+ case EP_CHARSPACE:
+ if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fCharSpace,
+ pWordProps->fCharSpace)) {
+ wordinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
+ bSet = TRUE;
+ }
+ break;
+ case EP_HORZSCALE:
+ if (wordinfo.WordProps.nHorzScale != pWordProps->nHorzScale) {
+ wordinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
+ bSet = TRUE;
+ }
+ break;
+ case EP_UNDERLINE:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) ==
+ 0) {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ } else {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) !=
+ 0) {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_CROSSOUT:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0) {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ } else {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0) {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_BOLD:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0) {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ } else {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0) {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_ITALIC:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0) {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ } else {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0) {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ }
+ break;
+ default:
+ break;
}
+ }
+ }
+
+ if (bSet) {
+ pIterator->SetWord(wordinfo);
- pIterator->SetAt(oldplace);
- return bSet;
+ if (bAddUndo && m_bEnableUndo) {
+ AddEditUndoItem(new CFXEU_SetWordProps(
+ this, place, eProps, OldWordinfo.WordProps, wordinfo.WordProps, wr));
}
}
- return FALSE;
+ pIterator->SetAt(oldplace);
+ return bSet;
}
void CFX_Edit::SetText(const FX_WCHAR* text,
@@ -1918,52 +1875,52 @@ void CFX_Edit::SetScrollLimit() {
void CFX_Edit::ScrollToCaret() {
SetScrollLimit();
- if (m_pVT->IsValid()) {
- CFX_FloatPoint ptHead(0, 0);
- CFX_FloatPoint ptFoot(0, 0);
+ if (!m_pVT->IsValid())
+ return;
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- pIterator->SetAt(m_wpCaret);
+ CFX_FloatPoint ptHead(0, 0);
+ CFX_FloatPoint ptFoot(0, 0);
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word)) {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- } else if (pIterator->GetLine(line)) {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
- }
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(m_wpCaret);
- CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead);
- CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot);
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word)) {
+ ptHead.x = word.ptWord.x + word.fWidth;
+ ptHead.y = word.ptWord.y + word.fAscent;
+ ptFoot.x = word.ptWord.x + word.fWidth;
+ ptFoot.y = word.ptWord.y + word.fDescent;
+ } else if (pIterator->GetLine(line)) {
+ ptHead.x = line.ptLine.x;
+ ptHead.y = line.ptLine.y + line.fLineAscent;
+ ptFoot.x = line.ptLine.x;
+ ptFoot.y = line.ptLine.y + line.fLineDescent;
+ }
- CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
+ CFX_FloatPoint ptHeadEdit = VTToEdit(ptHead);
+ CFX_FloatPoint ptFootEdit = VTToEdit(ptFoot);
- if (!FX_EDIT_IsFloatEqual(rcPlate.left, rcPlate.right)) {
- if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
- FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left)) {
- SetScrollPosX(ptHead.x);
- } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right)) {
- SetScrollPosX(ptHead.x - rcPlate.Width());
- }
+ CFX_FloatRect rcPlate = m_pVT->GetPlateRect();
+
+ if (!FX_EDIT_IsFloatEqual(rcPlate.left, rcPlate.right)) {
+ if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
+ FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left)) {
+ SetScrollPosX(ptHead.x);
+ } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right)) {
+ SetScrollPosX(ptHead.x - rcPlate.Width());
}
+ }
- if (!FX_EDIT_IsFloatEqual(rcPlate.top, rcPlate.bottom)) {
- if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) ||
- FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom)) {
- if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top)) {
- SetScrollPosY(ptFoot.y + rcPlate.Height());
- }
- } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top)) {
- if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) {
- SetScrollPosY(ptHead.y);
- }
+ if (!FX_EDIT_IsFloatEqual(rcPlate.top, rcPlate.bottom)) {
+ if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) ||
+ FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom)) {
+ if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top)) {
+ SetScrollPosY(ptFoot.y + rcPlate.Height());
+ }
+ } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top)) {
+ if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) {
+ SetScrollPosY(ptHead.y);
}
}
}
@@ -1995,129 +1952,128 @@ void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan,
}
void CFX_Edit::RefreshPushLineRects(const CPVT_WordRange& wr) {
- if (m_pVT->IsValid()) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- CPVT_WordPlace wpBegin = wr.BeginPos;
- m_pVT->UpdateWordPlace(wpBegin);
- CPVT_WordPlace wpEnd = wr.EndPos;
- m_pVT->UpdateWordPlace(wpEnd);
- pIterator->SetAt(wpBegin);
-
- CPVT_Line lineinfo;
- do {
- if (!pIterator->GetLine(lineinfo))
- break;
- if (lineinfo.lineplace.LineCmp(wpEnd) > 0)
- break;
+ if (!m_pVT->IsValid())
+ return;
- CFX_FloatRect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ CPVT_WordPlace wpBegin = wr.BeginPos;
+ m_pVT->UpdateWordPlace(wpBegin);
+ CPVT_WordPlace wpEnd = wr.EndPos;
+ m_pVT->UpdateWordPlace(wpEnd);
+ pIterator->SetAt(wpBegin);
- m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd),
- VTToEdit(rcLine));
- } while (pIterator->NextLine());
- }
- }
+ CPVT_Line lineinfo;
+ do {
+ if (!pIterator->GetLine(lineinfo))
+ break;
+ if (lineinfo.lineplace.LineCmp(wpEnd) > 0)
+ break;
+
+ CFX_FloatRect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd),
+ VTToEdit(rcLine));
+ } while (pIterator->NextLine());
}
void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange& wr) {
- if (m_pVT->IsValid()) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- CPVT_WordRange wrTemp = wr;
+ if (!m_pVT->IsValid())
+ return;
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ CPVT_WordRange wrTemp = wr;
- CPVT_Word wordinfo;
- CPVT_Line lineinfo;
- CPVT_WordPlace place;
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
- while (pIterator->NextWord()) {
- place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0)
- break;
+ CPVT_Word wordinfo;
+ CPVT_Line lineinfo;
+ CPVT_WordPlace place;
- pIterator->GetWord(wordinfo);
- pIterator->GetLine(lineinfo);
+ while (pIterator->NextWord()) {
+ place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)
+ break;
- if (place.LineCmp(wrTemp.BeginPos) == 0 ||
- place.LineCmp(wrTemp.EndPos) == 0) {
- CFX_FloatRect rcWord(wordinfo.ptWord.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- wordinfo.ptWord.x + wordinfo.fWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ pIterator->GetWord(wordinfo);
+ pIterator->GetLine(lineinfo);
- m_Refresh.AddRefresh(VTToEdit(rcWord));
- } else {
- CFX_FloatRect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ if (place.LineCmp(wrTemp.BeginPos) == 0 ||
+ place.LineCmp(wrTemp.EndPos) == 0) {
+ CFX_FloatRect rcWord(wordinfo.ptWord.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ wordinfo.ptWord.x + wordinfo.fWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
- m_Refresh.AddRefresh(VTToEdit(rcLine));
+ m_Refresh.AddRefresh(VTToEdit(rcWord));
+ } else {
+ CFX_FloatRect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
- pIterator->NextLine();
- }
- }
+ m_Refresh.AddRefresh(VTToEdit(rcLine));
+
+ pIterator->NextLine();
}
}
}
void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- CPVT_WordRange wrTemp = wr;
-
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
-
- CPVT_Word wordinfo;
- CPVT_Line lineinfo;
- CPVT_WordPlace place;
-
- while (pIterator->NextWord()) {
- place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0)
- break;
-
- pIterator->GetWord(wordinfo);
- pIterator->GetLine(lineinfo);
-
- if (place.LineCmp(wrTemp.BeginPos) == 0 ||
- place.LineCmp(wrTemp.EndPos) == 0) {
- CFX_FloatRect rcWord(wordinfo.ptWord.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- wordinfo.ptWord.x + wordinfo.fWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- if (m_bNotify && m_pNotify) {
- if (!m_bNotifyFlag) {
- m_bNotifyFlag = TRUE;
- CFX_FloatRect rcRefresh = VTToEdit(rcWord);
- m_pNotify->IOnInvalidateRect(&rcRefresh);
- m_bNotifyFlag = FALSE;
- }
- }
- } else {
- CFX_FloatRect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- if (m_bNotify && m_pNotify) {
- if (!m_bNotifyFlag) {
- m_bNotifyFlag = TRUE;
- CFX_FloatRect rcRefresh = VTToEdit(rcLine);
- m_pNotify->IOnInvalidateRect(&rcRefresh);
- m_bNotifyFlag = FALSE;
- }
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ CPVT_WordRange wrTemp = wr;
+
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
+
+ CPVT_Word wordinfo;
+ CPVT_Line lineinfo;
+ CPVT_WordPlace place;
+
+ while (pIterator->NextWord()) {
+ place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)
+ break;
+
+ pIterator->GetWord(wordinfo);
+ pIterator->GetLine(lineinfo);
+
+ if (place.LineCmp(wrTemp.BeginPos) == 0 ||
+ place.LineCmp(wrTemp.EndPos) == 0) {
+ CFX_FloatRect rcWord(wordinfo.ptWord.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ wordinfo.ptWord.x + wordinfo.fWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ if (m_bNotify && m_pNotify) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ CFX_FloatRect rcRefresh = VTToEdit(rcWord);
+ m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_bNotifyFlag = FALSE;
}
+ }
+ } else {
+ CFX_FloatRect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
- pIterator->NextLine();
+ if (m_bNotify && m_pNotify) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ CFX_FloatRect rcRefresh = VTToEdit(rcLine);
+ m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_bNotifyFlag = FALSE;
+ }
}
+
+ pIterator->NextLine();
}
}
}
@@ -2132,21 +2088,20 @@ void CFX_Edit::SetCaretInfo() {
if (!m_bNotifyFlag) {
CFX_FloatPoint ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f);
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word)) {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- } else if (pIterator->GetLine(line)) {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word)) {
+ ptHead.x = word.ptWord.x + word.fWidth;
+ ptHead.y = word.ptWord.y + word.fAscent;
+ ptFoot.x = word.ptWord.x + word.fWidth;
+ ptFoot.y = word.ptWord.y + word.fDescent;
+ } else if (pIterator->GetLine(line)) {
+ ptHead.x = line.ptLine.x;
+ ptHead.y = line.ptLine.y + line.fLineAscent;
+ ptFoot.x = line.ptLine.x;
+ ptFoot.y = line.ptLine.y + line.fLineDescent;
}
m_bNotifyFlag = TRUE;
@@ -2163,30 +2118,29 @@ void CFX_Edit::SetCaretChange() {
if (m_wpCaret == m_wpOldCaret)
return;
- if (m_bNotify && m_pVT->IsRichText() && m_pNotify) {
- CPVT_SecProps SecProps;
- CPVT_WordProps WordProps;
+ if (!m_bNotify || !m_pVT->IsRichText() || !m_pNotify)
+ return;
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Section section;
+ CPVT_SecProps SecProps;
+ CPVT_WordProps WordProps;
- if (pIterator->GetSection(section)) {
- SecProps = section.SecProps;
- WordProps = section.WordProps;
- }
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Section section;
- if (pIterator->GetWord(word)) {
- WordProps = word.WordProps;
- }
- }
+ if (pIterator->GetSection(section)) {
+ SecProps = section.SecProps;
+ WordProps = section.WordProps;
+ }
- if (!m_bNotifyFlag) {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnCaretChange(SecProps, WordProps);
- m_bNotifyFlag = FALSE;
- }
+ if (pIterator->GetWord(word))
+ WordProps = word.WordProps;
+
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnCaretChange(SecProps, WordProps);
+ m_bNotifyFlag = FALSE;
}
}
@@ -2550,11 +2504,10 @@ FX_BOOL CFX_Edit::Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint) {
CPVT_Word word;
if (bAddUndo) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- pIterator->SetAt(m_wpCaret);
- pIterator->GetSection(section);
- pIterator->GetWord(word);
- }
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(m_wpCaret);
+ pIterator->GetSection(section);
+ pIterator->GetWord(word);
}
m_pVT->UpdateWordPlace(m_wpCaret);
@@ -2613,11 +2566,10 @@ FX_BOOL CFX_Edit::Delete(FX_BOOL bAddUndo, FX_BOOL bPaint) {
CPVT_Word word;
if (bAddUndo) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- pIterator->SetAt(m_pVT->GetNextWordPlace(m_wpCaret));
- pIterator->GetSection(section);
- pIterator->GetWord(word);
- }
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(m_pVT->GetNextWordPlace(m_wpCaret));
+ pIterator->GetSection(section);
+ pIterator->GetWord(word);
}
m_pVT->UpdateWordPlace(m_wpCaret);
@@ -2679,73 +2631,72 @@ FX_BOOL CFX_Edit::Empty() {
}
FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) {
- if (m_pVT->IsValid()) {
- if (m_SelState.IsExist()) {
- CPVT_WordRange range = m_SelState.ConvertToWordRange();
+ if (!m_pVT->IsValid())
+ return FALSE;
- if (bAddUndo && m_bEnableUndo) {
- if (m_pVT->IsRichText()) {
- BeginGroupUndo(L"");
-
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- pIterator->SetAt(range.EndPos);
-
- CPVT_Word wordinfo;
- CPVT_Section secinfo;
- do {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(range.BeginPos) <= 0)
- break;
-
- CPVT_WordPlace oldplace = m_pVT->GetPrevWordPlace(place);
-
- if (oldplace.SecCmp(place) != 0) {
- if (pIterator->GetSection(secinfo)) {
- AddEditUndoItem(new CFXEU_ClearRich(
- this, oldplace, place, range, wordinfo.Word,
- wordinfo.nCharset, secinfo.SecProps, secinfo.WordProps));
- }
- } else {
- if (pIterator->GetWord(wordinfo)) {
- oldplace = m_pVT->AdjustLineHeader(oldplace, TRUE);
- place = m_pVT->AdjustLineHeader(place, TRUE);
+ if (!m_SelState.IsExist())
+ return FALSE;
- AddEditUndoItem(new CFXEU_ClearRich(
- this, oldplace, place, range, wordinfo.Word,
- wordinfo.nCharset, secinfo.SecProps, wordinfo.WordProps));
- }
- }
- } while (pIterator->PrevWord());
- }
- EndGroupUndo();
- } else {
- AddEditUndoItem(new CFXEU_Clear(this, range, GetSelText()));
- }
- }
+ CPVT_WordRange range = m_SelState.ConvertToWordRange();
- SelectNone();
- SetCaret(m_pVT->DeleteWords(range));
- m_SelState.Set(m_wpCaret, m_wpCaret);
+ if (bAddUndo && m_bEnableUndo) {
+ if (m_pVT->IsRichText()) {
+ BeginGroupUndo(L"");
- if (bPaint) {
- RearrangePart(range);
- ScrollToCaret();
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(range.EndPos);
- CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
- Refresh(RP_ANALYSE, &wr);
+ CPVT_Word wordinfo;
+ CPVT_Section secinfo;
+ do {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(range.BeginPos) <= 0)
+ break;
- SetCaretOrigin();
- SetCaretInfo();
- }
+ CPVT_WordPlace oldplace = m_pVT->GetPrevWordPlace(place);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret);
+ if (oldplace.SecCmp(place) != 0) {
+ if (pIterator->GetSection(secinfo)) {
+ AddEditUndoItem(new CFXEU_ClearRich(
+ this, oldplace, place, range, wordinfo.Word, wordinfo.nCharset,
+ secinfo.SecProps, secinfo.WordProps));
+ }
+ } else {
+ if (pIterator->GetWord(wordinfo)) {
+ oldplace = m_pVT->AdjustLineHeader(oldplace, TRUE);
+ place = m_pVT->AdjustLineHeader(place, TRUE);
- return TRUE;
+ AddEditUndoItem(new CFXEU_ClearRich(
+ this, oldplace, place, range, wordinfo.Word, wordinfo.nCharset,
+ secinfo.SecProps, wordinfo.WordProps));
+ }
+ }
+ } while (pIterator->PrevWord());
+ EndGroupUndo();
+ } else {
+ AddEditUndoItem(new CFXEU_Clear(this, range, GetSelText()));
}
}
- return FALSE;
+ SelectNone();
+ SetCaret(m_pVT->DeleteWords(range));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
+
+ if (bPaint) {
+ RearrangePart(range);
+ ScrollToCaret();
+
+ CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
+ Refresh(RP_ANALYSE, &wr);
+
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret);
+
+ return TRUE;
}
FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text,
@@ -2819,19 +2770,19 @@ FX_BOOL CFX_Edit::Undo() {
}
void CFX_Edit::SetCaretOrigin() {
- if (m_pVT->IsValid()) {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word)) {
- m_ptCaret.x = word.ptWord.x + word.fWidth;
- m_ptCaret.y = word.ptWord.y;
- } else if (pIterator->GetLine(line)) {
- m_ptCaret.x = line.ptLine.x;
- m_ptCaret.y = line.ptLine.y;
- }
- }
+ if (!m_pVT->IsValid())
+ return;
+
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word)) {
+ m_ptCaret.x = word.ptWord.x + word.fWidth;
+ m_ptCaret.y = word.ptWord.y;
+ } else if (pIterator->GetLine(line)) {
+ m_ptCaret.x = line.ptLine.x;
+ m_ptCaret.y = line.ptLine.y;
}
}
@@ -2933,35 +2884,29 @@ void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) {
}
FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- CPVT_WordPlace wpOld = pIterator->GetAt();
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ CPVT_WordPlace wpOld = pIterator->GetAt();
- pIterator->SetAt(place);
- CPVT_Line line;
- pIterator->GetLine(line);
+ pIterator->SetAt(place);
+ CPVT_Line line;
+ pIterator->GetLine(line);
- pIterator->SetAt(wpOld);
+ pIterator->SetAt(wpOld);
- return line.ptLine.y + line.fLineAscent;
- }
-
- return 0.0f;
+ return line.ptLine.y + line.fLineAscent;
}
FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const {
- if (CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator()) {
- CPVT_WordPlace wpOld = pIterator->GetAt();
+ CPDF_VariableText::Iterator* pIterator = m_pVT->GetIterator();
+ CPVT_WordPlace wpOld = pIterator->GetAt();
- pIterator->SetAt(place);
- CPVT_Line line;
- pIterator->GetLine(line);
+ pIterator->SetAt(place);
+ CPVT_Line line;
+ pIterator->GetLine(line);
- pIterator->SetAt(wpOld);
-
- return line.ptLine.y + line.fLineDescent;
- }
+ pIterator->SetAt(wpOld);
- return 0.0f;
+ return line.ptLine.y + line.fLineDescent;
}
CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place,
diff --git a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_list.cpp b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_list.cpp
index f3db38612c8..383b84f27fa 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_list.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_list.cpp
@@ -4,17 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/include/fxedit/fxet_list.h"
+#include "fpdfsdk/fxedit/include/fxet_list.h"
#include "core/fpdfdoc/include/cpvt_word.h"
-#include "fpdfsdk/include/fxedit/fxet_edit.h"
+#include "fpdfsdk/fxedit/include/fxet_edit.h"
CFX_ListItem::CFX_ListItem()
- : m_pEdit(NULL),
+ : m_pEdit(IFX_Edit::NewEdit()),
m_bSelected(FALSE),
- m_bCaret(FALSE),
m_rcListItem(0.0f, 0.0f, 0.0f, 0.0f) {
- m_pEdit = IFX_Edit::NewEdit();
m_pEdit->SetAlignmentV(1);
m_pEdit->Initialize();
}
@@ -24,8 +22,7 @@ CFX_ListItem::~CFX_ListItem() {
}
void CFX_ListItem::SetFontMap(IPVT_FontMap* pFontMap) {
- if (m_pEdit)
- m_pEdit->SetFontMap(pFontMap);
+ m_pEdit->SetFontMap(pFontMap);
}
IFX_Edit* CFX_ListItem::GetEdit() const {
@@ -33,10 +30,7 @@ IFX_Edit* CFX_ListItem::GetEdit() const {
}
IFX_Edit_Iterator* CFX_ListItem::GetIterator() const {
- if (m_pEdit)
- return m_pEdit->GetIterator();
-
- return NULL;
+ return m_pEdit->GetIterator();
}
void CFX_ListItem::SetRect(const CLST_Rect& rect) {
@@ -55,47 +49,28 @@ void CFX_ListItem::SetSelect(FX_BOOL bSelected) {
m_bSelected = bSelected;
}
-FX_BOOL CFX_ListItem::IsCaret() const {
- return m_bCaret;
-}
-
-void CFX_ListItem::SetCaret(FX_BOOL bCaret) {
- m_bCaret = bCaret;
-}
-
void CFX_ListItem::SetText(const FX_WCHAR* text) {
- if (m_pEdit)
- m_pEdit->SetText(text);
+ m_pEdit->SetText(text);
}
void CFX_ListItem::SetFontSize(FX_FLOAT fFontSize) {
- if (m_pEdit)
- m_pEdit->SetFontSize(fFontSize);
+ m_pEdit->SetFontSize(fFontSize);
}
FX_FLOAT CFX_ListItem::GetItemHeight() const {
- if (m_pEdit)
- return m_pEdit->GetContentRect().Height();
-
- return 0.0f;
+ return m_pEdit->GetContentRect().Height();
}
uint16_t CFX_ListItem::GetFirstChar() const {
CPVT_Word word;
-
- if (IFX_Edit_Iterator* pIterator = GetIterator()) {
- pIterator->SetAt(1);
- pIterator->GetWord(word);
- }
-
+ IFX_Edit_Iterator* pIterator = GetIterator();
+ pIterator->SetAt(1);
+ pIterator->GetWord(word);
return word.Word;
}
CFX_WideString CFX_ListItem::GetText() const {
- if (m_pEdit)
- return m_pEdit->GetText();
-
- return L"";
+ return m_pEdit->GetText();
}
CFX_List::CFX_List()
@@ -257,17 +232,15 @@ CFX_FloatRect CFX_List::GetItemRect(int32_t nIndex) const {
CFX_FloatRect rcItem = pListItem->GetRect();
rcItem.left = 0.0f;
rcItem.right = GetPlateRect().Width();
- return InnerToOuter(rcItem);
+ return InnerToOuter(CLST_Rect(rcItem));
}
return CFX_FloatRect();
}
FX_BOOL CFX_List::IsItemSelected(int32_t nIndex) const {
- if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex))
return pListItem->IsSelected();
- }
-
return FALSE;
}
@@ -277,12 +250,6 @@ void CFX_List::SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected) {
}
}
-void CFX_List::SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret) {
- if (CFX_ListItem* pListItem = m_aListItems.GetAt(nItemIndex)) {
- pListItem->SetCaret(bCaret);
- }
-}
-
void CFX_List::SetMultipleSel(FX_BOOL bMultiple) {
m_bMultiple = bMultiple;
}
@@ -639,10 +606,6 @@ void CFX_ListCtrl::SetCaret(int32_t nItemIndex) {
if (nOldIndex != nItemIndex) {
m_nCaretIndex = nItemIndex;
-
- SetItemCaret(nOldIndex, FALSE);
- SetItemCaret(nItemIndex, TRUE);
-
InvalidateItem(nOldIndex);
InvalidateItem(nItemIndex);
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_module.cpp b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_module.cpp
index 330b72bc8b9..99fd68e397b 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_module.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_module.cpp
@@ -5,8 +5,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fpdfdoc/include/cpdf_variabletext.h"
-#include "fpdfsdk/include/fxedit/fxet_edit.h"
-#include "fpdfsdk/include/fxedit/fxet_list.h"
+#include "fpdfsdk/fxedit/include/fxet_edit.h"
+#include "fpdfsdk/fxedit/include/fxet_list.h"
IFX_Edit* IFX_Edit::NewEdit() {
return new CFX_Edit(new CPDF_VariableText());
diff --git a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_pageobjs.cpp b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_pageobjs.cpp
index 1fe40d98c1a..e8d9e2a371f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_pageobjs.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/fxet_pageobjs.cpp
@@ -12,13 +12,10 @@
#include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h"
#include "core/fpdfdoc/include/cpvt_word.h"
#include "core/fpdfdoc/include/ipvt_fontmap.h"
-#include "core/include/fxge/fx_ge.h"
-#include "fpdfsdk/include/fx_systemhandler.h"
-#include "fpdfsdk/include/fxedit/fx_edit.h"
-#include "fpdfsdk/include/fxedit/fxet_edit.h"
-
-#define FX_EDIT_UNDERLINEHALFWIDTH 0.5f
-#define FX_EDIT_CROSSOUTHALFWIDTH 0.5f
+#include "core/fxge/include/fx_ge.h"
+#include "fpdfsdk/cfx_systemhandler.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fxet_edit.h"
CFX_FloatRect GetUnderLineRect(const CPVT_Word& word) {
return CFX_FloatRect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f,
@@ -110,32 +107,31 @@ void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice,
pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- CFX_PathData pathUnderline;
- CFX_FloatRect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
- pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
- rcUnderline.right, rcUnderline.top);
-
- pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0,
- FXFILL_WINDING);
- }
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ CFX_PathData pathUnderline;
+ CFX_FloatRect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
+ pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
+ rcUnderline.right, rcUnderline.top);
+
+ pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0,
+ FXFILL_WINDING);
}
}
}
@@ -151,7 +147,7 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
const CFX_FloatRect& rcClip,
const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange,
- IFX_SystemHandler* pSystemHandler,
+ CFX_SystemHandler* pSystemHandler,
void* pFFLData) {
const bool bContinuous =
pEdit->GetCharArray() == 0 && pEdit->GetCharSpace() <= 0.0f;
@@ -179,95 +175,88 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- if (wrSelect.IsExist()) {
- bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
- place.WordCmp(wrSelect.EndPos) <= 0;
- if (bSelect) {
- crCurFill = crWhite;
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ if (wrSelect.IsExist()) {
+ bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
+ place.WordCmp(wrSelect.EndPos) <= 0;
+ crCurFill = bSelect ? crWhite : crTextFill;
+ }
+ if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+ crCurFill = crTextFill;
+ crOldFill = crCurFill;
+ }
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (bSelect) {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+
+ if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+ CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent,
+ word.ptWord.x + word.fWidth,
+ line.ptLine.y + line.fLineAscent);
+ rc.Intersect(rcClip);
+ pSystemHandler->OutputSelectedRect(pFFLData, rc);
} else {
- crCurFill = crTextFill;
+ CFX_PathData pathSelBK;
+ pathSelBK.AppendRect(
+ word.ptWord.x, line.ptLine.y + line.fLineDescent,
+ word.ptWord.x + word.fWidth, line.ptLine.y + line.fLineAscent);
+
+ pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
+ FXFILL_WINDING);
}
}
- if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
- crCurFill = crTextFill;
- crOldFill = crCurFill;
- }
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (bSelect) {
- CPVT_Line line;
- pIterator->GetLine(line);
-
- if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
- CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent,
- word.ptWord.x + word.fWidth,
- line.ptLine.y + line.fLineAscent);
- rc.Intersect(rcClip);
- pSystemHandler->OutputSelectedRect(pFFLData, rc);
- } else {
- CFX_PathData pathSelBK;
- pathSelBK.AppendRect(word.ptWord.x,
- line.ptLine.y + line.fLineDescent,
- word.ptWord.x + word.fWidth,
- line.ptLine.y + line.fLineAscent);
-
- pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
- FXFILL_WINDING);
- }
- }
- if (bContinuous) {
- if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
- crOldFill != crCurFill) {
- if (sTextBuf.GetLength() > 0) {
- DrawTextString(pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x,
- ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(nFontIndex), fFontSize,
- pUser2Device, sTextBuf.GetByteString(),
- crOldFill, crTextStroke, nHorzScale);
-
- sTextBuf.Clear();
- }
- nFontIndex = word.nFontIndex;
- ptBT = word.ptWord;
- crOldFill = crCurFill;
- }
+ if (bContinuous) {
+ if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
+ crOldFill != crCurFill) {
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
+ sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale);
- sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word,
- SubWord)
- .AsByteStringC();
- } else {
- DrawTextString(
- pDevice, CFX_FloatPoint(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y),
- pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device,
- GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord),
- crCurFill, crTextStroke, nHorzScale);
+ sTextBuf.Clear();
+ }
+ nFontIndex = word.nFontIndex;
+ ptBT = word.ptWord;
+ crOldFill = crCurFill;
}
- oldplace = place;
+
+ sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word,
+ SubWord)
+ .AsStringC();
+ } else {
+ DrawTextString(
+ pDevice, CFX_FloatPoint(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y),
+ pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device,
+ GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord),
+ crCurFill, crTextStroke, nHorzScale);
}
+ oldplace = place;
}
+ }
- if (sTextBuf.GetLength() > 0) {
- DrawTextString(
- pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
- sTextBuf.GetByteString(), crOldFill, crTextStroke, nHorzScale);
- }
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
+ sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale);
}
}
@@ -300,102 +289,100 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
pDevice->SetClip_Rect(rcTemp.ToFxRect());
}
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
- CPVT_WordPlace oldplace;
+ CPVT_WordPlace oldplace;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- word.WordProps.fFontSize = word.fFontSize;
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ word.WordProps.fFontSize = word.fFontSize;
- crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
+ crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
- if (wrSelect.IsExist()) {
- bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
- place.WordCmp(wrSelect.EndPos) <= 0;
- if (bSelect) {
- crCurText = crWhite;
- }
+ if (wrSelect.IsExist()) {
+ bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
+ place.WordCmp(wrSelect.EndPos) <= 0;
+ if (bSelect) {
+ crCurText = crWhite;
}
+ }
- if (bSelect) {
- CPVT_Line line;
- pIterator->GetLine(line);
+ if (bSelect) {
+ CPVT_Line line;
+ pIterator->GetLine(line);
- CFX_PathData pathSelBK;
- pathSelBK.AppendRect(word.ptWord.x + ptOffset.x,
- line.ptLine.y + line.fLineDescent + ptOffset.y,
- word.ptWord.x + word.fWidth + ptOffset.x,
- line.ptLine.y + line.fLineAscent + ptOffset.y);
+ CFX_PathData pathSelBK;
+ pathSelBK.AppendRect(word.ptWord.x + ptOffset.x,
+ line.ptLine.y + line.fLineDescent + ptOffset.y,
+ word.ptWord.x + word.fWidth + ptOffset.x,
+ line.ptLine.y + line.fLineAscent + ptOffset.y);
- pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
- FXFILL_WINDING);
- }
+ pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
+ FXFILL_WINDING);
+ }
- if (place.LineCmp(oldplace) != 0 ||
- word.WordProps.fCharSpace > 0.0f ||
- word.WordProps.nHorzScale != 100 ||
- FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
- crOld != crCurText) {
- if (sTextBuf.GetLength() > 0) {
- DrawTextString(pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x,
- ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize,
- pUser2Device, sTextBuf.GetByteString(), crOld, 0,
- wp.nHorzScale);
+ if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f ||
+ word.WordProps.nHorzScale != 100 ||
+ FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
+ crOld != crCurText) {
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
+ sTextBuf.MakeString(), crOld, 0, wp.nHorzScale);
- sTextBuf.Clear();
- }
- wp = word.WordProps;
- ptBT = word.ptWord;
- crOld = crCurText;
+ sTextBuf.Clear();
}
+ wp = word.WordProps;
+ ptBT = word.ptWord;
+ crOld = crCurText;
+ }
- sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
- word.Word, 0)
- .AsByteStringC();
-
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
- CFX_PathData pathUnderline;
- CFX_FloatRect rcUnderline = GetUnderLineRect(word);
- pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
- rcUnderline.right, rcUnderline.top);
+ sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
+ word.Word, 0)
+ .AsStringC();
- pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0,
- FXFILL_WINDING);
- }
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ CFX_PathData pathUnderline;
+ CFX_FloatRect rcUnderline = GetUnderLineRect(word);
+ pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
+ rcUnderline.right, rcUnderline.top);
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
- CFX_PathData pathCrossout;
- CFX_FloatRect rcCrossout = GetCrossoutRect(word);
- pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom,
- rcCrossout.right, rcCrossout.top);
+ pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0,
+ FXFILL_WINDING);
+ }
- pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0,
- FXFILL_WINDING);
- }
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ CFX_PathData pathCrossout;
+ CFX_FloatRect rcCrossout = GetCrossoutRect(word);
+ pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom,
+ rcCrossout.right, rcCrossout.top);
- oldplace = place;
+ pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0,
+ FXFILL_WINDING);
}
- }
- if (sTextBuf.GetLength() > 0) {
- DrawTextString(
- pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
- sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale);
+ oldplace = place;
}
}
+
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
+ sTextBuf.MakeString(), crOld, 0, wp.nHorzScale);
+ }
}
pDevice->RestoreState();
@@ -474,52 +461,49 @@ void IFX_Edit::GeneratePageObjects(
ObjArray.RemoveAll();
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (place.LineCmp(oldplace) != 0 ||
- nOldFontIndex != word.nFontIndex) {
- if (sTextBuf.GetLength() > 0) {
- ObjArray.Add(AddTextObjToPageObjects(
- pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
- fFontSize, 0.0f, 100,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.GetByteString()));
-
- sTextBuf.Clear();
- }
-
- ptBT = word.ptWord;
- nOldFontIndex = word.nFontIndex;
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex) {
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
+ fFontSize, 0.0f, 100,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.MakeString()));
+
+ sTextBuf.Clear();
}
- sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0)
- .AsByteStringC();
- oldplace = place;
+ ptBT = word.ptWord;
+ nOldFontIndex = word.nFontIndex;
}
- }
- if (sTextBuf.GetLength() > 0) {
- ObjArray.Add(AddTextObjToPageObjects(
- pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
- fFontSize, 0.0f, 100,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.GetByteString()));
+ sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0)
+ .AsStringC();
+ oldplace = place;
}
}
+
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize,
+ 0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.MakeString()));
+ }
}
}
@@ -538,82 +522,80 @@ void IFX_Edit::GenerateRichPageObjects(
ObjArray.RemoveAll();
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- word.WordProps.fFontSize = word.fFontSize;
-
- crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
-
- if (place.LineCmp(oldplace) != 0 ||
- word.WordProps.fCharSpace > 0.0f ||
- word.WordProps.nHorzScale != 100 ||
- FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
- crOld != crCurText) {
- if (sTextBuf.GetLength() > 0) {
- ObjArray.Add(AddTextObjToPageObjects(
- pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
- wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.GetByteString()));
-
- sTextBuf.Clear();
- }
-
- wp = word.WordProps;
- ptBT = word.ptWord;
- crOld = crCurText;
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (IPVT_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ word.WordProps.fFontSize = word.fFontSize;
+
+ crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
+
+ if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f ||
+ word.WordProps.nHorzScale != 100 ||
+ FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
+ crOld != crCurText) {
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
+ wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.MakeString()));
+
+ sTextBuf.Clear();
}
- sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
- word.Word, 0)
- .AsByteStringC();
+ wp = word.WordProps;
+ ptBT = word.ptWord;
+ crOld = crCurText;
+ }
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
- CFX_FloatRect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
+ sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
+ word.Word, 0)
+ .AsStringC();
- AddRectToPageObjects(pObjectHolder, crCurText, rcUnderline);
- }
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ CFX_FloatRect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
- CFX_FloatRect rcCrossout = GetCrossoutRect(word);
- rcCrossout.left += ptOffset.x;
- rcCrossout.right += ptOffset.x;
- rcCrossout.top += ptOffset.y;
- rcCrossout.bottom += ptOffset.y;
+ AddRectToPageObjects(pObjectHolder, crCurText, rcUnderline);
+ }
- AddRectToPageObjects(pObjectHolder, crCurText, rcCrossout);
- }
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ CFX_FloatRect rcCrossout = GetCrossoutRect(word);
+ rcCrossout.left += ptOffset.x;
+ rcCrossout.right += ptOffset.x;
+ rcCrossout.top += ptOffset.y;
+ rcCrossout.bottom += ptOffset.y;
- oldplace = place;
+ AddRectToPageObjects(pObjectHolder, crCurText, rcCrossout);
}
- }
- if (sTextBuf.GetLength() > 0) {
- ObjArray.Add(AddTextObjToPageObjects(
- pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
- wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.GetByteString()));
+ oldplace = place;
}
}
+
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
+ wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
+ CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.MakeString()));
+ }
}
}
@@ -622,29 +604,28 @@ void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjectHolder* pObjectHolder,
const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange,
FX_COLORREF color) {
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- CFX_FloatRect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
- AddRectToPageObjects(pObjectHolder, color, rcUnderline);
- }
+ IFX_Edit_Iterator* pIterator = pEdit->GetIterator();
+ if (pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ CFX_FloatRect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
+ AddRectToPageObjects(pObjectHolder, color, rcUnderline);
}
}
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fxedit/DEPS b/chromium/third_party/pdfium/fpdfsdk/fxedit/include/DEPS
index db9a09c3423..db9a09c3423 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fxedit/DEPS
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/include/DEPS
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fxedit/fx_edit.h b/chromium/third_party/pdfium/fpdfsdk/fxedit/include/fx_edit.h
index 532e96d97f7..5f0283f06f6 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fxedit/fx_edit.h
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/include/fx_edit.h
@@ -4,12 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_
-#define FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_
+#ifndef FPDFSDK_FXEDIT_INCLUDE_FX_EDIT_H_
+#define FPDFSDK_FXEDIT_INCLUDE_FX_EDIT_H_
#include "core/fpdfdoc/include/cpdf_variabletext.h"
#include "core/fxcrt/include/fx_basic.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
class CPDF_Font;
class CPDF_PageObjectHolder;
@@ -17,6 +17,7 @@ class CPDF_TextObject;
class CFX_FloatPoint;
class CFX_Matrix;
class CFX_RenderDevice;
+class CFX_SystemHandler;
class IFX_Edit;
class IPVT_FontMap;
class IFX_Edit_Iterator;
@@ -24,7 +25,6 @@ class IFX_Edit_Notify;
class IFX_Edit_UndoItem;
class IFX_List;
class IFX_List_Notify;
-class IFX_SystemHandler;
struct CPVT_Line;
struct CPVT_SecProps;
@@ -169,10 +169,6 @@ class IFX_Edit {
// set a IPVT_FontMap pointer implemented by user.
virtual void SetFontMap(IPVT_FontMap* pFontMap) = 0;
- // if user don't like to use FontMap, implement VTProvider and set it
- // directly.
- virtual void SetVTProvider(CPDF_VariableText::Provider* pProvider) = 0;
-
// set a IFX_Edit_Notify pointer implemented by user.
virtual void SetNotify(IFX_Edit_Notify* pNotify) = 0;
virtual void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) = 0;
@@ -495,7 +491,7 @@ class IFX_Edit {
const CFX_FloatRect& rcClip,
const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange,
- IFX_SystemHandler* pSystemHandler,
+ CFX_SystemHandler* pSystemHandler,
void* pFFLData);
static void DrawUnderline(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
@@ -626,4 +622,4 @@ CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
uint16_t Word,
uint16_t SubWord);
-#endif // FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_
+#endif // FPDFSDK_FXEDIT_INCLUDE_FX_EDIT_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fxedit/fxet_edit.h b/chromium/third_party/pdfium/fpdfsdk/fxedit/include/fxet_edit.h
index fb6c9175821..c7500a05fb4 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fxedit/fxet_edit.h
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/include/fxet_edit.h
@@ -4,12 +4,14 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_
-#define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_
+#ifndef FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_
+#define FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_
+
+#include <memory>
#include "core/fpdfdoc/include/cpvt_secprops.h"
#include "core/fpdfdoc/include/cpvt_wordprops.h"
-#include "fpdfsdk/include/fxedit/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
class CFX_Edit;
class CFX_Edit_Iterator;
@@ -516,7 +518,6 @@ class CFX_Edit : public IFX_Edit {
// IFX_Edit
void SetFontMap(IPVT_FontMap* pFontMap) override;
- void SetVTProvider(CPDF_VariableText::Provider* pProvider) override;
void SetNotify(IFX_Edit_Notify* pNotify) override;
void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) override;
IFX_Edit_Iterator* GetIterator() override;
@@ -714,7 +715,6 @@ class CFX_Edit : public IFX_Edit {
CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1,
const CPVT_WordRange& wr2);
-
void BeginGroupUndo(const CFX_WideString& sTitle);
void EndGroupUndo();
void AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem);
@@ -729,7 +729,7 @@ class CFX_Edit : public IFX_Edit {
CPDF_VariableText* m_pVT;
IFX_Edit_Notify* m_pNotify;
IFX_Edit_OprNotify* m_pOprNotify;
- CFX_Edit_Provider* m_pVTProvide;
+ std::unique_ptr<CFX_Edit_Provider> m_pVTProvider;
CPVT_WordPlace m_wpCaret;
CPVT_WordPlace m_wpOldCaret;
@@ -738,7 +738,7 @@ class CFX_Edit : public IFX_Edit {
CFX_FloatPoint m_ptScrollPos;
CFX_FloatPoint m_ptRefreshScrollPos;
FX_BOOL m_bEnableScroll;
- IFX_Edit_Iterator* m_pIterator;
+ std::unique_ptr<IFX_Edit_Iterator> m_pIterator;
CFX_Edit_Refresh m_Refresh;
CFX_FloatPoint m_ptCaret;
CFX_Edit_Undo m_Undo;
@@ -801,4 +801,4 @@ class CFX_Edit_Provider : public CPDF_VariableText::Provider {
IPVT_FontMap* m_pFontMap;
};
-#endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_
+#endif // FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fxedit/fxet_list.h b/chromium/third_party/pdfium/fpdfsdk/fxedit/include/fxet_list.h
index 0018f13b464..58aa94c5b63 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fxedit/fxet_list.h
+++ b/chromium/third_party/pdfium/fpdfsdk/fxedit/include/fxet_list.h
@@ -4,10 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_
-#define FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_
+#ifndef FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_
+#define FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_
-#include "fpdfsdk/include/fxedit/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
class IFX_Edit;
@@ -46,7 +46,7 @@ class CLST_Rect : public CFX_FloatRect {
bottom = other_bottom;
}
- CLST_Rect(const CFX_FloatRect& rect) {
+ explicit CLST_Rect(const CFX_FloatRect& rect) {
left = rect.left;
top = rect.top;
right = rect.right;
@@ -113,33 +113,30 @@ class CLST_Rect : public CFX_FloatRect {
}
};
-class CFX_ListItem {
+class CFX_ListItem final {
public:
CFX_ListItem();
- virtual ~CFX_ListItem();
+ ~CFX_ListItem();
void SetFontMap(IPVT_FontMap* pFontMap);
- IFX_Edit_Iterator* GetIterator() const;
IFX_Edit* GetEdit() const;
- public:
void SetRect(const CLST_Rect& rect);
void SetSelect(FX_BOOL bSelected);
- void SetCaret(FX_BOOL bCaret);
void SetText(const FX_WCHAR* text);
void SetFontSize(FX_FLOAT fFontSize);
CFX_WideString GetText() const;
CLST_Rect GetRect() const;
FX_BOOL IsSelected() const;
- FX_BOOL IsCaret() const;
FX_FLOAT GetItemHeight() const;
uint16_t GetFirstChar() const;
private:
+ IFX_Edit_Iterator* GetIterator() const;
+
IFX_Edit* m_pEdit;
FX_BOOL m_bSelected;
- FX_BOOL m_bCaret;
CLST_Rect m_rcListItem;
};
@@ -233,7 +230,6 @@ class CFX_List : protected CFX_ListContainer, public IFX_List {
virtual void ReArrange(int32_t nItemIndex);
CFX_WideString GetItemText(int32_t nIndex) const;
void SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected);
- void SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret);
int32_t GetLastSelected() const;
FX_WCHAR Toupper(FX_WCHAR c) const;
@@ -340,4 +336,4 @@ class CFX_ListCtrl : public CFX_List {
int32_t m_nCaretIndex; // for multiple
};
-#endif // FPDFSDK_INCLUDE_FXEDIT_FXET_LIST_H_
+#endif // FPDFSDK_FXEDIT_INCLUDE_FXET_LIST_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_actionhandler.h b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_actionhandler.h
index a8022b0695b..bf2ebd3eba4 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_actionhandler.h
+++ b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_actionhandler.h
@@ -10,8 +10,8 @@
#include <memory>
#include <set>
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxcrt/include/fx_string.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
#include "fpdfsdk/include/fsdk_baseform.h"
class CPDFSDK_Annot;
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_annothandler.h b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_annothandler.h
index e810a7e5047..a9c76e25235 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_annothandler.h
+++ b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_annothandler.h
@@ -14,10 +14,10 @@
#include "core/fxcrt/include/fx_coordinates.h"
#ifdef PDF_ENABLE_XFA
-#include "xfa/include/fxfa/fxfa.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/include/fxfa.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
#define FSDK_XFAWIDGET_TYPENAME "XFAWidget"
#endif // PDF_ENABLE_XFA
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseannot.h b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseannot.h
index a8f4a67381e..236e2c78688 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseannot.h
+++ b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseannot.h
@@ -13,10 +13,11 @@
#include <ctime>
#endif
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxcrt/include/fx_basic.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
+#include "fpdfsdk/cfx_systemhandler.h"
+#include "fpdfsdk/include/fsdk_common.h"
#include "fpdfsdk/include/fsdk_define.h"
-#include "fpdfsdk/include/fx_systemhandler.h"
class CPDFSDK_PageView;
class CPDF_Annot;
@@ -25,8 +26,6 @@ class CFX_Matrix;
class CPDF_RenderOptions;
class CFX_RenderDevice;
-#define CFX_IntArray CFX_ArrayTemplate<int>
-
class CPDFSDK_DateTime {
public:
CPDFSDK_DateTime();
@@ -157,32 +156,17 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
void SetStructParent(int key);
int GetStructParent() const;
- // border
void SetBorderWidth(int nWidth);
int GetBorderWidth() const;
- // BBS_SOLID
- // BBS_DASH
- // BBS_BEVELED
- // BBS_INSET
- // BBS_UNDERLINE
-
- void SetBorderStyle(int nStyle);
- int GetBorderStyle() const;
-
- void SetBorderDash(const CFX_IntArray& array);
- void GetBorderDash(CFX_IntArray& array) const;
-
- // The background of the annotation's icon when closed
- // The title bar of the annotation's pop-up window
- // The border of a link annotation
+ void SetBorderStyle(BorderStyle nStyle);
+ BorderStyle GetBorderStyle() const;
void SetColor(FX_COLORREF color);
void RemoveColor();
FX_BOOL GetColor(FX_COLORREF& color) const;
FX_BOOL IsVisible() const;
- // action
CPDF_Action GetAction() const;
void SetAction(const CPDF_Action& a);
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseform.h b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseform.h
index 06f0666c815..fa19c75a6b5 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseform.h
+++ b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_baseform.h
@@ -10,13 +10,13 @@
#include <map>
#include <vector>
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxcrt/include/fx_basic.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "fpdfsdk/include/fsdk_baseannot.h"
#ifdef PDF_ENABLE_XFA
-#include "xfa/include/fxfa/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
#endif // PDF_ENABLE_XFA
#if _FX_OS_ == _FX_ANDROID_
@@ -243,9 +243,6 @@ class CPDFSDK_XFAWidget : public CPDFSDK_Annot {
CPDFSDK_InterForm* m_pInterForm;
CXFA_FFWidget* m_hXFAWidget;
};
-#define CPDFSDK_XFAWidgetMap \
- CFX_MapPtrTemplate<CXFA_FFWidget*, CPDFSDK_XFAWidget*>
-#define CPDFSDK_FieldSynchronizeMap CFX_MapPtrTemplate<CPDF_FormField*, int>
#endif // PDF_ENABLE_XFA
class CPDFSDK_InterForm : public CPDF_FormNotify {
@@ -341,8 +338,7 @@ class CPDFSDK_InterForm : public CPDF_FormNotify {
CPDF_InterForm* m_pInterForm;
CPDFSDK_WidgetMap m_Map;
#ifdef PDF_ENABLE_XFA
- CPDFSDK_XFAWidgetMap m_XFAMap;
- CPDFSDK_FieldSynchronizeMap m_FieldSynchronizeMap;
+ std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap;
FX_BOOL m_bXfaCalculate;
FX_BOOL m_bXfaValidationsEnabled;
#endif // PDF_ENABLE_XFA
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_common.h b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_common.h
index c20262dae8d..5c5d24f2c82 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_common.h
+++ b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_common.h
@@ -33,10 +33,4 @@
#define FIELDFLAG_MULTISELECT (1 << 21)
#define FIELDFLAG_COMMITONSELCHANGE (1 << 26)
-#define BBS_SOLID 0
-#define BBS_DASH 1
-#define BBS_BEVELED 2
-#define BBS_INSET 3
-#define BBS_UNDERLINE 4
-
#endif // FPDFSDK_INCLUDE_FSDK_COMMON_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_define.h b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_define.h
index 9d81737f62d..f3ed2da00f9 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_define.h
+++ b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_define.h
@@ -8,13 +8,13 @@
#define FPDFSDK_INCLUDE_FSDK_DEFINE_H_
#include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
-#include "core/include/fxge/fx_ge.h"
-#include "core/include/fxge/fx_ge_win32.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
+#include "core/fxge/include/fx_ge.h"
+#include "core/fxge/include/fx_ge_win32.h"
#include "public/fpdfview.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
#endif // PDF_ENABLE_XFA
#ifdef _WIN32
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_mgr.h b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_mgr.h
index 39edc38f57f..cd89a925abc 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/fsdk_mgr.h
+++ b/chromium/third_party/pdfium/fpdfsdk/include/fsdk_mgr.h
@@ -12,23 +12,23 @@
#include <vector>
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
+#include "fpdfsdk/cfx_systemhandler.h"
#include "fpdfsdk/include/fsdk_actionhandler.h"
#include "fpdfsdk/include/fsdk_annothandler.h"
#include "fpdfsdk/include/fsdk_baseannot.h"
#include "fpdfsdk/include/fsdk_baseform.h"
#include "fpdfsdk/include/fsdk_common.h"
#include "fpdfsdk/include/fsdk_define.h"
-#include "fpdfsdk/include/fx_systemhandler.h"
#include "public/fpdf_formfill.h"
#include "public/fpdf_fwlevent.h"
class CFFL_IFormFiller;
+class CFX_SystemHandler;
class CPDFSDK_ActionHandler;
class CPDFSDK_Annot;
class CPDFSDK_InterForm;
class CPDFSDK_PageView;
class CPDFSDK_Widget;
-class IFX_SystemHandler;
class IJS_Runtime;
// NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken
@@ -115,8 +115,6 @@ class CPDFDoc_Environment final {
return (nFlag & FWL_EVENTFLAG_AltKey) != 0;
}
- FX_BOOL FFI_IsINSERTKeyDown(uint32_t nFlag) const { return FALSE; }
-
FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document, int nPageIndex) {
if (m_pInfo && m_pInfo->FFI_GetPage)
return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex);
@@ -334,14 +332,14 @@ class CPDFDoc_Environment final {
FPDF_WIDESTRING header =
(FPDF_WIDESTRING)bsHeader.GetBuffer(bsHeader.GetLength());
- FPDF_BSTR respone;
- FPDF_BStr_Init(&respone);
+ FPDF_BSTR response;
+ FPDF_BStr_Init(&response);
m_pInfo->FFI_PostRequestURL(m_pInfo, URL, data, contentType, encode,
- header, &respone);
+ header, &response);
CFX_WideString wsRet = CFX_WideString::FromUTF16LE(
- (unsigned short*)respone.str, respone.len / sizeof(unsigned short));
- FPDF_BStr_Clear(&respone);
+ (unsigned short*)response.str, response.len / sizeof(unsigned short));
+ FPDF_BStr_Clear(&response);
return wsRet;
}
@@ -368,13 +366,6 @@ class CPDFDoc_Environment final {
return FALSE;
}
- FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle,
- const FX_WCHAR* wsFilter,
- std::vector<CFX_WideString>& wsPathArr,
- FX_BOOL bOpen) {
- return FALSE;
- }
-
CFX_WideString FFI_GetLanguage() {
if (m_pInfo && m_pInfo->FFI_GetLanguage) {
int nRequiredLen = m_pInfo->FFI_GetLanguage(m_pInfo, NULL, 0);
@@ -444,7 +435,7 @@ class CPDFDoc_Environment final {
return m_pUnderlyingDoc;
}
CFX_ByteString GetAppName() const { return ""; }
- IFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); }
+ CFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); }
FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; }
CFFL_IFormFiller* GetIFormFiller(); // Creates if not present.
@@ -460,7 +451,7 @@ class CPDFDoc_Environment final {
CPDFSDK_Document* m_pSDKDoc;
UnderlyingDocumentType* const m_pUnderlyingDoc;
std::unique_ptr<CFFL_IFormFiller> m_pIFormFiller;
- std::unique_ptr<IFX_SystemHandler> m_pSysHandler;
+ std::unique_ptr<CFX_SystemHandler> m_pSysHandler;
};
class CPDFSDK_Document {
@@ -614,7 +605,7 @@ class CPDFSDK_PageView final {
int nFlag);
bool IsValidAnnot(const CPDF_Annot* p) const;
void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; }
- void UpdateRects(CFX_RectArray& rects);
+ void UpdateRects(const std::vector<CFX_FloatRect>& rects);
void UpdateView(CPDFSDK_Annot* pAnnot);
const std::vector<CPDFSDK_Annot*>& GetAnnotList() const {
return m_fxAnnotArray;
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/fx_systemhandler.h b/chromium/third_party/pdfium/fpdfsdk/include/fx_systemhandler.h
deleted file mode 100644
index dc225df0a27..00000000000
--- a/chromium/third_party/pdfium/fpdfsdk/include/fx_systemhandler.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef FPDFSDK_INCLUDE_FX_SYSTEMHANDLER_H_
-#define FPDFSDK_INCLUDE_FX_SYSTEMHANDLER_H_
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_Document;
-class CPDF_Font;
-
-typedef void* FX_HWND;
-typedef void* FX_HMENU;
-typedef void (*TimerCallback)(int32_t idEvent);
-
-struct FX_SYSTEMTIME {
- FX_SYSTEMTIME()
- : wYear(0),
- wMonth(0),
- wDayOfWeek(0),
- wDay(0),
- wHour(0),
- wMinute(0),
- wSecond(0),
- wMilliseconds(0) {}
- uint16_t wYear;
- uint16_t wMonth;
- uint16_t wDayOfWeek;
- uint16_t wDay;
- uint16_t wHour;
- uint16_t wMinute;
- uint16_t wSecond;
- uint16_t wMilliseconds;
-};
-
-// cursor style
-#define FXCT_ARROW 0
-#define FXCT_NESW 1
-#define FXCT_NWSE 2
-#define FXCT_VBEAM 3
-#define FXCT_HBEAM 4
-#define FXCT_HAND 5
-
-class IFX_SystemHandler {
- public:
- virtual ~IFX_SystemHandler() {}
- virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) = 0;
- virtual void OutputSelectedRect(void* pFormFiller, CFX_FloatRect& rect) = 0;
-
- virtual FX_BOOL IsSelectionImplemented() = 0;
-
- virtual CFX_WideString GetClipboardText(FX_HWND hWnd) = 0;
- virtual FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString str) = 0;
-
- virtual void ClientToScreen(FX_HWND hWnd, int32_t& x, int32_t& y) = 0;
- virtual void ScreenToClient(FX_HWND hWnd, int32_t& x, int32_t& y) = 0;
-
- /*cursor style
- FXCT_ARROW
- FXCT_NESW
- FXCT_NWSE
- FXCT_VBEAM
- FXCT_HBEAM
- FXCT_HAND
- */
- virtual void SetCursor(int32_t nCursorType) = 0;
-
- virtual FX_HMENU CreatePopupMenu() = 0;
- virtual FX_BOOL AppendMenuItem(FX_HMENU hMenu,
- int32_t nIDNewItem,
- CFX_WideString str) = 0;
- virtual FX_BOOL EnableMenuItem(FX_HMENU hMenu,
- int32_t nIDItem,
- FX_BOOL bEnabled) = 0;
- virtual int32_t TrackPopupMenu(FX_HMENU hMenu,
- int32_t x,
- int32_t y,
- FX_HWND hParent) = 0;
- virtual void DestroyMenu(FX_HMENU hMenu) = 0;
-
- virtual CFX_ByteString GetNativeTrueTypeFont(int32_t nCharset) = 0;
- virtual FX_BOOL FindNativeTrueTypeFont(int32_t nCharset,
- CFX_ByteString sFontFaceName) = 0;
- virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc,
- CFX_ByteString sFontFaceName,
- uint8_t nCharset) = 0;
-
- virtual int32_t SetTimer(int32_t uElapse, TimerCallback lpTimerFunc) = 0;
- virtual void KillTimer(int32_t nID) = 0;
-
- virtual FX_BOOL IsSHIFTKeyDown(uint32_t nFlag) = 0;
- virtual FX_BOOL IsCTRLKeyDown(uint32_t nFlag) = 0;
- virtual FX_BOOL IsALTKeyDown(uint32_t nFlag) = 0;
- virtual FX_BOOL IsINSERTKeyDown(uint32_t nFlag) = 0;
-
- virtual FX_SYSTEMTIME GetLocalTime() = 0;
-
- virtual int32_t GetCharSet() = 0;
- virtual void SetCharSet(int32_t nCharSet) = 0;
-};
-
-#endif // FPDFSDK_INCLUDE_FX_SYSTEMHANDLER_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/Document.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/Document.cpp
index 762ba71cf23..12d8c2df31a 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/Document.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/Document.cpp
@@ -494,9 +494,7 @@ FX_BOOL Document::removeField(IJS_Context* cc,
++rcAnnot.right;
++rcAnnot.top;
- CFX_RectArray aRefresh;
- aRefresh.Add(rcAnnot);
-
+ std::vector<CFX_FloatRect> aRefresh(1, rcAnnot);
UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
ASSERT(pPage);
@@ -769,32 +767,28 @@ FX_BOOL Document::info(IJS_Context* cc,
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
v8::Local<v8::Object> pObj =
FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pRuntime, -1);
- FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str());
- FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str());
- FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str());
- FXJS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str());
- FXJS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str());
- FXJS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str());
- FXJS_PutObjectString(isolate, pObj, L"CreationDate",
- cwCreationDate.c_str());
- FXJS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str());
- FXJS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str());
+ FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor);
+ FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle);
+ FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject);
+ FXJS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords);
+ FXJS_PutObjectString(isolate, pObj, L"Creator", cwCreator);
+ FXJS_PutObjectString(isolate, pObj, L"Producer", cwProducer);
+ FXJS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate);
+ FXJS_PutObjectString(isolate, pObj, L"ModDate", cwModDate);
+ FXJS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped);
// It's to be compatible to non-standard info dictionary.
for (const auto& it : *pDictionary) {
const CFX_ByteString& bsKey = it.first;
CPDF_Object* pValueObj = it.second;
- CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength());
-
+ CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey.AsStringC());
if (pValueObj->IsString() || pValueObj->IsName()) {
- FXJS_PutObjectString(isolate, pObj, wsKey.c_str(),
- pValueObj->GetUnicodeText().c_str());
+ FXJS_PutObjectString(isolate, pObj, wsKey, pValueObj->GetUnicodeText());
} else if (pValueObj->IsNumber()) {
- FXJS_PutObjectNumber(isolate, pObj, wsKey.c_str(),
+ FXJS_PutObjectNumber(isolate, pObj, wsKey,
(float)pValueObj->GetNumber());
} else if (pValueObj->IsBoolean()) {
- FXJS_PutObjectBoolean(isolate, pObj, wsKey.c_str(),
- !!pValueObj->GetInteger());
+ FXJS_PutObjectBoolean(isolate, pObj, wsKey, !!pValueObj->GetInteger());
}
}
vp << pObj;
@@ -1354,9 +1348,8 @@ FX_BOOL Document::getPageNthWord(IJS_Context* cc,
if (!pPageDict)
return FALSE;
- CPDF_Page page;
- page.Load(pDocument, pPageDict);
- page.ParseContent(nullptr);
+ CPDF_Page page(pDocument, pPageDict, true);
+ page.ParseContent();
int nWords = 0;
CFX_WideString swRet;
@@ -1410,9 +1403,8 @@ FX_BOOL Document::getPageNumWords(IJS_Context* cc,
if (!pPageDict)
return FALSE;
- CPDF_Page page;
- page.Load(pDocument, pPageDict);
- page.ParseContent(nullptr);
+ CPDF_Page page(pDocument, pPageDict, true);
+ page.ParseContent();
int nWords = 0;
for (auto& pPageObj : *page.GetPageObjectList()) {
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/Field.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/Field.cpp
index 158d4d6a7f2..c1838332ba0 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/Field.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/Field.cpp
@@ -395,22 +395,20 @@ FX_BOOL Field::borderStyle(IJS_Context* cc,
if (!pWidget)
return FALSE;
- int nBorderstyle = pWidget->GetBorderStyle();
-
- switch (nBorderstyle) {
- case BBS_SOLID:
+ switch (pWidget->GetBorderStyle()) {
+ case BorderStyle::SOLID:
vp << L"solid";
break;
- case BBS_DASH:
+ case BorderStyle::DASH:
vp << L"dashed";
break;
- case BBS_BEVELED:
+ case BorderStyle::BEVELED:
vp << L"beveled";
break;
- case BBS_INSET:
+ case BorderStyle::INSET:
vp << L"inset";
break;
- case BBS_UNDERLINE:
+ case BorderStyle::UNDERLINE:
vp << L"underline";
break;
default:
@@ -428,18 +426,17 @@ void Field::SetBorderStyle(CPDFSDK_Document* pDocument,
const CFX_ByteString& string) {
ASSERT(pDocument);
- int nBorderStyle = 0;
-
+ BorderStyle nBorderStyle = BorderStyle::SOLID;
if (string == "solid")
- nBorderStyle = BBS_SOLID;
+ nBorderStyle = BorderStyle::SOLID;
else if (string == "beveled")
- nBorderStyle = BBS_BEVELED;
+ nBorderStyle = BorderStyle::BEVELED;
else if (string == "dashed")
- nBorderStyle = BBS_DASH;
+ nBorderStyle = BorderStyle::DASH;
else if (string == "inset")
- nBorderStyle = BBS_INSET;
+ nBorderStyle = BorderStyle::INSET;
else if (string == "underline")
- nBorderStyle = BBS_UNDERLINE;
+ nBorderStyle = BorderStyle::UNDERLINE;
else
return;
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Define.h b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Define.h
index 3c148cf3584..2c00818d081 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Define.h
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Define.h
@@ -9,15 +9,15 @@
#include <vector>
-#include "fpdfsdk/include/jsapi/fxjs_v8.h"
#include "fpdfsdk/javascript/JS_Object.h"
#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/resource.h"
+#include "fpdfsdk/jsapi/include/fxjs_v8.h"
struct JSConstSpec {
const wchar_t* pName;
double number;
- const wchar_t* string; // NOLINT
+ const wchar_t* str;
uint8_t t; // 0:double 1:str
};
@@ -50,12 +50,9 @@ struct JSMethodSpec {
#define BEGIN_JS_STATIC_PROP(js_class_name) \
JSPropertySpec js_class_name::JS_Class_Properties[] = {
-#define JS_STATIC_PROP_ENTRY(prop_name) \
- { \
- JS_WIDESTRING(prop_name), get_##prop_name##_static, \
- set_##prop_name##_static \
- } \
- ,
+#define JS_STATIC_PROP_ENTRY(prop_name) \
+ {JS_WIDESTRING(prop_name), get_##prop_name##_static, \
+ set_##prop_name##_static}, // NOLINT
#define END_JS_STATIC_PROP() \
{ 0, 0, 0 } \
@@ -211,15 +208,15 @@ void JSMethod(const char* method_name_string,
static JSConstSpec JS_Class_Consts[]; \
static void DefineConsts(v8::Isolate* pIsolate);
-#define IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \
- void js_class_name::DefineConsts(v8::Isolate* pIsolate) { \
- for (size_t i = 0; i < FX_ArraySize(JS_Class_Consts) - 1; ++i) { \
- FXJS_DefineObjConst( \
- pIsolate, g_nObjDefnID, JS_Class_Consts[i].pName, \
- JS_Class_Consts[i].t == 0 \
- ? FXJS_NewNumber(pIsolate, JS_Class_Consts[i].number) \
- : FXJS_NewString(pIsolate, JS_Class_Consts[i].string)); \
- } \
+#define IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \
+ void js_class_name::DefineConsts(v8::Isolate* pIsolate) { \
+ for (size_t i = 0; i < FX_ArraySize(JS_Class_Consts) - 1; ++i) { \
+ FXJS_DefineObjConst( \
+ pIsolate, g_nObjDefnID, JS_Class_Consts[i].pName, \
+ JS_Class_Consts[i].t == 0 \
+ ? FXJS_NewNumber(pIsolate, JS_Class_Consts[i].number) \
+ : FXJS_NewString(pIsolate, JS_Class_Consts[i].str)); \
+ } \
}
// Convenience macros for declaring classes without an alternate.
@@ -354,8 +351,8 @@ void JSSpecialPropQuery(const char*,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
v8::Isolate* isolate = info.GetIsolate();
v8::String::Utf8Value utf8_value(property);
- CFX_WideString propname =
- CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
+ CFX_WideString propname = CFX_WideString::FromUTF8(
+ CFX_ByteStringC(*utf8_value, utf8_value.length()));
CJS_Object* pJSObj =
reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
@@ -377,8 +374,8 @@ void JSSpecialPropGet(const char* class_name,
reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
- CFX_WideString propname =
- CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
+ CFX_WideString propname = CFX_WideString::FromUTF8(
+ CFX_ByteStringC(*utf8_value, utf8_value.length()));
CFX_WideString sError;
CJS_PropValue value(pRuntime);
value.StartGetting();
@@ -404,8 +401,8 @@ void JSSpecialPropPut(const char* class_name,
reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
- CFX_WideString propname =
- CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
+ CFX_WideString propname = CFX_WideString::FromUTF8(
+ CFX_ByteStringC(*utf8_value, utf8_value.length()));
CFX_WideString sError;
CJS_PropValue PropValue(CJS_Value(pRuntime, value, CJS_Value::VT_unknown));
PropValue.StartSetting();
@@ -427,8 +424,8 @@ void JSSpecialPropDel(const char* class_name,
reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder()));
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
v8::String::Utf8Value utf8_value(property);
- CFX_WideString propname =
- CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
+ CFX_WideString propname = CFX_WideString::FromUTF8(
+ CFX_ByteStringC(*utf8_value, utf8_value.length()));
CFX_WideString sError;
if (!pObj->DelProperty(pContext, propname.c_str(), sError)) {
CFX_ByteString cbName;
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.cpp
index fe3475c2b1e..8f7810f111f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.cpp
@@ -94,9 +94,7 @@ static const uint8_t JS_RC4KEY[] = {
0xf8, 0x77, 0xd5, 0xa3};
// Returns true if non-empty, setting sPropName
-static bool TrimPropName(const char* propname, CFX_ByteString* sPropName) {
- ASSERT(propname);
- *sPropName = propname;
+static bool TrimPropName(CFX_ByteString* sPropName) {
sPropName->TrimLeft();
sPropName->TrimRight();
return sPropName->GetLength() != 0;
@@ -130,7 +128,7 @@ CJS_GlobalData::~CJS_GlobalData() {
}
CJS_GlobalData::iterator CJS_GlobalData::FindGlobalVariable(
- const FX_CHAR* propname) {
+ const CFX_ByteString& propname) {
for (auto it = m_arrayGlobalData.begin(); it != m_arrayGlobalData.end();
++it) {
if ((*it)->data.sKey == propname)
@@ -140,7 +138,7 @@ CJS_GlobalData::iterator CJS_GlobalData::FindGlobalVariable(
}
CJS_GlobalData::const_iterator CJS_GlobalData::FindGlobalVariable(
- const FX_CHAR* propname) const {
+ const CFX_ByteString& propname) const {
for (auto it = m_arrayGlobalData.begin(); it != m_arrayGlobalData.end();
++it) {
if ((*it)->data.sKey == propname)
@@ -150,15 +148,15 @@ CJS_GlobalData::const_iterator CJS_GlobalData::FindGlobalVariable(
}
CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable(
- const FX_CHAR* propname) {
+ const CFX_ByteString& propname) {
auto iter = FindGlobalVariable(propname);
return iter != m_arrayGlobalData.end() ? iter->get() : nullptr;
}
-void CJS_GlobalData::SetGlobalVariableNumber(const FX_CHAR* propname,
+void CJS_GlobalData::SetGlobalVariableNumber(const CFX_ByteString& propname,
double dData) {
- CFX_ByteString sPropName;
- if (!TrimPropName(propname, &sPropName))
+ CFX_ByteString sPropName(propname);
+ if (!TrimPropName(&sPropName))
return;
if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
@@ -173,10 +171,10 @@ void CJS_GlobalData::SetGlobalVariableNumber(const FX_CHAR* propname,
m_arrayGlobalData.push_back(std::move(pNewData));
}
-void CJS_GlobalData::SetGlobalVariableBoolean(const FX_CHAR* propname,
+void CJS_GlobalData::SetGlobalVariableBoolean(const CFX_ByteString& propname,
bool bData) {
- CFX_ByteString sPropName;
- if (!TrimPropName(propname, &sPropName))
+ CFX_ByteString sPropName(propname);
+ if (!TrimPropName(&sPropName))
return;
if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
@@ -191,10 +189,10 @@ void CJS_GlobalData::SetGlobalVariableBoolean(const FX_CHAR* propname,
m_arrayGlobalData.push_back(std::move(pNewData));
}
-void CJS_GlobalData::SetGlobalVariableString(const FX_CHAR* propname,
+void CJS_GlobalData::SetGlobalVariableString(const CFX_ByteString& propname,
const CFX_ByteString& sData) {
- CFX_ByteString sPropName;
- if (!TrimPropName(propname, &sPropName))
+ CFX_ByteString sPropName(propname);
+ if (!TrimPropName(&sPropName))
return;
if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
@@ -210,10 +208,10 @@ void CJS_GlobalData::SetGlobalVariableString(const FX_CHAR* propname,
}
void CJS_GlobalData::SetGlobalVariableObject(
- const FX_CHAR* propname,
+ const CFX_ByteString& propname,
const CJS_GlobalVariableArray& array) {
- CFX_ByteString sPropName;
- if (!TrimPropName(propname, &sPropName))
+ CFX_ByteString sPropName(propname);
+ if (!TrimPropName(&sPropName))
return;
if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
@@ -228,9 +226,9 @@ void CJS_GlobalData::SetGlobalVariableObject(
m_arrayGlobalData.push_back(std::move(pNewData));
}
-void CJS_GlobalData::SetGlobalVariableNull(const FX_CHAR* propname) {
- CFX_ByteString sPropName;
- if (!TrimPropName(propname, &sPropName))
+void CJS_GlobalData::SetGlobalVariableNull(const CFX_ByteString& propname) {
+ CFX_ByteString sPropName(propname);
+ if (!TrimPropName(&sPropName))
return;
if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
@@ -243,10 +241,11 @@ void CJS_GlobalData::SetGlobalVariableNull(const FX_CHAR* propname) {
m_arrayGlobalData.push_back(std::move(pNewData));
}
-FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname,
- FX_BOOL bPersistent) {
- CFX_ByteString sPropName;
- if (!TrimPropName(propname, &sPropName))
+FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(
+ const CFX_ByteString& propname,
+ FX_BOOL bPersistent) {
+ CFX_ByteString sPropName(propname);
+ if (!TrimPropName(&sPropName))
return FALSE;
CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName);
@@ -257,9 +256,9 @@ FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname,
return TRUE;
}
-FX_BOOL CJS_GlobalData::DeleteGlobalVariable(const FX_CHAR* propname) {
- CFX_ByteString sPropName;
- if (!TrimPropName(propname, &sPropName))
+FX_BOOL CJS_GlobalData::DeleteGlobalVariable(const CFX_ByteString& propname) {
+ CFX_ByteString sPropName(propname);
+ if (!TrimPropName(&sPropName))
return FALSE;
auto iter = FindGlobalVariable(sPropName);
@@ -292,8 +291,6 @@ void CJS_GlobalData::LoadGlobalPersistentVariables() {
uint16_t wType = *((uint16_t*)p);
p += sizeof(uint16_t);
- // uint16_t wTemp = (uint16_t)(('X' << 8) | 'F');
-
if (wType == (uint16_t)(('X' << 8) | 'F')) {
uint16_t wVersion = *((uint16_t*)p);
p += sizeof(uint16_t);
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.h b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.h
index 65bb921ad91..056f26193ff 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.h
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_GlobalData.h
@@ -64,17 +64,16 @@ class CJS_GlobalData {
static CJS_GlobalData* GetRetainedInstance(CPDFDoc_Environment* pApp);
void Release();
- void SetGlobalVariableNumber(const FX_CHAR* propname, double dData);
- void SetGlobalVariableBoolean(const FX_CHAR* propname, bool bData);
- void SetGlobalVariableString(const FX_CHAR* propname,
+ void SetGlobalVariableNumber(const CFX_ByteString& propname, double dData);
+ void SetGlobalVariableBoolean(const CFX_ByteString& propname, bool bData);
+ void SetGlobalVariableString(const CFX_ByteString& propname,
const CFX_ByteString& sData);
- void SetGlobalVariableObject(const FX_CHAR* propname,
+ void SetGlobalVariableObject(const CFX_ByteString& propname,
const CJS_GlobalVariableArray& array);
- void SetGlobalVariableNull(const FX_CHAR* propname);
-
- FX_BOOL SetGlobalVariablePersistent(const FX_CHAR* propname,
+ void SetGlobalVariableNull(const CFX_ByteString& propname);
+ FX_BOOL SetGlobalVariablePersistent(const CFX_ByteString& propname,
FX_BOOL bPersistent);
- FX_BOOL DeleteGlobalVariable(const FX_CHAR* propname);
+ FX_BOOL DeleteGlobalVariable(const CFX_ByteString& propname);
int32_t GetSize() const;
CJS_GlobalData_Element* GetAt(int index) const;
@@ -93,9 +92,9 @@ class CJS_GlobalData {
void LoadGlobalPersistentVariables();
void SaveGlobalPersisitentVariables();
- CJS_GlobalData_Element* GetGlobalVariable(const FX_CHAR* propname);
- iterator FindGlobalVariable(const FX_CHAR* propname);
- const_iterator FindGlobalVariable(const FX_CHAR* propname) const;
+ CJS_GlobalData_Element* GetGlobalVariable(const CFX_ByteString& sPropname);
+ iterator FindGlobalVariable(const CFX_ByteString& sPropname);
+ const_iterator FindGlobalVariable(const CFX_ByteString& sPropname) const;
void LoadFileBuffer(const FX_WCHAR* sFilePath,
uint8_t*& pBuffer,
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.cpp
index d85cc1dbe49..7dc91a7291f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.cpp
@@ -107,7 +107,7 @@ CJS_Timer::CJS_Timer(CJS_EmbedObj* pObj,
m_swJScript(script),
m_pRuntime(pRuntime),
m_pApp(pApp) {
- IFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
+ CFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
m_nTimerID = pHandler->SetTimer(dwElapse, TimerProc);
(*GetGlobalTimerMap())[m_nTimerID] = this;
m_pRuntime->AddObserver(this);
@@ -123,7 +123,7 @@ CJS_Timer::~CJS_Timer() {
void CJS_Timer::KillJSTimer() {
if (m_nTimerID) {
if (m_bValid) {
- IFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
+ CFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
pHandler->KillTimer(m_nTimerID);
}
GetGlobalTimerMap()->erase(m_nTimerID);
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.h b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.h
index e0ec23e79ab..49c078d927a 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.h
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Object.h
@@ -11,8 +11,8 @@
#include <memory>
#include "fpdfsdk/include/fsdk_define.h"
-#include "fpdfsdk/include/jsapi/fxjs_v8.h"
#include "fpdfsdk/javascript/cjs_runtime.h"
+#include "fpdfsdk/jsapi/include/fxjs_v8.h"
class CJS_Context;
class CJS_Object;
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.cpp
index 0b31494b75c..ab02f02cfb0 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.cpp
@@ -151,7 +151,7 @@ void CJS_Value::MaybeCoerceToNumber() {
if (bstr == "NaN")
bAllowNaN = true;
}
- v8::TryCatch(m_pJSRuntime->GetIsolate());
+ v8::TryCatch try_catch(m_pJSRuntime->GetIsolate());
v8::MaybeLocal<v8::Number> maybeNum =
m_pValue->ToNumber(m_pJSRuntime->GetIsolate()->GetCurrentContext());
if (maybeNum.IsEmpty())
@@ -787,7 +787,7 @@ int JS_GetSecFromTime(double dt) {
return (int)_Mod(floor(dt / 1000), 60);
}
-double JS_DateParse(const wchar_t* str) {
+double JS_DateParse(const CFX_WideString& str) {
v8::Isolate* pIsolate = v8::Isolate::GetCurrent();
v8::Isolate::Scope isolate_scope(pIsolate);
v8::HandleScope scope(pIsolate);
@@ -809,7 +809,6 @@ double JS_DateParse(const wchar_t* str) {
.ToLocalChecked();
if (v->IsFunction()) {
v8::Local<v8::Function> funC = v8::Local<v8::Function>::Cast(v);
-
const int argc = 1;
v8::Local<v8::String> timeStr = FXJS_WSToJSString(pIsolate, str);
v8::Local<v8::Value> argv[argc] = {timeStr};
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.h b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.h
index 69656ea18c3..8adec4b1d17 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.h
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/JS_Value.h
@@ -10,7 +10,7 @@
#include <vector>
#include "core/fxcrt/include/fx_basic.h"
-#include "fpdfsdk/include/jsapi/fxjs_v8.h"
+#include "fpdfsdk/jsapi/include/fxjs_v8.h"
class CJS_Array;
class CJS_Date;
@@ -208,7 +208,7 @@ int JS_GetDayFromTime(double dt);
int JS_GetHourFromTime(double dt);
int JS_GetMinFromTime(double dt);
int JS_GetSecFromTime(double dt);
-double JS_DateParse(const wchar_t* str);
+double JS_DateParse(const CFX_WideString& str);
double JS_MakeDay(int nYear, int nMonth, int nDay);
double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
double JS_MakeDate(double day, double time);
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.cpp
index 308163d4542..fa7b5d4d362 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.cpp
@@ -7,7 +7,6 @@
#include "fpdfsdk/javascript/PublicMethods.h"
#include <algorithm>
-#include <string>
#include <vector>
#include "core/fxcrt/include/fx_ext.h"
@@ -52,20 +51,37 @@ END_JS_STATIC_GLOBAL_FUN()
IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods)
-static const FX_WCHAR* const months[] = {L"Jan", L"Feb", L"Mar", L"Apr",
- L"May", L"Jun", L"Jul", L"Aug",
- L"Sep", L"Oct", L"Nov", L"Dec"};
+namespace {
-static const FX_WCHAR* const fullmonths[] = {
- L"January", L"February", L"March", L"April",
- L"May", L"June", L"July", L"August",
- L"September", L"October", L"November", L"December"};
+const FX_WCHAR* const months[] = {L"Jan", L"Feb", L"Mar", L"Apr",
+ L"May", L"Jun", L"Jul", L"Aug",
+ L"Sep", L"Oct", L"Nov", L"Dec"};
-bool CJS_PublicMethods::IsNumber(const FX_WCHAR* str) {
+const FX_WCHAR* const fullmonths[] = {L"January", L"February", L"March",
+ L"April", L"May", L"June",
+ L"July", L"August", L"September",
+ L"October", L"November", L"December"};
+
+CFX_ByteString StrTrim(const CFX_ByteString& pStr) {
+ CFX_ByteString result(pStr);
+ result.TrimLeft(' ');
+ result.TrimRight(' ');
+ return result;
+}
+
+CFX_WideString StrTrim(const CFX_WideString& pStr) {
+ CFX_WideString result(pStr);
+ result.TrimLeft(' ');
+ result.TrimRight(' ');
+ return result;
+}
+
+} // namespace
+
+bool CJS_PublicMethods::IsNumber(const CFX_WideString& str) {
CFX_WideString sTrim = StrTrim(str);
const FX_WCHAR* pTrim = sTrim.c_str();
const FX_WCHAR* p = pTrim;
-
bool bDot = false;
bool bKXJS = false;
@@ -136,48 +152,6 @@ double CJS_PublicMethods::AF_Simple(const FX_WCHAR* sFuction,
return dValue1;
}
-CFX_WideString CJS_PublicMethods::StrLTrim(const FX_WCHAR* pStr) {
- while (*pStr && *pStr == L' ')
- pStr++;
-
- return pStr;
-}
-
-CFX_WideString CJS_PublicMethods::StrRTrim(const FX_WCHAR* pStr) {
- const FX_WCHAR* p = pStr;
- while (*p)
- p++;
- while (p > pStr && *(p - 1) == L' ')
- p--;
-
- return CFX_WideString(pStr, p - pStr);
-}
-
-CFX_WideString CJS_PublicMethods::StrTrim(const FX_WCHAR* pStr) {
- return StrRTrim(StrLTrim(pStr).c_str());
-}
-
-CFX_ByteString CJS_PublicMethods::StrLTrim(const FX_CHAR* pStr) {
- while (*pStr && *pStr == ' ')
- pStr++;
-
- return pStr;
-}
-
-CFX_ByteString CJS_PublicMethods::StrRTrim(const FX_CHAR* pStr) {
- const FX_CHAR* p = pStr;
- while (*p)
- p++;
- while (p > pStr && *(p - 1) == L' ')
- p--;
-
- return CFX_ByteString(pStr, p - pStr);
-}
-
-CFX_ByteString CJS_PublicMethods::StrTrim(const FX_CHAR* pStr) {
- return StrRTrim(StrLTrim(pStr));
-}
-
CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime,
CJS_Value val) {
CJS_Array StrArray(pRuntime);
@@ -187,7 +161,7 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime,
}
CFX_WideString wsStr = val.ToCFXWideString();
CFX_ByteString t = CFX_ByteString::FromUnicode(wsStr);
- const char* p = (const char*)t;
+ const char* p = t.c_str();
int ch = ',';
int nIndex = 0;
@@ -195,7 +169,8 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime,
while (*p) {
const char* pTemp = strchr(p, ch);
if (!pTemp) {
- StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(p).c_str()));
+ StrArray.SetElement(
+ nIndex, CJS_Value(pRuntime, StrTrim(CFX_ByteString(p)).c_str()));
break;
}
@@ -203,7 +178,8 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime,
strncpy(pSub, p, pTemp - p);
*(pSub + (pTemp - p)) = '\0';
- StrArray.SetElement(nIndex, CJS_Value(pRuntime, StrTrim(pSub).c_str()));
+ StrArray.SetElement(
+ nIndex, CJS_Value(pRuntime, StrTrim(CFX_ByteString(pSub)).c_str()));
delete[] pSub;
nIndex++;
@@ -329,7 +305,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString& value,
CFX_WideString swTemp;
swTemp.Format(L"%d/%d/%d %d:%d:%d", nMonth, nDay, nYear, nHour, nMin, nSec);
- return JS_DateParse(swTemp.c_str());
+ return JS_DateParse(swTemp);
}
double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value,
@@ -586,24 +562,21 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value,
bBadFormat = true;
double dRet = 0;
-
if (bBadFormat) {
dRet = ParseNormalDate(value, &bBadFormat);
} else {
dRet = JS_MakeDate(JS_MakeDay(nYear, nMonth - 1, nDay),
JS_MakeTime(nHour, nMin, nSec, 0));
-
- if (JS_PortIsNan(dRet)) {
- dRet = JS_DateParse(value.c_str());
- }
+ if (JS_PortIsNan(dRet))
+ dRet = JS_DateParse(value);
}
- if (JS_PortIsNan(dRet)) {
+ if (JS_PortIsNan(dRet))
dRet = ParseNormalDate(value, &bBadFormat);
- }
if (bWrongFormat)
*bWrongFormat = bBadFormat;
+
return dRet;
}
@@ -765,7 +738,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
int iSepStyle = params[1].ToInt();
int iNegStyle = params[2].ToInt();
// params[3] is iCurrStyle, it's not used.
- std::wstring wstrCurrency(params[4].ToCFXWideString().c_str());
+ CFX_WideString wstrCurrency = params[4].ToCFXWideString();
FX_BOOL bCurrencyPrepend = params[5].ToBool();
if (iDec < 0)
@@ -779,7 +752,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
// for processing decimal places
strValue.Replace(",", ".");
- double dValue = atof(strValue);
+ double dValue = atof(strValue.c_str());
if (iDec > 0)
dValue += DOUBLE_CORRECT;
@@ -837,22 +810,19 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
}
// for processing currency string
- Value = CFX_WideString::FromLocal(strValue);
- std::wstring strValue2 = Value.c_str();
+ Value = CFX_WideString::FromLocal(strValue.AsStringC());
if (bCurrencyPrepend)
- strValue2 = wstrCurrency + strValue2;
+ Value = wstrCurrency + Value;
else
- strValue2 = strValue2 + wstrCurrency;
+ Value = Value + wstrCurrency;
// for processing negative style
if (iNegative) {
if (iNegStyle == 0) {
- strValue2.insert(0, L"-");
- }
- if (iNegStyle == 2 || iNegStyle == 3) {
- strValue2.insert(0, L"(");
- strValue2.insert(strValue2.length(), L")");
+ Value = L"-" + Value;
+ } else if (iNegStyle == 2 || iNegStyle == 3) {
+ Value = L"(" + Value + L")";
}
if (iNegStyle == 1 || iNegStyle == 3) {
if (Field* fTarget = pEvent->Target_Field()) {
@@ -908,7 +878,6 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
}
}
}
- Value = strValue2.c_str();
#endif
return TRUE;
}
@@ -925,41 +894,35 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
if (params.size() < 2)
return FALSE;
- int iSepStyle = params[1].ToInt();
- if (iSepStyle < 0 || iSepStyle > 3)
- iSepStyle = 0;
if (!pEvent->m_pValue)
return FALSE;
+
CFX_WideString& val = pEvent->Value();
- CFX_WideString& w_strChange = pEvent->Change();
- CFX_WideString w_strValue = val;
+ CFX_WideString& wstrChange = pEvent->Change();
+ CFX_WideString wstrValue = val;
if (pEvent->WillCommit()) {
- CFX_WideString wstrChange = w_strChange;
- CFX_WideString wstrValue = StrLTrim(w_strValue.c_str());
- if (wstrValue.IsEmpty())
+ CFX_WideString swTemp = StrTrim(wstrValue);
+ if (swTemp.IsEmpty())
return TRUE;
- CFX_WideString swTemp = wstrValue;
swTemp.Replace(L",", L".");
if (!IsNumber(swTemp.c_str())) {
pEvent->Rc() = FALSE;
sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
Alert(pContext, sError.c_str());
- return TRUE;
}
return TRUE; // it happens after the last keystroke and before validating,
}
- std::wstring w_strValue2 = w_strValue.c_str();
- std::wstring w_strChange2 = w_strChange.c_str();
- std::wstring w_strSelected;
- if (-1 != pEvent->SelStart())
- w_strSelected = w_strValue2.substr(pEvent->SelStart(),
- (pEvent->SelEnd() - pEvent->SelStart()));
- bool bHasSign = (w_strValue2.find('-') != std::wstring::npos) &&
- (w_strSelected.find('-') == std::wstring::npos);
+ CFX_WideString wstrSelected;
+ if (pEvent->SelStart() != -1) {
+ wstrSelected = wstrValue.Mid(pEvent->SelStart(),
+ pEvent->SelEnd() - pEvent->SelStart());
+ }
+
+ bool bHasSign = wstrValue.Find(L'-') != -1 && wstrSelected.Find(L'-') == -1;
if (bHasSign) {
// can't insert "change" in front to sign postion.
if (pEvent->SelStart() == 0) {
@@ -969,23 +932,14 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
}
}
- char cSep = L'.';
-
- switch (iSepStyle) {
- case 0:
- case 1:
- cSep = L'.';
- break;
- case 2:
- case 3:
- cSep = L',';
- break;
- }
+ int iSepStyle = params[1].ToInt();
+ if (iSepStyle < 0 || iSepStyle > 3)
+ iSepStyle = 0;
+ const FX_WCHAR cSep = iSepStyle < 2 ? L'.' : L',';
- bool bHasSep = (w_strValue2.find(cSep) != std::wstring::npos);
- for (std::wstring::iterator it = w_strChange2.begin();
- it != w_strChange2.end(); it++) {
- if (*it == cSep) {
+ bool bHasSep = wstrValue.Find(cSep) != -1;
+ for (FX_STRSIZE i = 0; i < wstrChange.GetLength(); ++i) {
+ if (wstrChange[i] == cSep) {
if (bHasSep) {
FX_BOOL& bRc = pEvent->Rc();
bRc = FALSE;
@@ -994,14 +948,14 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
bHasSep = TRUE;
continue;
}
- if (*it == L'-') {
+ if (wstrChange[i] == L'-') {
if (bHasSign) {
FX_BOOL& bRc = pEvent->Rc();
bRc = FALSE;
return TRUE;
}
// sign's position is not correct
- if (it != w_strChange2.begin()) {
+ if (i != 0) {
FX_BOOL& bRc = pEvent->Rc();
bRc = FALSE;
return TRUE;
@@ -1015,20 +969,18 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
continue;
}
- if (!FXSYS_iswdigit(*it)) {
+ if (!FXSYS_iswdigit(wstrChange[i])) {
FX_BOOL& bRc = pEvent->Rc();
bRc = FALSE;
return TRUE;
}
}
- std::wstring w_prefix = w_strValue2.substr(0, pEvent->SelStart());
- std::wstring w_postfix;
- if (pEvent->SelEnd() < (int)w_strValue2.length())
- w_postfix = w_strValue2.substr(pEvent->SelEnd());
- w_strValue2 = w_prefix + w_strChange2 + w_postfix;
- w_strValue = w_strValue2.c_str();
- val = w_strValue;
+ CFX_WideString wprefix = wstrValue.Mid(0, pEvent->SelStart());
+ CFX_WideString wpostfix;
+ if (pEvent->SelEnd() < wstrValue.GetLength())
+ wpostfix = wstrValue.Mid(pEvent->SelEnd());
+ val = wprefix + wstrChange + wpostfix;
return TRUE;
}
@@ -1063,7 +1015,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(
iSepStyle = 0;
// for processing decimal places
- double dValue = atof(strValue);
+ double dValue = atof(strValue.c_str());
dValue *= 100;
if (iDec > 0)
dValue += DOUBLE_CORRECT;
@@ -1120,7 +1072,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(
if (iNegative)
strValue = "-" + strValue;
strValue += "%";
- Value = CFX_WideString::FromLocal(strValue);
+ Value = CFX_WideString::FromLocal(strValue.AsStringC());
#endif
return TRUE;
}
@@ -1176,7 +1128,7 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc,
return TRUE;
}
-double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) {
+double CJS_PublicMethods::MakeInterDate(const CFX_WideString& strValue) {
std::vector<CFX_WideString> wsArray;
CFX_WideString sTemp = L"";
for (int i = 0; i < strValue.GetLength(); ++i) {
@@ -1219,15 +1171,15 @@ double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) {
else if (sTemp.Compare(L"Dec") == 0)
nMonth = 12;
- int nDay = FX_atof(wsArray[2].AsWideStringC());
- int nHour = FX_atof(wsArray[3].AsWideStringC());
- int nMin = FX_atof(wsArray[4].AsWideStringC());
- int nSec = FX_atof(wsArray[5].AsWideStringC());
- int nYear = FX_atof(wsArray[7].AsWideStringC());
+ int nDay = FX_atof(wsArray[2].AsStringC());
+ int nHour = FX_atof(wsArray[3].AsStringC());
+ int nMin = FX_atof(wsArray[4].AsStringC());
+ int nSec = FX_atof(wsArray[5].AsStringC());
+ int nYear = FX_atof(wsArray[7].AsStringC());
double dRet = JS_MakeDate(JS_MakeDay(nYear, nMonth - 1, nDay),
JS_MakeTime(nHour, nMin, nSec, 0));
if (JS_PortIsNan(dRet))
- dRet = JS_DateParse(strValue.c_str());
+ dRet = JS_DateParse(strValue);
return dRet;
}
@@ -1466,21 +1418,18 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
if (wstrMask.IsEmpty())
return TRUE;
- const size_t wstrMaskLen = wstrMask.GetLength();
- const std::wstring wstrValue = valEvent.c_str();
-
if (pEvent->WillCommit()) {
- if (wstrValue.empty())
+ if (valEvent.IsEmpty())
return TRUE;
- size_t iIndexMask = 0;
- for (const auto& w_Value : wstrValue) {
- if (!maskSatisfied(w_Value, wstrMask[iIndexMask]))
+
+ FX_STRSIZE iIndexMask = 0;
+ for (; iIndexMask < valEvent.GetLength(); ++iIndexMask) {
+ if (!maskSatisfied(valEvent[iIndexMask], wstrMask[iIndexMask]))
break;
- iIndexMask++;
}
- if (iIndexMask != wstrMaskLen ||
- (iIndexMask != wstrValue.size() && wstrMaskLen != 0)) {
+ if (iIndexMask != wstrMask.GetLength() ||
+ (iIndexMask != valEvent.GetLength() && wstrMask.GetLength() != 0)) {
Alert(
pContext,
JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
@@ -1490,48 +1439,45 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
}
CFX_WideString& wideChange = pEvent->Change();
- std::wstring wChange = wideChange.c_str();
- if (wChange.empty())
+ if (wideChange.IsEmpty())
return TRUE;
- size_t iIndexMask = pEvent->SelStart();
-
- size_t combined_len = wstrValue.length() + wChange.length() -
- (pEvent->SelEnd() - pEvent->SelStart());
- if (combined_len > wstrMaskLen) {
+ CFX_WideString wChange = wideChange;
+ FX_STRSIZE iIndexMask = pEvent->SelStart();
+ FX_STRSIZE combined_len = valEvent.GetLength() + wChange.GetLength() +
+ pEvent->SelStart() - pEvent->SelEnd();
+ if (combined_len > wstrMask.GetLength()) {
Alert(pContext,
JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
- if (iIndexMask >= wstrMaskLen && (!wChange.empty())) {
+ if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
Alert(pContext,
JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
- for (std::wstring::iterator it = wChange.begin(); it != wChange.end(); it++) {
- if (iIndexMask >= wstrMaskLen) {
+ for (FX_STRSIZE i = 0; i < wChange.GetLength(); ++i) {
+ if (iIndexMask >= wstrMask.GetLength()) {
Alert(pContext,
JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
- wchar_t w_Mask = wstrMask[iIndexMask];
- if (!isReservedMaskChar(w_Mask)) {
- *it = w_Mask;
- }
- wchar_t w_Change = *it;
- if (!maskSatisfied(w_Change, w_Mask)) {
+ FX_WCHAR wMask = wstrMask[iIndexMask];
+ if (!isReservedMaskChar(wMask))
+ wChange.SetAt(i, wMask);
+
+ if (!maskSatisfied(wChange[i], wMask)) {
pEvent->Rc() = FALSE;
return TRUE;
}
iIndexMask++;
}
-
- wideChange = wChange.c_str();
+ wideChange = wChange;
return TRUE;
}
@@ -1551,13 +1497,8 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(
if (!pEvent->m_pValue)
return FALSE;
- std::string cFormat;
- int iIndex = params[0].ToInt();
- CFX_WideString& val = pEvent->Value();
- std::string strSrc = CFX_ByteString::FromUnicode(val).c_str();
- std::wstring wstrChange = pEvent->Change().c_str();
-
- switch (iIndex) {
+ const char* cFormat = "";
+ switch (params[0].ToInt()) {
case 0:
cFormat = "99999";
break;
@@ -1565,7 +1506,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(
cFormat = "999999999";
break;
case 2:
- if (strSrc.length() + wstrChange.length() > 7)
+ if (pEvent->Value().GetLength() + pEvent->Change().GetLength() > 7)
cFormat = "9999999999";
else
cFormat = "9999999";
@@ -1576,7 +1517,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_Keystroke(
}
std::vector<CJS_Value> params2;
- params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat.c_str()));
+ params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat));
return AFSpecial_KeystrokeEx(cc, params2, vRet, sError);
}
@@ -1677,7 +1618,7 @@ FX_BOOL CJS_PublicMethods::AFMakeNumber(IJS_Context* cc,
}
CFX_WideString ws = params[0].ToCFXWideString();
ws.Replace(L",", L".");
- vRet = ws;
+ vRet = ws.c_str();
vRet.MaybeCoerceToNumber();
if (vRet.GetType() != CJS_Value::VT_number)
vRet = 0;
@@ -1726,7 +1667,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(
CFX_WideString trimmed = pFormField->GetValue();
trimmed.TrimRight();
trimmed.TrimLeft();
- dTemp = FX_atof(trimmed.AsWideStringC());
+ dTemp = FX_atof(trimmed.AsStringC());
} break;
case FIELDTYPE_PUSHBUTTON: {
dTemp = 0.0;
@@ -1740,7 +1681,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(
CFX_WideString trimmed = pFormCtrl->GetExportValue();
trimmed.TrimRight();
trimmed.TrimLeft();
- dTemp = FX_atof(trimmed.AsWideStringC());
+ dTemp = FX_atof(trimmed.AsStringC());
break;
}
}
@@ -1751,7 +1692,7 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(
CFX_WideString trimmed = pFormField->GetValue();
trimmed.TrimRight();
trimmed.TrimLeft();
- dTemp = FX_atof(trimmed.AsWideStringC());
+ dTemp = FX_atof(trimmed.AsStringC());
}
} break;
default:
@@ -1801,7 +1742,8 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(
return FALSE;
if (pEvent->Value().IsEmpty())
return TRUE;
- double dEentValue = atof(CFX_ByteString::FromUnicode(pEvent->Value()));
+ double dEentValue =
+ atof(CFX_ByteString::FromUnicode(pEvent->Value()).c_str());
FX_BOOL bGreaterThan = params[0].ToBool();
double dGreaterThan = params[1].ToDouble();
FX_BOOL bLessThan = params[2].ToBool();
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.h b/chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.h
index 16cc5bc21ab..67ca082f314 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.h
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/PublicMethods.h
@@ -146,17 +146,9 @@ class CJS_PublicMethods : public CJS_Object {
const CFX_WideString& format);
static double ParseNormalDate(const CFX_WideString& value,
bool* bWrongFormat);
- static double MakeInterDate(CFX_WideString strValue);
+ static double MakeInterDate(const CFX_WideString& value);
- static CFX_WideString StrLTrim(const FX_WCHAR* pStr);
- static CFX_WideString StrRTrim(const FX_WCHAR* pStr);
- static CFX_WideString StrTrim(const FX_WCHAR* pStr);
-
- static CFX_ByteString StrLTrim(const FX_CHAR* pStr);
- static CFX_ByteString StrRTrim(const FX_CHAR* pStr);
- static CFX_ByteString StrTrim(const FX_CHAR* pStr);
-
- static bool IsNumber(const FX_WCHAR* string);
+ static bool IsNumber(const CFX_WideString& str);
static bool maskSatisfied(wchar_t c_Change, wchar_t c_Mask);
static bool isReservedMaskChar(wchar_t ch);
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.cpp
index 8e01017467d..8fd7cf1a0ef 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.cpp
@@ -13,7 +13,6 @@
#include "fpdfsdk/javascript/Document.h"
#include "fpdfsdk/javascript/Field.h"
#include "fpdfsdk/javascript/Icon.h"
-#include "fpdfsdk/javascript/cjs_context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_GlobalData.h"
@@ -21,6 +20,7 @@
#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/PublicMethods.h"
#include "fpdfsdk/javascript/app.h"
+#include "fpdfsdk/javascript/cjs_context.h"
#include "fpdfsdk/javascript/color.h"
#include "fpdfsdk/javascript/console.h"
#include "fpdfsdk/javascript/event.h"
@@ -30,7 +30,7 @@
#include "third_party/base/stl_util.h"
#ifdef PDF_ENABLE_XFA
-#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
+#include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
#include "xfa/fxjse/value.h"
#endif // PDF_ENABLE_XFA
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.h b/chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.h
index 97e30e7eee9..e2091fdcfd0 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.h
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/cjs_runtime.h
@@ -14,9 +14,9 @@
#include <vector>
#include "core/fxcrt/include/fx_basic.h"
-#include "fpdfsdk/include/jsapi/fxjs_v8.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/ijs_runtime.h"
+#include "fpdfsdk/jsapi/include/fxjs_v8.h"
class CJS_Context;
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/global.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/global.cpp
index fe974c7af28..043bd290ac7 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/global.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/global.cpp
@@ -53,7 +53,7 @@ const unsigned int JSCONST_nUndefHash =
CHash<'u', 'n', 'd', 'e', 'f', 'i', 'n', 'e', 'd'>::value;
static unsigned JS_CalcHash(const wchar_t* main) {
- return (unsigned)FX_HashCode_String_GetW(main, FXSYS_wcslen(main));
+ return (unsigned)FX_HashCode_GetW(CFX_WideStringC(main), false);
}
#ifndef NDEBUG
@@ -233,15 +233,14 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
pData->data.dData, false, "",
v8::Local<v8::Object>(), pData->bPersistent == 1);
FXJS_PutObjectNumber(NULL, m_pJSObject->ToV8Object(),
- pData->data.sKey.UTF8Decode().c_str(),
- pData->data.dData);
+ pData->data.sKey.UTF8Decode(), pData->data.dData);
break;
case JS_GLOBALDATA_TYPE_BOOLEAN:
SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0,
(bool)(pData->data.bData == 1), "",
v8::Local<v8::Object>(), pData->bPersistent == 1);
FXJS_PutObjectBoolean(NULL, m_pJSObject->ToV8Object(),
- pData->data.sKey.UTF8Decode().c_str(),
+ pData->data.sKey.UTF8Decode(),
(bool)(pData->data.bData == 1));
break;
case JS_GLOBALDATA_TYPE_STRING:
@@ -249,8 +248,8 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
false, pData->data.sData, v8::Local<v8::Object>(),
pData->bPersistent == 1);
FXJS_PutObjectString(NULL, m_pJSObject->ToV8Object(),
- pData->data.sKey.UTF8Decode().c_str(),
- pData->data.sData.UTF8Decode().c_str());
+ pData->data.sKey.UTF8Decode(),
+ pData->data.sData.UTF8Decode());
break;
case JS_GLOBALDATA_TYPE_OBJECT: {
v8::Isolate* pRuntime = m_pJSObject->ToV8Object()->GetIsolate();
@@ -261,14 +260,14 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_OBJECT, 0,
false, "", pObj, pData->bPersistent == 1);
FXJS_PutObjectObject(NULL, m_pJSObject->ToV8Object(),
- pData->data.sKey.UTF8Decode().c_str(), pObj);
+ pData->data.sKey.UTF8Decode(), pObj);
} break;
case JS_GLOBALDATA_TYPE_NULL:
SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false,
"", v8::Local<v8::Object>(),
pData->bPersistent == 1);
FXJS_PutObjectNull(NULL, m_pJSObject->ToV8Object(),
- pData->data.sKey.UTF8Decode().c_str());
+ pData->data.sKey.UTF8Decode());
break;
}
}
@@ -324,7 +323,7 @@ void JSGlobalAlternate::ObjectToArray(IJS_Context* cc,
FXJS_ToString(isolate, FXJS_GetArrayElement(isolate, pKeyList, i));
CFX_ByteString sKey = ws.UTF8Encode();
- v8::Local<v8::Value> v = FXJS_GetObjectElement(isolate, pObj, ws.c_str());
+ v8::Local<v8::Value> v = FXJS_GetObjectElement(isolate, pObj, ws);
switch (GET_VALUE_TYPE(v)) {
case CJS_Value::VT_number: {
CJS_KeyValue* pObjElement = new CJS_KeyValue;
@@ -374,27 +373,26 @@ void JSGlobalAlternate::PutObjectProperty(v8::Local<v8::Object> pObj,
CJS_KeyValue* pObjData = pData->objData.GetAt(i);
switch (pObjData->nType) {
case JS_GLOBALDATA_TYPE_NUMBER:
- FXJS_PutObjectNumber(NULL, pObj, pObjData->sKey.UTF8Decode().c_str(),
+ FXJS_PutObjectNumber(NULL, pObj, pObjData->sKey.UTF8Decode(),
pObjData->dData);
break;
case JS_GLOBALDATA_TYPE_BOOLEAN:
- FXJS_PutObjectBoolean(NULL, pObj, pObjData->sKey.UTF8Decode().c_str(),
+ FXJS_PutObjectBoolean(NULL, pObj, pObjData->sKey.UTF8Decode(),
pObjData->bData == 1);
break;
case JS_GLOBALDATA_TYPE_STRING:
- FXJS_PutObjectString(NULL, pObj, pObjData->sKey.UTF8Decode().c_str(),
- pObjData->sData.UTF8Decode().c_str());
+ FXJS_PutObjectString(NULL, pObj, pObjData->sKey.UTF8Decode(),
+ pObjData->sData.UTF8Decode());
break;
case JS_GLOBALDATA_TYPE_OBJECT: {
v8::Isolate* pRuntime = m_pJSObject->ToV8Object()->GetIsolate();
v8::Local<v8::Object> pNewObj =
FXJS_NewFxDynamicObj(pRuntime, NULL, -1);
PutObjectProperty(pNewObj, pObjData);
- FXJS_PutObjectObject(NULL, pObj, pObjData->sKey.UTF8Decode().c_str(),
- pNewObj);
+ FXJS_PutObjectObject(NULL, pObj, pObjData->sKey.UTF8Decode(), pNewObj);
} break;
case JS_GLOBALDATA_TYPE_NULL:
- FXJS_PutObjectNull(NULL, pObj, pObjData->sKey.UTF8Decode().c_str());
+ FXJS_PutObjectNull(NULL, pObj, pObjData->sKey.UTF8Decode());
break;
}
}
@@ -407,14 +405,14 @@ void JSGlobalAlternate::DestroyGlobalPersisitentVariables() {
m_mapGlobal.clear();
}
-FX_BOOL JSGlobalAlternate::SetGlobalVariables(const FX_CHAR* propname,
+FX_BOOL JSGlobalAlternate::SetGlobalVariables(const CFX_ByteString& propname,
int nType,
double dData,
bool bData,
const CFX_ByteString& sData,
v8::Local<v8::Object> pData,
bool bDefaultPersistent) {
- if (!propname)
+ if (propname.IsEmpty())
return FALSE;
auto it = m_mapGlobal.find(propname);
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/global.h b/chromium/third_party/pdfium/fpdfsdk/javascript/global.h
index 335b5402716..02c51d98a93 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/global.h
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/global.h
@@ -59,7 +59,7 @@ class JSGlobalAlternate : public CJS_EmbedObj {
void UpdateGlobalPersistentVariables();
void CommitGlobalPersisitentVariables(IJS_Context* cc);
void DestroyGlobalPersisitentVariables();
- FX_BOOL SetGlobalVariables(const FX_CHAR* propname,
+ FX_BOOL SetGlobalVariables(const CFX_ByteString& propname,
int nType,
double dData,
bool bData,
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/public_methods_embeddertest.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/public_methods_embeddertest.cpp
index 153b3cd64ff..1fc967b8908 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/public_methods_embeddertest.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/public_methods_embeddertest.cpp
@@ -113,56 +113,56 @@ TEST_F(PublicMethodsEmbedderTest, MakeFormatDate) {
// 1968-06-25
formatted_date = CJS_PublicMethods::MakeFormatDate(-47952000000, L"ddmmyy");
- EXPECT_STREQ(L"250668", formatted_date);
+ EXPECT_STREQ(L"250668", formatted_date.c_str());
formatted_date = CJS_PublicMethods::MakeFormatDate(-47952000000, L"yy/mm/dd");
- EXPECT_STREQ(L"68/06/25", formatted_date);
+ EXPECT_STREQ(L"68/06/25", formatted_date.c_str());
// 1969-12-31
formatted_date = CJS_PublicMethods::MakeFormatDate(-0.0001, L"ddmmyy");
- EXPECT_STREQ(L"311269", formatted_date);
+ EXPECT_STREQ(L"311269", formatted_date.c_str());
formatted_date = CJS_PublicMethods::MakeFormatDate(-0.0001, L"yy!mmdd");
- EXPECT_STREQ(L"69!1231", formatted_date);
+ EXPECT_STREQ(L"69!1231", formatted_date.c_str());
// 1970-01-01
formatted_date = CJS_PublicMethods::MakeFormatDate(0, L"ddmmyy");
- EXPECT_STREQ(L"010170", formatted_date);
+ EXPECT_STREQ(L"010170", formatted_date.c_str());
formatted_date = CJS_PublicMethods::MakeFormatDate(0, L"mm-yyyy-dd");
- EXPECT_STREQ(L"01-1970-01", formatted_date);
+ EXPECT_STREQ(L"01-1970-01", formatted_date.c_str());
// 1985-12-31
formatted_date = CJS_PublicMethods::MakeFormatDate(504835200000.0, L"ddmmyy");
- EXPECT_STREQ(L"311285", formatted_date);
+ EXPECT_STREQ(L"311285", formatted_date.c_str());
formatted_date = CJS_PublicMethods::MakeFormatDate(504835200000.0, L"yymmdd");
- EXPECT_STREQ(L"851231", formatted_date);
+ EXPECT_STREQ(L"851231", formatted_date.c_str());
// 1995-02-01
formatted_date = CJS_PublicMethods::MakeFormatDate(791596800000.0, L"ddmmyy");
- EXPECT_STREQ(L"010295", formatted_date);
+ EXPECT_STREQ(L"010295", formatted_date.c_str());
formatted_date =
CJS_PublicMethods::MakeFormatDate(791596800000.0, L"yyyymmdd");
- EXPECT_STREQ(L"19950201", formatted_date);
+ EXPECT_STREQ(L"19950201", formatted_date.c_str());
// 2005-02-01
formatted_date =
CJS_PublicMethods::MakeFormatDate(1107216000000.0, L"ddmmyy");
- EXPECT_STREQ(L"010205", formatted_date);
+ EXPECT_STREQ(L"010205", formatted_date.c_str());
formatted_date =
CJS_PublicMethods::MakeFormatDate(1107216000000.0, L"yyyyddmm");
- EXPECT_STREQ(L"20050102", formatted_date);
+ EXPECT_STREQ(L"20050102", formatted_date.c_str());
// 2085-12-31
formatted_date =
CJS_PublicMethods::MakeFormatDate(3660595200000.0, L"ddmmyy");
- EXPECT_STREQ(L"311285", formatted_date);
+ EXPECT_STREQ(L"311285", formatted_date.c_str());
formatted_date =
CJS_PublicMethods::MakeFormatDate(3660595200000.0, L"yyyydd");
- EXPECT_STREQ(L"208531", formatted_date);
+ EXPECT_STREQ(L"208531", formatted_date.c_str());
// 2095-02-01
formatted_date =
CJS_PublicMethods::MakeFormatDate(3947356800000.0, L"ddmmyy");
- EXPECT_STREQ(L"010295", formatted_date);
+ EXPECT_STREQ(L"010295", formatted_date.c_str());
formatted_date =
CJS_PublicMethods::MakeFormatDate(3947356800000.0, L"mmddyyyy");
- EXPECT_STREQ(L"02012095", formatted_date);
+ EXPECT_STREQ(L"02012095", formatted_date.c_str());
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/javascript/util.cpp b/chromium/third_party/pdfium/fpdfsdk/javascript/util.cpp
index adaa9c794b6..4f2d834208f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/javascript/util.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/javascript/util.cpp
@@ -312,7 +312,8 @@ FX_BOOL util::printx(IJS_Context* cc,
sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
return FALSE;
}
- vRet = printx(params[0].ToCFXWideString(), params[1].ToCFXWideString());
+ vRet =
+ printx(params[0].ToCFXWideString(), params[1].ToCFXWideString()).c_str();
return TRUE;
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/jsapi/fxjs_v8.cpp b/chromium/third_party/pdfium/fpdfsdk/jsapi/fxjs_v8.cpp
index 034f2c66423..a471d5613d4 100644
--- a/chromium/third_party/pdfium/fpdfsdk/jsapi/fxjs_v8.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/jsapi/fxjs_v8.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/include/jsapi/fxjs_v8.h"
+#include "fpdfsdk/jsapi/include/fxjs_v8.h"
#include <vector>
@@ -583,25 +583,24 @@ void FXJS_FreePrivate(v8::Local<v8::Object> pObj) {
}
v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
- const wchar_t* PropertyName,
- int Len) {
- CFX_WideString ws = CFX_WideString(PropertyName, Len);
- CFX_ByteString bs = ws.UTF8Encode();
+ const CFX_WideString& wsPropertyName) {
+ CFX_ByteString bs = wsPropertyName.UTF8Encode();
if (!pIsolate)
pIsolate = v8::Isolate::GetCurrent();
return v8::String::NewFromUtf8(pIsolate, bs.c_str(),
- v8::NewStringType::kNormal)
+ v8::NewStringType::kNormal, bs.GetLength())
.ToLocalChecked();
}
-v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName) {
+v8::Local<v8::Value> FXJS_GetObjectElement(
+ v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const CFX_WideString& wsPropertyName) {
if (pObj.IsEmpty())
return v8::Local<v8::Value>();
v8::Local<v8::Value> val;
if (!pObj->Get(pIsolate->GetCurrentContext(),
- FXJS_WSToJSString(pIsolate, PropertyName))
+ FXJS_WSToJSString(pIsolate, wsPropertyName))
.ToLocal(&val))
return v8::Local<v8::Value>();
return val;
@@ -619,82 +618,83 @@ v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate,
void FXJS_PutObjectString(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
- const wchar_t* sValue) {
+ const CFX_WideString& wsPropertyName,
+ const CFX_WideString& wsValue) {
if (pObj.IsEmpty())
return;
pObj->Set(pIsolate->GetCurrentContext(),
- FXJS_WSToJSString(pIsolate, PropertyName),
- FXJS_WSToJSString(pIsolate, sValue))
+ FXJS_WSToJSString(pIsolate, wsPropertyName),
+ FXJS_WSToJSString(pIsolate, wsValue))
.FromJust();
}
void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& wsPropertyName,
int nValue) {
if (pObj.IsEmpty())
return;
pObj->Set(pIsolate->GetCurrentContext(),
- FXJS_WSToJSString(pIsolate, PropertyName),
+ FXJS_WSToJSString(pIsolate, wsPropertyName),
v8::Int32::New(pIsolate, nValue))
.FromJust();
}
void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& wsPropertyName,
float fValue) {
if (pObj.IsEmpty())
return;
pObj->Set(pIsolate->GetCurrentContext(),
- FXJS_WSToJSString(pIsolate, PropertyName),
+ FXJS_WSToJSString(pIsolate, wsPropertyName),
v8::Number::New(pIsolate, (double)fValue))
.FromJust();
}
void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& wsPropertyName,
double dValue) {
if (pObj.IsEmpty())
return;
pObj->Set(pIsolate->GetCurrentContext(),
- FXJS_WSToJSString(pIsolate, PropertyName),
+ FXJS_WSToJSString(pIsolate, wsPropertyName),
v8::Number::New(pIsolate, (double)dValue))
.FromJust();
}
void FXJS_PutObjectBoolean(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& wsPropertyName,
bool bValue) {
if (pObj.IsEmpty())
return;
pObj->Set(pIsolate->GetCurrentContext(),
- FXJS_WSToJSString(pIsolate, PropertyName),
+ FXJS_WSToJSString(pIsolate, wsPropertyName),
v8::Boolean::New(pIsolate, bValue))
.FromJust();
}
void FXJS_PutObjectObject(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& wsPropertyName,
v8::Local<v8::Object> pPut) {
if (pObj.IsEmpty())
return;
pObj->Set(pIsolate->GetCurrentContext(),
- FXJS_WSToJSString(pIsolate, PropertyName), pPut)
+ FXJS_WSToJSString(pIsolate, wsPropertyName), pPut)
.FromJust();
}
void FXJS_PutObjectNull(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName) {
+ const CFX_WideString& wsPropertyName) {
if (pObj.IsEmpty())
return;
pObj->Set(pIsolate->GetCurrentContext(),
- FXJS_WSToJSString(pIsolate, PropertyName), v8::Local<v8::Object>())
+ FXJS_WSToJSString(pIsolate, wsPropertyName),
+ v8::Local<v8::Object>())
.FromJust();
}
@@ -807,7 +807,7 @@ CFX_WideString FXJS_ToString(v8::Isolate* pIsolate,
return L"";
v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
v8::String::Utf8Value s(pValue->ToString(context).ToLocalChecked());
- return CFX_WideString::FromUTF8(*s, s.length());
+ return CFX_WideString::FromUTF8(CFX_ByteStringC(*s, s.length()));
}
v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate,
diff --git a/chromium/third_party/pdfium/fpdfsdk/include/jsapi/fxjs_v8.h b/chromium/third_party/pdfium/fpdfsdk/jsapi/include/fxjs_v8.h
index 00107ef7e56..235f3bc902b 100644
--- a/chromium/third_party/pdfium/fpdfsdk/include/jsapi/fxjs_v8.h
+++ b/chromium/third_party/pdfium/fpdfsdk/jsapi/include/fxjs_v8.h
@@ -11,8 +11,8 @@
// PDFium code should include this file rather than including V8 headers
// directly.
-#ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
-#define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
+#ifndef FPDFSDK_JSAPI_INCLUDE_FXJS_V8_H_
+#define FPDFSDK_JSAPI_INCLUDE_FXJS_V8_H_
#include <v8-util.h>
#include <v8.h>
@@ -114,7 +114,7 @@ class FXJS_PerIsolateData {
protected:
#ifndef PDF_ENABLE_XFA
FXJS_PerIsolateData() : m_pDynamicObjsMap(nullptr) {}
-#else // PDF_ENABLE_XFA
+#else // PDF_ENABLE_XFA
FXJS_PerIsolateData()
: m_pFXJSERuntimeData(nullptr), m_pDynamicObjsMap(nullptr) {}
#endif // PDF_ENABLE_XFA
@@ -229,50 +229,47 @@ void FXJS_SetPrivate(v8::Isolate* pIsolate,
void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj);
void FXJS_FreePrivate(void* p);
void FXJS_FreePrivate(v8::Local<v8::Object> pObj);
-
void FXJS_Error(v8::Isolate* isolate, const CFX_WideString& message);
-v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
- const wchar_t* PropertyName,
- int Len = -1);
+v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
+ const CFX_WideString& wsPropertyName);
v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName);
+ const CFX_WideString& PropertyName);
v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj);
-
v8::Local<v8::Value> FXJS_GetArrayElement(v8::Isolate* pIsolate,
v8::Local<v8::Array> pArray,
unsigned index);
-unsigned FXJS_GetArrayLength(v8::Local<v8::Array> pArray);
+unsigned FXJS_GetArrayLength(v8::Local<v8::Array> pArray);
void FXJS_PutObjectString(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
- const wchar_t* sValue);
+ const CFX_WideString& wsPropertyName,
+ const CFX_WideString& wsValue);
void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& PropertyName,
int nValue);
void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& PropertyName,
float fValue);
void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& PropertyName,
double dValue);
void FXJS_PutObjectBoolean(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& PropertyName,
bool bValue);
void FXJS_PutObjectObject(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName,
+ const CFX_WideString& PropertyName,
v8::Local<v8::Object> pPut);
void FXJS_PutObjectNull(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
- const wchar_t* PropertyName);
+ const CFX_WideString& PropertyName);
unsigned FXJS_PutArrayElement(v8::Isolate* pIsolate,
v8::Local<v8::Array> pArray,
unsigned index,
@@ -302,4 +299,4 @@ v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate,
v8::Local<v8::Value> pValue);
void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom);
-#endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
+#endif // FPDFSDK_JSAPI_INCLUDE_FXJS_V8_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Caret.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Caret.cpp
index aa6f0182e26..a5728ceac87 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Caret.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Caret.cpp
@@ -6,7 +6,7 @@
#include "fpdfsdk/pdfwindow/PWL_Caret.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "fpdfsdk/pdfwindow/PWL_Utils.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
@@ -95,7 +95,7 @@ CFX_ByteString CPWL_Caret::GetCaretAppearanceStream(
const CFX_FloatPoint& ptOffset) {
CFX_ByteTextBuf sCaret;
GetCaretApp(sCaret, ptOffset);
- return sCaret.GetByteString();
+ return sCaret.MakeString();
}
void CPWL_Caret::TimerProc() {
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ComboBox.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
index c07233f499e..f49016123a3 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ComboBox.cpp
@@ -6,7 +6,7 @@
#include "fpdfsdk/pdfwindow/PWL_ComboBox.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "fpdfsdk/pdfwindow/PWL_Edit.h"
#include "fpdfsdk/pdfwindow/PWL_EditCtrl.h"
#include "fpdfsdk/pdfwindow/PWL_ListBox.h"
@@ -303,7 +303,7 @@ void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) {
ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
ecp.dwBorderWidth = 0;
- ecp.nBorderStyle = PBS_SOLID;
+ ecp.nBorderStyle = BorderStyle::SOLID;
m_pEdit->Create(ecp);
}
@@ -319,7 +319,7 @@ void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM& cp) {
bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR;
bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
bcp.dwBorderWidth = 2;
- bcp.nBorderStyle = PBS_BEVELED;
+ bcp.nBorderStyle = BorderStyle::BEVELED;
bcp.eCursorType = FXCT_ARROW;
m_pButton->Create(bcp);
@@ -334,7 +334,7 @@ void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM& cp) {
lcp.pParentWnd = this;
lcp.dwFlags =
PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL;
- lcp.nBorderStyle = PBS_SOLID;
+ lcp.nBorderStyle = BorderStyle::SOLID;
lcp.dwBorderWidth = 1;
lcp.eCursorType = FXCT_ARROW;
lcp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.cpp
index b5e2093483b..e39b6c13c70 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.cpp
@@ -12,7 +12,7 @@
#include "core/fpdfdoc/include/cpvt_word.h"
#include "core/fxcrt/include/fx_safe_types.h"
#include "core/fxcrt/include/fx_xml.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "fpdfsdk/pdfwindow/PWL_Caret.h"
#include "fpdfsdk/pdfwindow/PWL_EditCtrl.h"
#include "fpdfsdk/pdfwindow/PWL_FontMap.h"
@@ -23,9 +23,7 @@
#include "third_party/base/stl_util.h"
CPWL_Edit::CPWL_Edit()
- : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) {
- m_pFormFiller = NULL;
-}
+ : m_pFillerNotify(nullptr), m_bFocus(FALSE), m_pFormFiller(nullptr) {}
CPWL_Edit::~CPWL_Edit() {
ASSERT(m_bFocus == FALSE);
@@ -48,7 +46,7 @@ void CPWL_Edit::SetText(const FX_WCHAR* csText) {
int32_t nCount = pXML->CountChildren();
FX_BOOL bFirst = TRUE;
- swText.Empty();
+ swText.clear();
for (int32_t i = 0; i < nCount; i++) {
if (CXML_Element* pSubElement = pXML->GetElement(i)) {
@@ -131,67 +129,9 @@ FX_BOOL CPWL_Edit::CanCopy() const {
FX_BOOL CPWL_Edit::CanCut() const {
return CanCopy() && !IsReadOnly();
}
-
-FX_BOOL CPWL_Edit::CanPaste() const {
- if (IsReadOnly())
- return FALSE;
-
- CFX_WideString swClipboard;
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
-
- return !swClipboard.IsEmpty();
-}
-
-void CPWL_Edit::CopyText() {
- if (!CanCopy())
- return;
-
- CFX_WideString str = m_pEdit->GetSelText();
-
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->SetClipboardText(GetAttachedHWnd(), str);
-}
-
-void CPWL_Edit::PasteText() {
- if (!CanPaste())
- return;
-
- CFX_WideString swClipboard;
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
-
- if (m_pFillerNotify) {
- FX_BOOL bRC = TRUE;
- FX_BOOL bExit = FALSE;
- CFX_WideString strChangeEx;
- int nSelStart = 0;
- int nSelEnd = 0;
- GetSel(nSelStart, nSelEnd);
- m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swClipboard,
- strChangeEx, nSelStart, nSelEnd, TRUE,
- bRC, bExit, 0);
- if (!bRC)
- return;
- if (bExit)
- return;
- }
-
- if (swClipboard.GetLength() > 0) {
- Clear();
- InsertText(swClipboard.c_str());
- }
-}
-
void CPWL_Edit::CutText() {
if (!CanCut())
return;
-
- CFX_WideString str = m_pEdit->GetSelText();
-
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->SetClipboardText(GetAttachedHWnd(), str);
-
m_pEdit->Clear();
}
@@ -247,10 +187,6 @@ void CPWL_Edit::SetParamByFlag() {
GetClientRect(), 1.0f)); // +1 for caret beside border
}
}
-
- if (HasFlag(PES_SPELLCHECK)) {
- m_pSpellCheck = GetCreationParam().pSpellCheck;
- }
}
void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
@@ -263,10 +199,10 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (nCharArray > 0) {
switch (GetBorderStyle()) {
- case PBS_SOLID: {
+ case BorderStyle::SOLID: {
sLine << "q\n" << GetBorderWidth() << " w\n"
<< CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE)
- .AsByteStringC()
+ .AsStringC()
<< " 2 J 0 j\n";
for (int32_t i = 1; i < nCharArray; i++) {
@@ -279,11 +215,12 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
}
sLine << "Q\n";
- } break;
- case PBS_DASH: {
+ break;
+ }
+ case BorderStyle::DASH: {
sLine << "q\n" << GetBorderWidth() << " w\n"
<< CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE)
- .AsByteStringC()
+ .AsStringC()
<< " 2 J 0 j\n"
<< "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap
<< "] " << GetBorderDash().nPhase << " d\n";
@@ -298,7 +235,10 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
}
sLine << "Q\n";
- } break;
+ break;
+ }
+ default:
+ break;
}
}
@@ -321,9 +261,8 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp);
if (sEditSel.GetLength() > 0)
- sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR)
- .AsByteStringC()
- << sEditSel.AsByteStringC();
+ sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR).AsStringC()
+ << sEditSel.AsStringC();
wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore);
CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream(
@@ -331,9 +270,8 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
m_pEdit->GetPasswordChar());
if (sEditBefore.GetLength() > 0)
- sText << "BT\n"
- << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC()
- << sEditBefore.AsByteStringC() << "ET\n";
+ sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
+ << sEditBefore.AsStringC() << "ET\n";
wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect);
CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream(
@@ -343,8 +281,8 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (sEditMid.GetLength() > 0)
sText << "BT\n"
<< CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1))
- .AsByteStringC()
- << sEditMid.AsByteStringC() << "ET\n";
+ .AsStringC()
+ << sEditMid.AsStringC() << "ET\n";
wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter);
CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream(
@@ -352,19 +290,8 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
m_pEdit->GetPasswordChar());
if (sEditAfter.GetLength() > 0)
- sText << "BT\n"
- << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC()
- << sEditAfter.AsByteStringC() << "ET\n";
-
- if (HasFlag(PES_SPELLCHECK)) {
- CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream(
- m_pEdit, m_pSpellCheck, ptOffset, &wrVisible);
- if (sSpellCheck.GetLength() > 0)
- sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0),
- FALSE)
- .AsByteStringC()
- << sSpellCheck.AsByteStringC();
- }
+ sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
+ << sEditAfter.AsStringC() << "ET\n";
if (sText.GetLength() > 0) {
CFX_FloatRect rcClient = GetClientRect();
@@ -395,7 +322,7 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
if (nCharArray > 0 && nCharArraySafe.IsValid()) {
switch (GetBorderStyle()) {
- case PBS_SOLID: {
+ case BorderStyle::SOLID: {
CFX_GraphStateData gsd;
gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
@@ -414,13 +341,15 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
rcClient.top, FXPT_LINETO);
}
- if (path.GetPointCount() > 0)
+ if (path.GetPointCount() > 0) {
pDevice->DrawPath(
&path, pUser2Device, &gsd, 0,
CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255),
FXFILL_ALTERNATE);
- } break;
- case PBS_DASH: {
+ }
+ break;
+ }
+ case BorderStyle::DASH: {
CFX_GraphStateData gsd;
gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
@@ -444,12 +373,16 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
rcClient.top, FXPT_LINETO);
}
- if (path.GetPointCount() > 0)
+ if (path.GetPointCount() > 0) {
pDevice->DrawPath(
&path, pUser2Device, &gsd, 0,
CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255),
FXFILL_ALTERNATE);
- } break;
+ }
+ break;
+ }
+ default:
+ break;
}
}
@@ -461,18 +394,12 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
rcClip = GetClientRect();
pRange = &wrRange;
}
- IFX_SystemHandler* pSysHandler = GetSystemHandler();
+ CFX_SystemHandler* pSysHandler = GetSystemHandler();
IFX_Edit::DrawEdit(
pDevice, pUser2Device, m_pEdit,
CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()),
rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller);
-
- if (HasFlag(PES_SPELLCHECK)) {
- CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip,
- CFX_FloatPoint(0.0f, 0.0f), pRange,
- GetCreationParam().pSpellCheck);
- }
}
FX_BOOL CPWL_Edit::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) {
@@ -502,15 +429,6 @@ FX_BOOL CPWL_Edit::OnLButtonDblClk(const CFX_FloatPoint& point,
return TRUE;
}
-#define WM_PWLEDIT_UNDO 0x01
-#define WM_PWLEDIT_REDO 0x02
-#define WM_PWLEDIT_CUT 0x03
-#define WM_PWLEDIT_COPY 0x04
-#define WM_PWLEDIT_PASTE 0x05
-#define WM_PWLEDIT_DELETE 0x06
-#define WM_PWLEDIT_SELECTALL 0x07
-#define WM_PWLEDIT_SUGGEST 0x08
-
FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) {
if (m_bMouseDown)
return FALSE;
@@ -520,166 +438,13 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) {
if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point))
return TRUE;
- IFX_SystemHandler* pSH = GetSystemHandler();
+ CFX_SystemHandler* pSH = GetSystemHandler();
if (!pSH)
return FALSE;
SetFocus();
- CPVT_WordRange wrLatin = GetLatinWordsRange(point);
- CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);
-
- FX_HMENU hPopup = pSH->CreatePopupMenu();
- if (!hPopup)
- return FALSE;
-
- std::vector<CFX_ByteString> sSuggestWords;
- CFX_FloatPoint ptPopup = point;
-
- if (!IsReadOnly()) {
- if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) {
- if (m_pSpellCheck) {
- CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin);
- if (!m_pSpellCheck->CheckWord(sLatin)) {
- m_pSpellCheck->SuggestWords(sLatin, sSuggestWords);
-
- int32_t nSuggest = pdfium::CollectionSize<int32_t>(sSuggestWords);
- for (int32_t nWord = 0; nWord < nSuggest; nWord++) {
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord,
- sSuggestWords[nWord].UTF8Decode());
- }
- if (nSuggest > 0)
- pSH->AppendMenuItem(hPopup, 0, L"");
-
- ptPopup = GetWordRightBottomPoint(wrLatin.EndPos);
- }
- }
- }
- }
-
- IPWL_Provider* pProvider = GetProvider();
-
- if (HasFlag(PES_UNDO)) {
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_UNDO,
- pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo");
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_REDO,
- pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo");
- pSH->AppendMenuItem(hPopup, 0, L"");
-
- if (!m_pEdit->CanUndo())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE);
- if (!m_pEdit->CanRedo())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE);
- }
-
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT,
- pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t");
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY,
- pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy");
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_PASTE,
- pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste");
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_DELETE,
- pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete");
-
- CFX_WideString swText = pSH->GetClipboardText(GetAttachedHWnd());
- if (swText.IsEmpty())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
-
- if (!m_pEdit->IsSelected()) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
- }
-
- if (IsReadOnly()) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
- }
-
- if (HasFlag(PES_PASSWORD)) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- }
-
- if (HasFlag(PES_NOREAD)) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- }
-
- pSH->AppendMenuItem(hPopup, 0, L"");
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_SELECTALL,
- pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All");
-
- if (m_pEdit->GetTotalWords() == 0) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE);
- }
-
- int32_t x, y;
- PWLtoWnd(ptPopup, x, y);
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- pSH->SetCursor(FXCT_ARROW);
- int32_t nCmd = pSH->TrackPopupMenu(hPopup, x, y, GetAttachedHWnd());
-
- switch (nCmd) {
- case WM_PWLEDIT_UNDO:
- Undo();
- break;
- case WM_PWLEDIT_REDO:
- Redo();
- break;
- case WM_PWLEDIT_CUT:
- CutText();
- break;
- case WM_PWLEDIT_COPY:
- CopyText();
- break;
- case WM_PWLEDIT_PASTE:
- PasteText();
- break;
- case WM_PWLEDIT_DELETE:
- Clear();
- break;
- case WM_PWLEDIT_SELECTALL:
- SelectAll();
- break;
- case WM_PWLEDIT_SUGGEST + 0:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[0].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 1:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[1].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 2:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[2].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 3:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[3].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 4:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[4].UTF8Decode().c_str());
- break;
- default:
- break;
- }
-
- pSH->DestroyMenu(hPopup);
-
- return TRUE;
+ return FALSE;
}
void CPWL_Edit::OnSetFocus() {
@@ -748,14 +513,11 @@ CFX_ByteString CPWL_Edit::GetTextAppearanceStream(
const CFX_FloatPoint& ptOffset) const {
CFX_ByteTextBuf sRet;
CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset);
-
if (sEdit.GetLength() > 0) {
- sRet << "BT\n"
- << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC()
- << sEdit.AsByteStringC() << "ET\n";
+ sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
+ << sEdit.AsStringC() << "ET\n";
}
-
- return sRet.GetByteString();
+ return sRet.MakeString();
}
CFX_ByteString CPWL_Edit::GetCaretAppearanceStream(
@@ -770,18 +532,17 @@ CFX_FloatPoint CPWL_Edit::GetWordRightBottomPoint(
const CPVT_WordPlace& wpWord) {
CFX_FloatPoint pt(0.0f, 0.0f);
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- CPVT_WordPlace wpOld = pIterator->GetAt();
- pIterator->SetAt(wpWord);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- pt = CFX_FloatPoint(word.ptWord.x + word.fWidth,
- word.ptWord.y + word.fDescent);
- }
-
- pIterator->SetAt(wpOld);
+ IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
+ CPVT_WordPlace wpOld = pIterator->GetAt();
+ pIterator->SetAt(wpWord);
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ pt = CFX_FloatPoint(word.ptWord.x + word.fWidth,
+ word.ptWord.y + word.fDescent);
}
+ pIterator->SetAt(wpOld);
+
return pt;
}
@@ -864,13 +625,6 @@ FX_BOOL CPWL_Edit::IsVScrollBarVisible() const {
return FALSE;
}
-void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled) {
- if (bEnabled)
- AddFlag(PES_SPELLCHECK);
- else
- RemoveFlag(PES_SPELLCHECK);
-}
-
FX_BOOL CPWL_Edit::OnKeyDown(uint16_t nChar, uint32_t nFlag) {
if (m_bMouseDown)
return TRUE;
@@ -1132,52 +886,50 @@ CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace& place,
FX_BOOL bArabic) const {
CPVT_WordRange range;
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- CPVT_Word wordinfo;
- CPVT_WordPlace wpStart(place), wpEnd(place);
- pIterator->SetAt(place);
-
- if (bLatin) {
- while (pIterator->NextWord()) {
- if (!pIterator->GetWord(wordinfo) ||
- !FX_EDIT_ISLATINWORD(wordinfo.Word)) {
- break;
- }
+ IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
+ CPVT_Word wordinfo;
+ CPVT_WordPlace wpStart(place), wpEnd(place);
+ pIterator->SetAt(place);
- wpEnd = pIterator->GetAt();
+ if (bLatin) {
+ while (pIterator->NextWord()) {
+ if (!pIterator->GetWord(wordinfo) ||
+ !FX_EDIT_ISLATINWORD(wordinfo.Word)) {
+ break;
}
- } else if (bArabic) {
- while (pIterator->NextWord()) {
- if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word))
- break;
- wpEnd = pIterator->GetAt();
- }
+ wpEnd = pIterator->GetAt();
}
+ } else if (bArabic) {
+ while (pIterator->NextWord()) {
+ if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word))
+ break;
- pIterator->SetAt(place);
+ wpEnd = pIterator->GetAt();
+ }
+ }
- if (bLatin) {
- do {
- if (!pIterator->GetWord(wordinfo) ||
- !FX_EDIT_ISLATINWORD(wordinfo.Word)) {
- break;
- }
+ pIterator->SetAt(place);
- wpStart = pIterator->GetAt();
- } while (pIterator->PrevWord());
- } else if (bArabic) {
- do {
- if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word))
- break;
+ if (bLatin) {
+ do {
+ if (!pIterator->GetWord(wordinfo) ||
+ !FX_EDIT_ISLATINWORD(wordinfo.Word)) {
+ break;
+ }
- wpStart = pIterator->GetAt();
- } while (pIterator->PrevWord());
- }
+ wpStart = pIterator->GetAt();
+ } while (pIterator->PrevWord());
+ } else if (bArabic) {
+ do {
+ if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word))
+ break;
- range.Set(wpStart, wpEnd);
+ wpStart = pIterator->GetAt();
+ } while (pIterator->PrevWord());
}
+ range.Set(wpStart, wpEnd);
return range;
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.h b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.h
index 58793e33959..8a9d371b285 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.h
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Edit.h
@@ -8,12 +8,10 @@
#define FPDFSDK_PDFWINDOW_PWL_EDIT_H_
#include "core/fxcrt/include/fx_basic.h"
-#include "fpdfsdk/include/fxedit/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
#include "fpdfsdk/pdfwindow/PWL_EditCtrl.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
-class IPWL_SpellCheck;
-
class IPWL_Filler_Notify {
public:
virtual ~IPWL_Filler_Notify() {}
@@ -81,19 +79,14 @@ class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify {
void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE);
- void EnableSpellCheck(FX_BOOL bEnabled);
-
FX_BOOL CanSelectAll() const;
FX_BOOL CanClear() const;
FX_BOOL CanCopy() const;
FX_BOOL CanCut() const;
- FX_BOOL CanPaste() const;
- virtual void CopyText();
- virtual void PasteText();
- virtual void CutText();
+ void CutText();
- virtual void SetText(const FX_WCHAR* csText);
+ void SetText(const FX_WCHAR* csText);
void ReplaceSel(const FX_WCHAR* csText);
CFX_ByteString GetTextAppearanceStream(const CFX_FloatPoint& ptOffset) const;
@@ -117,6 +110,9 @@ class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify {
void GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder,
const CFX_FloatPoint& ptOffset);
+ FX_BOOL IsProceedtoOnChar(uint16_t nKeyCode, uint32_t nFlag);
+ void AttachFFLData(void* pData) { m_pFormFiller = pData; }
+
protected:
// IFX_Edit_OprNotify
void OnInsertWord(const CPVT_WordPlace& place,
@@ -152,20 +148,9 @@ class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify {
CPVT_WordRange GetSameWordsRange(const CPVT_WordPlace& place,
FX_BOOL bLatin,
FX_BOOL bArabic) const;
-
- public:
- FX_BOOL IsProceedtoOnChar(uint16_t nKeyCode, uint32_t nFlag);
-
- private:
IPWL_Filler_Notify* m_pFillerNotify;
- IPWL_SpellCheck* m_pSpellCheck;
FX_BOOL m_bFocus;
CFX_FloatRect m_rcOldWindow;
-
- public:
- void AttachFFLData(void* pData) { m_pFormFiller = pData; }
-
- private:
void* m_pFormFiller;
};
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
index af7e5837a3e..aa653929bd4 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp
@@ -21,15 +21,12 @@
#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
CPWL_EditCtrl::CPWL_EditCtrl()
- : m_pEdit(NULL),
+ : m_pEdit(IFX_Edit::NewEdit()),
m_pEditCaret(NULL),
m_bMouseDown(FALSE),
m_pEditNotify(NULL),
m_nCharSet(DEFAULT_CHARSET),
- m_nCodePage(0) {
- m_pEdit = IFX_Edit::NewEdit();
- ASSERT(m_pEdit);
-}
+ m_nCodePage(0) {}
CPWL_EditCtrl::~CPWL_EditCtrl() {
IFX_Edit::DelEdit(m_pEdit);
@@ -60,7 +57,7 @@ FX_BOOL CPWL_EditCtrl::IsWndHorV() {
void CPWL_EditCtrl::SetCursor() {
if (IsValid()) {
- if (IFX_SystemHandler* pSH = GetSystemHandler()) {
+ if (CFX_SystemHandler* pSH = GetSystemHandler()) {
if (IsWndHorV())
pSH->SetCursor(FXCT_VBEAM);
else
@@ -121,19 +118,20 @@ void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) {
}
void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) {
- if (!m_pEditCaret) {
- m_pEditCaret = new CPWL_Caret;
- m_pEditCaret->SetInvalidRect(GetClientRect());
-
- PWL_CREATEPARAM ecp = cp;
- ecp.pParentWnd = this;
- ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
- ecp.dwBorderWidth = 0;
- ecp.nBorderStyle = PBS_SOLID;
- ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
-
- m_pEditCaret->Create(ecp);
- }
+ if (m_pEditCaret)
+ return;
+
+ m_pEditCaret = new CPWL_Caret;
+ m_pEditCaret->SetInvalidRect(GetClientRect());
+
+ PWL_CREATEPARAM ecp = cp;
+ ecp.pParentWnd = this;
+ ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
+ ecp.dwBorderWidth = 0;
+ ecp.nBorderStyle = BorderStyle::SOLID;
+ ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
+
+ m_pEditCaret->Create(ecp);
}
void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) {
@@ -175,10 +173,8 @@ FX_BOOL CPWL_EditCtrl::OnKeyDown(uint16_t nChar, uint32_t nFlag) {
break;
}
- if (nChar == FWL_VKEY_Delete) {
- if (m_pEdit->IsSelected())
- nChar = FWL_VKEY_Unknown;
- }
+ if (nChar == FWL_VKEY_Delete && m_pEdit->IsSelected())
+ nChar = FWL_VKEY_Unknown;
switch (nChar) {
case FWL_VKEY_Delete:
@@ -284,8 +280,6 @@ FX_BOOL CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) {
case FWL_VKEY_Unknown:
break;
default:
- if (IsINSERTpressed(nFlag))
- Delete();
InsertWord(word, GetCharSet());
break;
}
@@ -353,21 +347,20 @@ void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) {
void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead,
CFX_FloatPoint& ptFoot) const {
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word)) {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- } else if (pIterator->GetLine(line)) {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
+ IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
+ pIterator->SetAt(m_pEdit->GetCaret());
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word)) {
+ ptHead.x = word.ptWord.x + word.fWidth;
+ ptHead.y = word.ptWord.y + word.fAscent;
+ ptFoot.x = word.ptWord.x + word.fWidth;
+ ptFoot.y = word.ptWord.y + word.fDescent;
+ } else if (pIterator->GetLine(line)) {
+ ptHead.x = line.ptLine.x;
+ ptHead.y = line.ptLine.y + line.fLineAscent;
+ ptFoot.x = line.ptLine.x;
+ ptFoot.y = line.ptLine.y + line.fLineDescent;
}
}
@@ -412,59 +405,45 @@ void CPWL_EditCtrl::SelectAll() {
}
void CPWL_EditCtrl::Paint() {
- if (m_pEdit)
- m_pEdit->Paint();
+ m_pEdit->Paint();
}
void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) {
- if (m_pEdit)
- m_pEdit->EnableRefresh(bRefresh);
+ m_pEdit->EnableRefresh(bRefresh);
}
int32_t CPWL_EditCtrl::GetCaret() const {
- if (m_pEdit)
- return m_pEdit->GetCaret();
-
- return -1;
+ return m_pEdit->GetCaret();
}
void CPWL_EditCtrl::SetCaret(int32_t nPos) {
- if (m_pEdit)
- m_pEdit->SetCaret(nPos);
+ m_pEdit->SetCaret(nPos);
}
int32_t CPWL_EditCtrl::GetTotalWords() const {
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
-
- return 0;
+ return m_pEdit->GetTotalWords();
}
void CPWL_EditCtrl::SetScrollPos(const CFX_FloatPoint& point) {
- if (m_pEdit)
- m_pEdit->SetScrollPos(point);
+ m_pEdit->SetScrollPos(point);
}
CFX_FloatPoint CPWL_EditCtrl::GetScrollPos() const {
- if (m_pEdit)
- return m_pEdit->GetScrollPos();
-
- return CFX_FloatPoint(0.0f, 0.0f);
+ return m_pEdit->GetScrollPos();
}
CPDF_Font* CPWL_EditCtrl::GetCaretFont() const {
int32_t nFontIndex = 0;
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Section section;
- if (pIterator->GetWord(word)) {
- nFontIndex = word.nFontIndex;
- } else if (HasFlag(PES_RICH)) {
- if (pIterator->GetSection(section)) {
- nFontIndex = section.WordProps.nFontIndex;
- }
+ IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
+ pIterator->SetAt(m_pEdit->GetCaret());
+ CPVT_Word word;
+ CPVT_Section section;
+ if (pIterator->GetWord(word)) {
+ nFontIndex = word.nFontIndex;
+ } else if (HasFlag(PES_RICH)) {
+ if (pIterator->GetSection(section)) {
+ nFontIndex = section.WordProps.nFontIndex;
}
}
@@ -477,16 +456,15 @@ CPDF_Font* CPWL_EditCtrl::GetCaretFont() const {
FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const {
FX_FLOAT fFontSize = GetFontSize();
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Section section;
- if (pIterator->GetWord(word)) {
- fFontSize = word.fFontSize;
- } else if (HasFlag(PES_RICH)) {
- if (pIterator->GetSection(section)) {
- fFontSize = section.WordProps.fFontSize;
- }
+ IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator();
+ pIterator->SetAt(m_pEdit->GetCaret());
+ CPVT_Word word;
+ CPVT_Section section;
+ if (pIterator->GetWord(word)) {
+ fFontSize = word.fFontSize;
+ } else if (HasFlag(PES_RICH)) {
+ if (pIterator->GetSection(section)) {
+ fFontSize = section.WordProps.fFontSize;
}
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.h b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.h
index 6d35ce95377..a8de08aaa69 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.h
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_EditCtrl.h
@@ -8,7 +8,7 @@
#define FPDFSDK_PDFWINDOW_PWL_EDITCTRL_H_
#include "core/fxcrt/include/fx_string.h"
-#include "fpdfsdk/include/fxedit/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
class CPWL_Caret;
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.cpp
index 42beab7d21e..f73468bf2bb 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.cpp
@@ -34,7 +34,7 @@ const char* const g_sDEStandardFontName[] = {"Courier",
} // namespace
-CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler)
+CPWL_FontMap::CPWL_FontMap(CFX_SystemHandler* pSystemHandler)
: m_pPDFDoc(NULL), m_pSystemHandler(pSystemHandler) {
ASSERT(m_pSystemHandler);
}
@@ -46,14 +46,14 @@ CPWL_FontMap::~CPWL_FontMap() {
Empty();
}
-void CPWL_FontMap::SetSystemHandler(IFX_SystemHandler* pSystemHandler) {
+void CPWL_FontMap::SetSystemHandler(CFX_SystemHandler* pSystemHandler) {
m_pSystemHandler = pSystemHandler;
}
CPDF_Document* CPWL_FontMap::GetDocument() {
if (!m_pPDFDoc) {
if (CPDF_ModuleMgr::Get()) {
- m_pPDFDoc = new CPDF_Document;
+ m_pPDFDoc = new CPDF_Document(nullptr);
m_pPDFDoc->CreateNewDoc();
}
}
@@ -284,7 +284,7 @@ CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) {
if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName))
return sFontName;
- sFontName = m_pSystemHandler->GetNativeTrueTypeFont(nCharset);
+ sFontName = "";
}
return sFontName;
}
@@ -306,10 +306,10 @@ CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc,
CPDF_Font* pFont = NULL;
if (sFontName == "ZapfDingbats") {
- pFont = pDoc->AddStandardFont(sFontName, NULL);
+ pFont = pDoc->AddStandardFont(sFontName.c_str(), NULL);
} else {
CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI);
- pFont = pDoc->AddStandardFont(sFontName, &fe);
+ pFont = pDoc->AddStandardFont(sFontName.c_str(), &fe);
}
return pFont;
@@ -491,7 +491,7 @@ int32_t CPWL_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) {
return ANSI_CHARSET;
}
-CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler,
+CPWL_DocFontMap::CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler,
CPDF_Document* pAttachedDoc)
: CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {}
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.h b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.h
index 70806ebdbc3..2c40c92a977 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.h
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_FontMap.h
@@ -8,11 +8,11 @@
#define FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_
#include "core/fpdfdoc/include/ipvt_fontmap.h"
-#include "fpdfsdk/include/fxedit/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
#include "public/fpdf_sysfontinfo.h"
class CPDF_Document;
-class IFX_SystemHandler;
+class CFX_SystemHandler;
struct CPWL_FontMap_Data {
CPDF_Font* pFont;
@@ -51,7 +51,7 @@ struct CPWL_FontMap_Native {
class CPWL_FontMap : public IPVT_FontMap {
public:
- CPWL_FontMap(IFX_SystemHandler* pSystemHandler);
+ CPWL_FontMap(CFX_SystemHandler* pSystemHandler);
~CPWL_FontMap() override;
// IPVT_FontMap
@@ -63,7 +63,7 @@ class CPWL_FontMap : public IPVT_FontMap {
int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override;
int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override;
- void SetSystemHandler(IFX_SystemHandler* pSystemHandler);
+ void SetSystemHandler(CFX_SystemHandler* pSystemHandler);
int32_t GetFontMapCount() const;
const CPWL_FontMap_Data* GetFontMapData(int32_t nIndex) const;
static int32_t GetNativeCharset();
@@ -119,12 +119,12 @@ class CPWL_FontMap : public IPVT_FontMap {
private:
CPDF_Document* m_pPDFDoc;
- IFX_SystemHandler* m_pSystemHandler;
+ CFX_SystemHandler* m_pSystemHandler;
};
class CPWL_DocFontMap : public CPWL_FontMap {
public:
- CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler,
+ CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler,
CPDF_Document* pAttachedDoc);
~CPWL_DocFontMap() override;
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Icon.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Icon.cpp
index 69f9e599daf..cfd62dfcd91 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Icon.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Icon.cpp
@@ -42,11 +42,11 @@ CFX_ByteString CPWL_Image::GetImageAppStream() {
sAppStream << mt.GetA() << " " << mt.GetB() << " " << mt.GetC() << " "
<< mt.GetD() << " " << mt.GetE() << " " << mt.GetF() << " cm\n";
- sAppStream << "0 g 0 G 1 w /" << sAlias.AsByteStringC() << " Do\n"
+ sAppStream << "0 g 0 G 1 w /" << sAlias.AsStringC() << " Do\n"
<< "Q\n";
}
- return sAppStream.GetByteString();
+ return sAppStream.MakeString();
}
void CPWL_Image::SetPDFStream(CPDF_Stream* pStream) {
@@ -133,7 +133,7 @@ void CPWL_Icon::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
CPDF_Array* pA =
m_pIconFit->GetDict() ? m_pIconFit->GetDict()->GetArrayBy("A") : NULL;
if (pA) {
- uint32_t dwCount = pA->GetCount();
+ size_t dwCount = pA->GetCount();
if (dwCount > 0)
fLeft = pA->GetNumberAt(0);
if (dwCount > 1)
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.cpp
index 951b6821f4a..4928560f1c1 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.cpp
@@ -129,8 +129,6 @@ void CPWL_IconList_Item::OnDisabled() {
CPWL_IconList_Content::CPWL_IconList_Content(int32_t nListCount)
: m_nSelectIndex(-1),
- m_pNotify(NULL),
- m_bEnableNotify(TRUE),
m_bMouseDown(FALSE),
m_nListCount(nListCount) {}
@@ -261,34 +259,18 @@ void CPWL_IconList_Content::ScrollToItem(int32_t nItemIndex) {
}
void CPWL_IconList_Content::SetSelect(int32_t nIndex) {
- if (m_nSelectIndex != nIndex) {
- SelectItem(m_nSelectIndex, FALSE);
- SelectItem(nIndex, TRUE);
- m_nSelectIndex = nIndex;
+ if (m_nSelectIndex == nIndex)
+ return;
- if (IPWL_IconList_Notify* pNotify = GetNotify())
- pNotify->OnNoteListSelChanged(nIndex);
- }
+ SelectItem(m_nSelectIndex, FALSE);
+ SelectItem(nIndex, TRUE);
+ m_nSelectIndex = nIndex;
}
int32_t CPWL_IconList_Content::GetSelect() const {
return m_nSelectIndex;
}
-IPWL_IconList_Notify* CPWL_IconList_Content::GetNotify() const {
- if (m_bEnableNotify)
- return m_pNotify;
- return NULL;
-}
-
-void CPWL_IconList_Content::SetNotify(IPWL_IconList_Notify* pNotify) {
- m_pNotify = pNotify;
-}
-
-void CPWL_IconList_Content::EnableNotify(FX_BOOL bNotify) {
- m_bEnableNotify = bNotify;
-}
-
void CPWL_IconList_Content::SelectItem(int32_t nItemIndex, FX_BOOL bSelect) {
if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) {
pItem->SetSelect(bSelect);
@@ -433,14 +415,6 @@ int32_t CPWL_IconList::GetSelect() const {
return m_pListContent->GetSelect();
}
-void CPWL_IconList::SetNotify(IPWL_IconList_Notify* pNotify) {
- m_pListContent->SetNotify(pNotify);
-}
-
-void CPWL_IconList::EnableNotify(FX_BOOL bNotify) {
- m_pListContent->EnableNotify(bNotify);
-}
-
void CPWL_IconList::SetListData(int32_t nItemIndex, void* pData) {
m_pListContent->SetListData(nItemIndex, pData);
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.h b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.h
index 53648d47e0d..901f4de9760 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.h
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_IconList.h
@@ -11,18 +11,11 @@
#include "fpdfsdk/pdfwindow/PWL_ListCtrl.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
-class IPWL_IconList_Notify;
class CPWL_IconList_Item;
class CPWL_IconList_Content;
class CPWL_IconList;
class CPWL_Label;
-class IPWL_IconList_Notify {
- public:
- virtual ~IPWL_IconList_Notify() {}
- virtual void OnNoteListSelChanged(int32_t nItemIndex) = 0;
-};
-
class CPWL_IconList_Item : public CPWL_Wnd {
public:
CPWL_IconList_Item();
@@ -62,14 +55,11 @@ class CPWL_IconList_Content : public CPWL_ListCtrl {
void SetSelect(int32_t nIndex);
int32_t GetSelect() const;
- void SetNotify(IPWL_IconList_Notify* pNotify);
- void EnableNotify(FX_BOOL bNotify);
void SetListData(int32_t nItemIndex, void* pData);
void SetListIcon(int32_t nItemIndex, int32_t nIconIndex);
void SetListString(int32_t nItemIndex, const CFX_WideString& str);
void SetIconFillColor(const CPWL_Color& color);
CFX_WideString GetListString(int32_t nItemIndex) const;
- IPWL_IconList_Notify* GetNotify() const;
void ScrollToItem(int32_t nItemIndex);
protected:
@@ -86,8 +76,6 @@ class CPWL_IconList_Content : public CPWL_ListCtrl {
int32_t FindItemIndex(const CFX_FloatPoint& point);
int32_t m_nSelectIndex;
- IPWL_IconList_Notify* m_pNotify;
- FX_BOOL m_bEnableNotify;
FX_BOOL m_bMouseDown;
int32_t m_nListCount;
};
@@ -100,8 +88,6 @@ class CPWL_IconList : public CPWL_Wnd {
void SetSelect(int32_t nIndex);
void SetTopItem(int32_t nIndex);
int32_t GetSelect() const;
- void SetNotify(IPWL_IconList_Notify* pNotify);
- void EnableNotify(FX_BOOL bNotify);
void SetListData(int32_t nItemIndex, void* pData);
void SetListIcon(int32_t nItemIndex, int32_t nIconIndex);
void SetListString(int32_t nItemIndex, const CFX_WideString& str);
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Label.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Label.cpp
index 0e9a9f687d3..203ec49e0f2 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Label.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Label.cpp
@@ -4,15 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/include/fxedit/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
#include "fpdfsdk/pdfwindow/PWL_Label.h"
#include "fpdfsdk/pdfwindow/PWL_Utils.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
-CPWL_Label::CPWL_Label() : m_pEdit(NULL) {
- m_pEdit = IFX_Edit::NewEdit();
- ASSERT(m_pEdit);
-}
+CPWL_Label::CPWL_Label() : m_pEdit(IFX_Edit::NewEdit()) {}
CPWL_Label::~CPWL_Label() {
IFX_Edit::DelEdit(m_pEdit);
@@ -96,7 +93,7 @@ void CPWL_Label::DrawThisAppearance(CFX_RenderDevice* pDevice,
rcClip = GetClientRect();
pRange = &wrRange;
}
- IFX_SystemHandler* pSysHandler = GetSystemHandler();
+ CFX_SystemHandler* pSysHandler = GetSystemHandler();
IFX_Edit::DrawEdit(
pDevice, pUser2Device, m_pEdit,
CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
@@ -119,22 +116,18 @@ CFX_FloatRect CPWL_Label::GetContentRect() const {
void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
CPWL_Wnd::GetThisAppearanceStream(sAppStream);
- sAppStream << GetTextAppearanceStream(CFX_FloatPoint(0.0f, 0.0f))
- .AsByteStringC();
+ sAppStream << GetTextAppearanceStream(CFX_FloatPoint(0.0f, 0.0f)).AsStringC();
}
CFX_ByteString CPWL_Label::GetTextAppearanceStream(
const CFX_FloatPoint& ptOffset) const {
CFX_ByteTextBuf sRet;
CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset);
-
if (sEdit.GetLength() > 0) {
- sRet << "BT\n"
- << CPWL_Utils::GetColorAppStream(GetTextColor()).AsByteStringC()
- << sEdit.AsByteStringC() << "ET\n";
+ sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC()
+ << sEdit.AsStringC() << "ET\n";
}
-
- return sRet.GetByteString();
+ return sRet.MakeString();
}
CFX_WideString CPWL_Label::GetText() const {
@@ -146,8 +139,5 @@ void CPWL_Label::SetLimitChar(int32_t nLimitChar) {
}
int32_t CPWL_Label::GetTotalWords() {
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
-
- return 0;
+ return m_pEdit->GetTotalWords();
}
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.cpp
index ccccc77dcd0..86f3b8f24a2 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.cpp
@@ -120,14 +120,14 @@ void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (m_pList->IsItemSelected(i)) {
sListItems << CPWL_Utils::GetRectFillAppStream(rcItem,
PWL_DEFAULT_SELBACKCOLOR)
- .AsByteStringC();
+ .AsStringC();
CFX_ByteString sItem =
CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
if (sItem.GetLength() > 0) {
sListItems << "BT\n"
<< CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELTEXTCOLOR)
- .AsByteStringC()
- << sItem.AsByteStringC() << "ET\n";
+ .AsStringC()
+ << sItem.AsStringC() << "ET\n";
}
} else {
CFX_ByteString sItem =
@@ -135,8 +135,8 @@ void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
if (sItem.GetLength() > 0) {
sListItems << "BT\n"
<< CPWL_Utils::GetColorAppStream(GetTextColor())
- .AsByteStringC()
- << sItem.AsByteStringC() << "ET\n";
+ .AsStringC()
+ << sItem.AsStringC() << "ET\n";
}
}
}
@@ -181,7 +181,7 @@ void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
}
if (m_pList->IsItemSelected(i)) {
- IFX_SystemHandler* pSysHandler = GetSystemHandler();
+ CFX_SystemHandler* pSysHandler = GetSystemHandler();
if (pSysHandler && pSysHandler->IsSelectionImplemented()) {
IFX_Edit::DrawEdit(
pDevice, pUser2Device, m_pList->GetItemEdit(i),
@@ -197,7 +197,7 @@ void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
ptOffset, NULL, pSysHandler, m_pFormFiller);
}
} else {
- IFX_SystemHandler* pSysHandler = GetSystemHandler();
+ CFX_SystemHandler* pSysHandler = GetSystemHandler();
IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
CPWL_Utils::PWLColorToFXColor(GetTextColor()),
CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()),
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.h b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.h
index caee22578bb..37299e12df9 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.h
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListBox.h
@@ -7,7 +7,7 @@
#ifndef FPDFSDK_PDFWINDOW_PWL_LISTBOX_H_
#define FPDFSDK_PDFWINDOW_PWL_LISTBOX_H_
-#include "fpdfsdk/include/fxedit/fx_edit.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
class CPWL_List_Notify;
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp
index 60bd40a2588..80679079789 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ListCtrl.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "fpdfsdk/pdfwindow/PWL_ListCtrl.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Note.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Note.cpp
deleted file mode 100644
index db7d1a56700..00000000000
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Note.cpp
+++ /dev/null
@@ -1,1513 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/pdfwindow/PWL_Note.h"
-
-#include "core/include/fxge/fx_ge.h"
-#include "fpdfsdk/pdfwindow/PWL_Button.h"
-#include "fpdfsdk/pdfwindow/PWL_Caret.h"
-#include "fpdfsdk/pdfwindow/PWL_Edit.h"
-#include "fpdfsdk/pdfwindow/PWL_EditCtrl.h"
-#include "fpdfsdk/pdfwindow/PWL_Label.h"
-#include "fpdfsdk/pdfwindow/PWL_ListCtrl.h"
-#include "fpdfsdk/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
-
-#define POPUP_ITEM_HEAD_BOTTOM 3.0f
-#define POPUP_ITEM_BOTTOMWIDTH 1.0f
-#define POPUP_ITEM_SIDEMARGIN 3.0f
-#define POPUP_ITEM_SPACE 4.0f
-#define POPUP_ITEM_TEXT_INDENT 2.0f
-#define POPUP_ITEM_BORDERCOLOR \
- CPWL_Color(COLORTYPE_RGB, 80 / 255.0f, 80 / 255.0f, 80 / 255.0f)
-
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-
-CPWL_Note_Options::CPWL_Note_Options() : m_pText(NULL) {}
-
-CPWL_Note_Options::~CPWL_Note_Options() {}
-
-void CPWL_Note_Options::SetTextColor(const CPWL_Color& color) {
- CPWL_Wnd::SetTextColor(color);
-
- if (m_pText)
- m_pText->SetTextColor(color);
-}
-
-void CPWL_Note_Options::RePosChildWnd() {
- if (IsValid()) {
- CFX_FloatRect rcClient = GetClientRect();
-
- if (rcClient.Width() > 15.0f) {
- rcClient.right -= 15.0f;
- m_pText->Move(rcClient, TRUE, FALSE);
- m_pText->SetVisible(TRUE);
- } else {
- m_pText->Move(CFX_FloatRect(0, 0, 0, 0), TRUE, FALSE);
- m_pText->SetVisible(FALSE);
- }
- }
-}
-
-void CPWL_Note_Options::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- m_pText = new CPWL_Label;
- PWL_CREATEPARAM tcp = cp;
- tcp.pParentWnd = this;
- tcp.dwFlags = PWS_CHILD | PWS_VISIBLE;
- m_pText->Create(tcp);
-}
-
-void CPWL_Note_Options::SetText(const CFX_WideString& sText) {
- m_pText->SetText(sText.c_str());
-}
-
-void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- CFX_FloatRect rcClient = GetClientRect();
- rcClient.left = rcClient.right - 15.0f;
-
- CFX_FloatPoint ptCenter =
- CFX_FloatPoint((rcClient.left + rcClient.right) * 0.5f,
- (rcClient.top + rcClient.bottom) * 0.5f);
-
- CFX_FloatPoint pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f);
- CFX_FloatPoint pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f);
- CFX_FloatPoint pt3(ptCenter.x, ptCenter.y - 3.0f * 0.5f);
-
- CFX_PathData path;
-
- path.SetPointCount(4);
- path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
- path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
- path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
- path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
-
- pDevice->DrawPath(
- &path, pUser2Device, NULL,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), 0,
- FXFILL_ALTERNATE);
-}
-
-CFX_FloatRect CPWL_Note_Options::GetContentRect() const {
- CFX_FloatRect rcText = m_pText->GetContentRect();
- rcText.right += 15.0f;
- return rcText;
-}
-
-CPWL_Note_Edit::CPWL_Note_Edit()
- : m_bEnableNotify(TRUE),
- m_fOldItemHeight(0.0f),
- m_bSizeChanged(FALSE),
- m_fOldMin(0.0f),
- m_fOldMax(0.0f) {}
-
-CPWL_Note_Edit::~CPWL_Note_Edit() {}
-
-void CPWL_Note_Edit::RePosChildWnd() {
- m_bEnableNotify = FALSE;
- CPWL_Edit::RePosChildWnd();
- m_bEnableNotify = TRUE;
-
- m_fOldItemHeight = GetContentRect().Height();
-}
-
-void CPWL_Note_Edit::SetText(const FX_WCHAR* csText) {
- m_bEnableNotify = FALSE;
- CPWL_Edit::SetText(csText);
- m_bEnableNotify = TRUE;
- m_fOldItemHeight = GetContentRect().Height();
-}
-
-void CPWL_Note_Edit::OnSetFocus() {
- m_bEnableNotify = FALSE;
- CPWL_Edit::OnSetFocus();
- m_bEnableNotify = TRUE;
-
- EnableSpellCheck(TRUE);
-}
-
-void CPWL_Note_Edit::OnKillFocus() {
- EnableSpellCheck(FALSE);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
-
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand;
-
- pNoteItem->OnContentsValidate();
- }
- }
-
- CPWL_Edit::OnKillFocus();
-}
-
-void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd,
- uint32_t msg,
- intptr_t wParam,
- intptr_t lParam) {
- if (m_bEnableNotify) {
- if (wParam == SBT_VSCROLL) {
- switch (msg) {
- case PNM_SETSCROLLINFO:
- if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) {
- if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) ||
- !IsFloatEqual(pInfo->fContentMin, m_fOldMin)) {
- m_bSizeChanged = TRUE;
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
-
- m_fOldMax = pInfo->fContentMax;
- m_fOldMin = pInfo->fContentMin;
- return;
- }
- }
- }
- }
- }
-
- CPWL_Edit::OnNotify(pWnd, msg, wParam, lParam);
-
- if (m_bEnableNotify) {
- switch (msg) {
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- break;
- }
- }
-}
-
-FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth) {
- if (fLimitWidth > 0) {
- if (!m_bSizeChanged)
- return m_fOldItemHeight;
-
- m_bSizeChanged = FALSE;
-
- EnableNotify(FALSE);
- EnableRefresh(FALSE);
- m_pEdit->EnableNotify(FALSE);
-
- Move(CFX_FloatRect(0, 0, fLimitWidth, 0), TRUE, FALSE);
- FX_FLOAT fRet = GetContentRect().Height();
-
- m_pEdit->EnableNotify(TRUE);
- EnableNotify(TRUE);
- EnableRefresh(TRUE);
-
- return fRet;
- }
-
- return 0;
-}
-
-FX_FLOAT CPWL_Note_Edit::GetItemLeftMargin() {
- return POPUP_ITEM_TEXT_INDENT;
-}
-
-FX_FLOAT CPWL_Note_Edit::GetItemRightMargin() {
- return POPUP_ITEM_TEXT_INDENT;
-}
-
-CPWL_Note_LBBox::CPWL_Note_LBBox() {}
-
-CPWL_Note_LBBox::~CPWL_Note_LBBox() {}
-
-void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
-
- CFX_PathData pathCross;
-
- pathCross.SetPointCount(4);
- pathCross.SetPoint(0, rcClient.left, rcClient.top, FXPT_MOVETO);
- pathCross.SetPoint(1, rcClient.right, rcClient.bottom, FXPT_LINETO);
- pathCross.SetPoint(2, rcClient.left,
- rcClient.bottom + rcClient.Height() * 0.5f, FXPT_MOVETO);
- pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f,
- rcClient.bottom, FXPT_LINETO);
-
- pDevice->DrawPath(
- &pathCross, pUser2Device, &gsd, 0,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- FXFILL_ALTERNATE);
-}
-
-CPWL_Note_RBBox::CPWL_Note_RBBox() {}
-
-CPWL_Note_RBBox::~CPWL_Note_RBBox() {}
-
-void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
-
- CFX_PathData pathCross;
-
- pathCross.SetPointCount(4);
- pathCross.SetPoint(0, rcClient.right, rcClient.top, FXPT_MOVETO);
- pathCross.SetPoint(1, rcClient.left, rcClient.bottom, FXPT_LINETO);
- pathCross.SetPoint(2, rcClient.right,
- rcClient.bottom + rcClient.Height() * 0.5f, FXPT_MOVETO);
- pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f,
- rcClient.bottom, FXPT_LINETO);
-
- pDevice->DrawPath(
- &pathCross, pUser2Device, &gsd, 0,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- FXFILL_ALTERNATE);
-}
-
-CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0) {}
-
-CPWL_Note_Icon::~CPWL_Note_Icon() {}
-
-void CPWL_Note_Icon::SetIconType(int32_t nType) {
- m_nType = nType;
-}
-
-void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nType, GetClientRect(),
- GetBackgroundColor(), PWL_DEFAULT_BLACKCOLOR,
- GetTransparency());
-}
-
-CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE) {}
-
-CPWL_Note_CloseBox::~CPWL_Note_CloseBox() {}
-
-void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Button::DrawThisAppearance(pDevice, pUser2Device);
-
- CFX_FloatRect rcClient = GetClientRect();
- rcClient = CPWL_Utils::DeflateRect(rcClient, 2.0f);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
-
- CFX_PathData pathCross;
-
- if (m_bMouseDown) {
- rcClient.left += 0.5f;
- rcClient.right += 0.5f;
- rcClient.top -= 0.5f;
- rcClient.bottom -= 0.5f;
- }
-
- pathCross.SetPointCount(4);
- pathCross.SetPoint(0, rcClient.left, rcClient.bottom, FXPT_MOVETO);
- pathCross.SetPoint(1, rcClient.right, rcClient.top, FXPT_LINETO);
- pathCross.SetPoint(2, rcClient.left, rcClient.top, FXPT_MOVETO);
- pathCross.SetPoint(3, rcClient.right, rcClient.bottom, FXPT_LINETO);
-
- pDevice->DrawPath(
- &pathCross, pUser2Device, &gsd, 0,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- FXFILL_ALTERNATE);
-}
-
-FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CFX_FloatPoint& point,
- uint32_t nFlag) {
- SetBorderStyle(PBS_INSET);
- InvalidateRect(NULL);
-
- m_bMouseDown = TRUE;
-
- return CPWL_Button::OnLButtonDown(point, nFlag);
-}
-
-FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CFX_FloatPoint& point,
- uint32_t nFlag) {
- m_bMouseDown = FALSE;
-
- SetBorderStyle(PBS_BEVELED);
- InvalidateRect(NULL);
-
- return CPWL_Button::OnLButtonUp(point, nFlag);
-}
-
-CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL) {}
-
-CPWL_Note_Contents::~CPWL_Note_Contents() {}
-
-CFX_ByteString CPWL_Note_Contents::GetClassName() const {
- return "CPWL_Note_Contents";
-}
-
-void CPWL_Note_Contents::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- m_pEdit = new CPWL_Note_Edit;
- PWL_CREATEPARAM ecp = cp;
- ecp.pParentWnd = this;
- ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_MULTILINE | PES_AUTORETURN |
- PES_TEXTOVERFLOW | PES_UNDO | PES_SPELLCHECK;
-
- m_pEdit->EnableNotify(FALSE);
- m_pEdit->Create(ecp);
- m_pEdit->EnableNotify(TRUE);
-}
-
-void CPWL_Note_Contents::SetText(const CFX_WideString& sText) {
- if (m_pEdit) {
- m_pEdit->EnableNotify(FALSE);
- m_pEdit->SetText(sText.c_str());
- m_pEdit->EnableNotify(TRUE);
- OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0);
- }
-}
-
-CFX_WideString CPWL_Note_Contents::GetText() const {
- if (m_pEdit)
- return m_pEdit->GetText();
-
- return L"";
-}
-
-CPWL_NoteItem* CPWL_Note_Contents::CreateSubItem() {
- CPWL_NoteItem* pNoteItem = new CPWL_NoteItem;
- PWL_CREATEPARAM icp = GetCreationParam();
- icp.pParentWnd = this;
- icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
- pNoteItem->Create(icp);
-
- pNoteItem->OnCreateNoteItem();
-
- pNoteItem->ResetSubjectName(m_aChildren.GetSize() - 1);
-
- FX_SYSTEMTIME st;
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- st = pSH->GetLocalTime();
- pNoteItem->SetDateTime(st);
-
- pNoteItem->SetContents(L"");
-
- OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0);
-
- return pNoteItem;
-}
-
-int32_t CPWL_Note_Contents::CountSubItems() const {
- return m_aChildren.GetSize() - 1;
-}
-
-IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(int32_t index) const {
- int32_t nIndex = index + 1;
-
- if (nIndex > 0 && nIndex < m_aChildren.GetSize()) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(nIndex)) {
- ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
- return pItem;
- }
- }
- return NULL;
-}
-
-void CPWL_Note_Contents::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
- int32_t nIndex = GetItemIndex((CPWL_NoteItem*)pNoteItem);
-
- if (nIndex > 0) {
- if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem) {
- pPWLNoteItem->KillFocus();
- pPWLNoteItem->Destroy();
- delete pPWLNoteItem;
- }
-
- for (int32_t i = nIndex, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
- pItem->ResetSubjectName(i);
- }
- }
-
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
-}
-
-IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CFX_FloatPoint& point) {
- CFX_FloatPoint pt = ParentToChild(point);
-
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (pChild->GetClassName() == "CPWL_NoteItem") {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt))
- return pRet;
- }
- }
- }
- return NULL;
-}
-
-void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd,
- uint32_t msg,
- intptr_t wParam,
- intptr_t lParam) {
- switch (msg) {
- case PNM_NOTEEDITCHANGED: {
- int32_t nIndex = GetItemIndex(pWnd);
- if (nIndex < 0)
- nIndex = 0;
-
- m_pEdit->EnableNotify(FALSE);
- ResetContent(nIndex);
- m_pEdit->EnableNotify(TRUE);
-
- for (int32_t i = nIndex + 1, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->OnNotify(this, PNM_NOTERESET, 0, 0);
- }
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
- }
- return;
- case PNM_SCROLLWINDOW:
- SetScrollPos(CFX_FloatPoint(0.0f, *(FX_FLOAT*)lParam));
- ResetFace();
- InvalidateRect(NULL);
- return;
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- return;
- case PNM_NOTERESET: {
- m_pEdit->EnableNotify(FALSE);
- ResetContent(0);
- m_pEdit->EnableNotify(TRUE);
-
- for (int32_t i = 1, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->OnNotify(this, PNM_NOTERESET, 0, 0);
- }
-
- m_pEdit->EnableNotify(FALSE);
- ResetContent(0);
- m_pEdit->EnableNotify(TRUE);
- }
- return;
- }
-
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CFX_FloatPoint& point,
- uint32_t nFlag) {
- if (CPWL_Wnd::OnLButtonDown(point, nFlag))
- return TRUE;
-
- if (!m_pEdit->IsFocused()) {
- m_pEdit->SetFocus();
- }
-
- return TRUE;
-}
-
-void CPWL_Note_Contents::SetEditFocus(FX_BOOL bLast) {
- if (!m_pEdit->IsFocused()) {
- m_pEdit->SetFocus();
- m_pEdit->SetCaret(bLast ? m_pEdit->GetTotalWords() : 0);
- }
-}
-
-CPWL_Edit* CPWL_Note_Contents::GetEdit() const {
- return m_pEdit;
-}
-
-void CPWL_Note_Contents::EnableModify(FX_BOOL bEnabled) {
- if (!bEnabled)
- m_pEdit->AddFlag(PWS_READONLY);
- else
- m_pEdit->RemoveFlag(PWS_READONLY);
-
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (pChild->GetClassName() == "CPWL_NoteItem") {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- pNoteItem->EnableModify(bEnabled);
- }
- }
- }
-}
-
-void CPWL_Note_Contents::EnableRead(FX_BOOL bEnabled) {
- if (!bEnabled)
- m_pEdit->AddFlag(PES_NOREAD);
- else
- m_pEdit->RemoveFlag(PES_NOREAD);
-
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (pChild->GetClassName() == "CPWL_NoteItem") {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- pNoteItem->EnableRead(bEnabled);
- }
- }
- }
-}
-
-CPWL_NoteItem::CPWL_NoteItem()
- : m_pSubject(NULL),
- m_pDateTime(NULL),
- m_pContents(NULL),
- m_pPrivateData(NULL),
- m_sAuthor(L""),
- m_fOldItemHeight(0.0f),
- m_bSizeChanged(FALSE),
- m_bAllowModify(TRUE) {}
-
-CPWL_NoteItem::~CPWL_NoteItem() {}
-
-CFX_ByteString CPWL_NoteItem::GetClassName() const {
- return "CPWL_NoteItem";
-}
-
-void CPWL_NoteItem::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(GetBackgroundColor()))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- m_pSubject = new CPWL_Label;
- PWL_CREATEPARAM scp = cp;
- scp.pParentWnd = this;
- scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
- scp.sTextColor = sTextColor;
- m_pSubject->Create(scp);
-
- m_pDateTime = new CPWL_Label;
- PWL_CREATEPARAM dcp = cp;
- dcp.pParentWnd = this;
- dcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_RIGHT | PES_TOP;
- dcp.sTextColor = sTextColor;
- m_pDateTime->Create(dcp);
-
- m_pContents = new CPWL_Note_Contents;
- PWL_CREATEPARAM ccp = cp;
- ccp.pParentWnd = this;
- ccp.sBackgroundColor =
- CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f);
- ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BACKGROUND;
- m_pContents->Create(ccp);
- m_pContents->SetItemSpace(POPUP_ITEM_SPACE);
- m_pContents->SetTopSpace(POPUP_ITEM_SPACE);
- m_pContents->SetBottomSpace(POPUP_ITEM_SPACE);
-}
-
-void CPWL_NoteItem::RePosChildWnd() {
- if (IsValid()) {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_FloatRect rcSubject = rcClient;
- rcSubject.left += POPUP_ITEM_TEXT_INDENT;
- rcSubject.top = rcClient.top;
- rcSubject.right =
- PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f,
- rcClient.right);
- rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height();
- rcSubject.Normalize();
- m_pSubject->Move(rcSubject, TRUE, FALSE);
- m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject));
-
- CFX_FloatRect rcDate = rcClient;
- rcDate.right -= POPUP_ITEM_TEXT_INDENT;
- rcDate.left =
- PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f,
- rcSubject.right);
- rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height();
- rcDate.Normalize();
- m_pDateTime->Move(rcDate, TRUE, FALSE);
- m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate));
-
- CFX_FloatRect rcContents = rcClient;
- rcContents.left += 1.0f;
- rcContents.right -= 1.0f;
- rcContents.top = rcDate.bottom - POPUP_ITEM_HEAD_BOTTOM;
- rcContents.bottom += POPUP_ITEM_BOTTOMWIDTH;
- rcContents.Normalize();
- m_pContents->Move(rcContents, TRUE, FALSE);
- m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents));
- }
-
- SetClipRect(CPWL_Utils::InflateRect(GetWindowRect(), 1.0f));
-}
-
-void CPWL_NoteItem::SetPrivateData(void* pData) {
- m_pPrivateData = pData;
-}
-
-void CPWL_NoteItem::SetBkColor(const CPWL_Color& color) {
- CPWL_Color sBK = color;
- SetBackgroundColor(sBK);
-
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(sBK))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- SetTextColor(sTextColor);
- if (m_pSubject)
- m_pSubject->SetTextColor(sTextColor);
- if (m_pDateTime)
- m_pDateTime->SetTextColor(sTextColor);
-
- InvalidateRect(nullptr);
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetBkColor(this);
- }
-}
-
-void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) {
- if (m_pSubject) {
- m_pSubject->SetText(sName.c_str());
- }
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetSubjectName(this);
- }
-}
-
-void CPWL_NoteItem::SetAuthorName(const CFX_WideString& sName) {
- m_sAuthor = sName;
- ResetSubjectName(-1);
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetAuthorName(this);
- }
-}
-
-void CPWL_NoteItem::ResetSubjectName(int32_t nItemIndex) {
- if (nItemIndex < 0) {
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
-
- CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent;
- nItemIndex = pContents->GetItemIndex(this);
- }
- }
-
- const CPWL_Note* pNote = GetNote();
- CFX_WideString sSubject;
- sSubject.Format(pNote->GetReplyString().c_str(), nItemIndex);
-
- if (!m_sAuthor.IsEmpty()) {
- sSubject += L" - ";
- sSubject += m_sAuthor;
- }
- SetSubjectName(sSubject);
- RePosChildWnd();
-}
-
-void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) {
- m_dtNote = time;
-
- CFX_WideString swTime;
- swTime.Format(L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear, time.wMonth,
- time.wDay, time.wHour, time.wMinute, time.wSecond);
- if (m_pDateTime) {
- m_pDateTime->SetText(swTime.c_str());
- }
-
- RePosChildWnd();
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetDateTime(this);
- }
-}
-
-void CPWL_NoteItem::SetContents(const CFX_WideString& sContents) {
- if (m_pContents) {
- m_pContents->SetText(sContents);
- }
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetContents(this);
- }
-}
-
-CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const {
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
- return (CPWL_NoteItem*)pGrand;
- }
- }
-
- return NULL;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetParentItem() const {
- return GetParentNoteItem();
-}
-
-CPWL_Edit* CPWL_NoteItem::GetEdit() const {
- if (m_pContents)
- return m_pContents->GetEdit();
- return NULL;
-}
-
-void* CPWL_NoteItem::GetPrivateData() const {
- return m_pPrivateData;
-}
-
-CFX_WideString CPWL_NoteItem::GetAuthorName() const {
- return m_sAuthor;
-}
-
-CPWL_Color CPWL_NoteItem::GetBkColor() const {
- return GetBackgroundColor();
-}
-
-CFX_WideString CPWL_NoteItem::GetContents() const {
- if (m_pContents)
- return m_pContents->GetText();
-
- return L"";
-}
-
-FX_SYSTEMTIME CPWL_NoteItem::GetDateTime() const {
- return m_dtNote;
-}
-
-CFX_WideString CPWL_NoteItem::GetSubjectName() const {
- if (m_pSubject)
- return m_pSubject->GetText();
-
- return L"";
-}
-
-CPWL_NoteItem* CPWL_NoteItem::CreateNoteItem() {
- if (m_pContents)
- return m_pContents->CreateSubItem();
-
- return NULL;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::CreateSubItem() {
- return CreateNoteItem();
-}
-
-int32_t CPWL_NoteItem::CountSubItems() const {
- if (m_pContents)
- return m_pContents->CountSubItems();
-
- return 0;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetSubItems(int32_t index) const {
- if (m_pContents)
- return m_pContents->GetSubItems(index);
-
- return NULL;
-}
-
-void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
- KillFocus();
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnItemDelete(pNoteItem);
- }
-
- if (m_pContents)
- m_pContents->DeleteSubItem(pNoteItem);
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CFX_FloatPoint& point) {
- CFX_FloatPoint pt = ParentToChild(point);
-
- if (WndHitTest(pt)) {
- if (m_pContents) {
- if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteItem(pt))
- return pNoteItem;
- }
-
- return this;
- }
-
- return NULL;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetFocusedNoteItem() const {
- if (const CPWL_Wnd* pWnd = GetFocused()) {
- if (pWnd->GetClassName() == "CPWL_Edit") {
- if (CPWL_Wnd* pParent = pWnd->GetParentWindow()) {
- ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
-
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
- return (CPWL_NoteItem*)pGrand;
- }
- }
- }
- }
-
- return NULL;
-}
-
-FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth) {
- if (fLimitWidth > 0) {
- if (!m_bSizeChanged)
- return m_fOldItemHeight;
-
- m_bSizeChanged = FALSE;
-
- FX_FLOAT fRet = m_pDateTime->GetContentRect().Height();
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- if (fLimitWidth > fBorderWidth * 2)
- fRet += m_pContents->GetContentsHeight(fLimitWidth - fBorderWidth * 2);
- fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorderWidth * 2;
-
- return m_fOldItemHeight = fRet;
- }
-
- return 0;
-}
-
-FX_FLOAT CPWL_NoteItem::GetItemLeftMargin() {
- return POPUP_ITEM_SIDEMARGIN;
-}
-
-FX_FLOAT CPWL_NoteItem::GetItemRightMargin() {
- return POPUP_ITEM_SIDEMARGIN;
-}
-
-FX_BOOL CPWL_NoteItem::OnLButtonDown(const CFX_FloatPoint& point,
- uint32_t nFlag) {
- if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) {
- SetNoteFocus(FALSE);
- }
-
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_NoteItem::OnRButtonUp(const CFX_FloatPoint& point,
- uint32_t nFlag) {
- if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) {
- SetNoteFocus(FALSE);
- PopupNoteItemMenu(point);
-
- return TRUE;
- }
-
- return CPWL_Wnd::OnRButtonUp(point, nFlag);
-}
-
-void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd,
- uint32_t msg,
- intptr_t wParam,
- intptr_t lParam) {
- switch (msg) {
- case PNM_NOTEEDITCHANGED:
- m_bSizeChanged = TRUE;
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
- return;
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- return;
- case PNM_NOTERESET:
- m_bSizeChanged = TRUE;
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
-
- return;
- }
-
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-void CPWL_NoteItem::PopupNoteItemMenu(const CFX_FloatPoint& point) {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- int32_t x, y;
- PWLtoWnd(point, x, y);
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- pNotify->OnPopupMenu(this, x, y);
- }
-}
-
-const CPWL_Note* CPWL_NoteItem::GetNote() const {
- if (const CPWL_Wnd* pRoot = GetRootWnd()) {
- ASSERT(pRoot->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pRoot;
- if (pNoteItem->IsTopItem()) {
- return (CPWL_Note*)pNoteItem;
- }
- }
-
- return NULL;
-}
-
-IPWL_NoteNotify* CPWL_NoteItem::GetNoteNotify() const {
- if (const CPWL_Note* pNote = GetNote())
- return pNote->GetNoteNotify();
-
- return NULL;
-}
-
-void CPWL_NoteItem::OnCreateNoteItem() {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnItemCreate(this);
- }
-}
-
-void CPWL_NoteItem::OnContentsValidate() {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetContents(this);
- }
-}
-
-void CPWL_NoteItem::SetNoteFocus(FX_BOOL bLast) {
- m_pContents->SetEditFocus(bLast);
-}
-
-void CPWL_NoteItem::EnableModify(FX_BOOL bEnabled) {
- m_pContents->EnableModify(bEnabled);
- m_bAllowModify = bEnabled;
-}
-
-void CPWL_NoteItem::EnableRead(FX_BOOL bEnabled) {
- m_pContents->EnableRead(bEnabled);
-}
-
-CPWL_Note::CPWL_Note(IPopup_Note* pPopupNote,
- IPWL_NoteNotify* pNoteNotify,
- IPWL_NoteHandler* pNoteHandler)
- : m_pAuthor(NULL),
- m_pIcon(NULL),
- m_pCloseBox(NULL),
- m_pLBBox(NULL),
- m_pRBBox(NULL),
- m_pContentsBar(NULL),
- m_pOptions(NULL),
- m_pNoteNotify(pNoteNotify),
- m_bResizing(FALSE),
- m_bEnableNotify(TRUE) {}
-
-CPWL_Note::~CPWL_Note() {}
-
-IPWL_NoteItem* CPWL_Note::Reply() {
- return CreateNoteItem();
-}
-
-void CPWL_Note::EnableNotify(FX_BOOL bEnabled) {
- m_bEnableNotify = bEnabled;
-}
-
-void CPWL_Note::RePosChildWnd() {
- RePosNoteChildren();
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- ResetScrollBar();
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- if (const CPWL_Wnd* pWnd = GetFocused()) {
- if (pWnd->GetClassName() == "CPWL_Edit") {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCaret(pEdit->GetCaret());
- }
- }
-}
-
-FX_BOOL CPWL_Note::ResetScrollBar() {
- FX_BOOL bScrollChanged = FALSE;
-
- if (ScrollBarShouldVisible()) {
- if (!m_pContentsBar->IsVisible()) {
- m_pContentsBar->SetVisible(TRUE);
- if (m_pContentsBar->IsVisible()) {
- m_pContentsBar->InvalidateRect(NULL);
- bScrollChanged = TRUE;
- }
- }
- } else {
- if (m_pContentsBar->IsVisible()) {
- m_pContentsBar->SetVisible(FALSE);
- m_pContentsBar->InvalidateRect(NULL);
-
- bScrollChanged = TRUE;
- }
- }
-
- if (bScrollChanged) {
- CFX_FloatRect rcNote = GetClientRect();
- CFX_FloatRect rcContents = m_pContents->GetWindowRect();
- rcContents.right = rcNote.right - 3.0f;
- if (m_pContentsBar->IsVisible())
- rcContents.right -= PWL_SCROLLBAR_WIDTH;
- m_pContents->Move(rcContents, TRUE, TRUE);
- m_pContents->SetScrollPos(CFX_FloatPoint(0.0f, 0.0f));
- m_pContents->InvalidateRect(NULL);
- }
-
- return bScrollChanged;
-}
-
-FX_BOOL CPWL_Note::ScrollBarShouldVisible() {
- CFX_FloatRect rcContentsFact = m_pContents->GetScrollArea();
- CFX_FloatRect rcContentsClient = m_pContents->GetClientRect();
-
- return rcContentsFact.Height() > rcContentsClient.Height();
-}
-
-void CPWL_Note::SetOptionsText(const CFX_WideString& sText) {
- if (m_pOptions)
- m_pOptions->SetText(sText);
-
- RePosNoteChildren();
-}
-
-void CPWL_Note::RePosNoteChildren() {
- if (m_bResizing)
- return;
-
- m_bResizing = TRUE;
-
- if (IsValid()) {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_FloatRect rcIcon = rcClient;
- rcIcon.top -= 2.0f;
- rcIcon.right = rcIcon.left + 14.0f;
- rcIcon.bottom = rcIcon.top - 14.0f;
- rcIcon.Normalize();
- m_pIcon->Move(rcIcon, TRUE, FALSE);
- m_pIcon->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcIcon));
-
- CFX_FloatRect rcCloseBox = rcClient;
- rcCloseBox.right -= 1.0f;
- rcCloseBox.top -= 1.0f;
- rcCloseBox.left = rcCloseBox.right - 14.0f;
- rcCloseBox.bottom = rcCloseBox.top - 14.0f;
- rcCloseBox.Normalize();
- m_pCloseBox->Move(rcCloseBox, TRUE, FALSE);
- m_pCloseBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcCloseBox));
-
- CFX_FloatRect rcDate = rcClient;
- rcDate.right = rcCloseBox.left - POPUP_ITEM_TEXT_INDENT;
- rcDate.left =
- PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f,
- rcIcon.right + 1.0f);
- rcDate.top = rcClient.top - 2.0f;
- rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height();
- rcDate.Normalize();
- m_pDateTime->Move(rcDate, TRUE, FALSE);
- m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate));
-
- CFX_FloatRect rcSubject = rcClient;
- rcSubject.top = rcClient.top - 2.0f;
- rcSubject.left = rcIcon.right + POPUP_ITEM_TEXT_INDENT;
- rcSubject.right =
- PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f,
- rcDate.left - 1.0f);
- rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height();
- rcSubject.Normalize();
- m_pSubject->Move(rcSubject, TRUE, FALSE);
- m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject));
-
- CFX_FloatRect rcOptions = rcClient;
- rcOptions.left =
- PWL_MAX(rcOptions.right - m_pOptions->GetContentRect().Width(),
- rcIcon.right + 1.0f);
- rcOptions.top = rcSubject.bottom - 4.0f;
- rcOptions.bottom = rcOptions.top - m_pOptions->GetContentRect().Height();
- rcOptions.Normalize();
- m_pOptions->Move(rcOptions, TRUE, FALSE);
- m_pOptions->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcOptions));
-
- CFX_FloatRect rcAuthor = rcClient;
- rcAuthor.top = rcSubject.bottom - 4.0f;
- rcAuthor.left = rcSubject.left;
- rcAuthor.right =
- PWL_MIN(rcSubject.left + m_pAuthor->GetContentRect().Width() + 1.0f,
- rcOptions.left - 1.0f);
- rcAuthor.bottom = rcAuthor.top - m_pAuthor->GetContentRect().Height();
- rcAuthor.Normalize();
- m_pAuthor->Move(rcAuthor, TRUE, FALSE);
- m_pAuthor->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcAuthor));
-
- CFX_FloatRect rcLBBox = rcClient;
- rcLBBox.top = rcLBBox.bottom + 7.0f;
- rcLBBox.right = rcLBBox.left + 7.0f;
- rcLBBox.Normalize();
- m_pLBBox->Move(rcLBBox, TRUE, FALSE);
- m_pLBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcLBBox));
-
- CFX_FloatRect rcRBBox = rcClient;
- rcRBBox.top = rcRBBox.bottom + 7.0f;
- rcRBBox.left = rcRBBox.right - 7.0f;
- rcRBBox.Normalize();
- m_pRBBox->Move(rcRBBox, TRUE, FALSE);
- m_pRBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcRBBox));
-
- CFX_FloatRect rcContents = rcClient;
- rcContents.top = rcAuthor.bottom - POPUP_ITEM_HEAD_BOTTOM;
- rcContents.left += 3.0f;
- rcContents.right -= 3.0f;
- if (m_pContentsBar->IsVisible())
- rcContents.right -= PWL_SCROLLBAR_WIDTH;
- rcContents.bottom += 14.0f;
- rcContents.Normalize();
- m_pContents->Move(rcContents, FALSE, FALSE);
- m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents));
-
- CFX_FloatRect rcContentsBar = rcContents;
- rcContentsBar.right = rcClient.right - 3.0f;
- rcContentsBar.left = rcContentsBar.right - PWL_SCROLLBAR_WIDTH;
- rcContentsBar.Normalize();
- m_pContentsBar->Move(rcContentsBar, TRUE, FALSE);
- }
-
- m_bResizing = FALSE;
-}
-
-void CPWL_Note::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- CPWL_NoteItem::CreateChildWnd(cp);
-
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(GetBackgroundColor()))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- m_pAuthor = new CPWL_Label;
- PWL_CREATEPARAM acp = cp;
- acp.pParentWnd = this;
- acp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
- acp.sTextColor = sTextColor;
- m_pAuthor->Create(acp);
-
- m_pCloseBox = new CPWL_Note_CloseBox;
- PWL_CREATEPARAM ccp = cp;
- ccp.pParentWnd = this;
- ccp.dwBorderWidth = 2;
- ccp.nBorderStyle = PBS_BEVELED;
- ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER;
- ccp.sTextColor = sTextColor;
- m_pCloseBox->Create(ccp);
-
- m_pIcon = new CPWL_Note_Icon;
- PWL_CREATEPARAM icp = cp;
- icp.pParentWnd = this;
- icp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- m_pIcon->Create(icp);
-
- m_pOptions = new CPWL_Note_Options;
- PWL_CREATEPARAM ocp = cp;
- ocp.pParentWnd = this;
- ocp.dwFlags = PWS_CHILD | PWS_VISIBLE;
- ocp.sTextColor = sTextColor;
- m_pOptions->Create(ocp);
-
- m_pLBBox = new CPWL_Note_LBBox;
- PWL_CREATEPARAM lcp = cp;
- lcp.pParentWnd = this;
- lcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- lcp.eCursorType = FXCT_NESW;
- lcp.sTextColor = sTextColor;
- m_pLBBox->Create(lcp);
-
- m_pRBBox = new CPWL_Note_RBBox;
- PWL_CREATEPARAM rcp = cp;
- rcp.pParentWnd = this;
- rcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- rcp.eCursorType = FXCT_NWSE;
- rcp.sTextColor = sTextColor;
- m_pRBBox->Create(rcp);
-
- m_pContentsBar = new CPWL_ScrollBar(SBT_VSCROLL);
- PWL_CREATEPARAM scp = cp;
- scp.pParentWnd = this;
- scp.sBackgroundColor =
- CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f);
- scp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
- m_pContentsBar->Create(scp);
- m_pContentsBar->SetNotifyForever(TRUE);
-}
-
-void CPWL_Note::SetSubjectName(const CFX_WideString& sName) {
- CPWL_NoteItem::SetSubjectName(sName);
- RePosChildWnd();
-}
-
-void CPWL_Note::SetAuthorName(const CFX_WideString& sName) {
- if (m_pAuthor) {
- m_pAuthor->SetText(sName.c_str());
- RePosChildWnd();
- }
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetAuthorName(this);
- }
-}
-
-CFX_WideString CPWL_Note::GetAuthorName() const {
- if (m_pAuthor)
- return m_pAuthor->GetText();
-
- return L"";
-}
-
-FX_BOOL CPWL_Note::OnMouseWheel(short zDelta,
- const CFX_FloatPoint& point,
- uint32_t nFlag) {
- CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
- CFX_FloatRect rcScroll = m_pContents->GetScrollArea();
- CFX_FloatRect rcContents = m_pContents->GetClientRect();
-
- if (rcScroll.top - rcScroll.bottom > rcContents.Height()) {
- CFX_FloatPoint ptNew = ptScroll;
-
- if (zDelta > 0)
- ptNew.y += 30;
- else
- ptNew.y -= 30;
-
- if (ptNew.y > rcScroll.top)
- ptNew.y = rcScroll.top;
- if (ptNew.y < rcScroll.bottom + rcContents.Height())
- ptNew.y = rcScroll.bottom + rcContents.Height();
- if (ptNew.y < rcScroll.bottom)
- ptNew.y = rcScroll.bottom;
-
- if (ptNew.y != ptScroll.y) {
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
- (intptr_t)&ptNew.y);
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptNew.y);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void CPWL_Note::OnNotify(CPWL_Wnd* pWnd,
- uint32_t msg,
- intptr_t wParam,
- intptr_t lParam) {
- switch (msg) {
- case PNM_NOTEEDITCHANGED: {
- CFX_FloatRect rcScroll = m_pContents->GetScrollArea();
-
- PWL_SCROLL_INFO sInfo;
- sInfo.fContentMin = rcScroll.bottom;
- sInfo.fContentMax = rcScroll.top;
- sInfo.fPlateWidth = m_pContents->GetClientRect().Height();
- sInfo.fSmallStep = 13.0f;
- sInfo.fBigStep = sInfo.fPlateWidth;
-
- if (FXSYS_memcmp(&m_OldScrollInfo, &sInfo, sizeof(PWL_SCROLL_INFO)) !=
- 0) {
- FX_BOOL bScrollChanged = FALSE;
-
- if (lParam < 3) {
- bScrollChanged = ResetScrollBar();
- if (bScrollChanged) {
- lParam++;
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam);
- }
- }
-
- if (!bScrollChanged) {
- if (m_pContentsBar->IsVisible()) {
- m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL,
- (intptr_t)&sInfo);
- m_OldScrollInfo = sInfo;
-
- CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
- CFX_FloatPoint ptOld = ptScroll;
-
- if (ptScroll.y > sInfo.fContentMax)
- ptScroll.y = sInfo.fContentMax;
- if (ptScroll.y < sInfo.fContentMin + sInfo.fPlateWidth)
- ptScroll.y = sInfo.fContentMin + sInfo.fPlateWidth;
- if (ptScroll.y < sInfo.fContentMin)
- ptScroll.y = sInfo.fContentMin;
-
- if (ptOld.y != ptScroll.y) {
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
- m_pContentsBar->InvalidateRect(NULL);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
- }
- }
- }
- }
- }
-
- m_pContents->InvalidateRect(NULL);
-
- return;
- case PNM_SCROLLWINDOW:
- if (m_pContents)
- m_pContents->OnNotify(pWnd, msg, wParam, lParam);
- return;
- case PNM_SETSCROLLPOS:
- if (m_pContentsBar)
- m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
- return;
- }
-
- if (msg == PNM_SETCARETINFO && IsValid()) {
- if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
- if (m_pContents) {
- CFX_FloatRect rcClient = m_pContents->GetClientRect();
- if (pInfo->ptHead.y > rcClient.top) {
- CFX_FloatPoint pt = m_pContents->OutToIn(pInfo->ptHead);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
- (intptr_t)&pt.y);
-
- CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
-
- return;
- }
-
- if (pInfo->ptFoot.y < rcClient.bottom) {
- CFX_FloatPoint pt = m_pContents->OutToIn(pInfo->ptFoot);
- pt.y += rcClient.Height();
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
- (intptr_t)&pt.y);
-
- CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
-
- return;
- }
- }
- }
- }
-
- CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-void CPWL_Note::SetBkColor(const CPWL_Color& color) {
- CPWL_NoteItem::SetBkColor(color);
-
- CPWL_Color sBK = color;
- CPWL_Color sTextColor;
- if (CPWL_Utils::IsBlackOrWhite(sBK))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- if (m_pCloseBox)
- m_pCloseBox->SetTextColor(sTextColor);
- if (m_pAuthor)
- m_pAuthor->SetTextColor(sTextColor);
- if (m_pOptions)
- m_pOptions->SetTextColor(sTextColor);
- if (m_pLBBox)
- m_pLBBox->SetTextColor(sTextColor);
- if (m_pRBBox)
- m_pRBBox->SetTextColor(sTextColor);
-}
-
-FX_BOOL CPWL_Note::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) {
- if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- int32_t x, y;
- PWLtoWnd(point, x, y);
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- KillFocus();
- pNotify->OnPopupMenu(x, y);
-
- return TRUE;
- }
- }
-
- return CPWL_Wnd::OnLButtonDown(point, nFlag);
-}
-
-FX_BOOL CPWL_Note::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) {
- return CPWL_Wnd::OnRButtonUp(point, nFlag);
-}
-
-const CPWL_Note* CPWL_Note::GetNote() const {
- return this;
-}
-
-IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const {
- return m_bEnableNotify ? m_pNoteNotify : nullptr;
-}
-
-void CPWL_Note::SetIconType(int32_t nType) {
- if (m_pIcon)
- m_pIcon->SetIconType(nType);
-}
-
-void CPWL_Note::EnableModify(FX_BOOL bEnabled) {
- m_pContents->EnableModify(bEnabled);
-}
-
-void CPWL_Note::EnableRead(FX_BOOL bEnabled) {
- m_pContents->EnableRead(bEnabled);
-}
-
-CFX_WideString CPWL_Note::GetReplyString() const {
- return m_sReplyString;
-}
-
-void CPWL_Note::SetReplyString(const CFX_WideString& str) {
- m_sReplyString = str;
-}
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Note.h b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Note.h
deleted file mode 100644
index 10689991346..00000000000
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Note.h
+++ /dev/null
@@ -1,351 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef FPDFSDK_PDFWINDOW_PWL_NOTE_H_
-#define FPDFSDK_PDFWINDOW_PWL_NOTE_H_
-
-#include "fpdfsdk/pdfwindow/PWL_Button.h"
-#include "fpdfsdk/pdfwindow/PWL_Edit.h"
-#include "fpdfsdk/pdfwindow/PWL_ListCtrl.h"
-#include "fpdfsdk/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
-
-class CPWL_Label;
-class CPWL_Note;
-class CPWL_NoteItem;
-class CPWL_Note_CloseBox;
-class CPWL_Note_Contents;
-class CPWL_Note_Edit;
-class CPWL_Note_Icon;
-class CPWL_Note_LBBox;
-class CPWL_Note_Options;
-class CPWL_Note_RBBox;
-class IPWL_NoteHandler;
-class IPWL_NoteItem;
-class IPWL_NoteNotify;
-class IPopup_Note;
-
-class IPWL_NoteNotify {
- public:
- virtual ~IPWL_NoteNotify() {}
- virtual void OnNoteMove(const FX_RECT& rtWin) = 0;
- virtual void OnNoteShow(FX_BOOL bShow) = 0;
- virtual void OnNoteActivate(FX_BOOL bActive) = 0;
- virtual void OnNoteClose() = 0;
- virtual void OnItemCreate(IPWL_NoteItem* pItem) = 0;
- virtual void OnItemDelete(IPWL_NoteItem* pItem) = 0;
- virtual void OnSetAuthorName(IPWL_NoteItem* pItem) = 0;
- virtual void OnSetBkColor(IPWL_NoteItem* pItem) = 0;
- virtual void OnSetContents(IPWL_NoteItem* pItem) = 0;
- virtual void OnSetDateTime(IPWL_NoteItem* pItem) = 0;
- virtual void OnSetSubjectName(IPWL_NoteItem* pItem) = 0;
- virtual void OnPopupMenu(int32_t x, int32_t y) = 0;
- virtual void OnPopupMenu(IPWL_NoteItem* pItem, int32_t x, int32_t y) = 0;
-};
-
-class IPWL_NoteHandler {
- public:
- virtual ~IPWL_NoteHandler() {}
- virtual void OnNoteColorChanged(const CPWL_Color& color) = 0;
-};
-
-class IPWL_NoteItem {
- public:
- virtual ~IPWL_NoteItem() {}
- virtual void SetPrivateData(void* pData) = 0;
- virtual void SetBkColor(const CPWL_Color& color) = 0;
- virtual void SetSubjectName(const CFX_WideString& sName) = 0;
- virtual void SetAuthorName(const CFX_WideString& sName) = 0;
- virtual void SetDateTime(FX_SYSTEMTIME time) = 0;
- virtual void SetContents(const CFX_WideString& sContents) = 0;
-
- virtual IPWL_NoteItem* CreateSubItem() = 0;
- virtual int32_t CountSubItems() const = 0;
- virtual IPWL_NoteItem* GetSubItems(int32_t index) const = 0;
- virtual void DeleteSubItem(IPWL_NoteItem* pNoteItem) = 0;
- virtual void SetFocus() = 0;
-
- virtual IPWL_NoteItem* GetParentItem() const = 0;
- virtual void* GetPrivateData() const = 0;
- virtual CFX_WideString GetAuthorName() const = 0;
- virtual CPWL_Color GetBkColor() const = 0;
- virtual CFX_WideString GetContents() const = 0;
- virtual FX_SYSTEMTIME GetDateTime() const = 0;
- virtual CFX_WideString GetSubjectName() const = 0;
-
- virtual CPWL_Edit* GetEdit() const = 0;
-};
-
-class CPWL_Note_Icon : public CPWL_Wnd {
- public:
- CPWL_Note_Icon();
- ~CPWL_Note_Icon() override;
-
- void SetIconType(int32_t nType);
-
- protected:
- // CPWL_Wnd
- void DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) override;
-
- private:
- int32_t m_nType;
-};
-
-class CPWL_Note_CloseBox : public CPWL_Button {
- public:
- CPWL_Note_CloseBox();
- ~CPWL_Note_CloseBox() override;
-
- protected:
- // CPWL_Button
- void DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) override;
- FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override;
- FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override;
-
- private:
- FX_BOOL m_bMouseDown;
-};
-
-class CPWL_Note_LBBox : public CPWL_Wnd {
- public:
- CPWL_Note_LBBox();
- ~CPWL_Note_LBBox() override;
-
- protected:
- // CPWL_Wnd
- void DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) override;
-};
-
-class CPWL_Note_RBBox : public CPWL_Wnd {
- public:
- CPWL_Note_RBBox();
- ~CPWL_Note_RBBox() override;
-
- protected:
- // CPWL_Wnd
- void DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) override;
-};
-
-class CPWL_Note_Edit : public CPWL_Edit {
- public:
- CPWL_Note_Edit();
- ~CPWL_Note_Edit() override;
-
- void EnableNotify(FX_BOOL bEnable) { m_bEnableNotify = bEnable; }
-
- // CPWL_Edit
- FX_FLOAT GetItemLeftMargin() override;
- FX_FLOAT GetItemRightMargin() override;
- FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth) override;
- void SetText(const FX_WCHAR* csText) override;
- void OnNotify(CPWL_Wnd* pWnd,
- uint32_t msg,
- intptr_t wParam = 0,
- intptr_t lParam = 0) override;
- void RePosChildWnd() override;
- void OnSetFocus() override;
- void OnKillFocus() override;
-
- private:
- FX_BOOL m_bEnableNotify;
- FX_FLOAT m_fOldItemHeight;
- FX_BOOL m_bSizeChanged;
- FX_FLOAT m_fOldMin;
- FX_FLOAT m_fOldMax;
-};
-
-class CPWL_Note_Options : public CPWL_Wnd {
- public:
- CPWL_Note_Options();
- ~CPWL_Note_Options() override;
-
- CFX_FloatRect GetContentRect() const;
- void SetText(const CFX_WideString& sText);
-
- // CPWL_Wnd
- void RePosChildWnd() override;
- void CreateChildWnd(const PWL_CREATEPARAM& cp) override;
- void DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) override;
- void SetTextColor(const CPWL_Color& color) override;
-
- private:
- CPWL_Label* m_pText;
-};
-
-class CPWL_Note_Contents : public CPWL_ListCtrl {
- public:
- CPWL_Note_Contents();
- ~CPWL_Note_Contents() override;
-
- void SetEditFocus(FX_BOOL bLast);
- CPWL_Edit* GetEdit() const;
-
- void SetText(const CFX_WideString& sText);
- CFX_WideString GetText() const;
-
- CPWL_NoteItem* CreateSubItem();
- void DeleteSubItem(IPWL_NoteItem* pNoteItem);
- int32_t CountSubItems() const;
- IPWL_NoteItem* GetSubItems(int32_t index) const;
-
- virtual IPWL_NoteItem* GetHitNoteItem(const CFX_FloatPoint& point);
- void EnableRead(FX_BOOL bEnabled);
- void EnableModify(FX_BOOL bEnabled);
-
- // CPWL_ListCtrl
- CFX_ByteString GetClassName() const override;
- void OnNotify(CPWL_Wnd* pWnd,
- uint32_t msg,
- intptr_t wParam = 0,
- intptr_t lParam = 0) override;
- FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override;
- void CreateChildWnd(const PWL_CREATEPARAM& cp) override;
-
- private:
- CPWL_Note_Edit* m_pEdit;
-};
-
-class CPWL_NoteItem : public CPWL_Wnd, public IPWL_NoteItem {
- public:
- CPWL_NoteItem();
- ~CPWL_NoteItem() override;
-
- virtual IPWL_NoteItem* GetHitNoteItem(const CFX_FloatPoint& point);
- virtual IPWL_NoteItem* GetFocusedNoteItem() const;
-
- virtual FX_BOOL IsTopItem() const { return FALSE; }
-
- virtual void ResetSubjectName(int32_t nItemIndex);
- void EnableRead(FX_BOOL bEnabled);
- void EnableModify(FX_BOOL bEnabled);
-
- void OnContentsValidate();
- void OnCreateNoteItem();
-
- // IPWL_NoteItem
- void SetPrivateData(void* pData) override;
- void SetBkColor(const CPWL_Color& color) override;
- void SetSubjectName(const CFX_WideString& sName) override;
- void SetAuthorName(const CFX_WideString& sName) override;
- void SetDateTime(FX_SYSTEMTIME time) override;
- void SetContents(const CFX_WideString& sContents) override;
- IPWL_NoteItem* CreateSubItem() override;
- int32_t CountSubItems() const override;
- IPWL_NoteItem* GetSubItems(int32_t index) const override;
- void DeleteSubItem(IPWL_NoteItem* pNoteItem) override;
- void SetFocus() override { SetNoteFocus(FALSE); }
- IPWL_NoteItem* GetParentItem() const override;
- void* GetPrivateData() const override;
- CFX_WideString GetAuthorName() const override;
- CPWL_Color GetBkColor() const override;
- CFX_WideString GetContents() const override;
- FX_SYSTEMTIME GetDateTime() const override;
- CFX_WideString GetSubjectName() const override;
- CPWL_Edit* GetEdit() const override;
-
- protected:
- // CPWL_Wnd
- FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override;
- FX_BOOL OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override;
- CFX_ByteString GetClassName() const override;
- void RePosChildWnd() override;
- void CreateChildWnd(const PWL_CREATEPARAM& cp) override;
- void OnNotify(CPWL_Wnd* pWnd,
- uint32_t msg,
- intptr_t wParam = 0,
- intptr_t lParam = 0) override;
- FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth) override;
- FX_FLOAT GetItemLeftMargin() override;
- FX_FLOAT GetItemRightMargin() override;
-
- CPWL_NoteItem* CreateNoteItem();
- CPWL_NoteItem* GetParentNoteItem() const;
-
- void SetNoteFocus(FX_BOOL bLast);
- void PopupNoteItemMenu(const CFX_FloatPoint& point);
-
- virtual const CPWL_Note* GetNote() const;
- virtual IPWL_NoteNotify* GetNoteNotify() const;
-
- protected:
- CPWL_Label* m_pSubject;
- CPWL_Label* m_pDateTime;
- CPWL_Note_Contents* m_pContents;
-
- private:
- void* m_pPrivateData;
- FX_SYSTEMTIME m_dtNote;
- CFX_WideString m_sAuthor;
-
- FX_FLOAT m_fOldItemHeight;
- FX_BOOL m_bSizeChanged;
- FX_BOOL m_bAllowModify;
-};
-
-class CPWL_Note : public CPWL_NoteItem {
- public:
- CPWL_Note(IPopup_Note* pPopupNote,
- IPWL_NoteNotify* pNoteNotify,
- IPWL_NoteHandler* pNoteHandler);
- ~CPWL_Note() override;
-
- IPWL_NoteItem* Reply();
- void EnableNotify(FX_BOOL bEnabled);
- void SetIconType(int32_t nType);
- void SetOptionsText(const CFX_WideString& sText);
- void EnableRead(FX_BOOL bEnabled);
- void EnableModify(FX_BOOL bEnabled);
-
- CFX_WideString GetReplyString() const;
- void SetReplyString(const CFX_WideString& str);
-
- // CPWL_NoteItem
- void SetSubjectName(const CFX_WideString& sName) override;
- void SetAuthorName(const CFX_WideString& sName) override;
- CFX_WideString GetAuthorName() const override;
- void SetBkColor(const CPWL_Color& color) override;
- void ResetSubjectName(int32_t nItemIndex) override {}
- FX_BOOL IsTopItem() const override { return TRUE; }
- const CPWL_Note* GetNote() const override;
- IPWL_NoteNotify* GetNoteNotify() const override;
- FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override;
- FX_BOOL OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override;
- FX_BOOL OnMouseWheel(short zDelta,
- const CFX_FloatPoint& point,
- uint32_t nFlag) override;
- void RePosChildWnd() override;
- void CreateChildWnd(const PWL_CREATEPARAM& cp) override;
- void OnNotify(CPWL_Wnd* pWnd,
- uint32_t msg,
- intptr_t wParam = 0,
- intptr_t lParam = 0) override;
-
- protected:
- FX_BOOL ResetScrollBar();
- void RePosNoteChildren();
- FX_BOOL ScrollBarShouldVisible();
-
- private:
- CPWL_Label* m_pAuthor;
- CPWL_Note_Icon* m_pIcon;
- CPWL_Note_CloseBox* m_pCloseBox;
- CPWL_Note_LBBox* m_pLBBox;
- CPWL_Note_RBBox* m_pRBBox;
- CPWL_ScrollBar* m_pContentsBar;
- CPWL_Note_Options* m_pOptions;
- IPWL_NoteNotify* m_pNoteNotify;
- FX_BOOL m_bResizing;
- PWL_SCROLL_INFO m_OldScrollInfo;
- FX_BOOL m_bEnableNotify;
- CFX_WideString m_sReplyString;
-};
-
-#endif // FPDFSDK_PDFWINDOW_PWL_NOTE_H_
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp
index a96cf5f2a52..9532244bc9f 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp
@@ -6,7 +6,7 @@
#include "fpdfsdk/pdfwindow/PWL_ScrollBar.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "fpdfsdk/pdfwindow/PWL_Utils.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
@@ -671,7 +671,7 @@ void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
sButton << "q\n";
sButton << "0 w\n"
<< CPWL_Utils::GetColorAppStream(GetBackgroundColor(), TRUE)
- .AsByteStringC();
+ .AsStringC();
sButton << rectWnd.left << " " << rectWnd.bottom << " "
<< rectWnd.right - rectWnd.left << " "
<< rectWnd.top - rectWnd.bottom << " re b Q\n";
@@ -852,7 +852,7 @@ void CPWL_ScrollBar::CreateButtons(const PWL_CREATEPARAM& cp) {
PWL_CREATEPARAM scp = cp;
scp.pParentWnd = this;
scp.dwBorderWidth = 2;
- scp.nBorderStyle = PBS_BEVELED;
+ scp.nBorderStyle = BorderStyle::BEVELED;
scp.dwFlags =
PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PWS_NOREFRESHCLIP;
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Signature.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Signature.cpp
index 221922972fe..c737998f263 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Signature.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Signature.cpp
@@ -6,7 +6,7 @@
#include "fpdfsdk/pdfwindow/PWL_Signature.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "fpdfsdk/pdfwindow/PWL_Icon.h"
#include "fpdfsdk/pdfwindow/PWL_Label.h"
#include "fpdfsdk/pdfwindow/PWL_Utils.h"
@@ -42,7 +42,7 @@ void CPWL_Signature_Image::DrawThisAppearance(CFX_RenderDevice* pDevice,
void CPWL_Signature_Image::GetThisAppearanceStream(
CFX_ByteTextBuf& sAppStream) {
- sAppStream << CPWL_Image::GetImageAppStream().AsByteStringC();
+ sAppStream << CPWL_Image::GetImageAppStream().AsStringC();
}
void CPWL_Signature_Image::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.cpp
index acd362a29cb..e4232db5e87 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.cpp
@@ -9,8 +9,8 @@
#include <algorithm>
#include "core/fpdfdoc/include/cpvt_word.h"
-#include "core/include/fxge/fx_ge.h"
-#include "fpdfsdk/include/fxedit/fx_edit.h"
+#include "core/fxge/include/fx_ge.h"
+#include "fpdfsdk/fxedit/include/fx_edit.h"
#include "fpdfsdk/pdfwindow/PWL_Icon.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
@@ -44,7 +44,7 @@ CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData,
}
}
- return csAP.GetByteString();
+ return csAP.MakeString();
}
void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path,
@@ -185,7 +185,7 @@ CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) {
<< pts[nNext][0].y << " c\n";
}
- return csAP.GetByteString();
+ return csAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) {
@@ -227,7 +227,7 @@ CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) {
csAP << pt4.x - px * FX_BEZIER << " " << pt4.y << " " << pt1.x << " "
<< pt1.y - py * FX_BEZIER << " " << pt1.x << " " << pt1.y << " c\n";
- return csAP.GetByteString();
+ return csAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) {
@@ -238,7 +238,7 @@ CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) {
csAP << crBBox.left << " " << crBBox.bottom << " m\n";
csAP << crBBox.right << " " << crBBox.top << " l\n";
- return csAP.GetByteString();
+ return csAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) {
@@ -258,7 +258,7 @@ CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) {
csAP << pt4.x << " " << pt4.y << " l\n";
csAP << pt1.x << " " << pt1.y << " l\n";
- return csAP.GetByteString();
+ return csAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) {
@@ -270,7 +270,7 @@ CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) {
csAP << crBBox.left << " " << crBBox.bottom << " l\n";
csAP << crBBox.left << " " << crBBox.top << " l\n";
- return csAP.GetByteString();
+ return csAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) {
@@ -302,7 +302,7 @@ CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) {
csAP << px[nNext] << " " << py[nNext] << " l\n";
}
- return csAP.GetByteString();
+ return csAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox,
@@ -337,7 +337,7 @@ CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox,
csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " "
<< pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
- return csAP.GetByteString();
+ return csAP.MakeString();
}
CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect,
@@ -378,7 +378,6 @@ CFX_FloatRect CPWL_Utils::ScaleRect(const CFX_FloatRect& rcRect,
CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect,
const CPWL_Color& color) {
CFX_ByteTextBuf sAppStream;
-
CFX_ByteString sColor = GetColorAppStream(color, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << "q\n" << sColor;
@@ -387,19 +386,17 @@ CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect,
<< " re f\nQ\n";
}
- return sAppStream.GetByteString();
+ return sAppStream.MakeString();
}
CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect,
const CPWL_Color& color) {
CFX_ByteTextBuf sAppStream;
-
CFX_ByteString sColor = GetColorAppStream(color, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n";
}
-
- return sAppStream.GetByteString();
+ return sAppStream.MakeString();
}
CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) {
@@ -430,152 +427,6 @@ CFX_ByteString CPWL_Utils::GetEditSelAppStream(IFX_Edit* pEdit,
return IFX_Edit::GetSelectAppearanceStream(pEdit, ptOffset, pRange);
}
-static CFX_ByteString GetSquigglyAppearanceStream(FX_FLOAT fStartX,
- FX_FLOAT fEndX,
- FX_FLOAT fY,
- FX_FLOAT fStep) {
- CFX_ByteTextBuf sRet;
-
- sRet << "0 w\n" << fStartX << " " << fY << " m\n";
-
- FX_FLOAT fx;
- int32_t i;
-
- for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
- sRet << fx << " " << fY + (i & 1) * fStep << " l\n";
- }
-
- sRet << "S\n";
-
- return sRet.GetByteString();
-}
-
-static CFX_ByteString GetWordSpellCheckAppearanceStream(
- IFX_Edit_Iterator* pIterator,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange& wrWord) {
- CFX_ByteTextBuf sRet;
-
- FX_FLOAT fStartX = 0.0f;
- FX_FLOAT fEndX = 0.0f;
- FX_FLOAT fY = 0.0f;
- FX_FLOAT fStep = 0.0f;
-
- FX_BOOL bBreak = FALSE;
-
- if (pIterator) {
- pIterator->SetAt(wrWord.BeginPos);
-
- do {
- CPVT_WordPlace place = pIterator->GetAt();
-
- CPVT_Line line;
- if (pIterator->GetLine(line)) {
- fY = line.ptLine.y;
- fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
- }
-
- if (place.LineCmp(wrWord.BeginPos) == 0) {
- pIterator->SetAt(wrWord.BeginPos);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- fStartX = word.ptWord.x;
- }
- } else {
- fStartX = line.ptLine.x;
- }
-
- if (place.LineCmp(wrWord.EndPos) == 0) {
- pIterator->SetAt(wrWord.EndPos);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- fEndX = word.ptWord.x + word.fWidth;
- }
-
- bBreak = TRUE;
- } else {
- fEndX = line.ptLine.x + line.fLineWidth;
- }
-
- sRet << GetSquigglyAppearanceStream(
- fStartX + ptOffset.x, fEndX + ptOffset.x, fY + ptOffset.y, fStep);
-
- if (bBreak)
- break;
- } while (pIterator->NextLine());
- }
-
- return sRet.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetSpellCheckAppStream(
- IFX_Edit* pEdit,
- IPWL_SpellCheck* pSpellCheck,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange) {
- CFX_ByteTextBuf sRet;
-
- if (pRange && pRange->IsExist()) {
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- pIterator->SetAt(pRange->BeginPos);
-
- FX_BOOL bLatinWord = FALSE;
- CPVT_WordPlace wpWordStart;
- CFX_ByteString sWord;
-
- CPVT_WordPlace oldplace;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (FX_EDIT_ISLATINWORD(word.Word)) {
- if (!bLatinWord) {
- wpWordStart = place;
- bLatinWord = TRUE;
- }
-
- sWord += (char)word.Word;
- oldplace = place;
- } else {
- if (bLatinWord) {
- if (!pSpellCheck->CheckWord(sWord)) {
- sRet << GetWordSpellCheckAppearanceStream(
- pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
- pIterator->SetAt(place);
- }
- bLatinWord = FALSE;
- }
-
- sWord.Empty();
- }
- } else {
- if (bLatinWord) {
- if (!pSpellCheck->CheckWord(sWord))
- sRet << GetWordSpellCheckAppearanceStream(
- pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
- bLatinWord = FALSE;
- sWord.Empty();
- }
- }
- }
-
- if (bLatinWord) {
- if (!pSpellCheck->CheckWord(sWord))
- sRet << GetWordSpellCheckAppearanceStream(
- pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
-
- bLatinWord = FALSE;
- sWord.Empty();
- }
- }
- }
-
- return sRet.GetByteString();
-}
-
CFX_ByteString CPWL_Utils::GetTextAppStream(const CFX_FloatRect& rcBBox,
IPVT_FontMap* pFontMap,
const CFX_WideString& sText,
@@ -587,31 +438,28 @@ CFX_ByteString CPWL_Utils::GetTextAppStream(const CFX_FloatRect& rcBBox,
const CPWL_Color& crText) {
CFX_ByteTextBuf sRet;
- if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
- pEdit->SetFontMap(pFontMap);
- pEdit->SetPlateRect(rcBBox);
- pEdit->SetAlignmentH(nAlignmentH);
- pEdit->SetAlignmentV(nAlignmentV);
- pEdit->SetMultiLine(bMultiLine);
- pEdit->SetAutoReturn(bAutoReturn);
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
-
- pEdit->Initialize();
- pEdit->SetText(sText.c_str());
+ IFX_Edit* pEdit = IFX_Edit::NewEdit();
+ pEdit->SetFontMap(pFontMap);
+ pEdit->SetPlateRect(rcBBox);
+ pEdit->SetAlignmentH(nAlignmentH);
+ pEdit->SetAlignmentV(nAlignmentV);
+ pEdit->SetMultiLine(bMultiLine);
+ pEdit->SetAutoReturn(bAutoReturn);
+ if (IsFloatZero(fFontSize))
+ pEdit->SetAutoFontSize(TRUE);
+ else
+ pEdit->SetFontSize(fFontSize);
- CFX_ByteString sEdit =
- CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
- if (sEdit.GetLength() > 0) {
- sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit
- << "ET\n";
- }
- IFX_Edit::DelEdit(pEdit);
- }
+ pEdit->Initialize();
+ pEdit->SetText(sText.c_str());
- return sRet.GetByteString();
+ CFX_ByteString sEdit =
+ CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
+ if (sEdit.GetLength() > 0)
+ sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
+ IFX_Edit::DelEdit(pEdit);
+
+ return sRet.MakeString();
}
CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
@@ -624,222 +472,217 @@ CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
int32_t nLayOut) {
const FX_FLOAT fAutoFontScale = 1.0f / 3.0f;
- if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
- pEdit->SetFontMap(pFontMap);
- pEdit->SetAlignmentH(1);
- pEdit->SetAlignmentV(1);
- pEdit->SetMultiLine(FALSE);
- pEdit->SetAutoReturn(FALSE);
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
-
- pEdit->Initialize();
- pEdit->SetText(sLabel.c_str());
-
- CFX_FloatRect rcLabelContent = pEdit->GetContentRect();
- CPWL_Icon Icon;
- PWL_CREATEPARAM cp;
- cp.dwFlags = PWS_VISIBLE;
- Icon.Create(cp);
- Icon.SetIconFit(&IconFit);
- Icon.SetPDFStream(pIconStream);
-
- CFX_FloatRect rcLabel = CFX_FloatRect(0, 0, 0, 0);
- CFX_FloatRect rcIcon = CFX_FloatRect(0, 0, 0, 0);
- FX_FLOAT fWidth = 0.0f;
- FX_FLOAT fHeight = 0.0f;
-
- switch (nLayOut) {
- case PPBL_LABEL:
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- break;
- case PPBL_ICON:
- rcIcon = rcBBox;
- rcLabel = CFX_FloatRect(0, 0, 0, 0);
- break;
- case PPBL_ICONTOPLABELBOTTOM:
+ IFX_Edit* pEdit = IFX_Edit::NewEdit();
+ pEdit->SetFontMap(pFontMap);
+ pEdit->SetAlignmentH(1);
+ pEdit->SetAlignmentV(1);
+ pEdit->SetMultiLine(FALSE);
+ pEdit->SetAutoReturn(FALSE);
+ if (IsFloatZero(fFontSize))
+ pEdit->SetAutoFontSize(TRUE);
+ else
+ pEdit->SetFontSize(fFontSize);
+
+ pEdit->Initialize();
+ pEdit->SetText(sLabel.c_str());
+
+ CFX_FloatRect rcLabelContent = pEdit->GetContentRect();
+ CPWL_Icon Icon;
+ PWL_CREATEPARAM cp;
+ cp.dwFlags = PWS_VISIBLE;
+ Icon.Create(cp);
+ Icon.SetIconFit(&IconFit);
+ Icon.SetPDFStream(pIconStream);
+
+ CFX_FloatRect rcLabel = CFX_FloatRect(0, 0, 0, 0);
+ CFX_FloatRect rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ FX_FLOAT fWidth = 0.0f;
+ FX_FLOAT fHeight = 0.0f;
+
+ switch (nLayOut) {
+ case PPBL_LABEL:
+ rcLabel = rcBBox;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ break;
+ case PPBL_ICON:
+ rcIcon = rcBBox;
+ rcLabel = CFX_FloatRect(0, 0, 0, 0);
+ break;
+ case PPBL_ICONTOPLABELBOTTOM:
+
+ if (pIconStream) {
+ if (IsFloatZero(fFontSize)) {
+ fHeight = rcBBox.top - rcBBox.bottom;
+ rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
+ rcBBox.bottom + fHeight * fAutoFontScale);
+ rcIcon =
+ CFX_FloatRect(rcBBox.left, rcLabel.top, rcBBox.right, rcBBox.top);
+ } else {
+ fHeight = rcLabelContent.Height();
- if (pIconStream) {
- if (IsFloatZero(fFontSize)) {
- fHeight = rcBBox.top - rcBBox.bottom;
+ if (rcBBox.bottom + fHeight > rcBBox.top) {
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ rcLabel = rcBBox;
+ } else {
rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
- rcBBox.bottom + fHeight * fAutoFontScale);
+ rcBBox.bottom + fHeight);
rcIcon = CFX_FloatRect(rcBBox.left, rcLabel.top, rcBBox.right,
rcBBox.top);
- } else {
- fHeight = rcLabelContent.Height();
-
- if (rcBBox.bottom + fHeight > rcBBox.top) {
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- rcLabel = rcBBox;
- } else {
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
- rcBBox.bottom + fHeight);
- rcIcon = CFX_FloatRect(rcBBox.left, rcLabel.top, rcBBox.right,
- rcBBox.top);
- }
}
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
+ } else {
+ rcLabel = rcBBox;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ }
- break;
- case PPBL_LABELTOPICONBOTTOM:
+ break;
+ case PPBL_LABELTOPICONBOTTOM:
+
+ if (pIconStream) {
+ if (IsFloatZero(fFontSize)) {
+ fHeight = rcBBox.top - rcBBox.bottom;
+ rcLabel =
+ CFX_FloatRect(rcBBox.left, rcBBox.top - fHeight * fAutoFontScale,
+ rcBBox.right, rcBBox.top);
+ rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
+ rcLabel.bottom);
+ } else {
+ fHeight = rcLabelContent.Height();
- if (pIconStream) {
- if (IsFloatZero(fFontSize)) {
- fHeight = rcBBox.top - rcBBox.bottom;
- rcLabel = CFX_FloatRect(rcBBox.left,
- rcBBox.top - fHeight * fAutoFontScale,
+ if (rcBBox.bottom + fHeight > rcBBox.top) {
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ rcLabel = rcBBox;
+ } else {
+ rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.top - fHeight,
rcBBox.right, rcBBox.top);
rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
rcLabel.bottom);
- } else {
- fHeight = rcLabelContent.Height();
-
- if (rcBBox.bottom + fHeight > rcBBox.top) {
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- rcLabel = rcBBox;
- } else {
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.top - fHeight,
- rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
- rcLabel.bottom);
- }
}
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
+ } else {
+ rcLabel = rcBBox;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ }
- break;
- case PPBL_ICONLEFTLABELRIGHT:
-
- if (pIconStream) {
- if (IsFloatZero(fFontSize)) {
- fWidth = rcBBox.right - rcBBox.left;
- rcLabel = CFX_FloatRect(rcBBox.right - fWidth * fAutoFontScale,
- rcBBox.bottom, rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
- rcBBox.top);
+ break;
+ case PPBL_ICONLEFTLABELRIGHT:
- if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
- } else {
- if (rcLabelContent.Width() < fWidth) {
- rcLabel =
- CFX_FloatRect(rcBBox.right - rcLabelContent.Width(),
+ if (pIconStream) {
+ if (IsFloatZero(fFontSize)) {
+ fWidth = rcBBox.right - rcBBox.left;
+ rcLabel = CFX_FloatRect(rcBBox.right - fWidth * fAutoFontScale,
rcBBox.bottom, rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
- rcBBox.top);
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
- }
- } else {
- fWidth = rcLabelContent.Width();
+ rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
+ rcBBox.top);
- if (rcBBox.left + fWidth > rcBBox.right) {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- } else {
- rcLabel = CFX_FloatRect(rcBBox.right - fWidth, rcBBox.bottom,
- rcBBox.right, rcBBox.top);
+ if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
+ } else {
+ if (rcLabelContent.Width() < fWidth) {
+ rcLabel = CFX_FloatRect(rcBBox.right - rcLabelContent.Width(),
+ rcBBox.bottom, rcBBox.right, rcBBox.top);
rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
rcBBox.top);
+ } else {
+ rcLabel = rcBBox;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
}
} else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
+ fWidth = rcLabelContent.Width();
- break;
- case PPBL_LABELLEFTICONRIGHT:
-
- if (pIconStream) {
- if (IsFloatZero(fFontSize)) {
- fWidth = rcBBox.right - rcBBox.left;
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
- rcBBox.left + fWidth * fAutoFontScale,
- rcBBox.top);
- rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
+ if (rcBBox.left + fWidth > rcBBox.right) {
+ rcLabel = rcBBox;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ } else {
+ rcLabel = CFX_FloatRect(rcBBox.right - fWidth, rcBBox.bottom,
+ rcBBox.right, rcBBox.top);
+ rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
rcBBox.top);
+ }
+ }
+ } else {
+ rcLabel = rcBBox;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ }
- if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
- } else {
- if (rcLabelContent.Width() < fWidth) {
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
- rcBBox.left + rcLabelContent.Width(),
- rcBBox.top);
- rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom,
- rcBBox.right, rcBBox.top);
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
- }
+ break;
+ case PPBL_LABELLEFTICONRIGHT:
+
+ if (pIconStream) {
+ if (IsFloatZero(fFontSize)) {
+ fWidth = rcBBox.right - rcBBox.left;
+ rcLabel =
+ CFX_FloatRect(rcBBox.left, rcBBox.bottom,
+ rcBBox.left + fWidth * fAutoFontScale, rcBBox.top);
+ rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
+ rcBBox.top);
+
+ if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
} else {
- fWidth = rcLabelContent.Width();
-
- if (rcBBox.left + fWidth > rcBBox.right) {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- } else {
+ if (rcLabelContent.Width() < fWidth) {
rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
- rcBBox.left + fWidth, rcBBox.top);
+ rcBBox.left + rcLabelContent.Width(),
+ rcBBox.top);
rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
rcBBox.top);
+ } else {
+ rcLabel = rcBBox;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
}
}
} else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
+ fWidth = rcLabelContent.Width();
- break;
- case PPBL_LABELOVERICON:
+ if (rcBBox.left + fWidth > rcBBox.right) {
+ rcLabel = rcBBox;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ } else {
+ rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
+ rcBBox.left + fWidth, rcBBox.top);
+ rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
+ rcBBox.top);
+ }
+ }
+ } else {
rcLabel = rcBBox;
- rcIcon = rcBBox;
- break;
- }
-
- CFX_ByteTextBuf sAppStream, sTemp;
+ rcIcon = CFX_FloatRect(0, 0, 0, 0);
+ }
- if (!rcIcon.IsEmpty()) {
- Icon.Move(rcIcon, FALSE, FALSE);
- sTemp << Icon.GetImageAppStream();
- }
+ break;
+ case PPBL_LABELOVERICON:
+ rcLabel = rcBBox;
+ rcIcon = rcBBox;
+ break;
+ }
- Icon.Destroy();
+ CFX_ByteTextBuf sAppStream, sTemp;
- if (!rcLabel.IsEmpty()) {
- pEdit->SetPlateRect(rcLabel);
- CFX_ByteString sEdit =
- CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
- if (sEdit.GetLength() > 0) {
- sTemp << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit
- << "ET\n";
- }
- }
+ if (!rcIcon.IsEmpty()) {
+ Icon.Move(rcIcon, FALSE, FALSE);
+ sTemp << Icon.GetImageAppStream();
+ }
- IFX_Edit::DelEdit(pEdit);
+ Icon.Destroy();
- if (sTemp.GetSize() > 0) {
- sAppStream << "q\n" << rcBBox.left << " " << rcBBox.bottom << " "
- << rcBBox.right - rcBBox.left << " "
- << rcBBox.top - rcBBox.bottom << " re W n\n";
- sAppStream << sTemp << "Q\n";
+ if (!rcLabel.IsEmpty()) {
+ pEdit->SetPlateRect(rcLabel);
+ CFX_ByteString sEdit =
+ CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
+ if (sEdit.GetLength() > 0) {
+ sTemp << "BT\n"
+ << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
}
-
- return sAppStream.GetByteString();
}
- return "";
+ IFX_Edit::DelEdit(pEdit);
+ if (sTemp.GetSize() > 0) {
+ sAppStream << "q\n"
+ << rcBBox.left << " " << rcBBox.bottom << " "
+ << rcBBox.right - rcBBox.left << " "
+ << rcBBox.top - rcBBox.bottom << " re W n\n";
+ sAppStream << sTemp << "Q\n";
+ }
+ return sAppStream.MakeString();
}
CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color,
@@ -863,7 +706,7 @@ CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color,
break;
}
- return sColorStream.GetByteString();
+ return sColorStream.MakeString();
}
CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
@@ -871,7 +714,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
const CPWL_Color& color,
const CPWL_Color& crLeftTop,
const CPWL_Color& crRightBottom,
- int32_t nStyle,
+ BorderStyle nStyle,
const CPWL_Dash& dash) {
CFX_ByteTextBuf sAppStream;
CFX_ByteString sColor;
@@ -888,7 +731,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
switch (nStyle) {
default:
- case PBS_SOLID:
+ case BorderStyle::SOLID:
sColor = CPWL_Utils::GetColorAppStream(color, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
@@ -900,7 +743,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
sAppStream << "f*\n";
}
break;
- case PBS_DASH:
+ case BorderStyle::DASH:
sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
@@ -919,8 +762,8 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
<< " l S\n";
}
break;
- case PBS_BEVELED:
- case PBS_INSET:
+ case BorderStyle::BEVELED:
+ case BorderStyle::INSET:
sColor = CPWL_Utils::GetColorAppStream(crLeftTop, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
@@ -965,7 +808,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
<< fTop - fBottom - fHalfWidth * 2 << " re f*\n";
}
break;
- case PBS_UNDERLINED:
+ case BorderStyle::UNDERLINE:
sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
@@ -979,7 +822,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
sAppStream << "Q\n";
}
- return sAppStream.GetByteString();
+ return sAppStream.MakeString();
}
CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
@@ -988,7 +831,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
const CPWL_Color& color,
const CPWL_Color& crLeftTop,
const CPWL_Color& crRightBottom,
- int32_t nStyle,
+ BorderStyle nStyle,
const CPWL_Dash& dash) {
CFX_ByteTextBuf sAppStream;
CFX_ByteString sColor;
@@ -998,8 +841,8 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
switch (nStyle) {
default:
- case PBS_SOLID:
- case PBS_UNDERLINED: {
+ case BorderStyle::SOLID:
+ case BorderStyle::UNDERLINE: {
sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
if (sColor.GetLength() > 0) {
sAppStream << "q\n" << fWidth << " w\n" << sColor
@@ -1008,7 +851,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
<< " S\nQ\n";
}
} break;
- case PBS_DASH: {
+ case BorderStyle::DASH: {
sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
if (sColor.GetLength() > 0) {
sAppStream << "q\n" << fWidth << " w\n"
@@ -1019,7 +862,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
<< " S\nQ\n";
}
} break;
- case PBS_BEVELED: {
+ case BorderStyle::BEVELED: {
FX_FLOAT fHalfWidth = fWidth / 2.0f;
sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
@@ -1046,7 +889,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
<< " S\nQ\n";
}
} break;
- case PBS_INSET: {
+ case BorderStyle::INSET: {
FX_FLOAT fHalfWidth = fWidth / 2.0f;
sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
@@ -1078,7 +921,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
sAppStream << "Q\n";
}
- return sAppStream.GetByteString();
+ return sAppStream.MakeString();
}
CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor,
@@ -1137,7 +980,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox,
CFX_ByteTextBuf sAP;
sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
<< CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
+ return sAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox,
@@ -1145,7 +988,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox,
CFX_ByteTextBuf sAP;
sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
<< CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
+ return sAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox,
@@ -1153,7 +996,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox,
CFX_ByteTextBuf sAP;
sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, FALSE)
<< CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n";
- return sAP.GetByteString();
+ return sAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox,
@@ -1161,7 +1004,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox,
CFX_ByteTextBuf sAP;
sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
<< CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
+ return sAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox,
@@ -1169,7 +1012,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox,
CFX_ByteTextBuf sAP;
sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
<< CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
+ return sAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox,
@@ -1177,7 +1020,7 @@ CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox,
CFX_ByteTextBuf sAP;
sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
<< CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
+ return sAP.MakeString();
}
CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox,
@@ -1235,11 +1078,12 @@ CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) {
<< rcBBox.top - rcBBox.bottom << " re f\n";
sAppStream << "Q\n";
- sAppStream << "q\n" << CPWL_Utils::GetBorderAppStream(
- rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0),
- CPWL_Color(COLORTYPE_GRAY, 1),
- CPWL_Color(COLORTYPE_GRAY, 0.5), PBS_BEVELED,
- CPWL_Dash(3, 0, 0))
+ sAppStream << "q\n"
+ << CPWL_Utils::GetBorderAppStream(
+ rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0),
+ CPWL_Color(COLORTYPE_GRAY, 1),
+ CPWL_Color(COLORTYPE_GRAY, 0.5), BorderStyle::BEVELED,
+ CPWL_Dash(3, 0, 0))
<< "Q\n";
CFX_FloatPoint ptCenter = CFX_FloatPoint((rcBBox.left + rcBBox.right) / 2,
@@ -1256,7 +1100,7 @@ CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) {
}
}
- return sAppStream.GetByteString();
+ return sAppStream.MakeString();
}
void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC,
@@ -1479,7 +1323,7 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
const CPWL_Color& color,
const CPWL_Color& crLeftTop,
const CPWL_Color& crRightBottom,
- int32_t nStyle,
+ BorderStyle nStyle,
int32_t nTransparancy) {
FX_FLOAT fLeft = rect.left;
FX_FLOAT fRight = rect.right;
@@ -1491,7 +1335,7 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
switch (nStyle) {
default:
- case PBS_SOLID: {
+ case BorderStyle::SOLID: {
CFX_PathData path;
path.AppendRect(fLeft, fBottom, fRight, fTop);
path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth,
@@ -1499,8 +1343,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
pDevice->DrawPath(&path, pUser2Device, NULL,
PWLColorToFXColor(color, nTransparancy), 0,
FXFILL_ALTERNATE);
- } break;
- case PBS_DASH: {
+ break;
+ }
+ case BorderStyle::DASH: {
CFX_PathData path;
path.SetPointCount(5);
@@ -1525,9 +1370,10 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
PWLColorToFXColor(color, nTransparancy),
FXFILL_WINDING);
- } break;
- case PBS_BEVELED:
- case PBS_INSET: {
+ break;
+ }
+ case BorderStyle::BEVELED:
+ case BorderStyle::INSET: {
CFX_GraphStateData gsd;
gsd.m_LineWidth = fHalfWidth;
@@ -1580,8 +1426,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
pDevice->DrawPath(&path, pUser2Device, &gsd,
PWLColorToFXColor(color, nTransparancy), 0,
FXFILL_ALTERNATE);
- } break;
- case PBS_UNDERLINED: {
+ break;
+ }
+ case BorderStyle::UNDERLINE: {
CFX_PathData path;
path.SetPointCount(2);
@@ -1594,185 +1441,10 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
PWLColorToFXColor(color, nTransparancy),
FXFILL_ALTERNATE);
- } break;
- case PBS_SHADOW: {
- CFX_PathData path;
- path.AppendRect(fLeft, fBottom, fRight, fTop);
- path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth,
- fTop - fWidth);
- pDevice->DrawPath(&path, pUser2Device, NULL,
- PWLColorToFXColor(color, nTransparancy / 2), 0,
- FXFILL_ALTERNATE);
- } break;
- }
- }
-}
-
-static void AddSquigglyPath(CFX_PathData& PathData,
- FX_FLOAT fStartX,
- FX_FLOAT fEndX,
- FX_FLOAT fY,
- FX_FLOAT fStep) {
- PathData.AddPointCount(1);
- PathData.SetPoint(PathData.GetPointCount() - 1, fStartX, fY, FXPT_MOVETO);
-
- FX_FLOAT fx;
- int32_t i;
-
- for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
- PathData.AddPointCount(1);
- PathData.SetPoint(PathData.GetPointCount() - 1, fx, fY + (i & 1) * fStep,
- FXPT_LINETO);
- }
-}
-
-static void AddSpellCheckObj(CFX_PathData& PathData,
- IFX_Edit* pEdit,
- const CPVT_WordRange& wrWord) {
- FX_FLOAT fStartX = 0.0f;
- FX_FLOAT fEndX = 0.0f;
- FX_FLOAT fY = 0.0f;
- FX_FLOAT fStep = 0.0f;
-
- FX_BOOL bBreak = FALSE;
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- pIterator->SetAt(wrWord.BeginPos);
-
- do {
- CPVT_WordPlace place = pIterator->GetAt();
-
- CPVT_Line line;
- if (pIterator->GetLine(line)) {
- fY = line.ptLine.y;
- fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
- }
-
- if (place.LineCmp(wrWord.BeginPos) == 0) {
- pIterator->SetAt(wrWord.BeginPos);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- fStartX = word.ptWord.x;
- }
- } else {
- fStartX = line.ptLine.x;
- }
-
- if (place.LineCmp(wrWord.EndPos) == 0) {
- pIterator->SetAt(wrWord.EndPos);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- fEndX = word.ptWord.x + word.fWidth;
- }
-
- bBreak = TRUE;
- } else {
- fEndX = line.ptLine.x + line.fLineWidth;
- }
-
- AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
-
- if (bBreak)
break;
- } while (pIterator->NextLine());
- }
-}
-
-void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- IFX_Edit* pEdit,
- const CFX_FloatRect& rcClip,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange,
- IPWL_SpellCheck* pSpellCheck) {
- const FX_COLORREF crSpell = ArgbEncode(255, 255, 0, 0);
-
- // for spellcheck
- FX_BOOL bLatinWord = FALSE;
- CPVT_WordPlace wpWordStart;
- CFX_ByteString sLatinWord;
-
- CFX_PathData pathSpell;
-
- pDevice->SaveState();
-
- if (!rcClip.IsEmpty()) {
- CFX_FloatRect rcTemp = rcClip;
- pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(rcTemp.ToFxRect());
- }
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (FX_EDIT_ISLATINWORD(word.Word)) {
- if (!bLatinWord) {
- wpWordStart = place;
- bLatinWord = TRUE;
- }
-
- sLatinWord += (char)word.Word;
- } else {
- if (bLatinWord) {
- if (!sLatinWord.IsEmpty()) {
- if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
- AddSpellCheckObj(pathSpell, pEdit,
- CPVT_WordRange(wpWordStart, oldplace));
- pIterator->SetAt(place);
- }
- }
- bLatinWord = FALSE;
- }
-
- sLatinWord.Empty();
- }
-
- oldplace = place;
- } else {
- if (bLatinWord) {
- if (!sLatinWord.IsEmpty()) {
- if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
- AddSpellCheckObj(pathSpell, pEdit,
- CPVT_WordRange(wpWordStart, oldplace));
- pIterator->SetAt(place);
- }
- }
- bLatinWord = FALSE;
- }
-
- sLatinWord.Empty();
- }
- }
-
- if (!sLatinWord.IsEmpty()) {
- if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
- AddSpellCheckObj(pathSpell, pEdit,
- CPVT_WordRange(wpWordStart, oldplace));
- }
}
}
}
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 0;
- if (pathSpell.GetPointCount() > 0)
- pDevice->DrawPath(&pathSpell, pUser2Device, &gsd, 0, crSpell,
- FXFILL_ALTERNATE);
-
- pDevice->RestoreState();
}
FX_BOOL CPWL_Utils::IsBlackOrWhite(const CPWL_Color& color) {
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.h b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.h
index 76c3c478b7a..8ab08a857e6 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.h
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Utils.h
@@ -100,8 +100,6 @@ class CPWL_PathData {
PWL_PATHDATA_TYPE type;
};
-class IPWL_SpellCheck;
-
class CPWL_Utils {
public:
static CFX_FloatRect InflateRect(const CFX_FloatRect& rcRect, FX_FLOAT fSize);
@@ -138,7 +136,7 @@ class CPWL_Utils {
const CPWL_Color& color,
const CPWL_Color& crLeftTop,
const CPWL_Color& crRightBottom,
- int32_t nStyle,
+ BorderStyle nStyle,
const CPWL_Dash& dash);
static CFX_ByteString GetCircleBorderAppStream(
const CFX_FloatRect& rect,
@@ -146,7 +144,7 @@ class CPWL_Utils {
const CPWL_Color& color,
const CPWL_Color& crLeftTop,
const CPWL_Color& crRightBottom,
- int32_t nStyle,
+ BorderStyle nStyle,
const CPWL_Dash& dash);
static CFX_ByteString GetRectFillAppStream(const CFX_FloatRect& rect,
const CPWL_Color& color);
@@ -177,11 +175,6 @@ class CPWL_Utils {
IFX_Edit* pEdit,
const CFX_FloatPoint& ptOffset,
const CPVT_WordRange* pRange = NULL);
- static CFX_ByteString GetSpellCheckAppStream(
- IFX_Edit* pEdit,
- IPWL_SpellCheck* pSpellCheck,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange = NULL);
static CFX_ByteString GetTextAppStream(const CFX_FloatRect& rcBBox,
IPVT_FontMap* pFontMap,
const CFX_WideString& sText,
@@ -220,7 +213,7 @@ class CPWL_Utils {
const CPWL_Color& color,
const CPWL_Color& crLeftTop,
const CPWL_Color& crRightBottom,
- int32_t nStyle,
+ BorderStyle nStyle,
int32_t nTransparancy);
static void DrawFillArea(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
@@ -235,13 +228,6 @@ class CPWL_Utils {
int32_t nTransparancy,
int32_t nStartGray,
int32_t nEndGray);
- static void DrawEditSpellCheck(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- IFX_Edit* pEdit,
- const CFX_FloatRect& rcClip,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange,
- IPWL_SpellCheck* pSpellCheck);
public:
static void ConvertCMYK2RGB(FX_FLOAT dC,
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.cpp
index 538651797e0..310f2f3f900 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.cpp
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.cpp
@@ -17,7 +17,7 @@ static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() {
}
CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached,
- IFX_SystemHandler* pSystemHandler)
+ CFX_SystemHandler* pSystemHandler)
: m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) {
ASSERT(m_pAttached);
ASSERT(m_pSystemHandler);
@@ -398,7 +398,7 @@ void CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) {
rcWin.right += PWL_INVALIDATE_INFLATE;
rcWin.bottom += PWL_INVALIDATE_INFLATE;
- if (IFX_SystemHandler* pSH = GetSystemHandler()) {
+ if (CFX_SystemHandler* pSH = GetSystemHandler()) {
if (FX_HWND hWnd = GetAttachedHWnd()) {
pSH->InvalidateRect(hWnd, rcWin);
}
@@ -585,11 +585,11 @@ CPWL_Color CPWL_Wnd::GetTextStrokeColor() const {
return m_sPrivateParam.sTextStrokeColor;
}
-int32_t CPWL_Wnd::GetBorderStyle() const {
+BorderStyle CPWL_Wnd::GetBorderStyle() const {
return m_sPrivateParam.nBorderStyle;
}
-void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) {
+void CPWL_Wnd::SetBorderStyle(BorderStyle nBorderStyle) {
if (HasFlag(PWS_BORDER))
m_sPrivateParam.nBorderStyle = nBorderStyle;
}
@@ -744,7 +744,7 @@ void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM& cp) {}
void CPWL_Wnd::SetCursor() {
if (IsValid()) {
- if (IFX_SystemHandler* pSH = GetSystemHandler()) {
+ if (CFX_SystemHandler* pSH = GetSystemHandler()) {
int32_t nCursorType = GetCreationParam().eCursorType;
pSH->SetCursor(nCursorType);
}
@@ -803,7 +803,7 @@ void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize) {
m_sPrivateParam.fFontSize = fFontSize;
}
-IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const {
+CFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const {
return m_sPrivateParam.pSystemHandler;
}
@@ -819,46 +819,26 @@ IPVT_FontMap* CPWL_Wnd::GetFontMap() const {
return m_sPrivateParam.pFontMap;
}
-CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const {
- CPWL_Color color;
-
+CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(BorderStyle nBorderStyle) const {
switch (nBorderStyle) {
- case PBS_SOLID:
- break;
- case PBS_DASH:
- break;
- case PBS_BEVELED:
- color = CPWL_Color(COLORTYPE_GRAY, 1);
- break;
- case PBS_INSET:
- color = CPWL_Color(COLORTYPE_GRAY, 0.5f);
- break;
- case PBS_UNDERLINED:
- break;
+ case BorderStyle::BEVELED:
+ return CPWL_Color(COLORTYPE_GRAY, 1);
+ case BorderStyle::INSET:
+ return CPWL_Color(COLORTYPE_GRAY, 0.5f);
+ default:
+ return CPWL_Color();
}
-
- return color;
}
-CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const {
- CPWL_Color color;
-
+CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(BorderStyle nBorderStyle) const {
switch (nBorderStyle) {
- case PBS_SOLID:
- break;
- case PBS_DASH:
- break;
- case PBS_BEVELED:
- color = CPWL_Utils::DevideColor(GetBackgroundColor(), 2);
- break;
- case PBS_INSET:
- color = CPWL_Color(COLORTYPE_GRAY, 0.75f);
- break;
- case PBS_UNDERLINED:
- break;
+ case BorderStyle::BEVELED:
+ return CPWL_Utils::DevideColor(GetBackgroundColor(), 2);
+ case BorderStyle::INSET:
+ return CPWL_Color(COLORTYPE_GRAY, 0.75f);
+ default:
+ return CPWL_Color();
}
-
- return color;
}
int32_t CPWL_Wnd::GetTransparency() {
@@ -1007,7 +987,7 @@ void CPWL_Wnd::OnEnabled() {}
void CPWL_Wnd::OnDisabled() {}
FX_BOOL CPWL_Wnd::IsCTRLpressed(uint32_t nFlag) const {
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
+ if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
return pSystemHandler->IsCTRLKeyDown(nFlag);
}
@@ -1015,7 +995,7 @@ FX_BOOL CPWL_Wnd::IsCTRLpressed(uint32_t nFlag) const {
}
FX_BOOL CPWL_Wnd::IsSHIFTpressed(uint32_t nFlag) const {
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
+ if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
return pSystemHandler->IsSHIFTKeyDown(nFlag);
}
@@ -1023,17 +1003,9 @@ FX_BOOL CPWL_Wnd::IsSHIFTpressed(uint32_t nFlag) const {
}
FX_BOOL CPWL_Wnd::IsALTpressed(uint32_t nFlag) const {
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
+ if (CFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
return pSystemHandler->IsALTKeyDown(nFlag);
}
return FALSE;
}
-
-FX_BOOL CPWL_Wnd::IsINSERTpressed(uint32_t nFlag) const {
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
- return pSystemHandler->IsINSERTKeyDown(nFlag);
- }
-
- return FALSE;
-}
diff --git a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.h b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.h
index f05b1e67846..c8552fb9856 100644
--- a/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.h
+++ b/chromium/third_party/pdfium/fpdfsdk/pdfwindow/PWL_Wnd.h
@@ -9,19 +9,18 @@
#include <vector>
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxcrt/include/fx_basic.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
-#include "fpdfsdk/include/fx_systemhandler.h"
+#include "fpdfsdk/cfx_systemhandler.h"
class CPWL_MsgControl;
class CPWL_ScrollBar;
class CPWL_Timer;
class CPWL_TimerHandler;
class CPWL_Wnd;
+class CFX_SystemHandler;
class IPVT_FontMap;
-class IFX_SystemHandler;
class IPWL_Provider;
-class IPWL_SpellCheck;
// window styles
#define PWS_CHILD 0x80000000L
@@ -65,19 +64,10 @@ class IPWL_SpellCheck;
#define PRES_MULTILINE 0x0001L
#define PRES_AUTORETURN 0x0002L
#define PRES_AUTOSCROLL 0x0004L
-#define PRES_SPELLCHECK 0x0008L
#define PRES_UNDO 0x0100L
#define PRES_MULTIPAGES 0x0200L
#define PRES_TEXTOVERFLOW 0x0400L
-// border style
-#define PBS_SOLID 0
-#define PBS_DASH 1
-#define PBS_BEVELED 2
-#define PBS_INSET 3
-#define PBS_UNDERLINED 4
-#define PBS_SHADOW 5
-
// notification messages
#define PNM_ADDCHILD 0x00000000L
#define PNM_REMOVECHILD 0x00000001L
@@ -168,14 +158,6 @@ inline bool operator!=(const CPWL_Color& c1, const CPWL_Color& c2) {
#define PWL_CBBUTTON_TRIANGLE_HALFLEN 3.0f
#define PWL_INVALIDATE_INFLATE 2
-class IPWL_SpellCheck {
- public:
- virtual ~IPWL_SpellCheck() {}
- virtual FX_BOOL CheckWord(const FX_CHAR* sWord) = 0;
- virtual void SuggestWords(const FX_CHAR* sWord,
- std::vector<CFX_ByteString>& sSuggest) = 0;
-};
-
class IPWL_Provider {
public:
virtual ~IPWL_Provider() {}
@@ -213,8 +195,7 @@ struct PWL_CREATEPARAM {
dwFlags(0),
sBackgroundColor(),
hAttachedWnd(NULL),
- pSpellCheck(NULL),
- nBorderStyle(PBS_SOLID),
+ nBorderStyle(BorderStyle::SOLID),
dwBorderWidth(1),
sBorderColor(),
sTextColor(),
@@ -229,15 +210,14 @@ struct PWL_CREATEPARAM {
mtChild(1, 0, 0, 1, 0, 0) {}
CFX_FloatRect rcRectWnd; // required
- IFX_SystemHandler* pSystemHandler; // required
+ CFX_SystemHandler* pSystemHandler; // required
IPVT_FontMap* pFontMap; // required for text window
IPWL_Provider* pProvider; // required for self coordinate
IPWL_FocusHandler* pFocusHandler; // optional
uint32_t dwFlags; // optional
CPWL_Color sBackgroundColor; // optional
FX_HWND hAttachedWnd; // required for no-reader framework
- IPWL_SpellCheck* pSpellCheck; // required for spellchecking
- int32_t nBorderStyle; // optional
+ BorderStyle nBorderStyle; // optional
int32_t dwBorderWidth; // optional
CPWL_Color sBorderColor; // optional
CPWL_Color sTextColor; // optional
@@ -254,7 +234,7 @@ struct PWL_CREATEPARAM {
class CPWL_Timer {
public:
- CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler);
+ CPWL_Timer(CPWL_TimerHandler* pAttached, CFX_SystemHandler* pSystemHandler);
virtual ~CPWL_Timer();
int32_t SetPWLTimer(int32_t nElapse);
@@ -264,7 +244,7 @@ class CPWL_Timer {
private:
int32_t m_nTimerID;
CPWL_TimerHandler* m_pAttached;
- IFX_SystemHandler* m_pSystemHandler;
+ CFX_SystemHandler* m_pSystemHandler;
};
class CPWL_TimerHandler {
@@ -275,7 +255,7 @@ class CPWL_TimerHandler {
void BeginTimer(int32_t nElapse);
void EndTimer();
virtual void TimerProc();
- virtual IFX_SystemHandler* GetSystemHandler() const = 0;
+ virtual CFX_SystemHandler* GetSystemHandler() const = 0;
private:
CPWL_Timer* m_pTimer;
@@ -334,14 +314,14 @@ class CPWL_Wnd : public CPWL_TimerHandler {
virtual CPWL_Color GetTextStrokeColor() const;
virtual FX_FLOAT GetFontSize() const;
virtual int32_t GetInnerBorderWidth() const;
- virtual CPWL_Color GetBorderLeftTopColor(int32_t nBorderStyle) const;
- virtual CPWL_Color GetBorderRightBottomColor(int32_t nBorderStyle) const;
+ virtual CPWL_Color GetBorderLeftTopColor(BorderStyle nBorderStyle) const;
+ virtual CPWL_Color GetBorderRightBottomColor(BorderStyle nBorderStyle) const;
virtual void SetFontSize(FX_FLOAT fFontSize);
void SetBackgroundColor(const CPWL_Color& color);
void SetClipRect(const CFX_FloatRect& rect);
- void SetBorderStyle(int32_t eBorderStyle);
+ void SetBorderStyle(BorderStyle eBorderStyle);
virtual CFX_FloatRect GetWindowRect() const;
virtual CFX_FloatRect GetClientRect() const;
@@ -353,7 +333,7 @@ class CPWL_Wnd : public CPWL_TimerHandler {
void RemoveFlag(uint32_t dwFlags);
const CFX_FloatRect& GetClipRect() const;
CPWL_Wnd* GetParentWindow() const;
- int32_t GetBorderStyle() const;
+ BorderStyle GetBorderStyle() const;
const CPWL_Dash& GetBorderDash() const;
void* GetAttachedData() const;
@@ -394,7 +374,7 @@ class CPWL_Wnd : public CPWL_TimerHandler {
protected:
// CPWL_TimerHandler
- IFX_SystemHandler* GetSystemHandler() const override;
+ CFX_SystemHandler* GetSystemHandler() const override;
virtual void CreateChildWnd(const PWL_CREATEPARAM& cp);
virtual void RePosChildWnd();
@@ -437,7 +417,6 @@ class CPWL_Wnd : public CPWL_TimerHandler {
FX_BOOL IsCTRLpressed(uint32_t nFlag) const;
FX_BOOL IsSHIFTpressed(uint32_t nFlag) const;
FX_BOOL IsALTpressed(uint32_t nFlag) const;
- FX_BOOL IsINSERTpressed(uint32_t nFlag) const;
private:
void AddChild(CPWL_Wnd* pWnd);
diff --git a/chromium/third_party/pdfium/infra/config/cq.cfg b/chromium/third_party/pdfium/infra/config/cq.cfg
index 0a494e8c04c..4ab16aaff58 100644
--- a/chromium/third_party/pdfium/infra/config/cq.cfg
+++ b/chromium/third_party/pdfium/infra/config/cq.cfg
@@ -15,6 +15,10 @@ verifiers {
committer_list: "project-pdfium-committers"
}
+ tree_status {
+ tree_status_url: "https://pdfium-status.appspot.com"
+ }
+
try_job {
buckets {
name: "master.tryserver.client.pdfium"
@@ -45,6 +49,15 @@ verifiers {
builders {
name: "win_no_v8"
}
+ builders {
+ name: "linux_xfa_rel_gn"
+ }
+ builders {
+ name: "mac_xfa_rel_gn"
+ }
+ builders {
+ name: "win_xfa_64_rel_gn"
+ }
}
}
}
diff --git a/chromium/third_party/pdfium/pdfium.gni b/chromium/third_party/pdfium/pdfium.gni
index ec71db9e2b1..9e20f96bf7a 100644
--- a/chromium/third_party/pdfium/pdfium.gni
+++ b/chromium/third_party/pdfium/pdfium.gni
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build_overrides/pdfium.gni")
+
# This file contains PDFium-related build flags.
declare_args() {
@@ -10,11 +12,14 @@ declare_args() {
pdfium_bundle_freetype = !is_linux
# Build PDFium either with or without v8 support.
- pdf_enable_v8 = true
+ pdf_enable_v8 = pdf_enable_v8_override
# Build PDFium either with or without XFA Forms support.
- pdf_enable_xfa = false
+ pdf_enable_xfa = pdf_enable_xfa_override
# Build PDFium against skia (experimental) rather than agg.
- pdf_use_skia = false
+ pdf_use_skia = pdf_use_skia_override
+
+ # Build PDFium standalone
+ pdf_is_standalone = false
}
diff --git a/chromium/third_party/pdfium/pdfium.gyp b/chromium/third_party/pdfium/pdfium.gyp
index b13fcef89a5..310fec5bf4b 100644
--- a/chromium/third_party/pdfium/pdfium.gyp
+++ b/chromium/third_party/pdfium/pdfium.gyp
@@ -4,8 +4,7 @@
{
'variables': {
- # TODO(thakis): Enable this, pdfium:29
- #'chromium_code': 1,
+ 'chromium_code': 1,
'variables': {
'clang_use_pdfium_plugins%': 0,
@@ -95,14 +94,6 @@
'msvs_disabled_warnings': [
4267,
],
- 'variables': {
- 'clang_warning_flags': [
- # TODO(thestig): Fix all instances, remove this, pdfium:29
- '-Wno-sign-compare',
- ],
- # Make sure Chromium's build/common.gypi doesn't re-add the flag on linux.
- 'cflags_cc!': [ '-Wsign-compare' ],
- },
},
'targets': [
{
@@ -124,6 +115,8 @@
'pdfwindow',
],
'sources': [
+ 'fpdfsdk/cfx_systemhandler.cpp',
+ 'fpdfsdk/cfx_systemhandler.h',
'fpdfsdk/include/fsdk_actionhandler.h',
'fpdfsdk/include/fsdk_annothandler.h',
'fpdfsdk/include/fsdk_baseannot.h',
@@ -219,8 +212,8 @@
'target_name': 'fpdfdoc',
'type': 'static_library',
'sources': [
- 'core/include/fpdfdoc/fpdf_doc.h',
- 'core/include/fpdfdoc/fpdf_tagged.h',
+ 'core/fpdfdoc/include/fpdf_doc.h',
+ 'core/fpdfdoc/include/fpdf_tagged.h',
'core/fpdfdoc/cpdf_variabletext.cpp',
'core/fpdfdoc/cpvt_color.cpp',
'core/fpdfdoc/cpvt_color.h',
@@ -233,7 +226,9 @@
'core/fpdfdoc/cpvt_lineinfo.h',
'core/fpdfdoc/cpvt_sectioninfo.h',
'core/fpdfdoc/cpvt_wordinfo.h',
+ 'core/fpdfdoc/csection.cpp',
'core/fpdfdoc/csection.h',
+ 'core/fpdfdoc/ctypeset.cpp',
'core/fpdfdoc/ctypeset.h',
'core/fpdfdoc/doc_action.cpp',
'core/fpdfdoc/doc_annot.cpp',
@@ -258,7 +253,7 @@
'core/fpdfdoc/include/cpvt_wordplace.h',
'core/fpdfdoc/include/cpvt_wordprops.h',
'core/fpdfdoc/include/cpvt_wordrange.h',
- 'core/fpdfdoc/ipvt_fontmap.h',
+ 'core/fpdfdoc/include/ipvt_fontmap.h',
'core/fpdfdoc/pdf_vt.h',
'core/fpdfdoc/tagged_int.h',
],
@@ -334,7 +329,6 @@
'core/fpdfapi/fpdf_edit/editint.h',
'core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp',
'core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp',
- 'core/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp',
'core/fpdfapi/fpdf_edit/include/cpdf_creator.h',
'core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h',
'core/fpdfapi/fpdf_font/cpdf_cidfont.cpp',
@@ -388,12 +382,12 @@
'core/fpdfapi/fpdf_page/cpdf_meshstream.cpp',
'core/fpdfapi/fpdf_page/cpdf_meshstream.h',
'core/fpdfapi/fpdf_page/cpdf_page.cpp',
+ "core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp",
+ "core/fpdfapi/fpdf_page/cpdf_pagemodule.h",
'core/fpdfapi/fpdf_page/cpdf_pageobject.cpp',
'core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp',
'core/fpdfapi/fpdf_page/cpdf_pageobjectlist.cpp',
'core/fpdfapi/fpdf_page/cpdf_pageobjectlist.h',
- 'core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp',
- 'core/fpdfapi/fpdf_page/cpdf_parseoptions.h',
'core/fpdfapi/fpdf_page/cpdf_pathobject.cpp',
'core/fpdfapi/fpdf_page/cpdf_pattern.cpp',
'core/fpdfapi/fpdf_page/cpdf_pattern.h',
@@ -411,7 +405,6 @@
'core/fpdfapi/fpdf_page/fpdf_page_func.cpp',
'core/fpdfapi/fpdf_page/fpdf_page_parser.cpp',
'core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp',
- 'core/fpdfapi/fpdf_page/fpdf_page_pattern.cpp',
'core/fpdfapi/fpdf_page/include/cpdf_clippath.h',
'core/fpdfapi/fpdf_page/include/cpdf_color.h',
'core/fpdfapi/fpdf_page/include/cpdf_colorspace.h',
@@ -433,6 +426,8 @@
'core/fpdfapi/fpdf_parser/cpdf_array.cpp',
'core/fpdfapi/fpdf_parser/cpdf_boolean.cpp',
'core/fpdfapi/fpdf_parser/cpdf_boolean.h',
+ 'core/fpdfapi/fpdf_parser/cpdf_crypto_handler.cpp',
+ 'core/fpdfapi/fpdf_parser/cpdf_crypto_handler.h',
'core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp',
'core/fpdfapi/fpdf_parser/cpdf_data_avail.h',
'core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp',
@@ -447,11 +442,9 @@
'core/fpdfapi/fpdf_parser/cpdf_object.cpp',
'core/fpdfapi/fpdf_parser/cpdf_parser.cpp',
'core/fpdfapi/fpdf_parser/cpdf_reference.cpp',
+ 'core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp',
+ 'core/fpdfapi/fpdf_parser/cpdf_security_handler.h',
'core/fpdfapi/fpdf_parser/cpdf_simple_parser.cpp',
- 'core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.cpp',
- 'core/fpdfapi/fpdf_parser/cpdf_standard_crypto_handler.h',
- 'core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp',
- 'core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.h',
'core/fpdfapi/fpdf_parser/cpdf_stream.cpp',
'core/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp',
'core/fpdfapi/fpdf_parser/cpdf_string.cpp',
@@ -476,10 +469,6 @@
'core/fpdfapi/fpdf_parser/include/cpdf_string.h',
'core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h',
'core/fpdfapi/fpdf_parser/include/ipdf_data_avail.h',
- 'core/fpdfapi/fpdf_parser/ipdf_occontext.h',
- 'core/fpdfapi/fpdf_parser/ipdf_occontext.cpp',
- 'core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h',
- 'core/fpdfapi/fpdf_parser/ipdf_security_handler.h',
'core/fpdfapi/fpdf_render/cpdf_pagerendercache.h',
'core/fpdfapi/fpdf_render/fpdf_render.cpp',
'core/fpdfapi/fpdf_render/fpdf_render_cache.cpp',
@@ -493,21 +482,16 @@
'core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h',
'core/fpdfapi/fpdf_render/render_int.h',
'core/fpdfapi/include/cpdf_modulemgr.h',
- 'core/fpdfapi/ipdf_rendermodule.h',
- 'core/fpdfapi/ipdf_pagemodule.h',
],
},
{
'target_name': 'fpdftext',
'type': 'static_library',
'sources': [
- 'core/fpdftext/include/ipdf_linkextract.h',
- 'core/fpdftext/include/ipdf_textpage.h',
- 'core/fpdftext/include/ipdf_textpagefind.h',
+ 'core/fpdftext/include/cpdf_linkextract.h',
+ 'core/fpdftext/include/cpdf_textpage.h',
+ 'core/fpdftext/include/cpdf_textpagefind.h',
'core/fpdftext/fpdf_text_int.cpp',
- 'core/fpdftext/fpdf_text_int.h',
- 'core/fpdftext/unicodenormalization.cpp',
- 'core/fpdftext/unicodenormalization.h',
'core/fpdftext/unicodenormalizationdata.cpp',
'core/fpdftext/unicodenormalizationdata.h',
],
@@ -522,9 +506,17 @@
'third_party/third_party.gyp:fx_zlib',
],
'sources': [
- 'core/include/fxcodec/fx_codec.h',
- 'core/include/fxcodec/fx_codec_def.h',
- 'core/include/fxcodec/fx_codec_flate.h',
+ 'core/fxcodec/include/fx_codec.h',
+ 'core/fxcodec/include/fx_codec_def.h',
+ 'core/fxcodec/include/fx_codec_flate.h',
+ 'core/fxcodec/codec/ccodec_basicmodule.h',
+ 'core/fxcodec/codec/ccodec_faxmodule.h',
+ 'core/fxcodec/codec/ccodec_flatemodule.h',
+ 'core/fxcodec/codec/ccodec_iccmodule.h',
+ 'core/fxcodec/codec/ccodec_jbig2module.h',
+ 'core/fxcodec/codec/ccodec_jpegmodule.h',
+ 'core/fxcodec/codec/ccodec_jpxmodule.h',
+ 'core/fxcodec/codec/ccodec_scanlinedecoder.h',
'core/fxcodec/codec/codec_int.h',
'core/fxcodec/codec/fx_codec.cpp',
'core/fxcodec/codec/fx_codec_fax.cpp',
@@ -587,12 +579,16 @@
'third_party/third_party.gyp:fx_tiff',
],
'sources': [
+ 'core/fxcodec/codec/ccodec_bmpmodule.h',
+ 'core/fxcodec/codec/ccodec_gifmodule.h',
+ 'core/fxcodec/codec/ccodec_pngmodule.h',
+ 'core/fxcodec/codec/ccodec_tiffmodule.h',
'core/fxcodec/codec/fx_codec_bmp.cpp',
'core/fxcodec/codec/fx_codec_gif.cpp',
'core/fxcodec/codec/fx_codec_png.cpp',
'core/fxcodec/codec/fx_codec_progress.cpp',
- 'core/fxcodec/codec/fx_codec_progress.h',
'core/fxcodec/codec/fx_codec_tiff.cpp',
+ 'core/fxcodec/codec/include/ccodec_progressivedecoder.h',
'core/fxcodec/lbmp/fx_bmp.cpp',
'core/fxcodec/lbmp/fx_bmp.h',
'core/fxcodec/lgif/fx_gif.cpp',
@@ -610,6 +606,7 @@
'target_name': 'fxcrt',
'type': 'static_library',
'sources': [
+ 'core/fxcrt/cfx_string_c_template.h',
'core/fxcrt/cfx_string_data_template.h',
'core/fxcrt/extension.h',
'core/fxcrt/fx_basic_array.cpp',
@@ -654,10 +651,10 @@
'conditions': [
['pdf_enable_xfa==1', {
'sources': [
- 'core/fxcrt/include/fx_arb.h',
'core/fxcrt/fx_arabic.cpp',
- 'core/fxcrt/fx_arabic.h',
'core/fxcrt/fx_basic_maps.cpp',
+ 'core/fxcrt/include/fx_arabic.h',
+ 'core/fxcrt/include/fx_arb.h',
],
}],
],
@@ -669,13 +666,6 @@
'third_party/third_party.gyp:fx_agg',
],
'sources': [
- 'core/include/fxge/fpf.h',
- 'core/include/fxge/fx_dib.h',
- 'core/include/fxge/fx_font.h',
- 'core/include/fxge/fx_freetype.h',
- 'core/include/fxge/fx_ge.h',
- 'core/include/fxge/fx_ge_apple.h',
- 'core/include/fxge/fx_ge_win32.h',
'core/fxge/agg/fx_agg_driver.h',
'core/fxge/agg/fx_agg_driver.cpp',
'core/fxge/android/fpf_skiafont.cpp',
@@ -724,6 +714,12 @@
'core/fxge/ge/fx_ge_ps.cpp',
'core/fxge/ge/fx_ge_text.cpp',
'core/fxge/ge/fx_text_int.h',
+ 'core/fxge/include/fx_dib.h',
+ 'core/fxge/include/fx_font.h',
+ 'core/fxge/include/fx_freetype.h',
+ 'core/fxge/include/fx_ge.h',
+ 'core/fxge/include/fx_ge_apple.h',
+ 'core/fxge/include/fx_ge_win32.h',
],
'variables': {
'clang_warning_flags': [
@@ -760,9 +756,9 @@
'target_name': 'fxedit',
'type': 'static_library',
'sources': [
- 'fpdfsdk/include/fxedit/fx_edit.h',
- 'fpdfsdk/include/fxedit/fxet_edit.h',
- 'fpdfsdk/include/fxedit/fxet_list.h',
+ 'fpdfsdk/fxedit/include/fx_edit.h',
+ 'fpdfsdk/fxedit/include/fxet_edit.h',
+ 'fpdfsdk/fxedit/include/fxet_list.h',
'fpdfsdk/fxedit/fxet_ap.cpp',
'fpdfsdk/fxedit/fxet_edit.cpp',
'fpdfsdk/fxedit/fxet_list.cpp',
@@ -796,8 +792,6 @@
'fpdfsdk/pdfwindow/PWL_ListBox.h',
'fpdfsdk/pdfwindow/PWL_ListCtrl.cpp',
'fpdfsdk/pdfwindow/PWL_ListCtrl.h',
- 'fpdfsdk/pdfwindow/PWL_Note.cpp',
- 'fpdfsdk/pdfwindow/PWL_Note.h',
'fpdfsdk/pdfwindow/PWL_ScrollBar.cpp',
'fpdfsdk/pdfwindow/PWL_ScrollBar.h',
'fpdfsdk/pdfwindow/PWL_Signature.cpp',
@@ -825,10 +819,10 @@
'<(DEPTH)/v8/include',
],
'dependencies': [
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ '<(DEPTH)/v8/src/v8.gyp:v8',
],
'export_dependent_settings': [
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ '<(DEPTH)/v8/src/v8.gyp:v8',
],
'sources!': [
'fpdfsdk/javascript/JS_Runtime_Stub.cpp',
@@ -876,7 +870,7 @@
'fpdfsdk/javascript/resource.h',
'fpdfsdk/javascript/util.cpp',
'fpdfsdk/javascript/util.h',
- 'fpdfsdk/include/jsapi/fxjs_v8.h',
+ 'fpdfsdk/jsapi/include/fxjs_v8.h',
'fpdfsdk/jsapi/fxjs_v8.cpp',
],
}],
@@ -921,6 +915,7 @@
'core/fpdfapi/fpdf_font/fpdf_font_unittest.cpp',
'core/fpdfapi/fpdf_page/fpdf_page_parser_unittest.cpp',
'core/fpdfapi/fpdf_page/fpdf_page_parser_old_unittest.cpp',
+ 'core/fpdfapi/fpdf_parser/cpdf_array_unittest.cpp',
'core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp',
'core/fpdfapi/fpdf_parser/cpdf_parser_unittest.cpp',
'core/fpdfapi/fpdf_parser/cpdf_simple_parser_unittest.cpp',
@@ -957,6 +952,15 @@
'fpdfsdk/javascript/public_methods_unittest.cpp',
],
}],
+ ['pdf_use_skia==1', {
+ 'defines': ['PDF_ENABLE_SKIA'],
+ 'dependencies': [
+ '<(DEPTH)/skia/skia.gyp:skia',
+ ],
+ 'sources': [
+ 'core/fxge/skia/fx_skia_device_unittest.cpp',
+ ],
+ }],
],
},
{
@@ -1003,8 +1007,8 @@
'<(DEPTH)/v8/include',
],
'dependencies': [
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8_libplatform',
+ '<(DEPTH)/v8/src/v8.gyp:v8',
+ '<(DEPTH)/v8/src/v8.gyp:v8_libplatform',
],
'sources': [
'fpdfsdk/javascript/public_methods_embeddertest.cpp',
@@ -1036,8 +1040,8 @@
'<(DEPTH)/v8/include',
],
'dependencies': [
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8_libplatform',
+ '<(DEPTH)/v8/src/v8.gyp:v8',
+ '<(DEPTH)/v8/src/v8.gyp:v8_libplatform',
],
}],
],
@@ -1058,10 +1062,10 @@
'fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp',
'fpdfsdk/fpdfxfa/fpdfxfa_page.cpp',
'fpdfsdk/fpdfxfa/fpdfxfa_util.cpp',
- 'fpdfsdk/include/fpdfxfa/fpdfxfa_app.h',
- 'fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h',
- 'fpdfsdk/include/fpdfxfa/fpdfxfa_page.h',
- 'fpdfsdk/include/fpdfxfa/fpdfxfa_util.h',
+ 'fpdfsdk/fpdfxfa/include/fpdfxfa_app.h',
+ 'fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h',
+ 'fpdfsdk/fpdfxfa/include/fpdfxfa_page.h',
+ 'fpdfsdk/fpdfxfa/include/fpdfxfa_util.h',
],
},
]
diff --git a/chromium/third_party/pdfium/public/fpdf_dataavail.h b/chromium/third_party/pdfium/public/fpdf_dataavail.h
index effa68e1795..5599171619c 100644
--- a/chromium/third_party/pdfium/public/fpdf_dataavail.h
+++ b/chromium/third_party/pdfium/public/fpdf_dataavail.h
@@ -64,7 +64,7 @@ DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail,
// Destroy the |avail| document availability provider.
//
-// |avail| - handle to document availability provider to be destroyed.
+// avail - handle to document availability provider to be destroyed.
DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail);
// Download hints interface. Used to receive hints for further downloading.
diff --git a/chromium/third_party/pdfium/public/fpdf_ext.h b/chromium/third_party/pdfium/public/fpdf_ext.h
index c80dcbbf58f..d00c568241f 100644
--- a/chromium/third_party/pdfium/public/fpdf_ext.h
+++ b/chromium/third_party/pdfium/public/fpdf_ext.h
@@ -11,98 +11,87 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif // __cplusplus
-// flags for type of unsupport object.
+// Unsupported XFA form.
#define FPDF_UNSP_DOC_XFAFORM 1
+// Unsupported portable collection.
#define FPDF_UNSP_DOC_PORTABLECOLLECTION 2
+// Unsupported attachment.
#define FPDF_UNSP_DOC_ATTACHMENT 3
+// Unsupported security.
#define FPDF_UNSP_DOC_SECURITY 4
+// Unsupported shared review.
#define FPDF_UNSP_DOC_SHAREDREVIEW 5
+// Unsupported shared form, acrobat.
#define FPDF_UNSP_DOC_SHAREDFORM_ACROBAT 6
+// Unsupported shared form, filesystem.
#define FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM 7
+// Unsupported shared form, email.
#define FPDF_UNSP_DOC_SHAREDFORM_EMAIL 8
+// Unsupported 3D annotation.
#define FPDF_UNSP_ANNOT_3DANNOT 11
+// Unsupported movie annotation.
#define FPDF_UNSP_ANNOT_MOVIE 12
+// Unsupported sound annotation.
#define FPDF_UNSP_ANNOT_SOUND 13
+// Unsupported screen media annotation.
#define FPDF_UNSP_ANNOT_SCREEN_MEDIA 14
+// Unsupported screen rich media annotation.
#define FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA 15
+// Unsupported attachment annotation.
#define FPDF_UNSP_ANNOT_ATTACHMENT 16
+// Unsupported signature annotation.
#define FPDF_UNSP_ANNOT_SIG 17
+// Interface for unsupported feature notifications.
typedef struct _UNSUPPORT_INFO {
- /**
- * Version number of the interface. Currently must be 1.
- **/
+ // Version number of the interface. Must be 1.
int version;
- /**
- * Method: FSDK_UnSupport_Handler
- * UnSupport Object process handling function.
- * Interface Version:
- * 1
- * Implementation Required:
- * Yes
- * Parameters:
- * pThis - Pointer to the interface structure itself.
- * nType - The type of unsupportObject
- * Return value:
- * None.
- * */
-
+ // Unsupported object notification function.
+ // Interface Version: 1
+ // Implementation Required: Yes
+ //
+ // pThis - pointer to the interface structure.
+ // nType - the type of unsupported object. One of the |FPDF_UNSP_*| entries.
void (*FSDK_UnSupport_Handler)(struct _UNSUPPORT_INFO* pThis, int nType);
} UNSUPPORT_INFO;
-/**
- * Function: FSDK_SetUnSpObjProcessHandler
- * Setup A UnSupport Object process handler for foxit sdk.
- * Parameters:
- * unsp_info - Pointer to a UNSUPPORT_INFO structure.
- * Return Value:
- * TRUE means successful. FALSE means fails.
- **/
-
+// Setup an unsupported object handler.
+//
+// unsp_info - Pointer to an UNSUPPORT_INFO structure.
+//
+// Returns TRUE on success.
DLLEXPORT FPDF_BOOL STDCALL
FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info);
-// flags for page mode.
-
-// Unknown value
+// Unknown page mode.
#define PAGEMODE_UNKNOWN -1
-
-// Neither document outline nor thumbnail images visible
+// Document outline, and thumbnails hidden.
#define PAGEMODE_USENONE 0
-
-// Document outline visible
+// Document outline visible.
#define PAGEMODE_USEOUTLINES 1
-
-// Thumbnial images visible
+// Thumbnail images visible.
#define PAGEMODE_USETHUMBS 2
-
-// Full-screen mode, with no menu bar, window controls, or any other window
-// visible
+// Full-screen mode, no menu bar, window controls, or other decorations visible.
#define PAGEMODE_FULLSCREEN 3
-
-// Optional content group panel visible
+// Optional content group panel visible.
#define PAGEMODE_USEOC 4
-
-// Attachments panel visible
+// Attachments panel visible.
#define PAGEMODE_USEATTACHMENTS 5
-/**
- * Function: FPDFDoc_GetPageMode
- * Get the document's PageMode(How the document should be displayed
- *when opened)
- * Parameters:
- * doc - Handle to document. Returned by FPDF_LoadDocument
- *function.
- * Return Value:
- * The flags for page mode.
- **/
+// Get the document's PageMode.
+//
+// doc - Handle to document.
+//
+// Returns one of the |PAGEMODE_*| flags defined above.
+//
+// The page mode defines how the document should be initially displayed.
DLLEXPORT int FPDFDoc_GetPageMode(FPDF_DOCUMENT document);
#ifdef __cplusplus
-}
-#endif
+} // extern "C"
+#endif // __cplusplus
#endif // PUBLIC_FPDF_EXT_H_
diff --git a/chromium/third_party/pdfium/public/fpdf_flatten.h b/chromium/third_party/pdfium/public/fpdf_flatten.h
index af77c293432..8d641809fe8 100644
--- a/chromium/third_party/pdfium/public/fpdf_flatten.h
+++ b/chromium/third_party/pdfium/public/fpdf_flatten.h
@@ -9,37 +9,35 @@
#include "fpdfview.h"
-// Result codes.
-#define FLATTEN_FAIL 0 // Flatten operation failed.
-#define FLATTEN_SUCCESS 1 // Flatten operation succeed.
-#define FLATTEN_NOTHINGTODO 2 // There is nothing to be flattened.
-
-// Flags.
+// Flatten operation failed.
+#define FLATTEN_FAIL 0
+// Flatten operation succeed.
+#define FLATTEN_SUCCESS 1
+// Nothing to be flattened.
+#define FLATTEN_NOTHINGTODO 2
+
+// Flatten for normal display.
#define FLAT_NORMALDISPLAY 0
+// Flatten for print.
#define FLAT_PRINT 1
#ifdef __cplusplus
extern "C" {
-#endif
-
-// Function: FPDFPage_Flatten
-// Make annotations and form fields become part of the page contents
-// itself.
-// Parameters:
-// page - Handle to the page, as returned by FPDF_LoadPage().
-// nFlag - Intended use of the flattened result: 0 for normal display,
-// 1 for printing.
-// Return value:
-// Either FLATTEN_FAIL, FLATTEN_SUCCESS, or FLATTEN_NOTHINGTODO (see
-// above).
-// Comments:
-// Currently, all failures return FLATTEN_FAIL, with no indication for
-// the reason
-// for the failure.
+#endif // __cplusplus
+
+// Flatten annotations and form fields into the page contents.
+//
+// page - handle to the page.
+// nFlag - One of the |FLAT_*| values denoting the page usage.
+//
+// Returns one of the |FLATTEN_*| values.
+//
+// Currently, all failures return |FLATTEN_FAIL| with no indication of the
+// cause.
DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag);
#ifdef __cplusplus
-}
-#endif
+} // extern "C"
+#endif // __cplusplus
#endif // PUBLIC_FPDF_FLATTEN_H_
diff --git a/chromium/third_party/pdfium/public/fpdf_fwlevent.h b/chromium/third_party/pdfium/public/fpdf_fwlevent.h
index 22c01e4297a..511c6a34800 100644
--- a/chromium/third_party/pdfium/public/fpdf_fwlevent.h
+++ b/chromium/third_party/pdfium/public/fpdf_fwlevent.h
@@ -11,19 +11,20 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif // __cplusplus
typedef int FPDF_INT32;
typedef unsigned int FPDF_UINT32;
typedef float FPDF_FLOAT;
-// event type
+
+// Event types.
typedef enum {
FWL_EVENTTYPE_Mouse = 0,
FWL_EVENTTYPE_MouseWheel,
FWL_EVENTTYPE_Key,
} FWL_EVENTTYPE;
-// key flag
+// Key flags.
typedef enum {
FWL_EVENTFLAG_ShiftKey = 1 << 0,
FWL_EVENTFLAG_ControlKey = 1 << 1,
@@ -36,7 +37,7 @@ typedef enum {
FWL_EVENTFLAG_RightButtonDown = 1 << 8,
} FWL_EVENTFLAG;
-// Mouse message command
+// Mouse messages.
typedef enum {
FWL_EVENTMOUSECMD_LButtonDown = 1,
FWL_EVENTMOUSECMD_LButtonUp,
@@ -53,7 +54,7 @@ typedef enum {
FWL_EVENTMOUSECMD_MouseLeave,
} FWL_EVENT_MOUSECMD;
-// mouse event
+// Mouse events.
struct FWL_EVENT_MOUSE {
FPDF_UINT32 command;
FPDF_DWORD flag;
@@ -61,7 +62,7 @@ struct FWL_EVENT_MOUSE {
FPDF_FLOAT y;
};
-// mouse wheel
+// Mouse wheel events.
struct FWL_EVENT_MOUSEWHEEL {
FPDF_DWORD flag;
FPDF_FLOAT x;
@@ -70,7 +71,7 @@ struct FWL_EVENT_MOUSEWHEEL {
FPDF_FLOAT deltaY;
};
-// virtual keycode
+// Virtual keycodes.
typedef enum {
FWL_VKEY_Back = 0x08,
FWL_VKEY_Tab = 0x09,
@@ -242,14 +243,14 @@ typedef enum {
FWL_VKEY_Unknown = 0,
} FWL_VKEYCODE;
-// key event command
+// Key event commands.
typedef enum {
FWL_EVENTKEYCMD_KeyDown = 1,
FWL_EVENTKEYCMD_KeyUp,
FWL_EVENTKEYCMD_Char,
} FWL_EVENTKEYCMD;
-// key event
+// Key events.
struct FWL_EVENT_KEY {
FPDF_UINT32 command;
FPDF_DWORD flag;
@@ -261,9 +262,9 @@ struct FWL_EVENT_KEY {
} code;
};
-// event type
+// Event types.
struct FWL_EVENT {
- // structure size.
+ // Structure size.
FPDF_UINT32 size;
// FWL_EVENTTYPE.
FPDF_UINT32 type;
@@ -275,7 +276,7 @@ struct FWL_EVENT {
};
#ifdef __cplusplus
-}
-#endif
+} // extern "C"
+#endif // __cplusplus
#endif // PUBLIC_FPDF_FWLEVENT_H_
diff --git a/chromium/third_party/pdfium/public/fpdf_ppo.h b/chromium/third_party/pdfium/public/fpdf_ppo.h
index e7d77678f95..532494e7fa7 100644
--- a/chromium/third_party/pdfium/public/fpdf_ppo.h
+++ b/chromium/third_party/pdfium/public/fpdf_ppo.h
@@ -13,35 +13,31 @@
extern "C" {
#endif
-// Function: FPDF_ImportPages
-// Import some pages to a PDF document.
-// Parameters:
-// dest_doc - The destination document which add the pages.
-// src_doc - A document to be imported.
-// pagerange - A page range string, Such as "1,3,5-7".
-// If this parameter is NULL, it would import all pages
-// in src_doc.
-// index - The page index wanted to insert from.
-// Return value:
-// TRUE for succeed, FALSE for Failed.
+// Import pages to a FPDF_DOCUMENT.
+//
+// dest_doc - The destination document for the pages.
+// src_doc - The document to be imported.
+// pagerange - A page range string, Such as "1,3,5-7". If |pagerange| is NULL,
+// all pages from |src_doc| are imported.
+// index - The page index to insert at.
+//
+// Returns TRUE on success.
DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
FPDF_DOCUMENT src_doc,
FPDF_BYTESTRING pagerange,
int index);
-// Function: FPDF_CopyViewerPreferences
-// Copy the viewer preferences from one PDF document to another.#endif
-// Parameters:
-// dest_doc - Handle to document to write the viewer preferences
-// to.
-// src_doc - Handle to document with the viewer preferences.
-// Return value:
-// TRUE for success, FALSE for failure.
+// Copy the viewer preferences from |src_doc| into |dest_doc|.
+//
+// dest_doc - Document to write the viewer preferences into.
+// src_doc - Document to read the viewer preferences from.
+//
+// Returns TRUE on success.
DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc,
FPDF_DOCUMENT src_doc);
#ifdef __cplusplus
-}
-#endif
+} // extern "C"
+#endif // __cplusplus
#endif // PUBLIC_FPDF_PPO_H_
diff --git a/chromium/third_party/pdfium/public/fpdf_searchex.h b/chromium/third_party/pdfium/public/fpdf_searchex.h
index a6b6e1bdbff..0d90bdddb91 100644
--- a/chromium/third_party/pdfium/public/fpdf_searchex.h
+++ b/chromium/third_party/pdfium/public/fpdf_searchex.h
@@ -11,22 +11,19 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif // __cplusplus
-// Function: FPDFText_GetCharIndexFromTextIndex
-// Get the actually char index in text_page's internal char list.
-// Parameters:
-// text_page - Handle to a text page information structure.
-// Returned by FPDFText_LoadPage function.
-// nTextIndex - The index of the text in the string get from
-// FPDFText_GetText.
-// Return value:
-// The index of the character in internal charlist. -1 for error.
+// Get the character index in |text_page| internal character list.
+//
+// text_page - a text page information structure.
+// nTextIndex - index of the text returned from |FPDFText_GetText|.
+//
+// Returns the index of the character in internal character list. -1 for error.
DLLEXPORT int STDCALL
FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex);
#ifdef __cplusplus
-}
-#endif
+} // extern "C"
+#endif // __cplusplus
#endif // PUBLIC_FPDF_SEARCHEX_H_
diff --git a/chromium/third_party/pdfium/public/fpdf_text.h b/chromium/third_party/pdfium/public/fpdf_text.h
index 32cc1318592..2bf574b12f0 100644
--- a/chromium/third_party/pdfium/public/fpdf_text.h
+++ b/chromium/third_party/pdfium/public/fpdf_text.h
@@ -351,13 +351,19 @@ DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page);
// Parameters:
// link_page - Handle returned by FPDFLink_LoadWebLinks.
// link_index - Zero-based index for the link.
-// buffer - A unicode buffer.
+// buffer - A unicode buffer for the result.
// buflen - Number of characters (not bytes) for the buffer,
-// including an additional terminator.
+// including an additional terminator.
// Return Value:
-// If buffer is NULL or buflen is zero, return number of characters
-// (not bytes and an additional terminator is also counted) needed,
-// otherwise, return number of characters copied into the buffer.
+// If |buffer| is NULL or |buflen| is zero, return the number of
+// characters (not bytes) needed to buffer the result (an additional
+// terminator is included in this count).
+// Otherwise, copy the result into |buffer|, truncating at |buflen| if
+// the result is too large to fit, and return the number of characters
+// actually copied into the buffer (the additional terminator is also
+// included in this count).
+// If |link_index| does not correspond to a valid link, then the result
+// is an empty string.
//
DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page,
int link_index,
@@ -370,7 +376,8 @@ DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page,
// link_page - Handle returned by FPDFLink_LoadWebLinks.
// link_index - Zero-based index for the link.
// Return Value:
-// Number of rectangular areas for the link.
+// Number of rectangular areas for the link. If |link_index| does
+// not correspond to a valid link, then 0 is returned.
//
DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page,
int link_index);
@@ -382,15 +389,16 @@ DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page,
// link_index - Zero-based index for the link.
// rect_index - Zero-based index for a rectangle.
// left - Pointer to a double value receiving the rectangle
-// left boundary.
+// left boundary.
// top - Pointer to a double value receiving the rectangle
-// top boundary.
+// top boundary.
// right - Pointer to a double value receiving the rectangle
-// right boundary.
+// right boundary.
// bottom - Pointer to a double value receiving the rectangle
-// bottom boundary.
+// bottom boundary.
// Return Value:
-// None.
+// None. If |link_index| does not correspond to a valid link, then
+// |left|, |top|, |right|, and |bottom| remain unmodified.
//
DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page,
int link_index,
diff --git a/chromium/third_party/pdfium/samples/BUILD.gn b/chromium/third_party/pdfium/samples/BUILD.gn
index 5e300158c9a..c2d6eef7d2d 100644
--- a/chromium/third_party/pdfium/samples/BUILD.gn
+++ b/chromium/third_party/pdfium/samples/BUILD.gn
@@ -39,14 +39,15 @@ executable("pdfium_test") {
"pdfium_test.cc",
]
deps = [
+ "../:pdfium",
+ "../:test_support",
"//build/config/sanitizers:deps",
- "//third_party/pdfium:pdfium",
- "//third_party/pdfium:test_support",
+ "//build/win:default_exe_manifest",
# Regardless of whether the library ships against system freetype,
# always link this binary against the bundled one for consistency
# of results across platforms.
- "//third_party/pdfium/third_party:fx_freetype",
+ "../third_party:fx_freetype",
]
if (!pdf_enable_xfa) {
deps += [ "../third_party:fx_lpng" ]
@@ -73,8 +74,9 @@ executable("pdfium_diff") {
"image_diff_png.h",
]
deps = [
+ "../:pdfium",
"//build/config/sanitizers:deps",
- "//third_party/pdfium",
+ "//build/win:default_exe_manifest",
]
if (!pdf_enable_xfa) {
deps += [ "../third_party:fx_lpng" ]
diff --git a/chromium/third_party/pdfium/samples/pdfium_test.cc b/chromium/third_party/pdfium/samples/pdfium_test.cc
index 2ca31b08e9b..149ebf793c1 100644
--- a/chromium/third_party/pdfium/samples/pdfium_test.cc
+++ b/chromium/third_party/pdfium/samples/pdfium_test.cc
@@ -54,9 +54,11 @@ enum OutputFormat {
};
struct Options {
- Options() : show_config(false), output_format(OUTPUT_NONE) {}
+ Options()
+ : show_config(false), send_events(false), output_format(OUTPUT_NONE) {}
bool show_config;
+ bool send_events;
OutputFormat output_format;
std::string scale_factor_as_string;
std::string exe_path;
@@ -220,7 +222,7 @@ void WriteSkp(const char* pdf_name, int num, const void* recorder) {
}
SkPictureRecorder* r = (SkPictureRecorder*)recorder;
- SkPicture* picture = r->endRecordingAsPicture();
+ sk_sp<SkPicture> picture(r->finishRecordingAsPicture());
SkFILEWStream wStream(filename);
picture->serialize(&wStream);
}
@@ -338,6 +340,8 @@ bool ParseCommandLine(const std::vector<std::string>& args,
const std::string& cur_arg = args[cur_idx];
if (cur_arg == "--show-config") {
options->show_config = true;
+ } else if (cur_arg == "--send-events") {
+ options->send_events = true;
} else if (cur_arg == "--ppm") {
if (options->output_format != OUTPUT_NONE) {
fprintf(stderr, "Duplicate or conflicting --ppm argument\n");
@@ -418,11 +422,73 @@ FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) {
void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {
}
+void SendPageEvents(const FPDF_FORMHANDLE& form,
+ const FPDF_PAGE& page,
+ const std::string& events) {
+ auto lines = StringSplit(events, '\n');
+ for (auto line : lines) {
+ auto command = StringSplit(line, '#');
+ if (command[0].empty())
+ continue;
+ auto tokens = StringSplit(command[0], ',');
+ if (tokens[0] == "keycode") {
+ if (tokens.size() == 2) {
+ int keycode = atoi(tokens[1].c_str());
+ FORM_OnKeyDown(form, page, keycode, 0);
+ FORM_OnKeyUp(form, page, keycode, 0);
+ } else {
+ fprintf(stderr, "keycode: bad args\n");
+ }
+ } else if (tokens[0] == "mousedown") {
+ if (tokens.size() == 4) {
+ int x = atoi(tokens[2].c_str());
+ int y = atoi(tokens[3].c_str());
+ if (tokens[1] == "left")
+ FORM_OnLButtonDown(form, page, 0, x, y);
+#ifdef PDF_ENABLE_XFA
+ else if (tokens[1] == "right")
+ FORM_OnRButtonDown(form, page, 0, x, y);
+#endif
+ else
+ fprintf(stderr, "mousedown: bad button name\n");
+ } else {
+ fprintf(stderr, "mousedown: bad args\n");
+ }
+ } else if (tokens[0] == "mouseup") {
+ if (tokens.size() == 4) {
+ int x = atoi(tokens[2].c_str());
+ int y = atoi(tokens[3].c_str());
+ if (tokens[1] == "left")
+ FORM_OnLButtonUp(form, page, 0, x, y);
+#ifdef PDF_ENABLE_XFA
+ else if (tokens[1] == "right")
+ FORM_OnRButtonUp(form, page, 0, x, y);
+#endif
+ else
+ fprintf(stderr, "mouseup: bad button name\n");
+ } else {
+ fprintf(stderr, "mouseup: bad args\n");
+ }
+ } else if (tokens[0] == "mousemove") {
+ if (tokens.size() == 3) {
+ int x = atoi(tokens[1].c_str());
+ int y = atoi(tokens[2].c_str());
+ FORM_OnMouseMove(form, page, 0, x, y);
+ } else {
+ fprintf(stderr, "mousemove: bad args\n");
+ }
+ } else {
+ fprintf(stderr, "Unrecognized event: %s\n", tokens[0].c_str());
+ }
+ }
+}
+
bool RenderPage(const std::string& name,
const FPDF_DOCUMENT& doc,
const FPDF_FORMHANDLE& form,
const int page_index,
- const Options& options) {
+ const Options& options,
+ const std::string& events) {
FPDF_PAGE page = FPDF_LoadPage(doc, page_index);
if (!page) {
return false;
@@ -431,6 +497,9 @@ bool RenderPage(const std::string& name,
FORM_OnAfterLoadPage(page, form);
FORM_DoPageAAction(page, form, FPDFPAGE_AACTION_OPEN);
+ if (options.send_events)
+ SendPageEvents(form, page, events);
+
double scale = 1.0;
if (!options.scale_factor_as_string.empty()) {
std::stringstream(options.scale_factor_as_string) >> scale;
@@ -490,10 +559,11 @@ bool RenderPage(const std::string& name,
return true;
}
-void RenderPdf(const std::string& name, const char* pBuf, size_t len,
- const Options& options) {
- fprintf(stderr, "Rendering PDF file %s.\n", name.c_str());
-
+void RenderPdf(const std::string& name,
+ const char* pBuf,
+ size_t len,
+ const Options& options,
+ const std::string& events) {
IPDF_JSPLATFORM platform_callbacks;
memset(&platform_callbacks, '\0', sizeof(platform_callbacks));
platform_callbacks.version = 3;
@@ -534,7 +604,6 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
FPDF_AVAIL pdf_avail = FPDFAvail_Create(&file_avail, &file_access);
if (FPDFAvail_IsLinearized(pdf_avail) == PDF_LINEARIZED) {
- fprintf(stderr, "Linearized path...\n");
doc = FPDFAvail_GetDocument(pdf_avail, nullptr);
if (doc) {
while (nRet == PDF_DATA_NOTAVAIL) {
@@ -554,7 +623,6 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
bIsLinearized = true;
}
} else {
- fprintf(stderr, "Non-linearized path...\n");
doc = FPDF_LoadCustomDocument(&file_access, nullptr);
}
@@ -623,7 +691,7 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
return;
}
}
- if (RenderPage(name, doc, form, i, options)) {
+ if (RenderPage(name, doc, form, i, options, events)) {
++rendered_pages;
} else {
++bad_pages;
@@ -646,7 +714,8 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
FPDFAvail_Destroy(pdf_avail);
fprintf(stderr, "Rendered %d pages.\n", rendered_pages);
- fprintf(stderr, "Skipped %d bad pages.\n", bad_pages);
+ if (bad_pages)
+ fprintf(stderr, "Skipped %d bad pages.\n", bad_pages);
}
static void ShowConfig() {
@@ -673,6 +742,7 @@ static void ShowConfig() {
static const char usage_string[] =
"Usage: pdfium_test [OPTION] [FILE]...\n"
" --show-config - print build options and exit\n"
+ " --send-events - send input described by .evt file\n"
" --bin-dir=<path> - override path to v8 external data\n"
" --font-dir=<path> - override path to external fonts\n"
" --scale=<number> - scale output size by number (e.g. 0.5)\n"
@@ -744,8 +814,25 @@ int main(int argc, const char* argv[]) {
size_t file_length = 0;
std::unique_ptr<char, pdfium::FreeDeleter> file_contents =
GetFileContents(filename.c_str(), &file_length);
- if (file_contents)
- RenderPdf(filename, file_contents.get(), file_length, options);
+ if (!file_contents)
+ continue;
+ fprintf(stderr, "Rendering PDF file %s.\n", filename.c_str());
+ std::string events;
+ if (options.send_events) {
+ std::string event_filename = filename;
+ size_t event_length = 0;
+ size_t extension_pos = event_filename.find(".pdf");
+ if (extension_pos != std::string::npos) {
+ event_filename.replace(extension_pos, 4, ".evt");
+ std::unique_ptr<char, pdfium::FreeDeleter> event_contents =
+ GetFileContents(event_filename.c_str(), &event_length);
+ if (event_contents) {
+ fprintf(stderr, "Sending events from: %s\n", event_filename.c_str());
+ events = std::string(event_contents.get(), event_length);
+ }
+ }
+ }
+ RenderPdf(filename, file_contents.get(), file_length, options, events);
}
FPDF_DestroyLibrary();
diff --git a/chromium/third_party/pdfium/samples/samples.gyp b/chromium/third_party/pdfium/samples/samples.gyp
index 6bb48af1748..2c956c5eb36 100644
--- a/chromium/third_party/pdfium/samples/samples.gyp
+++ b/chromium/third_party/pdfium/samples/samples.gyp
@@ -64,7 +64,7 @@
}],
['pdf_enable_v8==1', {
'dependencies': [
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8_libplatform',
+ '<(DEPTH)/v8/src/v8.gyp:v8_libplatform',
],
}],
['pdf_use_skia==1', {
diff --git a/chromium/third_party/pdfium/skia/BUILD.gn b/chromium/third_party/pdfium/skia/BUILD.gn
new file mode 100644
index 00000000000..97f6d583e21
--- /dev/null
+++ b/chromium/third_party/pdfium/skia/BUILD.gn
@@ -0,0 +1,562 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/features.gni")
+import("//build/config/ui.gni")
+import("//testing/test.gni")
+
+if (current_cpu == "arm") {
+ import("//build/config/arm.gni")
+}
+if (current_cpu == "mipsel" || current_cpu == "mips64el") {
+ import("//build/config/mips.gni")
+}
+
+skia_support_gpu = !is_ios
+skia_support_pdf = false #!is_ios && (enable_basic_printing || enable_print_preview)
+
+# The list of Skia core sources that are to be set for chromium.
+gypi_skia_core =
+ exec_script("//build/gypi_to_gn.py",
+ [
+ rebase_path("//third_party/skia/gyp/core.gypi"),
+ "--replace=<(skia_include_path)=//third_party/skia/include",
+ "--replace=<(skia_src_path)=//third_party/skia/src",
+ ],
+ "scope",
+ [ "//third_party/skia/gyp/core.gypi" ])
+
+# The list of Skia gpu sources that are to be set for chromium.
+if (skia_support_gpu) {
+ gypi_skia_gpu =
+ exec_script("//build/gypi_to_gn.py",
+ [
+ rebase_path("//third_party/skia/gyp/gpu.gypi"),
+ "--replace=<(skia_include_path)=//third_party/skia/include",
+ "--replace=<(skia_src_path)=//third_party/skia/src",
+ ],
+ "scope",
+ [ "//third_party/skia/gyp/gpu.gypi" ])
+}
+
+# The list of Skia pdf sources that are to be set for chromium.
+if (skia_support_pdf) {
+ gypi_skia_pdf =
+ exec_script("//build/gypi_to_gn.py",
+ [
+ rebase_path("//third_party/skia/gyp/pdf.gypi"),
+ "--replace=<(skia_include_path)=//third_party/skia/include",
+ "--replace=<(skia_src_path)=//third_party/skia/src",
+ ],
+ "scope",
+ [ "//third_party/skia/gyp/pdf.gypi" ])
+}
+
+# The list of Skia effects that are to be set for chromium.
+gypi_skia_effects =
+ exec_script("//build/gypi_to_gn.py",
+ [
+ rebase_path("//third_party/skia/gyp/effects.gypi"),
+ "--replace=<(skia_include_path)=//third_party/skia/include",
+ "--replace=<(skia_src_path)=//third_party/skia/src",
+ ],
+ "scope",
+ [ "//third_party/skia/gyp/effects.gypi" ])
+
+# The list of Skia utils that are to be set for chromium.
+gypi_skia_utils =
+ exec_script("//build/gypi_to_gn.py",
+ [
+ rebase_path("//third_party/skia/gyp/utils.gypi"),
+ "--replace=<(skia_include_path)=//third_party/skia/include",
+ "--replace=<(skia_src_path)=//third_party/skia/src",
+ ],
+ "scope",
+ [ "//third_party/skia/gyp/utils.gypi" ])
+
+gypi_skia_opts =
+ exec_script("//build/gypi_to_gn.py",
+ [
+ rebase_path("//third_party/skia/gyp/opts.gypi"),
+ "--replace=<(skia_include_path)=//third_party/skia/include",
+ "--replace=<(skia_src_path)=//third_party/skia/src",
+ ],
+ "scope",
+ [ "//third_party/skia/gyp/opts.gypi" ])
+
+# The list of Skia files is kept in skia_gn_files.gypi. Read it.
+gypi_values =
+ exec_script("//build/gypi_to_gn.py",
+ [
+ rebase_path("skia_gn_files.gypi"),
+ "--replace=<(skia_include_path)=//third_party/skia/include",
+ "--replace=<(skia_src_path)=//third_party/skia/src",
+ ],
+ "scope",
+ [ "skia_gn_files.gypi" ])
+
+# External-facing config for dependent code.
+config("skia_config") {
+ include_dirs = [
+ "config",
+ "ext",
+ "//third_party/skia/include/c",
+ "//third_party/skia/include/config",
+ "//third_party/skia/include/core",
+ "//third_party/skia/include/effects",
+ "//third_party/skia/include/images",
+ "//third_party/skia/include/lazy",
+ "//third_party/skia/include/pathops",
+ "//third_party/skia/include/pdf",
+ "//third_party/skia/include/pipe",
+ "//third_party/skia/include/ports",
+ "//third_party/skia/include/utils",
+ # TODO(dsinclair): Right way to use //third_party/freetype?
+ "//third_party/freetype/include",
+ ]
+
+ defines = []
+
+ if (skia_support_gpu) {
+ include_dirs += [
+ "//third_party/skia/include/gpu",
+ "//third_party/skia/src/gpu",
+ ]
+ defines += [ "SK_SUPPORT_GPU=1" ]
+ } else {
+ defines += [ "SK_SUPPORT_GPU=0" ]
+ }
+
+ if (is_android) {
+ defines += [
+ "SK_BUILD_FOR_ANDROID",
+ "USE_CHROMIUM_SKIA",
+ ]
+ }
+
+ if (is_mac) {
+ defines += [ "SK_BUILD_FOR_MAC" ]
+ }
+
+ if (is_win) {
+ defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ]
+ }
+}
+
+# Internal-facing config for Skia library code.
+config("skia_library_config") {
+ # These include directories are only included for Skia code and are not
+ # exported to dependents. It's not clear if this is on purpose, but this
+ # matches the GYP build.
+ include_dirs = [
+ "//third_party/skia/include/private",
+ "//third_party/skia/include/client/android",
+ "//third_party/skia/src/core",
+ "//third_party/skia/src/image",
+ "//third_party/skia/src/opts",
+ "//third_party/skia/src/pdf",
+ "//third_party/skia/src/ports",
+ "//third_party/skia/src/sfnt",
+ "//third_party/skia/src/utils",
+ "//third_party/skia/src/lazy",
+ ]
+ if (is_mac || is_ios) {
+ include_dirs += [ "//third_party/skia/include/utils/mac" ]
+ }
+ if (is_mac) {
+ include_dirs += [ "//third_party/skia/include/utils/ios" ]
+ }
+
+ defines = []
+
+ if (current_cpu == "arm") {
+ if (arm_use_neon) {
+ defines += [ "SK_ARM_HAS_NEON" ]
+ } else if (arm_optionally_use_neon) {
+ defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
+ }
+ }
+
+ # Settings for text blitting, chosen to approximate the system browser.
+ if (is_linux) {
+ defines += [
+ "SK_GAMMA_EXPONENT=1.2",
+ "SK_GAMMA_CONTRAST=0.2",
+ ]
+ } else if (is_android) {
+ defines += [
+ "SK_GAMMA_APPLY_TO_A8",
+ "SK_GAMMA_EXPONENT=1.4",
+ "SK_GAMMA_CONTRAST=0.0",
+ ]
+ } else if (is_win) {
+ defines += [
+ "SK_GAMMA_SRGB",
+ "SK_GAMMA_CONTRAST=0.5",
+ ]
+ } else if (is_mac) {
+ defines += [
+ "SK_GAMMA_SRGB",
+ "SK_GAMMA_CONTRAST=0.0",
+ ]
+ }
+
+ if (is_android) {
+ defines += [
+ # Android devices are typically more memory constrained, so default to a
+ # smaller glyph cache (it may be overriden at runtime when the renderer
+ # starts up, depending on the actual device memory).
+ "SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024
+ ]
+ } else {
+ defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
+ }
+
+ if (is_win) {
+ include_dirs += [
+ "//third_party/skia/include/utils/win",
+ "//third_party/skia/src/utils/win",
+ ]
+
+ defines += [
+ # On windows, GDI handles are a scarse system-wide resource so we have to
+ # keep the glyph cache, which holds up to 4 GDI handles per entry, to a
+ # fairly small size. http://crbug.com/314387
+ "SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256",
+ ]
+
+ cflags = [
+ "/wd4244", # conversion from 'type1( __int64)' to 'type2 (unsigned int)'
+ "/wd4267", # conversion from 'size_t' (64 bit) to 'type'(32 bit).
+ "/wd4341", # signed value is out of range for enum constant.
+ "/wd4345", # Object is default-initialized if initialization is omitted.
+ "/wd4390", # ';'empty statement found in looping;is it what was intended?
+ "/wd4554", # 'operator' : check operator precedence for possible error
+ "/wd4748", # compiler will disable optimizations if a function has inline
+ # assembly code contains flow control(jmp or jcc) statements.
+
+ "/wd4800", # forcing value to bool 'true/false'(assigning int to bool).
+ ]
+ }
+}
+
+component("skia") {
+ sources = [
+ # PDFium sources.
+ "config/SkUserConfig.h",
+ "ext/google_logging.cc",
+ ]
+
+ # The skia gypi values are relative to the skia_dir, so we need to rebase.
+ sources += gypi_skia_core.sources
+ sources += gypi_skia_effects.sources
+ sources += gypi_skia_utils.sources
+ sources += gypi_values.skia_library_sources
+
+ # This and skia_opts are really the same conceptual target so share headers.
+ allow_circular_includes_from = [ ":skia_opts" ]
+
+ if (current_cpu == "arm") {
+ sources += [ "//third_party/skia/src/core/SkUtilsArm.cpp" ]
+ }
+
+ # GPU
+ if (skia_support_gpu) {
+ sources += gypi_skia_gpu.skgpu_sources
+ sources += gypi_skia_gpu.skgpu_null_gl_sources
+ }
+
+ # Remove unused util files include in utils.gypi
+ sources -= [
+ "//third_party/skia/src/utils/SkBoundaryPatch.cpp",
+ "//third_party/skia/src/utils/SkCamera.cpp",
+ "//third_party/skia/src/utils/SkDumpCanvas.cpp",
+ "//third_party/skia/src/utils/SkFrontBufferedStream.cpp",
+ "//third_party/skia/src/utils/SkInterpolator.cpp",
+ "//third_party/skia/src/utils/SkLayer.cpp",
+ "//third_party/skia/src/utils/SkMeshUtils.cpp",
+ "//third_party/skia/src/utils/SkNinePatch.cpp",
+ "//third_party/skia/src/utils/SkParsePath.cpp",
+
+ #testing
+ "//third_party/skia/src/fonts/SkGScalerContext.cpp",
+ ]
+
+ if (is_win) {
+ sources -= [
+ # Keeping _win.cpp
+ "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
+ ]
+ } else {
+ sources -= [
+ # Keeping _pthread.cpp
+ "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
+ ]
+ }
+
+ # need separate win section to handle chromes auto gn filter
+ # (build/config/BUILDCONFIG.gn)
+ if (is_win) {
+ sources -= [
+ #windows
+ "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
+ "//third_party/skia/src/utils/win/SkIStream.cpp",
+ "//third_party/skia/src/utils/win/SkWGL_win.cpp",
+ ]
+ }
+
+ # Fixup skia library sources.
+ if (is_win) {
+ sources -= [
+ "//third_party/skia/src/ports/SkOSFile_posix.cpp",
+ "//third_party/skia/src/ports/SkTLS_pthread.cpp",
+ ]
+ } else {
+ sources -= [
+ "//third_party/skia/src/ports/SkFontHost_win.cpp",
+ "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
+ "//third_party/skia/src/ports/SkOSFile_win.cpp",
+ "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
+ "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
+ "//third_party/skia/src/ports/SkTLS_win.cpp",
+ "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
+ ]
+ }
+ if (!is_android) {
+ sources -= [
+ "//third_party/skia/src/ports/SkFontMgr_android.cpp",
+ "//third_party/skia/src/ports/SkFontMgr_android_factory.cpp",
+ "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
+ ]
+ }
+ if (!is_mac) {
+ sources -= [ "//third_party/skia/src/ports/SkFontHost_mac.cpp" ]
+ }
+
+ if (!is_linux) {
+ sources -= [
+ "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
+ "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
+ "//third_party/skia/src/ports/SkFontConfigInterface_direct_factory.cpp",
+ "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
+ ]
+ }
+
+ if (!is_linux && !is_android) {
+ sources -= [
+ "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
+ "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
+ ]
+ }
+
+ if (is_clang && !is_nacl) {
+ # Skia won't compile with some of the more strict clang warnings.
+ # e.g. it does:
+ # SkASSERT(!"sk_out_of_memory");
+ configs -= [ "//build/config/clang:extra_warnings" ]
+ }
+
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
+ public_configs = [ ":skia_config" ]
+
+ deps = [
+ ":skia_opts",
+ "../third_party:fx_zlib",
+ ]
+
+ if (is_linux) {
+ deps += [
+ "//third_party/icu:icuuc",
+ ]
+ }
+
+ if (is_android) {
+ set_sources_assignment_filter([])
+ set_sources_assignment_filter(sources_assignment_filter)
+ deps += [
+ "//third_party/android_tools:cpu_features",
+ "//third_party/expat",
+ "//third_party/freetype-android:freetype",
+ ]
+ }
+
+ if (skia_support_pdf) {
+ deps += [ "//third_party/sfntly" ]
+ sources += gypi_skia_pdf.sources
+ } else {
+ sources += [ "//third_party/skia/src/pdf/SkDocument_PDF_None.cpp" ]
+ }
+
+ if (is_android && !is_debug) {
+ configs -= [ "//build/config/compiler:default_optimization" ]
+ configs += [ "//build/config/compiler:optimize_max" ]
+ }
+
+ if (is_ios) {
+ libs = [ "ImageIO.framework" ]
+ set_sources_assignment_filter([])
+ sources += [
+ "//third_party/skia/src/ports/SkFontHost_mac.cpp",
+ "//third_party/skia/src/utils/mac/SkCreateCGImageRef.cpp",
+ "//third_party/skia/src/utils/mac/SkStream_mac.cpp",
+ ]
+ set_sources_assignment_filter(sources_assignment_filter)
+
+ # To disable warning "CGContextSelectFont' is deprecated"
+ cflags = [ "-Wno-deprecated-declarations" ]
+ }
+}
+
+# Separated out so it can be compiled with different flags for SSE.
+if (current_cpu == "x86" || current_cpu == "x64") {
+ source_set("skia_opts_sse3") {
+ sources = gypi_skia_opts.ssse3_sources
+ if (!is_win || is_clang) {
+ cflags = [ "-mssse3" ]
+ }
+ if (is_win) {
+ defines = [ "SK_CPU_SSE_LEVEL=31" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
+ }
+ source_set("skia_opts_sse41") {
+ sources = gypi_skia_opts.sse41_sources
+ if (!is_win || is_clang) {
+ cflags = [ "-msse4.1" ]
+ }
+ if (is_win) {
+ defines = [ "SK_CPU_SSE_LEVEL=41" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
+ }
+ source_set("skia_opts_sse42") {
+ sources = gypi_skia_opts.sse42_sources
+ if (!is_win || is_clang) {
+ cflags = [ "-msse4.2" ]
+ }
+ if (is_win) {
+ defines = [ "SK_CPU_SSE_LEVEL=42" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
+ }
+ source_set("skia_opts_avx") {
+ sources = gypi_skia_opts.avx_sources
+ if (!is_win) {
+ cflags = [ "-mavx" ]
+ }
+ if (is_win) {
+ cflags = [ "/arch:AVX" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
+ }
+ source_set("skia_opts_avx2") {
+ sources = gypi_skia_opts.avx2_sources
+ if (!is_win) {
+ cflags = [ "-mavx2" ]
+ }
+ if (is_win) {
+ cflags = [ "/arch:AVX2" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
+ }
+}
+source_set("skia_opts") {
+ cflags = []
+ defines = []
+
+ if (current_cpu == "x86" || current_cpu == "x64") {
+ sources = gypi_skia_opts.sse2_sources
+ deps = [
+ ":skia_opts_avx",
+ ":skia_opts_avx2",
+ ":skia_opts_sse3",
+ ":skia_opts_sse41",
+ ":skia_opts_sse42",
+ ]
+ } else if (current_cpu == "arm") {
+ # The assembly uses the frame pointer register (r7 in Thumb/r11 in
+ # ARM), the compiler doesn't like that.
+ cflags += [ "-fomit-frame-pointer" ]
+
+ if (arm_version >= 7) {
+ sources = gypi_skia_opts.armv7_sources
+ if (arm_use_neon || arm_optionally_use_neon) {
+ sources += gypi_skia_opts.neon_sources
+
+ # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
+ # when running this.
+ if (!arm_use_neon) {
+ configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
+ cflags += [ "-mfpu=neon" ]
+ }
+ }
+ } else {
+ sources = gypi_skia_opts.none_sources
+ }
+ } else if (current_cpu == "arm64") {
+ sources = gypi_skia_opts.arm64_sources
+ } else if (current_cpu == "mipsel") {
+ cflags += [ "-fomit-frame-pointer" ]
+
+ if (mips_dsp_rev >= 1) {
+ sources = gypi_skia_opts.mips_dsp_sources
+ } else {
+ sources = gypi_skia_opts.none_sources
+ }
+ } else if (current_cpu == "mips64el") {
+ cflags += [ "-fomit-frame-pointer" ]
+ sources = gypi_skia_opts.none_sources
+ } else {
+ assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
+ }
+
+ if (is_android && !is_debug) {
+ configs -= [ "//build/config/compiler:default_optimization" ]
+ configs += [ "//build/config/compiler:optimize_max" ]
+ }
+
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
+
+ visibility = [ ":skia" ]
+}
diff --git a/chromium/third_party/pdfium/skia/skia_gn_files.gypi b/chromium/third_party/pdfium/skia/skia_gn_files.gypi
new file mode 100644
index 00000000000..7f7495996a5
--- /dev/null
+++ b/chromium/third_party/pdfium/skia/skia_gn_files.gypi
@@ -0,0 +1,45 @@
+# This file is read into the GN build.
+
+# Files are relative to third_party/skia.
+{
+ 'skia_library_sources': [
+ '<(skia_src_path)/ports/SkImageGenerator_none.cpp',
+
+ '<(skia_src_path)/fonts/SkFontMgr_indirect.cpp',
+ '<(skia_src_path)/fonts/SkRemotableFontMgr.cpp',
+ '<(skia_src_path)/ports/SkFontHost_FreeType_common.cpp',
+ '<(skia_src_path)/ports/SkFontHost_FreeType.cpp',
+ '<(skia_src_path)/ports/SkFontHost_mac.cpp',
+ '<(skia_src_path)/ports/SkFontHost_win.cpp',
+ '<(skia_src_path)/ports/SkFontMgr_android.cpp',
+ '<(skia_src_path)/ports/SkFontMgr_android_factory.cpp',
+ '<(skia_src_path)/ports/SkFontMgr_android_parser.cpp',
+ '<(skia_src_path)/ports/SkFontMgr_win_dw.cpp',
+ '<(skia_src_path)/ports/SkGlobalInitialization_default.cpp',
+ '<(skia_src_path)/ports/SkImageEncoder_none.cpp',
+ '<(skia_src_path)/ports/SkOSFile_posix.cpp',
+ '<(skia_src_path)/ports/SkOSFile_stdio.cpp',
+ '<(skia_src_path)/ports/SkOSFile_win.cpp',
+ '<(skia_src_path)/ports/SkRemotableFontMgr_win_dw.cpp',
+ '<(skia_src_path)/ports/SkScalerContext_win_dw.cpp',
+ '<(skia_src_path)/ports/SkTLS_pthread.cpp',
+ '<(skia_src_path)/ports/SkTLS_win.cpp',
+ '<(skia_src_path)/ports/SkTypeface_win_dw.cpp',
+ '<(skia_src_path)/sfnt/SkOTTable_name.cpp',
+ '<(skia_src_path)/sfnt/SkOTUtils.cpp',
+
+ #mac
+ '<(skia_src_path)/utils/mac/SkStream_mac.cpp',
+
+ #windows
+
+ #testing
+ '<(skia_src_path)/fonts/SkGScalerContext.cpp',
+
+ #pdfium
+ '<(skia_src_path)/ports/SkDiscardableMemory_none.cpp',
+ '<(skia_src_path)/ports/SkFontMgr_custom.cpp',
+ '<(skia_src_path)/ports/SkFontMgr_custom_empty_factory.cpp',
+ '<(skia_src_path)/ports/SkMemory_malloc.cpp',
+ ],
+}
diff --git a/chromium/third_party/pdfium/skia/skia_library.gypi b/chromium/third_party/pdfium/skia/skia_library.gypi
index bd29a5a9849..a4eb0abf30f 100644
--- a/chromium/third_party/pdfium/skia/skia_library.gypi
+++ b/chromium/third_party/pdfium/skia/skia_library.gypi
@@ -5,7 +5,7 @@
# This gypi file contains the Skia library.
# In component mode (shared_lib) it is folded into a single shared library with
-# the Chrome-specific enhancements but in all other cases it is a separate lib.
+# the PDFium-specific enhancements but in all other cases it is a separate lib.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# variables and defines should go in skia_common.gypi so they can be seen
@@ -27,9 +27,6 @@
'sources': [
'../third_party/skia/src/lazy/SkDiscardableMemoryPool.cpp',
- '../third_party/skia/src/ports/SkImageDecoder_empty.cpp',
- '../third_party/skia/src/images/SkScaledBitmapSampler.cpp',
-
'../third_party/skia/src/ports/SkFontConfigInterface_direct.cpp',
'../third_party/skia/src/ports/SkFontConfigInterface_direct_factory.cpp',
@@ -39,6 +36,7 @@
'../third_party/skia/src/fonts/SkRemotableFontMgr.cpp',
'../third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp',
+ '../third_party/skia/src/ports/SkImageEncoder_none.cpp',
'../third_party/skia/src/ports/SkImageGenerator_none.cpp',
'../third_party/skia/src/ports/SkFontHost_FreeType.cpp',
@@ -57,7 +55,6 @@
'../third_party/skia/src/ports/SkOSFile_stdio.cpp',
'../third_party/skia/src/ports/SkOSFile_win.cpp',
'../third_party/skia/src/ports/SkScalerContext_win_dw.cpp',
- '../third_party/skia/src/ports/SkTime_Unix.cpp',
'../third_party/skia/src/ports/SkTLS_pthread.cpp',
'../third_party/skia/src/ports/SkTLS_win.cpp',
'../third_party/skia/src/ports/SkTypeface_win_dw.cpp',
diff --git a/chromium/third_party/pdfium/skia/skia_pdfium.gypi b/chromium/third_party/pdfium/skia/skia_pdfium.gypi
index 0de3f84d721..5c80a4b9fdc 100644
--- a/chromium/third_party/pdfium/skia/skia_pdfium.gypi
+++ b/chromium/third_party/pdfium/skia/skia_pdfium.gypi
@@ -3,7 +3,7 @@
# found in the LICENSE file.
-# This gypi file contains all the Chrome-specific enhancements to Skia.
+# This gypi file contains all the PDFium-specific enhancements to Skia.
# In component mode (shared_lib) it is folded into a single shared library with
# the Skia files but in all other cases it is a separate library.
{
@@ -24,6 +24,7 @@
],
},
'sources': [
+ 'config/SkUserConfig.h',
'ext/google_logging.cc',
],
}
diff --git a/chromium/third_party/pdfium/testing/DEPS b/chromium/third_party/pdfium/testing/DEPS
index 99f34dc1909..2e7767721a5 100644
--- a/chromium/third_party/pdfium/testing/DEPS
+++ b/chromium/third_party/pdfium/testing/DEPS
@@ -2,7 +2,8 @@ include_rules = [
'+core/include',
'+core/fxcodec',
'+core/fxcrt/include',
- '+fpdfsdk/include',
+ '+core/fxge/include',
+ '+fpdfsdk/jsapi/include',
'+public',
'+v8',
'+xfa/fxfa/parser',
diff --git a/chromium/third_party/pdfium/testing/SUPPRESSIONS b/chromium/third_party/pdfium/testing/SUPPRESSIONS
index 7aca89d0243..3717f75c3ad 100644
--- a/chromium/third_party/pdfium/testing/SUPPRESSIONS
+++ b/chromium/third_party/pdfium/testing/SUPPRESSIONS
@@ -477,3 +477,15 @@ widget_javascript.pdf mac * *
zh_file1.pdf mac * *
zh_function_list.pdf mac * *
zh_shared_document.pdf mac * *
+
+#
+# xfa_specific
+#
+Choose.pdf * * *
+data_binding.pdf * * *
+Date_FormCale.pdf * * *
+Sum.pdf * * *
+TimeField.pdf * * *
+Test_CheckBox.pdf * * *
+Test_DateField_locale_zh_HK.pdf * * *
+
diff --git a/chromium/third_party/pdfium/testing/fx_string_testhelpers.cpp b/chromium/third_party/pdfium/testing/fx_string_testhelpers.cpp
index b2d30f3a060..934dd680e40 100644
--- a/chromium/third_party/pdfium/testing/fx_string_testhelpers.cpp
+++ b/chromium/third_party/pdfium/testing/fx_string_testhelpers.cpp
@@ -17,7 +17,7 @@ std::ostream& output_string(std::ostream& out, const T& str) {
unsigned int c = str.GetAt(i);
if (c >= 0x20 && c < 0x7F) {
out << static_cast<char>(c);
- } else if (sizeof(typename T::value_type) == 1) {
+ } else if (sizeof(typename T::CharType) == 1) {
out << "\\x" << std::setw(2) << c << std::setw(0);
} else if (c < 0x10000) {
out << "\\u" << std::setw(4) << c << std::setw(0);
diff --git a/chromium/third_party/pdfium/testing/gtest_mac.h b/chromium/third_party/pdfium/testing/gtest_mac.h
new file mode 100644
index 00000000000..0c0b6555a3d
--- /dev/null
+++ b/chromium/third_party/pdfium/testing/gtest_mac.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#ifndef TESTING_GTEST_MAC_H_
+#define TESTING_GTEST_MAC_H_
+#include <gtest/internal/gtest-port.h>
+#include <gtest/gtest.h>
+#ifdef GTEST_OS_MAC
+#import <Foundation/Foundation.h>
+namespace testing {
+namespace internal {
+// This overloaded version allows comparison between ObjC objects that conform
+// to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NSEQ().
+GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
+ const char* actual_expression,
+ id<NSObject> expected,
+ id<NSObject> actual);
+// This overloaded version allows comparison between ObjC objects that conform
+// to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NSNE().
+GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
+ const char* actual_expression,
+ id<NSObject> expected,
+ id<NSObject> actual);
+#if !defined(GTEST_OS_IOS)
+// This overloaded version allows comparison between NSRect objects using
+// NSEqualRects. Used to implement {ASSERT|EXPECT}_NSEQ().
+GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
+ const char* actual_expression,
+ const NSRect& expected,
+ const NSRect& actual);
+// This overloaded version allows comparison between NSRect objects using
+// NSEqualRects. Used to implement {ASSERT|EXPECT}_NSNE().
+GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
+ const char* actual_expression,
+ const NSRect& expected,
+ const NSRect& actual);
+// This overloaded version allows comparison between NSPoint objects using
+// NSEqualPoints. Used to implement {ASSERT|EXPECT}_NSEQ().
+GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
+ const char* actual_expression,
+ const NSPoint& expected,
+ const NSPoint& actual);
+// This overloaded version allows comparison between NSPoint objects using
+// NSEqualPoints. Used to implement {ASSERT|EXPECT}_NSNE().
+GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
+ const char* actual_expression,
+ const NSPoint& expected,
+ const NSPoint& actual);
+#endif // !GTEST_OS_IOS
+} // namespace internal
+} // namespace testing
+// Tests that [expected isEqual:actual].
+#define EXPECT_NSEQ(expected, actual) \
+ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNSEQ, expected, actual)
+#define EXPECT_NSNE(val1, val2) \
+ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNSNE, val1, val2)
+#define ASSERT_NSEQ(expected, actual) \
+ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNSEQ, expected, actual)
+#define ASSERT_NSNE(val1, val2) \
+ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNSNE, val1, val2)
+#endif // GTEST_OS_MAC
+#endif // TESTING_GTEST_MAC_H_
diff --git a/chromium/third_party/pdfium/testing/gtest_mac.mm b/chromium/third_party/pdfium/testing/gtest_mac.mm
new file mode 100644
index 00000000000..b490f558bdb
--- /dev/null
+++ b/chromium/third_party/pdfium/testing/gtest_mac.mm
@@ -0,0 +1,98 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#import "gtest_mac.h"
+#include <string>
+#include <gtest/gtest.h>
+#include <gtest/internal/gtest-port.h>
+#include <gtest/internal/gtest-string.h>
+#ifdef GTEST_OS_MAC
+#import <Foundation/Foundation.h>
+namespace testing {
+namespace internal {
+// Handles nil values for |obj| properly by using safe printing of %@ in
+// -stringWithFormat:.
+static inline const char* StringDescription(id<NSObject> obj) {
+ return [[NSString stringWithFormat:@"%@", obj] UTF8String];
+}
+// This overloaded version allows comparison between ObjC objects that conform
+// to the NSObject protocol. Used to implement {ASSERT|EXPECT}_EQ().
+GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
+ const char* actual_expression,
+ id<NSObject> expected,
+ id<NSObject> actual) {
+ if (expected == actual || [expected isEqual:actual]) {
+ return AssertionSuccess();
+ }
+ return EqFailure(expected_expression, actual_expression,
+ std::string(StringDescription(expected)),
+ std::string(StringDescription(actual)), false);
+}
+// This overloaded version allows comparison between ObjC objects that conform
+// to the NSObject protocol. Used to implement {ASSERT|EXPECT}_NE().
+GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
+ const char* actual_expression,
+ id<NSObject> expected,
+ id<NSObject> actual) {
+ if (expected != actual && ![expected isEqual:actual]) {
+ return AssertionSuccess();
+ }
+ Message msg;
+ msg << "Expected: (" << expected_expression << ") != (" << actual_expression
+ << "), actual: " << StringDescription(expected) << " vs "
+ << StringDescription(actual);
+ return AssertionFailure(msg);
+}
+#if !defined(GTEST_OS_IOS)
+GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
+ const char* actual_expression,
+ const NSRect& expected,
+ const NSRect& actual) {
+ if (NSEqualRects(expected, actual)) {
+ return AssertionSuccess();
+ }
+ return EqFailure(expected_expression, actual_expression,
+ [NSStringFromRect(expected) UTF8String],
+ [NSStringFromRect(actual) UTF8String], false);
+}
+GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
+ const char* actual_expression,
+ const NSRect& expected,
+ const NSRect& actual) {
+ if (!NSEqualRects(expected, actual)) {
+ return AssertionSuccess();
+ }
+ Message msg;
+ msg << "Expected: (" << expected_expression << ") != (" << actual_expression
+ << "), actual: " << [NSStringFromRect(expected) UTF8String] << " vs "
+ << [NSStringFromRect(actual) UTF8String];
+ return AssertionFailure(msg);
+}
+GTEST_API_ AssertionResult CmpHelperNSEQ(const char* expected_expression,
+ const char* actual_expression,
+ const NSPoint& expected,
+ const NSPoint& actual) {
+ if (NSEqualPoints(expected, actual)) {
+ return AssertionSuccess();
+ }
+ return EqFailure(expected_expression, actual_expression,
+ [NSStringFromPoint(expected) UTF8String],
+ [NSStringFromPoint(actual) UTF8String], false);
+}
+GTEST_API_ AssertionResult CmpHelperNSNE(const char* expected_expression,
+ const char* actual_expression,
+ const NSPoint& expected,
+ const NSPoint& actual) {
+ if (!NSEqualPoints(expected, actual)) {
+ return AssertionSuccess();
+ }
+ Message msg;
+ msg << "Expected: (" << expected_expression << ") != (" << actual_expression
+ << "), actual: " << [NSStringFromPoint(expected) UTF8String] << " vs "
+ << [NSStringFromPoint(actual) UTF8String];
+ return AssertionFailure(msg);
+}
+#endif // !GTEST_OS_IOS
+} // namespace internal
+} // namespace testing
+#endif // GTEST_OS_MAC
diff --git a/chromium/third_party/pdfium/testing/js_embedder_test.h b/chromium/third_party/pdfium/testing/js_embedder_test.h
index 319bd407288..5583e7e3880 100644
--- a/chromium/third_party/pdfium/testing/js_embedder_test.h
+++ b/chromium/third_party/pdfium/testing/js_embedder_test.h
@@ -8,7 +8,7 @@
#include <memory>
#include <vector>
-#include "fpdfsdk/include/jsapi/fxjs_v8.h"
+#include "fpdfsdk/jsapi/include/fxjs_v8.h"
#include "testing/embedder_test.h"
class JSEmbedderTest : public EmbedderTest {
diff --git a/chromium/third_party/pdfium/testing/libfuzzer/pdf_fm2js_fuzzer.cc b/chromium/third_party/pdfium/testing/libfuzzer/pdf_fm2js_fuzzer.cc
index 0a5f6d64ae2..c1f2de09623 100644
--- a/chromium/third_party/pdfium/testing/libfuzzer/pdf_fm2js_fuzzer.cc
+++ b/chromium/third_party/pdfium/testing/libfuzzer/pdf_fm2js_fuzzer.cc
@@ -14,9 +14,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return 0;
CFX_WideString input = CFX_WideString::FromUTF8(
- reinterpret_cast<const char*>(data), static_cast<FX_STRSIZE>(size));
+ CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
CXFA_FMProgram program;
- if (program.Init(input.AsWideStringC()) || program.ParseProgram())
+ if (program.Init(input.AsStringC()) || program.ParseProgram())
return 0;
CFX_WideTextBuf js;
diff --git a/chromium/third_party/pdfium/testing/libfuzzer/pdf_jpx_fuzzer.cc b/chromium/third_party/pdfium/testing/libfuzzer/pdf_jpx_fuzzer.cc
index 12d20614451..7af5d13fc11 100644
--- a/chromium/third_party/pdfium/testing/libfuzzer/pdf_jpx_fuzzer.cc
+++ b/chromium/third_party/pdfium/testing/libfuzzer/pdf_jpx_fuzzer.cc
@@ -7,7 +7,7 @@
#include <vector>
#include "core/fxcodec/codec/codec_int.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
CCodec_JpxModule g_module;
diff --git a/chromium/third_party/pdfium/testing/libfuzzer/pdf_xml_fuzzer.cc b/chromium/third_party/pdfium/testing/libfuzzer/pdf_xml_fuzzer.cc
index 998e2ec6503..ebafab374a9 100644
--- a/chromium/third_party/pdfium/testing/libfuzzer/pdf_xml_fuzzer.cc
+++ b/chromium/third_party/pdfium/testing/libfuzzer/pdf_xml_fuzzer.cc
@@ -48,7 +48,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return 0;
CFX_WideString input = CFX_WideString::FromUTF8(
- reinterpret_cast<const char*>(data), static_cast<FX_STRSIZE>(size));
+ CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> stream(
XFA_CreateWideTextRead(input));
if (!stream)
diff --git a/chromium/third_party/pdfium/testing/resources/bug_602650.pdf b/chromium/third_party/pdfium/testing/resources/bug_602650.pdf
new file mode 100644
index 00000000000..fc915f3e80b
--- /dev/null
+++ b/chromium/third_party/pdfium/testing/resources/bug_602650.pdf
@@ -0,0 +1,105 @@
+%PDF-1.3
+%Â Ă²Â¤Ă´
+1 0 obj <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Times-Roman
+>>
+endobj
+2 0 obj <<
+ /Type /Font
+ /Subtype /Type1
+ /BaseFont /Helvetica
+>>
+endobj
+3 0 obj <<
+>>
+stream
+BT
+20 50 Td
+/F1 12 Tf
+(Hello, world!) Tj
+0 50 Td
+/F2 16 Tf
+(Goodbye, world!) Tj
+ET
+endstream
+endobj
+4 0 obj <<
+ /Type /Catalog
+ /Pages 5 0 R
+>>
+5 0 obj <<
+ /Type /Pages
+ /MediaBox [ 0 0 200 200 ]
+ /Count 1
+ /Kids [ 6 0 R ]
+>>
+endobj
+6 0 obj <<
+ /Type /Page
+ /Parent 5 0 R
+ /Resources <<
+ /Font <<
+ /F1 1 0 R
+ /F2 2 0 R
+ >>
+ >>
+ /Contents 3 0 R
+>>
+endobj
+xref
+1 7
+0000000000 65535 f
+0000000015 00000 n
+0000000093 00000 n
+0000000169 00000 n
+0000000290 00000 n
+0000000336 00000 n
+0000000429 00000 n
+trailer <<
+ /Size 7
+ /Root 4 0 R
+>>
+startxref
+571
+%%EOF
+4 0 obj <<
+ /Type /Catalog
+ /Pages 5 0 R
+>>
+endobj
+5 0 obj <<
+ /Type /Pages
+ /MediaBox [ 1 1 250 250 ]
+ /Count 1
+ /Kids [ 6 0 R ]
+>>
+endobj
+6 0 obj <<
+ /Type /Page
+ /Parent 5 0 R
+ /Resources <<
+ /Font <<
+ /F1 1 0 R
+ /F2 2 0 R
+ >>
+ >>
+ /Contents 3 0 R
+>>
+endobj
+xref
+0 1
+0000000000 65535 f
+4 3
+0000000778 00000 n
+0000000831 00000 n
+0000000924 00000 n
+trailer <<
+ /Size 7
+ /Root 4 0 R
+ /Prev 571
+>>
+startxref
+1066
+%%EOF
diff --git a/chromium/third_party/pdfium/testing/resources/pixel/font_size.pdf b/chromium/third_party/pdfium/testing/resources/pixel/font_size.pdf
deleted file mode 100644
index e0b882b67a1..00000000000
--- a/chromium/third_party/pdfium/testing/resources/pixel/font_size.pdf
+++ /dev/null
@@ -1,72 +0,0 @@
-%PDF-1.7
-% ̣¤ô
-1 0 obj <<
- /Type /Catalog
- /Pages 2 0 R
->>
-2 0 obj <<
- /Type /Pages
- /MediaBox [ 0 0 100 400 ]
- /Count 1
- /Kids [ 3 0 R ]
->>
-endobj
-3 0 obj <<
- /Type /Page
- /Parent 2 0 R
- /Resources <<
- /Font <<
- /F1 4 0 R
- >>
- >>
- /Contents 6 0 R
->>
-endobj
-4 0 obj <<
- /Type /Font
- /Subtype /Type1
- /BaseFont /Times-Roman
->>
-endobj
-6 0 obj <<
->>
-stream
-BT
-20 0 Td
-0 20 Td /F1 0 Tf (Size 0) Tj
-0 20 Td /F1 1 Tf (Size 1) Tj
-0 20 Td /F1 2 Tf (Size 2) Tj
-0 20 Td /F1 3 Tf (Size 3) Tj
-0 20 Td /F1 4 Tf (Size 4) Tj
-0 20 Td /F1 5 Tf (Size 5) Tj
-0 20 Td /F1 6 Tf (Size 6) Tj
-0 20 Td /F1 7 Tf (Size 7) Tj
-0 20 Td /F1 8 Tf (Size 8) Tj
-0 20 Td /F1 9 Tf (Size 9) Tj
-0 20 Td /F1 10 Tf (Size 10) Tj
-0 20 Td /F1 11 Tf (Size 11) Tj
-0 20 Td /F1 12 Tf (Size 12) Tj
-0 20 Td /F1 13 Tf (Size 13) Tj
-0 20 Td /F1 14 Tf (Size 14) Tj
-0 20 Td /F1 15 Tf (Size 15) Tj
-0 20 Td /F1 16 Tf (Size 16) Tj
-0 20 Td /F1 17 Tf (Size 17) Tj
-0 20 Td /F1 18 Tf (Size 18) Tj
-ET
-endstream
-endobj
-xref
-0 7
-0000000000 65535 f
-0000000015 00000 n
-0000000061 00000 n
-0000000154 00000 n
-0000000280 00000 n
-0000000000 65535 f
-0000000358 00000 n
-trailer <<
- /Root 1 0 R
->>
-startxref
-979
-%%EOF
diff --git a/chromium/third_party/pdfium/testing/test.gni b/chromium/third_party/pdfium/testing/test.gni
new file mode 100644
index 00000000000..13c434238ac
--- /dev/null
+++ b/chromium/third_party/pdfium/testing/test.gni
@@ -0,0 +1,232 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# ==============================================================================
+# TEST SETUP
+# ==============================================================================
+
+# Define a test as an executable (or apk on Android) with the "testonly" flag
+# set.
+# Variable:
+# use_raw_android_executable: Use executable() rather than android_apk().
+template("test") {
+ if (is_android) {
+ import("//build/config/android/config.gni")
+ import("//build/config/android/rules.gni")
+
+ _use_raw_android_executable = defined(invoker.use_raw_android_executable) &&
+ invoker.use_raw_android_executable
+
+ # output_name is used to allow targets with the same name but in different
+ # packages to still produce unique runner scripts.
+ _output_name = invoker.target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ if (_use_raw_android_executable) {
+ _exec_target = "${target_name}__exec"
+ _dist_target = "${target_name}__dist"
+ _exec_output =
+ "$target_out_dir/${invoker.target_name}/${invoker.target_name}"
+
+ executable(_exec_target) {
+ # Configs will always be defined since we set_defaults in BUILDCONFIG.gn.
+ configs = []
+ data_deps = []
+ forward_variables_from(invoker, "*", [ "extra_dist_files" ])
+ testonly = true
+
+ # Thanks to the set_defaults() for test(), configs are initialized with
+ # the default shared_library configs rather than executable configs.
+ configs -= [
+ "//build/config:shared_library_config",
+ "//build/config/android:hide_native_jni_exports",
+ ]
+ configs += [ "//build/config:executable_config" ]
+
+ # Don't output to the root or else conflict with the group() below.
+ output_name = rebase_path(_exec_output, root_out_dir)
+ if (is_component_build || is_asan) {
+ data_deps += [ "//build/android:cpplib_stripped" ]
+ }
+ }
+
+ create_native_executable_dist(_dist_target) {
+ testonly = true
+ dist_dir = "$root_out_dir/$target_name"
+ binary = _exec_output
+ deps = [
+ ":$_exec_target",
+ ]
+ if (defined(invoker.extra_dist_files)) {
+ extra_files = invoker.extra_dist_files
+ }
+ }
+ } else {
+ _library_target = "_${target_name}__library"
+ _apk_target = "${target_name}_apk"
+ _apk_specific_vars = [
+ "android_manifest",
+ "enable_multidex",
+ "use_default_launcher",
+ "write_asset_list",
+ ]
+ shared_library(_library_target) {
+ # Configs will always be defined since we set_defaults in BUILDCONFIG.gn.
+ configs = [] # Prevent list overwriting warning.
+ configs = invoker.configs
+ testonly = true
+
+ deps = []
+ forward_variables_from(invoker,
+ "*",
+ _apk_specific_vars + [
+ "isolate_file",
+ "visibility",
+ ])
+
+ if (!defined(invoker.use_default_launcher) ||
+ invoker.use_default_launcher) {
+ deps += [ "//testing/android/native_test:native_test_native_code" ]
+ }
+ }
+ unittest_apk(_apk_target) {
+ forward_variables_from(invoker, _apk_specific_vars + [ "deps" ])
+ unittests_dep = ":$_library_target"
+ apk_name = invoker.target_name
+ if (defined(invoker.output_name)) {
+ apk_name = invoker.output_name
+ unittests_binary = "lib${apk_name}.so"
+ install_script_name = "install_${invoker.output_name}"
+ }
+ deps += [ ":$_library_target" ]
+ }
+
+ # Incremental test targets work only for .apks.
+ _incremental_test_runner_target =
+ "${_output_name}_incremental__test_runner_script"
+ test_runner_script(_incremental_test_runner_target) {
+ forward_variables_from(invoker, [ "isolate_file" ])
+ apk_target = ":$_apk_target"
+ test_name = "${_output_name}_incremental"
+ test_type = "gtest"
+ test_suite = _output_name
+ incremental_install = true
+ }
+ group("${target_name}_incremental") {
+ testonly = true
+ datadeps = [
+ ":$_incremental_test_runner_target",
+ ]
+ deps = [
+ ":${_apk_target}_incremental",
+ ]
+ }
+ }
+
+ _test_runner_target = "${_output_name}__test_runner_script"
+ test_runner_script(_test_runner_target) {
+ forward_variables_from(invoker, [ "isolate_file" ])
+ if (_use_raw_android_executable) {
+ executable_dist_dir = "$root_out_dir/$_dist_target"
+ } else {
+ apk_target = ":$_apk_target"
+ }
+ test_name = _output_name
+ test_type = "gtest"
+ test_suite = _output_name
+ }
+
+ group(target_name) {
+ testonly = true
+ deps = [
+ ":$_test_runner_target",
+ ]
+ if (_use_raw_android_executable) {
+ deps += [ ":$_dist_target" ]
+ } else {
+ deps += [ ":$_apk_target" ]
+ }
+ }
+
+ # TODO(GYP): Delete this after we've converted everything to GN.
+ # The _run targets exist only for compatibility w/ GYP.
+ group("${target_name}_apk_run") {
+ testonly = true
+ deps = [
+ ":${invoker.target_name}",
+ ]
+ }
+ } else if (is_ios) {
+ import("//build/config/ios/rules.gni")
+
+ _test_target = target_name
+ _resources_bundle_data = target_name + "_resources_bundle_data"
+
+ bundle_data(_resources_bundle_data) {
+ visibility = [
+ ":${_test_target}",
+ ":${_test_target}_generate_executable",
+ ]
+ sources = [
+ "//testing/gtest_ios/Default.png",
+ ]
+ outputs = [
+ "{{bundle_resources_dir}}/{{source_file_part}}",
+ ]
+ }
+
+ app(_test_target) {
+ # TODO(GYP): Make this configurable and only provide a default
+ # that can be overridden.
+ info_plist = "//testing/gtest_ios/unittest-Info.plist"
+ app_name = target_name
+ entitlements_path = "//testing/gtest_ios"
+ code_signing_identity = ""
+ testonly = true
+ extra_substitutions = [ "BUNDLE_ID_TEST_NAME=$app_name" ]
+
+ # See above call.
+ set_sources_assignment_filter([])
+
+ forward_variables_from(invoker, "*")
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [
+ ":$_resources_bundle_data",
+
+ # All shared libraries must have the sanitizer deps to properly link in
+ # asan mode (this target will be empty in other cases).
+ "//build/config/sanitizers:deps",
+ ]
+ }
+ } else {
+ executable(target_name) {
+ deps = []
+ forward_variables_from(invoker, "*")
+
+ testonly = true
+ deps += [
+ # All shared libraries must have the sanitizer deps to properly link in
+ # asan mode (this target will be empty in other cases).
+ "//build/config/sanitizers:deps",
+
+ # Give tests the default manifest on Windows (a no-op elsewhere).
+ "//build/win:default_exe_manifest",
+ ]
+ }
+
+ # TODO(GYP): Delete this after we've converted everything to GN.
+ # The _run targets exist only for compatibility with GYP.
+ group("${target_name}_run") {
+ testonly = true
+ deps = [
+ ":${invoker.target_name}",
+ ]
+ }
+ }
+}
diff --git a/chromium/third_party/pdfium/testing/test_support.cpp b/chromium/third_party/pdfium/testing/test_support.cpp
index 1ccd32f084f..c50edeba2da 100644
--- a/chromium/third_party/pdfium/testing/test_support.cpp
+++ b/chromium/third_party/pdfium/testing/test_support.cpp
@@ -118,6 +118,21 @@ std::wstring GetPlatformWString(FPDF_WIDESTRING wstr) {
return platform_string;
}
+std::vector<std::string> StringSplit(const std::string& str, char delimiter) {
+ std::vector<std::string> result;
+ size_t pos = 0;
+ while (1) {
+ size_t found = str.find(delimiter, pos);
+ if (found == std::string::npos)
+ break;
+
+ result.push_back(str.substr(pos, found - pos));
+ pos = found + 1;
+ }
+ result.push_back(str.substr(pos));
+ return result;
+}
+
std::unique_ptr<unsigned short, pdfium::FreeDeleter> GetFPDFWideString(
const std::wstring& wstr) {
size_t length = sizeof(uint16_t) * (wstr.length() + 1);
diff --git a/chromium/third_party/pdfium/testing/test_support.h b/chromium/third_party/pdfium/testing/test_support.h
index 4b716ae7720..fdb24fe61ba 100644
--- a/chromium/third_party/pdfium/testing/test_support.h
+++ b/chromium/third_party/pdfium/testing/test_support.h
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <memory>
#include <string>
+#include <vector>
#include "public/fpdf_save.h"
#include "public/fpdfview.h"
@@ -63,6 +64,8 @@ struct FreeDeleter {
std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename,
size_t* retlen);
+std::vector<std::string> StringSplit(const std::string& str, char delimiter);
+
// Converts a FPDF_WIDESTRING to a std::wstring.
// Deals with differences between UTF16LE and wchar_t.
std::wstring GetPlatformWString(const FPDF_WIDESTRING wstr);
diff --git a/chromium/third_party/pdfium/testing/tools/common.py b/chromium/third_party/pdfium/testing/tools/common.py
index 6e9de7c82c6..1e1d257f48d 100755
--- a/chromium/third_party/pdfium/testing/tools/common.py
+++ b/chromium/third_party/pdfium/testing/tools/common.py
@@ -18,12 +18,9 @@ def os_name():
raise Exception('Confused, can not determine OS, aborting.')
-def RunCommand(cmd, redirect_output=False):
+def RunCommand(cmd):
try:
- if redirect_output:
- sys.stdout.write(subprocess.check_output(cmd, stderr=subprocess.STDOUT))
- else:
- subprocess.check_call(cmd)
+ subprocess.check_call(cmd)
return None
except subprocess.CalledProcessError as e:
return e
diff --git a/chromium/third_party/pdfium/testing/tools/pngdiffer.py b/chromium/third_party/pdfium/testing/tools/pngdiffer.py
index bef252674f0..a1533b8329f 100755
--- a/chromium/third_party/pdfium/testing/tools/pngdiffer.py
+++ b/chromium/third_party/pdfium/testing/tools/pngdiffer.py
@@ -38,8 +38,7 @@ class PNGDiffer():
i += 1
return actual_paths
- def HasDifferences(self, input_filename, source_dir, working_dir,
- redirect_output=False):
+ def HasDifferences(self, input_filename, source_dir, working_dir):
template_paths = self._GetTemplatePaths(
input_filename, source_dir, working_dir)
actual_path_template = template_paths[0];
@@ -49,21 +48,30 @@ class PNGDiffer():
while True:
actual_path = actual_path_template % i
expected_path = expected_path_template % i
+ # PDFium tests should be platform independent. Platform based results are
+ # used to capture platform dependent implementations.
platform_expected_path = (
platform_expected_path_template % (self.os_name, i))
- if os.path.exists(platform_expected_path):
- expected_path = platform_expected_path
- elif not os.path.exists(expected_path):
+ if (not os.path.exists(expected_path) and
+ not os.path.exists(platform_expected_path)):
if i == 0:
print "WARNING: no expected results files for " + input_filename
break
print "Checking " + actual_path
sys.stdout.flush()
- error = common.RunCommand(
- [self.pdfium_diff_path, expected_path, actual_path], redirect_output)
+ if os.path.exists(expected_path):
+ error = common.RunCommand(
+ [self.pdfium_diff_path, expected_path, actual_path])
+ else:
+ error = 1;
if error:
- print "FAILURE: " + input_filename + "; " + str(error)
- return True
+ # When failed, we check against platform based results.
+ if os.path.exists(platform_expected_path):
+ error = common.RunCommand(
+ [self.pdfium_diff_path, platform_expected_path, actual_path])
+ if error:
+ print "FAILURE: " + input_filename + "; " + str(error)
+ return True
i += 1
return False
diff --git a/chromium/third_party/pdfium/testing/tools/run_corpus_tests.py b/chromium/third_party/pdfium/testing/tools/run_corpus_tests.py
index 0c44cc69729..49424065796 100755
--- a/chromium/third_party/pdfium/testing/tools/run_corpus_tests.py
+++ b/chromium/third_party/pdfium/testing/tools/run_corpus_tests.py
@@ -3,174 +3,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import cStringIO
-import functools
-import multiprocessing
-import optparse
-import os
-import re
-import shutil
-import subprocess
import sys
-import common
-import pngdiffer
-import suppressor
-
-class KeyboardInterruptError(Exception): pass
-
-# Nomenclature:
-# x_root - "x"
-# x_filename - "x.ext"
-# x_path - "path/to/a/b/c/x.ext"
-# c_dir - "path/to/a/b/c"
-
-def test_one_file(input_filename, source_dir, working_dir,
- pdfium_test_path, image_differ, drmem_wrapper,
- redirect_output=False):
- input_path = os.path.join(source_dir, input_filename)
- pdf_path = os.path.join(working_dir, input_filename)
- # Remove any existing generated images from previous runs.
- actual_images = image_differ.GetActualFiles(
- input_filename, source_dir, working_dir)
- for image in actual_images:
- if os.path.exists(image):
- os.remove(image)
-
- shutil.copyfile(input_path, pdf_path)
- sys.stdout.flush()
- # add Dr. Memory wrapper if exist
- # remove .pdf suffix
- cmd_to_run = common.DrMemoryWrapper(drmem_wrapper,
- os.path.splitext(input_filename)[0])
- cmd_to_run.extend([pdfium_test_path, '--png', pdf_path])
- # run test
- error = common.RunCommand(cmd_to_run, redirect_output)
- if error:
- print "FAILURE: " + input_filename + "; " + str(error)
- return False
- return not image_differ.HasDifferences(input_filename, source_dir,
- working_dir, redirect_output)
-
-
-def test_one_file_parallel(working_dir, pdfium_test_path, image_differ,
- test_case):
- """Wrapper function to call test_one_file() and redirect output to stdout."""
- try:
- old_stdout = sys.stdout
- old_stderr = sys.stderr
- sys.stdout = cStringIO.StringIO()
- sys.stderr = sys.stdout
- input_filename, source_dir = test_case
- result = test_one_file(input_filename, source_dir, working_dir,
- pdfium_test_path, image_differ, "", True);
- output = sys.stdout
- sys.stdout = old_stdout
- sys.stderr = old_stderr
- return (result, output.getvalue(), input_filename, source_dir)
- except KeyboardInterrupt:
- raise KeyboardInterruptError()
-
-
-def handle_result(test_suppressor, input_filename, input_path, result,
- surprises, failures):
- if test_suppressor.IsSuppressed(input_filename):
- if result:
- surprises.append(input_path)
- else:
- if not result:
- failures.append(input_path)
-
+import test_runner
def main():
- parser = optparse.OptionParser()
- parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
- help='relative path from the base source directory')
- parser.add_option('-j', default=multiprocessing.cpu_count(),
- dest='num_workers', type='int',
- help='run NUM_WORKERS jobs in parallel')
- parser.add_option('--wrapper', default='', dest="wrapper",
- help='Dr. Memory wrapper for running test under Dr. Memory')
- options, args = parser.parse_args()
- finder = common.DirectoryFinder(options.build_dir)
- pdfium_test_path = finder.ExecutablePath('pdfium_test')
- if not os.path.exists(pdfium_test_path):
- print "FAILURE: Can't find test executable '%s'" % pdfium_test_path
- print "Use --build-dir to specify its location."
- return 1
- working_dir = finder.WorkingDir(os.path.join('testing', 'corpus'))
- if not os.path.exists(working_dir):
- os.makedirs(working_dir)
-
- feature_string = subprocess.check_output([pdfium_test_path, '--show-config'])
- test_suppressor = suppressor.Suppressor(finder, feature_string)
- image_differ = pngdiffer.PNGDiffer(finder)
-
- # test files are under .../pdfium/testing/corpus.
- failures = []
- surprises = []
- walk_from_dir = finder.TestingDir('corpus');
- input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]pdf$')
- test_cases = []
-
- if len(args):
- for file_name in args:
- input_path = os.path.join(walk_from_dir, file_name)
- if not os.path.isfile(input_path):
- print "Can't find test file '%s'" % file_name
- return 1
-
- test_cases.append((os.path.basename(input_path),
- os.path.dirname(input_path)))
- else:
- for source_dir, _, filename_list in os.walk(walk_from_dir):
- for input_filename in filename_list:
- if input_file_re.match(input_filename):
- input_path = os.path.join(source_dir, input_filename)
- if os.path.isfile(input_path):
- test_cases.append((input_filename, source_dir))
-
- if options.num_workers > 1 and len(test_cases) > 1:
- try:
- pool = multiprocessing.Pool(options.num_workers)
- worker_func = functools.partial(test_one_file_parallel, working_dir,
- pdfium_test_path, image_differ)
- worker_results = pool.imap(worker_func, test_cases)
- for worker_result in worker_results:
- result, output, input_filename, source_dir = worker_result
- input_path = os.path.join(source_dir, input_filename)
- sys.stdout.write(output)
- handle_result(test_suppressor, input_filename, input_path, result,
- surprises, failures)
- pool.close()
- except KeyboardInterrupt:
- pool.terminate()
- finally:
- pool.join()
- else:
- for test_case in test_cases:
- input_filename, source_dir = test_case
- result = test_one_file(input_filename, source_dir, working_dir,
- pdfium_test_path, image_differ,
- options.wrapper)
- handle_result(test_suppressor, input_filename, input_path, result,
- surprises, failures)
-
- if surprises:
- surprises.sort()
- print '\n\nUnexpected Successes:'
- for surprise in surprises:
- print surprise;
-
- if failures:
- failures.sort()
- print '\n\nSummary of Failures:'
- for failure in failures:
- print failure
- return 1
-
- return 0
-
+ runner = test_runner.TestRunner('corpus')
+ return runner.Run()
if __name__ == '__main__':
sys.exit(main())
+
diff --git a/chromium/third_party/pdfium/testing/tools/run_javascript_tests.py b/chromium/third_party/pdfium/testing/tools/run_javascript_tests.py
index b09ea49e788..76d2379dbbb 100755
--- a/chromium/third_party/pdfium/testing/tools/run_javascript_tests.py
+++ b/chromium/third_party/pdfium/testing/tools/run_javascript_tests.py
@@ -3,97 +3,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import optparse
-import os
-import re
-import subprocess
import sys
-import common
-
-# Nomenclature:
-# x_root - "x"
-# x_filename - "x.ext"
-# x_path - "path/to/a/b/c/x.ext"
-# c_dir - "path/to/a/b/c"
-
-def generate_and_test(input_filename, source_dir, working_dir,
- fixup_path, pdfium_test_path, text_diff_path,
- drmem_wrapper):
- input_root, _ = os.path.splitext(input_filename)
- input_path = os.path.join(source_dir, input_root + '.in')
- pdf_path = os.path.join(working_dir, input_root + '.pdf')
- txt_path = os.path.join(working_dir, input_root + '.txt')
- expected_path = os.path.join(source_dir, input_root + '_expected.txt')
- try:
- sys.stdout.flush()
- subprocess.check_call(
- [sys.executable, fixup_path, '--output-dir=' + working_dir, input_path])
- with open(txt_path, 'w') as outfile:
- # add Dr. Memory wrapper if exist
- cmd_to_run = common.DrMemoryWrapper(drmem_wrapper, input_root)
- cmd_to_run.extend([pdfium_test_path, pdf_path])
- # run test
- subprocess.check_call(cmd_to_run, stdout=outfile)
- subprocess.check_call(
- [sys.executable, text_diff_path, expected_path, txt_path])
- except subprocess.CalledProcessError as e:
- print "FAILURE: " + input_filename + "; " + str(e)
- return False
- return True
+import test_runner
def main():
- parser = optparse.OptionParser()
- parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
- help='relative path from the base source directory')
- parser.add_option('--wrapper', default='', dest="wrapper",
- help='Dr. Memory wrapper for running test under Dr. Memory')
- options, args = parser.parse_args()
-
- finder = common.DirectoryFinder(options.build_dir)
- fixup_path = finder.ScriptPath('fixup_pdf_template.py')
- text_diff_path = finder.ScriptPath('text_diff.py')
- source_dir = finder.TestingDir(os.path.join('resources', 'javascript'))
- pdfium_test_path = finder.ExecutablePath('pdfium_test')
- if not os.path.exists(pdfium_test_path):
- print "FAILURE: Can't find test executable '%s'" % pdfium_test_path
- print "Use --build-dir to specify its location."
- return 1
- working_dir = finder.WorkingDir(os.path.join('testing', 'javascript'))
- if not os.path.exists(working_dir):
- os.makedirs(working_dir)
-
- feature_string = subprocess.check_output([pdfium_test_path, '--show-config'])
- if "V8" not in feature_string.strip().split(","):
- print "V8 not enabled, skipping."
- return 0
-
- input_files = []
- if len(args):
- for file_name in args:
- input_files.append(file_name.replace(".pdf", ".in"))
- else:
- input_files = os.listdir(source_dir)
-
- failures = []
- input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
- for input_filename in input_files:
- if input_file_re.match(input_filename):
- input_path = os.path.join(source_dir, input_filename)
- if os.path.isfile(input_path):
- if not generate_and_test(input_filename, source_dir, working_dir,
- fixup_path, pdfium_test_path, text_diff_path,
- options.wrapper):
- failures.append(input_path)
-
- if failures:
- failures.sort()
- print '\n\nSummary of Failures:'
- for failure in failures:
- print failure
- return 1
- return 0
-
+ runner = test_runner.TestRunner('javascript')
+ return runner.Run()
if __name__ == '__main__':
sys.exit(main())
diff --git a/chromium/third_party/pdfium/testing/tools/run_pixel_tests.py b/chromium/third_party/pdfium/testing/tools/run_pixel_tests.py
index 8a102f4c42e..aad39c56002 100755
--- a/chromium/third_party/pdfium/testing/tools/run_pixel_tests.py
+++ b/chromium/third_party/pdfium/testing/tools/run_pixel_tests.py
@@ -3,105 +3,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import optparse
-import os
-import re
-import subprocess
import sys
-import common
-import pngdiffer
-import suppressor
-
-# Nomenclature:
-# x_root - "x"
-# x_filename - "x.ext"
-# x_path - "path/to/a/b/c/x.ext"
-# c_dir - "path/to/a/b/c"
-
-def generate_and_test(input_filename, source_dir, working_dir,
- fixup_path, pdfium_test_path, image_differ,
- drmem_wrapper):
- input_root, _ = os.path.splitext(input_filename)
- input_path = os.path.join(source_dir, input_root + '.in')
- pdf_path = os.path.join(working_dir, input_root + '.pdf')
-
- # Remove any existing generated images from previous runs.
- actual_images = image_differ.GetActualFiles(
- input_filename, source_dir, working_dir)
- for image in actual_images:
- if os.path.exists(image):
- os.remove(image)
-
- try:
- sys.stdout.flush()
- subprocess.check_call(
- [sys.executable, fixup_path, '--output-dir=' + working_dir, input_path])
- # add Dr. Memory wrapper if exist
- cmd_to_run = common.DrMemoryWrapper(drmem_wrapper, input_root)
- cmd_to_run.extend([pdfium_test_path, '--png', pdf_path])
- # run test
- subprocess.check_call(cmd_to_run)
- except subprocess.CalledProcessError as e:
- print "FAILURE: " + input_filename + "; " + str(e)
- return False
- if image_differ.HasDifferences(input_filename, source_dir, working_dir):
- print "FAILURE: " + input_filename
- return False
- return True
-
+import test_runner
def main():
- parser = optparse.OptionParser()
- parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
- help='relative path from the base source directory')
- parser.add_option('--wrapper', default='', dest="wrapper",
- help='Dr. Memory wrapper for running test under Dr. Memory')
- options, args = parser.parse_args()
- finder = common.DirectoryFinder(options.build_dir)
- fixup_path = finder.ScriptPath('fixup_pdf_template.py')
- source_dir = finder.TestingDir(os.path.join('resources', 'pixel'))
- pdfium_test_path = finder.ExecutablePath('pdfium_test')
- if not os.path.exists(pdfium_test_path):
- print "FAILURE: Can't find test executable '%s'" % pdfium_test_path
- print "Use --build-dir to specify its location."
- return 1
- working_dir = finder.WorkingDir(os.path.join('testing', 'pixel'))
- if not os.path.exists(working_dir):
- os.makedirs(working_dir)
-
- feature_string = subprocess.check_output([pdfium_test_path, '--show-config'])
- test_suppressor = suppressor.Suppressor(finder, feature_string)
- image_differ = pngdiffer.PNGDiffer(finder)
-
- input_files = []
- if len(args):
- for file_name in args:
- input_files.append(file_name.replace(".pdf", ".in"))
- else:
- input_files = os.listdir(source_dir)
-
- failures = []
- input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
- for input_filename in input_files:
- if input_file_re.match(input_filename):
- input_path = os.path.join(source_dir, input_filename)
- if os.path.isfile(input_path):
- if test_suppressor.IsSuppressed(input_filename):
- continue
- if not generate_and_test(input_filename, source_dir, working_dir,
- fixup_path, pdfium_test_path, image_differ,
- options.wrapper):
- failures.append(input_path)
-
- if failures:
- failures.sort()
- print '\n\nSummary of Failures:'
- for failure in failures:
- print failure
- return 1
- return 0
-
+ runner = test_runner.TestRunner('pixel')
+ return runner.Run()
if __name__ == '__main__':
sys.exit(main())
diff --git a/chromium/third_party/pdfium/testing/tools/suppressor.py b/chromium/third_party/pdfium/testing/tools/suppressor.py
index a1c3171de11..b7629ef6f8c 100755
--- a/chromium/third_party/pdfium/testing/tools/suppressor.py
+++ b/chromium/third_party/pdfium/testing/tools/suppressor.py
@@ -10,8 +10,10 @@ import common
class Suppressor:
def __init__(self, finder, feature_string):
feature_vector = feature_string.strip().split(",")
- v8_option = ["nov8", "v8"]["V8" in feature_vector]
- xfa_option = ["noxfa", "xfa"]["XFA" in feature_vector]
+ self.has_v8 = "V8" in feature_vector
+ self.has_xfa = "XFA" in feature_vector
+ v8_option = "v8" if self.has_v8 else "nov8"
+ xfa_option = "xfa" if self.has_xfa else "noxfa"
with open(os.path.join(finder.TestingDir(), 'SUPPRESSIONS')) as f:
self.suppression_set = set(self._FilterSuppressions(
common.os_name(), v8_option, xfa_option, self._ExtractSuppressions(f)))
@@ -33,8 +35,14 @@ class Suppressor:
('*' in js_column or js in js_column) and
('*' in xfa_column or xfa in xfa_column))
- def IsSuppressed(self, input_filename):
+ def IsResultSuppressed(self, input_filename):
if input_filename in self.suppression_set:
- print "%s is suppressed" % input_filename
+ print "%s result is suppressed" % input_filename
+ return True
+ return False
+
+ def IsExecutionSuppressed(self, input_filepath):
+ if "xfa_specific" in input_filepath and not self.has_xfa:
+ print "%s execution is suppressed" % input_filepath
return True
return False
diff --git a/chromium/third_party/pdfium/testing/tools/test_runner.py b/chromium/third_party/pdfium/testing/tools/test_runner.py
new file mode 100644
index 00000000000..5c377067d02
--- /dev/null
+++ b/chromium/third_party/pdfium/testing/tools/test_runner.py
@@ -0,0 +1,231 @@
+#!/usr/bin/env python
+# Copyright 2016 The PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import cStringIO
+import functools
+import multiprocessing
+import optparse
+import os
+import re
+import shutil
+import subprocess
+import sys
+
+import common
+import pngdiffer
+import suppressor
+
+class KeyboardInterruptError(Exception): pass
+
+# Nomenclature:
+# x_root - "x"
+# x_filename - "x.ext"
+# x_path - "path/to/a/b/c/x.ext"
+# c_dir - "path/to/a/b/c"
+
+def TestOneFileParallel(this, test_case):
+ """Wrapper to call GenerateAndTest() and redirect output to stdout."""
+ try:
+ input_filename, source_dir = test_case
+ result = this.GenerateAndTest(input_filename, source_dir);
+ return (result, input_filename, source_dir)
+ except KeyboardInterrupt:
+ raise KeyboardInterruptError()
+
+
+class TestRunner:
+ def __init__(self, dirname):
+ self.test_dir = dirname
+
+ def GenerateAndTest(self, input_filename, source_dir):
+ input_root, _ = os.path.splitext(input_filename)
+ expected_txt_path = os.path.join(source_dir, input_root + '_expected.txt')
+
+ pdf_path = os.path.join(self.working_dir, input_root + '.pdf')
+
+ # Remove any existing generated images from previous runs.
+ actual_images = self.image_differ.GetActualFiles(input_filename, source_dir,
+ self.working_dir)
+ for image in actual_images:
+ if os.path.exists(image):
+ os.remove(image)
+
+ sys.stdout.flush()
+
+ raised_exception = self.Generate(source_dir, input_filename, input_root,
+ pdf_path)
+
+ if raised_exception != None:
+ print "FAILURE: " + input_filename + "; " + str(raised_exception)
+ return False
+
+ if os.path.exists(expected_txt_path):
+ raised_exception = self.TestText(input_root, expected_txt_path, pdf_path)
+ else:
+ raised_exception = self.TestPixel(input_root, pdf_path)
+
+ if raised_exception != None:
+ print "FAILURE: " + input_filename + "; " + str(raised_exception)
+ return False
+
+ if len(actual_images):
+ if self.image_differ.HasDifferences(input_filename, source_dir,
+ self.working_dir):
+ return False
+
+ return True
+
+ def Generate(self, source_dir, input_filename, input_root, pdf_path):
+ original_path = os.path.join(source_dir, input_filename)
+ input_path = os.path.join(source_dir, input_root + '.in')
+
+ input_event_path = os.path.join(source_dir, input_root + ".evt")
+ if os.path.exists(input_event_path):
+ output_event_path = os.path.splitext(pdf_path)[0] + ".evt"
+ shutil.copyfile(input_event_path, output_event_path)
+
+ if not os.path.exists(input_path):
+ if os.path.exists(original_path):
+ shutil.copyfile(original_path, pdf_path)
+ return None
+
+ sys.stdout.flush()
+
+ return common.RunCommand(
+ [sys.executable, self.fixup_path, '--output-dir=' + self.working_dir,
+ input_path])
+
+
+ def TestText(self, input_root, expected_txt_path, pdf_path):
+ txt_path = os.path.join(self.working_dir, input_root + '.txt')
+
+ with open(txt_path, 'w') as outfile:
+ # add Dr. Memory wrapper if exist
+ cmd_to_run = common.DrMemoryWrapper(self.drmem_wrapper, input_root)
+ cmd_to_run.extend([self.pdfium_test_path, pdf_path])
+ subprocess.check_call(cmd_to_run, stdout=outfile)
+
+ cmd = [sys.executable, self.text_diff_path, expected_txt_path, txt_path]
+ return common.RunCommand(cmd)
+
+
+ def TestPixel(self, input_root, pdf_path):
+ cmd_to_run = common.DrMemoryWrapper(self.drmem_wrapper, input_root)
+ cmd_to_run.extend([self.pdfium_test_path, '--send-events', '--png',
+ pdf_path])
+ return common.RunCommand(cmd_to_run)
+
+
+ def HandleResult(self, input_filename, input_path, result):
+ if self.test_suppressor.IsResultSuppressed(input_filename):
+ if result:
+ self.surprises.append(input_path)
+ else:
+ if not result:
+ self.failures.append(input_path)
+
+
+ def Run(self):
+ parser = optparse.OptionParser()
+ parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
+ help='relative path from the base source directory')
+ parser.add_option('-j', default=multiprocessing.cpu_count(),
+ dest='num_workers', type='int',
+ help='run NUM_WORKERS jobs in parallel')
+ parser.add_option('--wrapper', default='', dest="wrapper",
+ help='wrapper for running test under Dr. Memory')
+ options, args = parser.parse_args()
+
+ finder = common.DirectoryFinder(options.build_dir)
+ self.fixup_path = finder.ScriptPath('fixup_pdf_template.py')
+ self.text_diff_path = finder.ScriptPath('text_diff.py')
+
+ self.drmem_wrapper = options.wrapper
+
+ self.source_dir = finder.TestingDir()
+ if self.test_dir != 'corpus':
+ test_dir = finder.TestingDir(os.path.join('resources', self.test_dir))
+ else:
+ test_dir = finder.TestingDir(self.test_dir)
+
+ self.pdfium_test_path = finder.ExecutablePath('pdfium_test')
+ if not os.path.exists(self.pdfium_test_path):
+ print "FAILURE: Can't find test executable '%s'" % self.pdfium_test_path
+ print "Use --build-dir to specify its location."
+ return 1
+
+ self.working_dir = finder.WorkingDir(os.path.join('testing', self.test_dir))
+ if not os.path.exists(self.working_dir):
+ os.makedirs(self.working_dir)
+
+ self.feature_string = subprocess.check_output([self.pdfium_test_path,
+ '--show-config'])
+ self.test_suppressor = suppressor.Suppressor(finder, self.feature_string)
+ self.image_differ = pngdiffer.PNGDiffer(finder)
+
+ walk_from_dir = finder.TestingDir(test_dir);
+
+ test_cases = []
+ input_file_re = re.compile('^[a-zA-Z0-9_.]+[.](in|pdf)$')
+ if len(args):
+ for file_name in args:
+ file_name.replace(".pdf", ".in")
+ input_path = os.path.join(walk_from_dir, file_name)
+ if not os.path.isfile(input_path):
+ print "Can't find test file '%s'" % file_name
+ return 1
+
+ test_cases.append((os.path.basename(input_path),
+ os.path.dirname(input_path)))
+ else:
+ for file_dir, _, filename_list in os.walk(walk_from_dir):
+ for input_filename in filename_list:
+ if input_file_re.match(input_filename):
+ input_path = os.path.join(file_dir, input_filename)
+ if not self.test_suppressor.IsExecutionSuppressed(input_path):
+ if os.path.isfile(input_path):
+ test_cases.append((input_filename, file_dir))
+
+ self.failures = []
+ self.surprises = []
+
+ if options.num_workers > 1 and len(test_cases) > 1:
+ try:
+ pool = multiprocessing.Pool(options.num_workers)
+ worker_func = functools.partial(TestOneFileParallel, self)
+
+ worker_results = pool.imap(worker_func, test_cases)
+ for worker_result in worker_results:
+ result, input_filename, source_dir = worker_result
+ input_path = os.path.join(source_dir, input_filename)
+
+ self.HandleResult(input_filename, input_path, result)
+
+ except KeyboardInterrupt:
+ pool.terminate()
+ finally:
+ pool.close()
+ pool.join()
+ else:
+ for test_case in test_cases:
+ input_filename, input_file_dir = test_case
+ result = self.GenerateAndTest(input_filename, input_file_dir)
+ self.HandleResult(input_filename,
+ os.path.join(input_file_dir, input_filename), result)
+
+ if self.surprises:
+ self.surprises.sort()
+ print '\n\nUnexpected Successes:'
+ for surprise in self.surprises:
+ print surprise;
+
+ if self.failures:
+ self.failures.sort()
+ print '\n\nSummary of Failures:'
+ for failure in self.failures:
+ print failure
+ return 1
+
+ return 0
diff --git a/chromium/third_party/pdfium/testing/utils/path_service.cpp b/chromium/third_party/pdfium/testing/utils/path_service.cpp
index 9b2657406d8..c3b8f40d184 100644
--- a/chromium/third_party/pdfium/testing/utils/path_service.cpp
+++ b/chromium/third_party/pdfium/testing/utils/path_service.cpp
@@ -33,7 +33,7 @@ bool PathService::GetExecutableDir(std::string* path) {
return false;
*path = std::string(path_buffer);
#elif defined(__APPLE__)
- FXSYS_assert(path);
+ ASSERT(path);
unsigned int path_length = 0;
_NSGetExecutablePath(NULL, &path_length);
if (path_length == 0)
diff --git a/chromium/third_party/pdfium/third_party/third_party.gyp b/chromium/third_party/pdfium/third_party/third_party.gyp
index 7fd10824544..41db3b28db1 100644
--- a/chromium/third_party/pdfium/third_party/third_party.gyp
+++ b/chromium/third_party/pdfium/third_party/third_party.gyp
@@ -12,16 +12,12 @@
'OPJ_STATIC',
'PNG_PREFIX',
'PNG_USE_READ_MACROS',
- '_CRT_SECURE_NO_WARNINGS',
],
'include_dirs': [
# This is implicit in GN.
'<(DEPTH)',
'..',
],
- 'msvs_disabled_warnings': [
- 4005, 4018, 4146, 4333, 4345, 4267
- ],
},
'targets': [
{
@@ -89,6 +85,13 @@
'freetype/src/base/fttype1.c',
],
}],
+ ['os_posix==1 and clang==0', {
+ 'cflags': [
+ # open_face_PS_from_sfnt_stream() and open_face_from_buffer() in
+ # ftbase.h are unused. GCC needs this flag too.
+ '-Wno-unused-function',
+ ],
+ }],
],
'variables': {
'clang_warning_flags': [
@@ -97,6 +100,11 @@
'-Wno-unused-function',
],
},
+ 'msvs_disabled_warnings': [
+ # Warnings about conversion from 'size_t' to 'long', possible loss of
+ # data.
+ 4267,
+ ],
},
{
'target_name': 'fx_agg',
@@ -121,7 +129,7 @@
'conditions': [
['os_posix==1', {
# library contains several enum vs non-enum conditionals.
- 'cflags': [ '-Wno-extra', ],
+ 'cflags': [ '-Wno-extra' ],
}],
],
'variables': {
@@ -254,7 +262,12 @@
# Avoid warning for undefined behaviour.
'-Wno-shift-negative-value',
],
- }
+ },
+ 'msvs_disabled_warnings': [
+ # Warnings about conversion from 'size_t' to 'long', possible loss of
+ # data.
+ 4267,
+ ],
},
{
'target_name': 'fx_libopenjpeg',
@@ -280,6 +293,9 @@
'libopenjpeg20/tcd.c',
'libopenjpeg20/tgt.c',
],
+ 'msvs_disabled_warnings': [
+ 4018,
+ ],
},
{
'target_name': 'fx_lpng',
@@ -411,6 +427,15 @@
'libtiff/tif_write.c',
'libtiff/tif_zip.c',
],
+ 'conditions': [
+ ['OS=="win"', {
+ 'defines!': [
+ # Need to undefine the macro since it is redefined in
+ # tif_ojpeg.c and tif_jpeg.c.
+ 'WIN32_LEAN_AND_MEAN',
+ ],
+ }],
+ ],
},
],
}],
diff --git a/chromium/third_party/pdfium/xfa.gyp b/chromium/third_party/pdfium/xfa.gyp
index 1d0c8281510..f6293d5774e 100644
--- a/chromium/third_party/pdfium/xfa.gyp
+++ b/chromium/third_party/pdfium/xfa.gyp
@@ -11,14 +11,6 @@
# TODO(thestig): Fix all instances, remove this, pdfium:29
4245, 4310, 4389, 4701, 4702, 4706, 4800,
],
- 'variables': {
- 'clang_warning_flags': [
- # TODO(thestig): Fix all instances, remove this, pdfium:29
- '-Wno-sign-compare',
- ],
- # Make sure Chromium's build/common.gypi doesn't re-add the flag on linux.
- 'cflags_cc!': [ '-Wsign-compare' ],
- },
},
"targets":[
{
@@ -35,20 +27,19 @@
'FT2_BUILD_LIBRARY',
],
"sources":[
- "xfa/include/fxfa/fxfa.h",
- "xfa/include/fxfa/fxfa_basic.h",
- "xfa/include/fxfa/fxfa_objectacc.h",
- "xfa/include/fxfa/fxfa_widget.h",
- "xfa/include/fxfa/xfa_checksum.h",
- "xfa/include/fxfa/xfa_ffapp.h",
- "xfa/include/fxfa/xfa_ffdoc.h",
- "xfa/include/fxfa/xfa_ffdochandler.h",
- "xfa/include/fxfa/xfa_ffdocview.h",
- "xfa/include/fxfa/xfa_ffpageview.h",
- "xfa/include/fxfa/xfa_ffwidget.h",
- "xfa/include/fxfa/xfa_ffwidgethandler.h",
- "xfa/include/fxfa/xfa_fontmgr.h",
- "xfa/include/fxfa/xfa_rendercontext.h",
+ "xfa/fxfa/include/fxfa.h",
+ "xfa/fxfa/include/fxfa_basic.h",
+ "xfa/fxfa/include/fxfa_widget.h",
+ "xfa/fxfa/include/xfa_checksum.h",
+ "xfa/fxfa/include/xfa_ffapp.h",
+ "xfa/fxfa/include/xfa_ffdoc.h",
+ "xfa/fxfa/include/xfa_ffdochandler.h",
+ "xfa/fxfa/include/xfa_ffdocview.h",
+ "xfa/fxfa/include/xfa_ffpageview.h",
+ "xfa/fxfa/include/xfa_ffwidget.h",
+ "xfa/fxfa/include/xfa_ffwidgethandler.h",
+ "xfa/fxfa/include/xfa_fontmgr.h",
+ "xfa/fxfa/include/xfa_rendercontext.h",
"xfa/fde/css/fde_css.h",
"xfa/fde/css/fde_csscache.cpp",
"xfa/fde/css/fde_csscache.h",
@@ -62,21 +53,13 @@
"xfa/fde/css/fde_cssstylesheet.h",
"xfa/fde/css/fde_csssyntax.cpp",
"xfa/fde/css/fde_csssyntax.h",
- "xfa/fde/fde_brush.h",
- "xfa/fde/fde_devbasic.cpp",
- "xfa/fde/fde_devbasic.h",
- "xfa/fde/fde_renderdevice.h",
+ "xfa/fde/cfde_path.cpp",
+ "xfa/fde/cfde_path.h",
"xfa/fde/fde_gedevice.cpp",
"xfa/fde/fde_gedevice.h",
- "xfa/fde/fde_geobject.cpp",
- "xfa/fde/fde_geobject.h",
- "xfa/fde/fde_image.h",
"xfa/fde/fde_iterator.cpp",
"xfa/fde/fde_iterator.h",
- "xfa/fde/fde_object.cpp",
"xfa/fde/fde_object.h",
- "xfa/fde/fde_path.h",
- "xfa/fde/fde_pen.h",
"xfa/fde/fde_render.cpp",
"xfa/fde/fde_render.h",
"xfa/fde/tto/fde_textout.cpp",
@@ -96,7 +79,6 @@
"xfa/fee/fx_wordbreak/fx_wordbreakdata.cpp",
"xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp",
"xfa/fee/fx_wordbreak/fx_wordbreak_impl.h",
- "xfa/fee/ifde_txtedtbuf.h",
"xfa/fee/ifde_txtedtengine.h",
"xfa/fee/ifde_txtedtpage.h",
"xfa/fgas/crt/fgas_algorithm.cpp",
@@ -135,9 +117,8 @@
"xfa/fgas/localization/fgas_localeimp.h",
"xfa/fgas/localization/fgas_localemgr.cpp",
"xfa/fgas/localization/fgas_localemgr.h",
+ "xfa/fgas/xml/fgas_sax.cpp",
"xfa/fgas/xml/fgas_sax.h",
- "xfa/fgas/xml/fgas_sax_imp.cpp",
- "xfa/fgas/xml/fgas_sax_imp.h",
"xfa/fwl/basewidget/fwl_barcodeimp.cpp",
"xfa/fwl/basewidget/fwl_barcodeimp.h",
"xfa/fwl/basewidget/fwl_caretimp.cpp",
@@ -181,9 +162,7 @@
"xfa/fwl/basewidget/ifwl_scrollbar.h",
"xfa/fwl/basewidget/ifwl_spinbutton.h",
"xfa/fwl/basewidget/ifwl_tooltip.h",
- "xfa/fwl/basewidget/ifx_barcode.h",
"xfa/fwl/core/cfwl_event.h",
- "xfa/fwl/core/cfwl_note.h",
"xfa/fwl/core/cfwl_message.h",
"xfa/fwl/core/cfwl_themebackground.h",
"xfa/fwl/core/cfwl_themepart.h",
@@ -191,60 +170,30 @@
"xfa/fwl/core/cfwl_widgetimpproperties.h",
"xfa/fwl/core/fwl_appimp.cpp",
"xfa/fwl/core/fwl_appimp.h",
- "xfa/fwl/core/fwl_contentimp.cpp",
- "xfa/fwl/core/fwl_contentimp.h",
"xfa/fwl/core/fwl_error.h",
"xfa/fwl/core/fwl_formimp.cpp",
"xfa/fwl/core/fwl_formimp.h",
- "xfa/fwl/core/fwl_gridimp.cpp",
- "xfa/fwl/core/fwl_gridimp.h",
"xfa/fwl/core/fwl_noteimp.cpp",
"xfa/fwl/core/fwl_noteimp.h",
- "xfa/fwl/core/fwl_panelimp.cpp",
- "xfa/fwl/core/fwl_panelimp.h",
- "xfa/fwl/core/fwl_sdadapterimp.cpp",
- "xfa/fwl/core/fwl_sdadapterimp.h",
- "xfa/fwl/core/fwl_targetimp.cpp",
- "xfa/fwl/core/fwl_targetimp.h",
- "xfa/fwl/core/fwl_threadimp.cpp",
- "xfa/fwl/core/fwl_threadimp.h",
"xfa/fwl/core/fwl_timerimp.cpp",
"xfa/fwl/core/fwl_widgetdef.h",
"xfa/fwl/core/fwl_widgetimp.cpp",
"xfa/fwl/core/fwl_widgetimp.h",
"xfa/fwl/core/fwl_widgetmgrimp.cpp",
"xfa/fwl/core/fwl_widgetmgrimp.h",
- "xfa/fwl/core/ifwl_adapternative.h",
- "xfa/fwl/core/ifwl_adapterthreadmgr.h",
- "xfa/fwl/core/ifwl_adapterwidgetmgr.h",
"xfa/fwl/core/ifwl_app.h",
- "xfa/fwl/core/ifwl_content.h",
- "xfa/fwl/core/ifwl_custom.h",
- "xfa/fwl/core/ifwl_custompanel.h",
"xfa/fwl/core/ifwl_dataprovider.h",
"xfa/fwl/core/ifwl_form.h",
- "xfa/fwl/core/ifwl_grid.h",
- "xfa/fwl/core/ifwl_notedriver.h",
- "xfa/fwl/core/ifwl_noteloop.h",
- "xfa/fwl/core/ifwl_notethread.h",
- "xfa/fwl/core/ifwl_panel.h",
- "xfa/fwl/core/ifwl_proxy.h",
- "xfa/fwl/core/ifwl_target.h",
"xfa/fwl/core/ifwl_themeprovider.h",
- "xfa/fwl/core/ifwl_thread.h",
"xfa/fwl/core/ifwl_timer.h",
"xfa/fwl/core/ifwl_tooltiptarget.h",
"xfa/fwl/core/ifwl_widget.h",
"xfa/fwl/core/ifwl_widgetdelegate.h",
"xfa/fwl/core/ifwl_widgetmgr.h",
- "xfa/fwl/core/ifwl_widgetmgrdelegate.h",
+ "xfa/fwl/core/include/fwl_widgethit.h",
"xfa/fwl/core/include/ifwl_adaptertimermgr.h",
- "xfa/fwl/lightwidget/cfwl_app.cpp",
- "xfa/fwl/lightwidget/cfwl_app.h",
"xfa/fwl/lightwidget/cfwl_barcode.cpp",
"xfa/fwl/lightwidget/cfwl_barcode.h",
- "xfa/fwl/lightwidget/cfwl_caret.cpp",
- "xfa/fwl/lightwidget/cfwl_caret.h",
"xfa/fwl/lightwidget/cfwl_checkbox.cpp",
"xfa/fwl/lightwidget/cfwl_checkbox.h",
"xfa/fwl/lightwidget/cfwl_combobox.cpp",
@@ -621,11 +570,63 @@
"xfa/fxfa/fm2js/xfa_program.h",
"xfa/fxfa/fm2js/xfa_simpleexpression.cpp",
"xfa/fxfa/fm2js/xfa_simpleexpression.h",
+ "xfa/fxfa/parser/cxfa_arc.h",
+ "xfa/fxfa/parser/cxfa_assist.cpp",
+ "xfa/fxfa/parser/cxfa_assist.h",
+ "xfa/fxfa/parser/cxfa_bind.cpp",
+ "xfa/fxfa/parser/cxfa_bind.h",
+ "xfa/fxfa/parser/cxfa_binditems.cpp",
+ "xfa/fxfa/parser/cxfa_binditems.h",
+ "xfa/fxfa/parser/cxfa_border.h",
+ "xfa/fxfa/parser/cxfa_box.cpp",
+ "xfa/fxfa/parser/cxfa_box.h",
+ "xfa/fxfa/parser/cxfa_calculate.cpp",
+ "xfa/fxfa/parser/cxfa_calculate.h",
+ "xfa/fxfa/parser/cxfa_caption.cpp",
+ "xfa/fxfa/parser/cxfa_caption.h",
+ "xfa/fxfa/parser/cxfa_corner.h",
+ "xfa/fxfa/parser/cxfa_data.cpp",
+ "xfa/fxfa/parser/cxfa_data.h",
+ "xfa/fxfa/parser/cxfa_edge.h",
+ "xfa/fxfa/parser/cxfa_event.cpp",
+ "xfa/fxfa/parser/cxfa_event.h",
+ "xfa/fxfa/parser/cxfa_exdata.cpp",
+ "xfa/fxfa/parser/cxfa_exdata.h",
+ "xfa/fxfa/parser/cxfa_fill.cpp",
+ "xfa/fxfa/parser/cxfa_fill.h",
+ "xfa/fxfa/parser/cxfa_font.cpp",
+ "xfa/fxfa/parser/cxfa_font.h",
+ "xfa/fxfa/parser/cxfa_image.cpp",
+ "xfa/fxfa/parser/cxfa_image.h",
+ "xfa/fxfa/parser/cxfa_line.cpp",
+ "xfa/fxfa/parser/cxfa_line.h",
+ "xfa/fxfa/parser/cxfa_margin.cpp",
+ "xfa/fxfa/parser/cxfa_margin.h",
+ "xfa/fxfa/parser/cxfa_occur.cpp",
+ "xfa/fxfa/parser/cxfa_occur.h",
+ "xfa/fxfa/parser/cxfa_para.cpp",
+ "xfa/fxfa/parser/cxfa_para.h",
+ "xfa/fxfa/parser/cxfa_rectangle.h",
+ "xfa/fxfa/parser/cxfa_script.cpp",
+ "xfa/fxfa/parser/cxfa_script.h",
+ "xfa/fxfa/parser/cxfa_stroke.cpp",
+ "xfa/fxfa/parser/cxfa_stroke.h",
+ "xfa/fxfa/parser/cxfa_submit.cpp",
+ "xfa/fxfa/parser/cxfa_submit.h",
+ "xfa/fxfa/parser/cxfa_text.cpp",
+ "xfa/fxfa/parser/cxfa_text.h",
+ "xfa/fxfa/parser/cxfa_tooltip.cpp",
+ "xfa/fxfa/parser/cxfa_tooltip.h",
+ "xfa/fxfa/parser/cxfa_validate.cpp",
+ "xfa/fxfa/parser/cxfa_validate.h",
+ "xfa/fxfa/parser/cxfa_value.cpp",
+ "xfa/fxfa/parser/cxfa_value.h",
+ "xfa/fxfa/parser/cxfa_widgetdata.cpp",
+ "xfa/fxfa/parser/cxfa_widgetdata.h",
"xfa/fxfa/parser/xfa_basic_data.cpp",
"xfa/fxfa/parser/xfa_basic_data.h",
"xfa/fxfa/parser/xfa_basic_imp.cpp",
"xfa/fxfa/parser/xfa_basic_imp.h",
- "xfa/fxfa/parser/xfa_docdata.h",
"xfa/fxfa/parser/xfa_doclayout.h",
"xfa/fxfa/parser/xfa_document.h",
"xfa/fxfa/parser/xfa_document_datadescription_imp.cpp",
@@ -650,7 +651,6 @@
"xfa/fxfa/parser/xfa_localevalue.cpp",
"xfa/fxfa/parser/xfa_localevalue.h",
"xfa/fxfa/parser/xfa_object.h",
- "xfa/fxfa/parser/xfa_objectacc_imp.cpp",
"xfa/fxfa/parser/xfa_object_imp.cpp",
"xfa/fxfa/parser/xfa_parser.h",
"xfa/fxfa/parser/xfa_parser_imp.cpp",
@@ -697,10 +697,10 @@
}],
["pdf_enable_v8==1", {
'dependencies': [
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ '<(DEPTH)/v8/src/v8.gyp:v8',
],
'export_dependent_settings': [
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ '<(DEPTH)/v8/src/v8.gyp:v8',
],
'include_dirs': [
'<(DEPTH)/v8',
diff --git a/chromium/third_party/pdfium/xfa/DEPS b/chromium/third_party/pdfium/xfa/DEPS
index ef5e5b9d068..f935fbc2694 100644
--- a/chromium/third_party/pdfium/xfa/DEPS
+++ b/chromium/third_party/pdfium/xfa/DEPS
@@ -1,6 +1,6 @@
include_rules = [
- '+core/include',
'+core/fxcrt/include',
'+core/fpdfapi/fpdf_parser/include',
+ '+core/fxge/include',
'+third_party/bigint'
]
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_geobject.cpp b/chromium/third_party/pdfium/xfa/fde/cfde_path.cpp
index f4aede0ee4f..7ea458d4853 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_geobject.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/cfde_path.cpp
@@ -4,57 +4,59 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fde/fde_geobject.h"
+#include "xfa/fde/cfde_path.h"
#include "xfa/fde/fde_object.h"
-IFDE_Path* IFDE_Path::Create() {
- return new CFDE_Path;
-}
FX_BOOL CFDE_Path::StartFigure() {
return CloseFigure();
}
+
FX_BOOL CFDE_Path::CloseFigure() {
FX_PATHPOINT* pPoint = GetLastPoint();
- if (pPoint) {
+ if (pPoint)
pPoint->m_Flag |= FXPT_CLOSEFIGURE;
- }
return TRUE;
}
+
FX_PATHPOINT* CFDE_Path::GetLastPoint(int32_t iCount) const {
- if (iCount < 1) {
- return NULL;
- }
+ if (iCount < 1)
+ return nullptr;
+
int32_t iPoints = m_Path.GetPointCount();
- if (iCount > iPoints) {
- return NULL;
- }
+ if (iCount > iPoints)
+ return nullptr;
return m_Path.GetPoints() + iPoints - iCount;
}
+
FX_BOOL CFDE_Path::FigureClosed() const {
FX_PATHPOINT* pPoint = GetLastPoint();
return pPoint ? (pPoint->m_Flag & FXPT_CLOSEFIGURE) : TRUE;
}
+
FX_PATHPOINT* CFDE_Path::AddPoints(int32_t iCount) {
- if (iCount < 1) {
- return NULL;
- }
+ if (iCount < 1)
+ return nullptr;
+
int32_t iPoints = m_Path.GetPointCount();
m_Path.AddPointCount(iCount);
return m_Path.GetPoints() + iPoints;
}
+
void CFDE_Path::MoveTo(FX_FLOAT fx, FX_FLOAT fy) {
FX_PATHPOINT* pPoint = AddPoints(1);
pPoint->m_PointX = fx;
pPoint->m_PointY = fy;
pPoint->m_Flag = FXPT_MOVETO;
}
+
void CFDE_Path::LineTo(FX_FLOAT fx, FX_FLOAT fy) {
FX_PATHPOINT* pPoint = AddPoints(1);
pPoint->m_PointX = fx;
pPoint->m_PointY = fy;
pPoint->m_Flag = FXPT_LINETO;
}
+
void CFDE_Path::BezierTo(const CFX_PointF& p1,
const CFX_PointF& p2,
const CFX_PointF& p3) {
@@ -69,6 +71,7 @@ void CFDE_Path::BezierTo(const CFX_PointF& p1,
p[2].m_PointY = p3.y;
p[2].m_Flag = FXPT_BEZIERTO;
}
+
void CFDE_Path::ArcTo(FX_BOOL bStart,
const CFX_RectF& rect,
FX_FLOAT startAngle,
@@ -82,11 +85,10 @@ void CFDE_Path::ArcTo(FX_BOOL bStart,
FX_FLOAT beta =
FXSYS_atan2(rx * FXSYS_sin(endAngle), ry * FXSYS_cos(endAngle));
if (FXSYS_fabs(beta - alpha) > FX_PI) {
- if (beta > alpha) {
+ if (beta > alpha)
beta -= 2 * FX_PI;
- } else {
+ else
alpha -= 2 * FX_PI;
- }
}
FX_FLOAT half_delta = (beta - alpha) / 2;
FX_FLOAT bcp = 4.0f / 3 * (1 - FXSYS_cos(half_delta)) / FXSYS_sin(half_delta);
@@ -105,57 +107,58 @@ void CFDE_Path::ArcTo(FX_BOOL bStart,
}
void CFDE_Path::AddBezier(const CFX_PointsF& points) {
- if (points.GetSize() != 4) {
+ if (points.GetSize() != 4)
return;
- }
+
const CFX_PointF* p = points.GetData();
MoveTo(p[0]);
BezierTo(p[1], p[2], p[3]);
}
+
void CFDE_Path::AddBeziers(const CFX_PointsF& points) {
int32_t iCount = points.GetSize();
- if (iCount < 4) {
+ if (iCount < 4)
return;
- }
+
const CFX_PointF* p = points.GetData();
const CFX_PointF* pEnd = p + iCount;
MoveTo(p[0]);
- for (++p; p <= pEnd - 3; p += 3) {
+ for (++p; p <= pEnd - 3; p += 3)
BezierTo(p[0], p[1], p[2]);
- }
}
+
void CFDE_Path::GetCurveTangents(const CFX_PointsF& points,
CFX_PointsF& tangents,
FX_BOOL bClosed,
FX_FLOAT fTension) const {
int32_t iCount = points.GetSize();
tangents.SetSize(iCount);
- if (iCount < 3) {
+ if (iCount < 3)
return;
- }
+
FX_FLOAT fCoefficient = fTension / 3.0f;
const CFX_PointF* pPoints = points.GetData();
CFX_PointF* pTangents = tangents.GetData();
for (int32_t i = 0; i < iCount; ++i) {
int32_t r = i + 1;
int32_t s = i - 1;
- if (r >= iCount) {
+ if (r >= iCount)
r = bClosed ? (r - iCount) : (iCount - 1);
- }
- if (s < 0) {
+ if (s < 0)
s = bClosed ? (s + iCount) : 0;
- }
+
pTangents[i].x += (fCoefficient * (pPoints[r].x - pPoints[s].x));
pTangents[i].y += (fCoefficient * (pPoints[r].y - pPoints[s].y));
}
}
+
void CFDE_Path::AddCurve(const CFX_PointsF& points,
FX_BOOL bClosed,
FX_FLOAT fTension) {
int32_t iLast = points.GetUpperBound();
- if (iLast < 1) {
+ if (iLast < 1)
return;
- }
+
CFX_PointsF tangents;
GetCurveTangents(points, tangents, bClosed, fTension);
const CFX_PointF* pPoints = points.GetData();
@@ -177,6 +180,7 @@ void CFDE_Path::AddCurve(const CFX_PointsF& points,
CloseFigure();
}
}
+
void CFDE_Path::AddEllipse(const CFX_RectF& rect) {
FX_FLOAT fStartAngle = 0;
FX_FLOAT fEndAngle = FX_PI / 2;
@@ -187,33 +191,35 @@ void CFDE_Path::AddEllipse(const CFX_RectF& rect) {
}
CloseFigure();
}
+
void CFDE_Path::AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2) {
FX_PATHPOINT* pLast = GetLastPoint();
- if (pLast == NULL || FXSYS_fabs(pLast->m_PointX - pt1.x) > 0.001 ||
+ if (!pLast || FXSYS_fabs(pLast->m_PointX - pt1.x) > 0.001 ||
FXSYS_fabs(pLast->m_PointY - pt1.y) > 0.001) {
MoveTo(pt1);
}
LineTo(pt2);
}
-void CFDE_Path::AddPath(const IFDE_Path* pSrc, FX_BOOL bConnect) {
+
+void CFDE_Path::AddPath(const CFDE_Path* pSrc, FX_BOOL bConnect) {
CFDE_Path* pPath = (CFDE_Path*)pSrc;
- if (pPath == NULL) {
+ if (!pPath)
return;
- }
+
int32_t iCount = pPath->m_Path.GetPointCount();
- if (iCount < 1) {
+ if (iCount < 1)
return;
- }
- if (bConnect) {
+ if (bConnect)
LineTo(pPath->m_Path.GetPointX(0), pPath->m_Path.GetPointY(0));
- }
- m_Path.Append(&pPath->m_Path, NULL);
+
+ m_Path.Append(&pPath->m_Path, nullptr);
}
+
void CFDE_Path::AddPolygon(const CFX_PointsF& points) {
int32_t iCount = points.GetSize();
- if (iCount < 2) {
+ if (iCount < 2)
return;
- }
+
AddLines(points);
const CFX_PointF* p = points.GetData();
if (FXSYS_fabs(p[0].x - p[iCount - 1].x) < 0.01f ||
@@ -222,18 +228,19 @@ void CFDE_Path::AddPolygon(const CFX_PointsF& points) {
}
CloseFigure();
}
+
void CFDE_Path::AddLines(const CFX_PointsF& points) {
int32_t iCount = points.GetSize();
- if (iCount < 2) {
+ if (iCount < 2)
return;
- }
+
const CFX_PointF* p = points.GetData();
const CFX_PointF* pEnd = p + iCount;
MoveTo(p[0]);
- for (++p; p < pEnd; ++p) {
+ for (++p; p < pEnd; ++p)
LineTo(*p);
- }
}
+
void CFDE_Path::AddRectangle(const CFX_RectF& rect) {
MoveTo(rect.TopLeft());
LineTo(rect.TopRight());
@@ -241,11 +248,13 @@ void CFDE_Path::AddRectangle(const CFX_RectF& rect) {
LineTo(rect.BottomLeft());
CloseFigure();
}
+
void CFDE_Path::GetBBox(CFX_RectF& bbox) const {
CFX_FloatRect rect = m_Path.GetBoundingBox();
bbox.Set(rect.left, rect.top, rect.Width(), rect.Height());
bbox.Normalize();
}
+
void CFDE_Path::GetBBox(CFX_RectF& bbox,
FX_FLOAT fLineWidth,
FX_FLOAT fMiterLimit) const {
diff --git a/chromium/third_party/pdfium/xfa/fde/cfde_path.h b/chromium/third_party/pdfium/xfa/fde/cfde_path.h
new file mode 100644
index 00000000000..c9f213d3508
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fde/cfde_path.h
@@ -0,0 +1,54 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FDE_CFDE_PATH_H_
+#define XFA_FDE_CFDE_PATH_H_
+
+#include "core/fxge/include/fx_ge.h"
+#include "xfa/fgas/crt/fgas_memory.h"
+
+class CFDE_Path : public CFX_Target {
+ public:
+ FX_BOOL StartFigure();
+ FX_BOOL CloseFigure();
+
+ void AddBezier(const CFX_PointsF& points);
+ void AddBeziers(const CFX_PointsF& points);
+ void AddCurve(const CFX_PointsF& points,
+ FX_BOOL bClosed,
+ FX_FLOAT fTension = 0.5f);
+ void AddEllipse(const CFX_RectF& rect);
+ void AddLines(const CFX_PointsF& points);
+ void AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2);
+ void AddPath(const CFDE_Path* pSrc, FX_BOOL bConnect);
+ void AddPolygon(const CFX_PointsF& points);
+ void AddRectangle(const CFX_RectF& rect);
+ void GetBBox(CFX_RectF& bbox) const;
+ void GetBBox(CFX_RectF& bbox,
+ FX_FLOAT fLineWidth,
+ FX_FLOAT fMiterLimit) const;
+ FX_PATHPOINT* AddPoints(int32_t iCount);
+ FX_PATHPOINT* GetLastPoint(int32_t iCount = 1) const;
+ FX_BOOL FigureClosed() const;
+ void MoveTo(FX_FLOAT fx, FX_FLOAT fy);
+ void LineTo(FX_FLOAT fx, FX_FLOAT fy);
+ void BezierTo(const CFX_PointF& p1,
+ const CFX_PointF& p2,
+ const CFX_PointF& p3);
+ void ArcTo(FX_BOOL bStart,
+ const CFX_RectF& rect,
+ FX_FLOAT startAngle,
+ FX_FLOAT endAngle);
+ void MoveTo(const CFX_PointF& p0) { MoveTo(p0.x, p0.y); }
+ void LineTo(const CFX_PointF& p1) { LineTo(p1.x, p1.y); }
+ void GetCurveTangents(const CFX_PointsF& points,
+ CFX_PointsF& tangents,
+ FX_BOOL bClosed,
+ FX_FLOAT fTension) const;
+ CFX_PathData m_Path;
+};
+
+#endif // XFA_FDE_CFDE_PATH_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_css.h b/chromium/third_party/pdfium/xfa/fde/css/fde_css.h
index 6a1b0d65433..b949ace778a 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_css.h
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_css.h
@@ -7,40 +7,44 @@
#ifndef XFA_FDE_CSS_FDE_CSS_H_
#define XFA_FDE_CSS_FDE_CSS_H_
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fgas/crt/fgas_stream.h"
#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/font/fgas_font.h"
-class IFDE_CSSValue;
-class IFDE_CSSValueList;
-class IFDE_CSSDeclaration;
-class IFDE_CSSSelector;
-class IFDE_CSSRule;
-class IFDE_CSSStyleSheet;
-class IFDE_CSSStyleSheetCache;
-class IFDE_CSSSyntaxParser;
-class IFDE_CSSRubyStyle;
-class IFDE_CSSMultiColumnStyle;
-class IFDE_CSSGeneratedContentStyle;
-class IFDE_CSSFontStyle;
+class CFDE_CSSAccelerator;
+class CFDE_CSSDeclaration;
+class CFDE_CSSSelector;
+class CXFA_CSSTagProvider;
class IFDE_CSSBoundaryStyle;
-class IFDE_CSSPositionStyle;
-class IFDE_CSSParagraphStyle;
-class IFDE_CSSBackgroundStyle;
-class IFDE_CSSListStyle;
-class IFDE_CSSTableStyle;
-class IFDE_CSSVisualStyle;
class IFDE_CSSComputedStyle;
-class IFDE_CSSTagProvider;
-class IFDE_CSSAccelerator;
-class IFDE_CSSStyleSelector;
+class IFDE_CSSFontStyle;
+class IFDE_CSSParagraphStyle;
+class IFDE_CSSPositionStyle;
+class IFDE_CSSRule;
+class IFDE_CSSStyleSheet;
+class IFDE_CSSValue;
+class IFDE_CSSValueList;
+
+#define FDE_CSSMEDIATYPE_Braille 0x01
+#define FDE_CSSMEDIATYPE_Emboss 0x02
+#define FDE_CSSMEDIATYPE_Handheld 0x04
+#define FDE_CSSMEDIATYPE_Print 0x08
+#define FDE_CSSMEDIATYPE_Projection 0x10
+#define FDE_CSSMEDIATYPE_Screen 0x20
+#define FDE_CSSMEDIATYPE_TTY 0x40
+#define FDE_CSSMEDIATYPE_TV 0x80
+#define FDE_CSSMEDIATYPE_ALL 0xFF
+
+#define FDE_CSSUNITBITS (3)
+#define FDE_CSSUNITMASK ((1 << FDE_CSSUNITBITS) - 1)
enum FDE_CSSVALUETYPE {
FDE_CSSVALUETYPE_Primitive = 1,
FDE_CSSVALUETYPE_List = 2,
FDE_CSSVALUETYPE_Shorthand,
};
+
enum FDE_CSSPRIMITIVETYPE {
FDE_CSSPRIMITIVETYPE_Unknown = 0,
FDE_CSSPRIMITIVETYPE_Number = 1,
@@ -59,6 +63,7 @@ enum FDE_CSSPRIMITIVETYPE {
FDE_CSSPRIMITIVETYPE_Enum,
FDE_CSSPRIMITIVETYPE_Function,
};
+
enum FDE_CSSPROPERTYVALUE {
FDE_CSSPROPERTYVALUE_Bolder,
FDE_CSSPROPERTYVALUE_LowerLatin,
@@ -223,31 +228,7 @@ enum FDE_CSSPROPERTYVALUE {
FDE_CSSPROPERTYVALUE_NoDisplay,
FDE_CSSPROPERTYVALUE_MAX
};
-class IFDE_CSSValue {
- public:
- virtual ~IFDE_CSSValue() {}
- virtual FDE_CSSVALUETYPE GetType() const = 0;
-};
-class IFDE_CSSPrimitiveValue : public IFDE_CSSValue {
- public:
- virtual FDE_CSSVALUETYPE GetType() const {
- return FDE_CSSVALUETYPE_Primitive;
- }
- virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const = 0;
- virtual FX_ARGB GetRGBColor() const = 0;
- virtual FX_FLOAT GetFloat() const = 0;
- virtual const FX_WCHAR* GetString(int32_t& iLength) const = 0;
- virtual FDE_CSSPROPERTYVALUE GetEnum() const = 0;
- virtual const FX_WCHAR* GetFuncName() const = 0;
- virtual int32_t CountArgs() const = 0;
- virtual IFDE_CSSValue* GetArgs(int32_t index) const = 0;
-};
-class IFDE_CSSValueList : public IFDE_CSSValue {
- public:
- virtual FDE_CSSVALUETYPE GetType() const { return FDE_CSSVALUETYPE_List; }
- virtual int32_t CountValues() const = 0;
- virtual IFDE_CSSValue* GetValue(int32_t index) const = 0;
-};
+
enum FDE_CSSPROPERTY {
FDE_CSSPROPERTY_WritingMode,
FDE_CSSPROPERTY_ColumnRuleWidth,
@@ -362,22 +343,7 @@ enum FDE_CSSPROPERTY {
FDE_CSSPROPERTY_Direction,
FDE_CSSPROPERTY_MAX
};
-class IFDE_CSSDeclaration {
- public:
- virtual ~IFDE_CSSDeclaration() {}
- virtual IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty,
- FX_BOOL& bImportant) const = 0;
- virtual FX_POSITION GetStartPosition() const = 0;
- virtual void GetNextProperty(FX_POSITION& pos,
- FDE_CSSPROPERTY& eProperty,
- IFDE_CSSValue*& pValue,
- FX_BOOL& bImportant) const = 0;
- virtual FX_POSITION GetStartCustom() const = 0;
- virtual void GetNextCustom(FX_POSITION& pos,
- CFX_WideString& wsName,
- CFX_WideString& wsValue) const = 0;
-};
-typedef CFX_ArrayTemplate<IFDE_CSSDeclaration*> CFDE_CSSDeclarationArray;
+
enum FDE_CSSPERSUDO {
FDE_CSSPERSUDO_After,
FDE_CSSPERSUDO_Before,
@@ -390,88 +356,14 @@ enum FDE_CSSSELECTORTYPE {
FDE_CSSSELECTORTYPE_Persudo,
FDE_CSSSELECTORTYPE_ID,
};
-class IFDE_CSSSelector {
- public:
- virtual ~IFDE_CSSSelector() {}
- virtual FDE_CSSSELECTORTYPE GetType() const = 0;
- virtual uint32_t GetNameHash() const = 0;
- virtual IFDE_CSSSelector* GetNextSelector() const = 0;
-};
-#define FDE_CSSMEDIATYPE_Braille 0x01
-#define FDE_CSSMEDIATYPE_Emboss 0x02
-#define FDE_CSSMEDIATYPE_Handheld 0x04
-#define FDE_CSSMEDIATYPE_Print 0x08
-#define FDE_CSSMEDIATYPE_Projection 0x10
-#define FDE_CSSMEDIATYPE_Screen 0x20
-#define FDE_CSSMEDIATYPE_TTY 0x40
-#define FDE_CSSMEDIATYPE_TV 0x80
-#define FDE_CSSMEDIATYPE_ALL 0xFF
+
enum FDE_CSSRULETYPE {
FDE_CSSRULETYPE_Unknown = 0,
FDE_CSSRULETYPE_Style = 1,
FDE_CSSRULETYPE_Media = 4,
FDE_CSSRULETYPE_FontFace = 5,
};
-class IFDE_CSSRule {
- public:
- virtual ~IFDE_CSSRule() {}
- virtual FDE_CSSRULETYPE GetType() const = 0;
-};
-typedef CFX_MassArrayTemplate<IFDE_CSSRule*> CFDE_CSSRuleArray;
-class IFDE_CSSStyleRule : public IFDE_CSSRule {
- public:
- virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Style; }
- virtual int32_t CountSelectorLists() const = 0;
- virtual IFDE_CSSSelector* GetSelectorList(int32_t index) const = 0;
- virtual IFDE_CSSDeclaration* GetDeclaration() const = 0;
-};
-class IFDE_CSSMediaRule : public IFDE_CSSRule {
- public:
- virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Media; }
- virtual uint32_t GetMediaList() const = 0;
- virtual int32_t CountRules() const = 0;
- virtual IFDE_CSSRule* GetRule(int32_t index) = 0;
-};
-class IFDE_CSSFontFaceRule : public IFDE_CSSRule {
- public:
- virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_FontFace; }
- virtual IFDE_CSSDeclaration* GetDeclaration() const = 0;
-};
-class IFDE_CSSStyleSheet : public IFX_Unknown {
- public:
- static IFDE_CSSStyleSheet* LoadHTMLStandardStyleSheet();
- static IFDE_CSSStyleSheet* LoadFromStream(
- const CFX_WideString& szUrl,
- IFX_Stream* pStream,
- uint16_t wCodePage,
- uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
- static IFDE_CSSStyleSheet* LoadFromBuffer(
- const CFX_WideString& szUrl,
- const FX_WCHAR* pBuffer,
- int32_t iBufSize,
- uint16_t wCodePage,
- uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
- virtual FX_BOOL GetUrl(CFX_WideString& szUrl) = 0;
- virtual uint32_t GetMediaList() const = 0;
- virtual uint16_t GetCodePage() const = 0;
-
- virtual int32_t CountRules() const = 0;
- virtual IFDE_CSSRule* GetRule(int32_t index) = 0;
-};
-typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray;
-class IFDE_CSSStyleSheetCache {
- public:
- static IFDE_CSSStyleSheetCache* Create();
- virtual ~IFDE_CSSStyleSheetCache() {}
- virtual void Release() = 0;
- virtual void SetMaxItems(int32_t iMaxCount = 5) = 0;
- virtual void AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet) = 0;
- virtual IFDE_CSSStyleSheet* GetStyleSheet(
- const CFX_ByteStringC& szKey) const = 0;
- virtual void RemoveStyleSheet(const CFX_ByteStringC& szKey) = 0;
-};
enum FDE_CSSSYNTAXSTATUS {
FDE_CSSSYNTAXSTATUS_Error,
FDE_CSSSYNTAXSTATUS_EOS,
@@ -491,23 +383,7 @@ enum FDE_CSSSYNTAXSTATUS {
FDE_CSSSYNTAXSTATUS_PropertyName,
FDE_CSSSYNTAXSTATUS_PropertyValue,
};
-class IFDE_CSSSyntaxParser {
- public:
- static IFDE_CSSSyntaxParser* Create();
- virtual ~IFDE_CSSSyntaxParser() {}
- virtual void Release() = 0;
- virtual FX_BOOL Init(IFX_Stream* pStream,
- int32_t iCSSPlaneSize,
- int32_t iTextDataSize = 32,
- FX_BOOL bOnlyDeclaration = FALSE) = 0;
- virtual FX_BOOL Init(const FX_WCHAR* pBuffer,
- int32_t iBufferSize,
- int32_t iTextDatSize = 32,
- FX_BOOL bOnlyDeclaration = FALSE) = 0;
-
- virtual FDE_CSSSYNTAXSTATUS DoSyntaxParse() = 0;
- virtual const FX_WCHAR* GetCurrentString(int32_t& iLength) const = 0;
-};
+
enum FDE_CSSLENGTHUNIT {
FDE_CSSLENGTHUNIT_Auto,
FDE_CSSLENGTHUNIT_None,
@@ -515,80 +391,19 @@ enum FDE_CSSLENGTHUNIT {
FDE_CSSLENGTHUNIT_Point,
FDE_CSSLENGTHUNIT_Percent,
};
-#define FDE_CSSUNITBITS (3)
-#define FDE_CSSUNITMASK ((1 << FDE_CSSUNITBITS) - 1)
-struct FDE_CSSLENGTH {
- FDE_CSSLENGTH& Set(FDE_CSSLENGTHUNIT eUnit) {
- m_iData = eUnit;
- return *this;
- }
- FDE_CSSLENGTH& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
- m_iData = ((intptr_t)(fValue * 1024.0f) << FDE_CSSUNITBITS) | eUnit;
- return *this;
- }
- FDE_CSSLENGTHUNIT GetUnit() const {
- return (FDE_CSSLENGTHUNIT)(m_iData & FDE_CSSUNITMASK);
- }
- FX_FLOAT GetValue() const { return (m_iData >> FDE_CSSUNITBITS) / 1024.0f; }
- FX_BOOL NonZero() const { return (m_iData >> FDE_CSSUNITBITS) != 0; }
-
- private:
- intptr_t m_iData;
-};
-struct FDE_CSSPOINT {
- FDE_CSSPOINT& Set(FDE_CSSLENGTHUNIT eUnit) {
- x.Set(eUnit);
- y.Set(eUnit);
- return *this;
- }
- FDE_CSSPOINT& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
- x.Set(eUnit, fValue);
- y.Set(eUnit, fValue);
- return *this;
- }
- FDE_CSSLENGTH x, y;
-};
-struct FDE_CSSSIZE {
- FDE_CSSSIZE& Set(FDE_CSSLENGTHUNIT eUnit) {
- cx.Set(eUnit);
- cy.Set(eUnit);
- return *this;
- }
- FDE_CSSSIZE& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
- cx.Set(eUnit, fValue);
- cy.Set(eUnit, fValue);
- return *this;
- }
- FDE_CSSLENGTH cx, cy;
-};
-struct FDE_CSSRECT {
- FDE_CSSRECT& Set(FDE_CSSLENGTHUNIT eUnit) {
- left.Set(eUnit);
- top.Set(eUnit);
- right.Set(eUnit);
- bottom.Set(eUnit);
- return *this;
- }
- FDE_CSSRECT& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
- left.Set(eUnit, fValue);
- top.Set(eUnit, fValue);
- right.Set(eUnit, fValue);
- bottom.Set(eUnit, fValue);
- return *this;
- }
- FDE_CSSLENGTH left, top, right, bottom;
-};
enum FDE_CSSBKGATTACHMENT {
FDE_CSSBKGATTACHMENT_Scroll,
FDE_CSSBKGATTACHMENT_Fixed,
};
+
enum FDE_CSSBKGREPEAT {
FDE_CSSBKGREPEAT_Repeat,
FDE_CSSBKGREPEAT_RepeatX,
FDE_CSSBKGREPEAT_RepeatY,
FDE_CSSBKGREPEAT_NoRepeat,
};
+
enum FDE_CSSBORDERSTYLE {
FDE_CSSBORDERSTYLE_None,
FDE_CSSBORDERSTYLE_Hidden,
@@ -601,12 +416,14 @@ enum FDE_CSSBORDERSTYLE {
FDE_CSSBORDERSTYLE_Inset,
FDE_CSSBORDERSTYLE_outset,
};
+
enum FDE_CSSCLEAR {
FDE_CSSCLEAR_None,
FDE_CSSCLEAR_Left,
FDE_CSSCLEAR_Right,
FDE_CSSCLEAR_Both,
};
+
enum FDE_CSSDISPLAY {
FDE_CSSDISPLAY_None,
FDE_CSSDISPLAY_ListItem,
@@ -630,31 +447,37 @@ enum FDE_CSSDISPLAY {
FDE_CSSDISPLSY_RubyBaseGroup,
FDE_CSSDISPLAY_RubyTextGroup,
};
+
enum FDE_CSSVISIBILITY {
FDE_CSSVISIBILITY_Visible,
FDE_CSSVISIBILITY_Hidden,
FDE_CSSVISIBILITY_Collapse,
};
+
enum FDE_CSSFONTSTYLE {
FDE_CSSFONTSTYLE_Normal,
FDE_CSSFONTSTYLE_Italic,
};
+
enum FDE_CSSFLOAT {
FDE_CSSFLOAT_None,
FDE_CSSFLOAT_Left,
FDE_CSSFLOAT_Right,
};
+
enum FDE_CSSWRITINGMODE {
FDE_CSSWRITINGMODE_HorizontalTb,
FDE_CSSWRITINGMODE_VerticalRl,
FDE_CSSWRITINGMODE_VerticalLr,
};
+
enum FDE_CSSWORDBREAK {
FDE_CSSWORDBREAK_Normal,
FDE_CSSWORDBREAK_KeepAll,
FDE_CSSWORDBREAK_BreakAll,
FDE_CSSWORDBREAK_KeepWords,
};
+
enum FDE_CSSPAGEBREAK {
FDE_CSSPAGEBREAK_Auto,
FDE_CSSPAGEBREAK_Always,
@@ -662,6 +485,7 @@ enum FDE_CSSPAGEBREAK {
FDE_CSSPAGEBREAK_Left,
FDE_CSSPAGEBREAK_Right,
};
+
enum FDE_CSSOVERFLOW {
FDE_CSSOVERFLOW_Visible,
FDE_CSSOVERFLOW_Hidden,
@@ -670,16 +494,19 @@ enum FDE_CSSOVERFLOW {
FDE_CSSOVERFLOW_NoDisplay,
FDE_CSSOVERFLOW_NoContent,
};
+
enum FDE_CSSLINEBREAK {
FDE_CSSLINEBREAK_Auto,
FDE_CSSLINEBREAK_Loose,
FDE_CSSLINEBREAK_Normal,
FDE_CSSLINEBREAK_Strict,
};
+
enum FDE_CSSTEXTEMPHASISFILL {
FDE_CSSTEXTEMPHASISFILL_Filled,
FDE_CSSTEXTEMPHASISFILL_Open,
};
+
enum FDE_CSSTEXTEMPHASISMARK {
FDE_CSSTEXTEMPHASISMARK_None,
FDE_CSSTEXTEMPHASISMARK_Auto,
@@ -690,10 +517,12 @@ enum FDE_CSSTEXTEMPHASISMARK {
FDE_CSSTEXTEMPHASISMARK_Sesame,
FDE_CSSTEXTEMPHASISMARK_Custom,
};
+
enum FDE_CSSTEXTCOMBINE {
FDE_CSSTEXTCOMBINE_Horizontal,
FDE_CSSTEXTCOMBINE_None,
};
+
enum FDE_CSSCURSOR {
FDE_CSSCURSOR_Auto,
FDE_CSSCURSOR_Crosshair,
@@ -713,12 +542,14 @@ enum FDE_CSSCURSOR {
FDE_CSSCURSOR_Help,
FDE_CSSCURSOR_Progress,
};
+
enum FDE_CSSPOSITION {
FDE_CSSPOSITION_Static,
FDE_CSSPOSITION_Relative,
FDE_CSSPOSITION_Absolute,
FDE_CSSPOSITION_Fixed,
};
+
enum FDE_CSSCAPTIONSIDE {
FDE_CSSCAPTIONSIDE_Top,
FDE_CSSCAPTIONSIDE_Bottom,
@@ -727,6 +558,7 @@ enum FDE_CSSCAPTIONSIDE {
FDE_CSSCAPTIONSIDE_Before,
FDE_CSSCAPTIONSIDE_After,
};
+
enum FDE_CSSRUBYALIGN {
FDE_CSSRUBYALIGN_Auto,
FDE_CSSRUBYALIGN_Start,
@@ -738,22 +570,26 @@ enum FDE_CSSRUBYALIGN {
FDE_CSSRUBYALIGN_DistributeSpace,
FDE_CSSRUBYALIGN_LineEdge,
};
+
enum FDE_CSSRUBYOVERHANG {
FDE_CSSRUBYOVERHANG_Auto,
FDE_CSSRUBYOVERHANG_Start,
FDE_CSSRUBYOVERHANG_End,
FDE_CSSRUBYOVERHANG_None,
};
+
enum FDE_CSSRUBYPOSITION {
FDE_CSSRUBYPOSITION_Before,
FDE_CSSRUBYPOSITION_After,
FDE_CSSRUBYPOSITION_Right,
FDE_CSSRUBYPOSITION_Inline,
};
+
enum FDE_CSSRUBYSPAN {
FDE_CSSRUBYSPAN_None,
FDE_CSSRUBYSPAN_Attr,
};
+
enum FDE_CSSTEXTALIGN {
FDE_CSSTEXTALIGN_Left,
FDE_CSSTEXTALIGN_Right,
@@ -761,6 +597,7 @@ enum FDE_CSSTEXTALIGN {
FDE_CSSTEXTALIGN_Justify,
FDE_CSSTEXTALIGN_JustifyAll,
};
+
enum FDE_CSSVERTICALALIGN {
FDE_CSSVERTICALALIGN_Baseline,
FDE_CSSVERTICALALIGN_Sub,
@@ -772,6 +609,7 @@ enum FDE_CSSVERTICALALIGN {
FDE_CSSVERTICALALIGN_TextBottom,
FDE_CSSVERTICALALIGN_Number,
};
+
enum FDE_CSSLISTSTYLETYPE {
FDE_CSSLISTSTYLETYPE_Disc,
FDE_CSSLISTSTYLETYPE_Circle,
@@ -795,10 +633,12 @@ enum FDE_CSSLISTSTYLETYPE {
FDE_CSSLISTSTYLETYPE_Katakana,
FDE_CSSLISTSTYLETYPE_KatakanaIroha,
};
+
enum FDE_CSSLISTSTYLEPOSITION {
FDE_CSSLISTSTYLEPOSITION_Outside,
FDE_CSSLISTSTYLEPOSITION_Inside,
};
+
enum FDE_CSSWHITESPACE {
FDE_CSSWHITESPACE_Normal,
FDE_CSSWHITESPACE_Pre,
@@ -806,16 +646,19 @@ enum FDE_CSSWHITESPACE {
FDE_CSSWHITESPACE_PreWrap,
FDE_CSSWHITESPACE_PreLine,
};
+
enum FDE_CSSFONTVARIANT {
FDE_CSSFONTVARIANT_Normal,
FDE_CSSFONTVARIANT_SmallCaps,
};
+
enum FDE_CSSTEXTTRANSFORM {
FDE_CSSTEXTTRANSFORM_None,
FDE_CSSTEXTTRANSFORM_Capitalize,
FDE_CSSTEXTTRANSFORM_UpperCase,
FDE_CSSTEXTTRANSFORM_LowerCase,
};
+
enum FDE_CSSTEXTDECORATION {
FDE_CSSTEXTDECORATION_None = 0,
FDE_CSSTEXTDECORATION_Underline = 1,
@@ -824,45 +667,171 @@ enum FDE_CSSTEXTDECORATION {
FDE_CSSTEXTDECORATION_Blink = 8,
FDE_CSSTEXTDECORATION_Double = 16,
};
-class IFDE_CSSRubyStyle {
+
+enum FDE_CSSSTYLESHEETGROUP {
+ FDE_CSSSTYLESHEETGROUP_UserAgent,
+ FDE_CSSSTYLESHEETGROUP_User,
+ FDE_CSSSTYLESHEETGROUP_Author,
+ FDE_CSSSTYLESHEETGROUP_MAX,
+};
+
+enum FDE_CSSSTYLESHEETPRIORITY {
+ FDE_CSSSTYLESHEETPRIORITY_High,
+ FDE_CSSSTYLESHEETPRIORITY_Mid,
+ FDE_CSSSTYLESHEETPRIORITY_Low,
+ FDE_CSSSTYLESHEETPRIORITY_MAX,
+};
+
+class IFDE_CSSValue {
+ public:
+ virtual ~IFDE_CSSValue() {}
+ virtual FDE_CSSVALUETYPE GetType() const = 0;
+};
+
+class IFDE_CSSPrimitiveValue : public IFDE_CSSValue {
+ public:
+ virtual FDE_CSSVALUETYPE GetType() const {
+ return FDE_CSSVALUETYPE_Primitive;
+ }
+ virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const = 0;
+ virtual FX_ARGB GetRGBColor() const = 0;
+ virtual FX_FLOAT GetFloat() const = 0;
+ virtual const FX_WCHAR* GetString(int32_t& iLength) const = 0;
+ virtual FDE_CSSPROPERTYVALUE GetEnum() const = 0;
+ virtual const FX_WCHAR* GetFuncName() const = 0;
+ virtual int32_t CountArgs() const = 0;
+ virtual IFDE_CSSValue* GetArgs(int32_t index) const = 0;
+};
+
+class IFDE_CSSValueList : public IFDE_CSSValue {
+ public:
+ virtual FDE_CSSVALUETYPE GetType() const { return FDE_CSSVALUETYPE_List; }
+ virtual int32_t CountValues() const = 0;
+ virtual IFDE_CSSValue* GetValue(int32_t index) const = 0;
+};
+
+class IFDE_CSSRule {
public:
- virtual ~IFDE_CSSRubyStyle() {}
- virtual FDE_CSSRUBYALIGN GetRubyAlign() const = 0;
- virtual FDE_CSSRUBYOVERHANG GetRubyOverhang() const = 0;
- virtual FDE_CSSRUBYPOSITION GetRubyPosition() const = 0;
- virtual FDE_CSSRUBYSPAN GetRubySpanType() const = 0;
- virtual IFDE_CSSValue* GetRubySpanAttr() const = 0;
+ virtual ~IFDE_CSSRule() {}
+ virtual FDE_CSSRULETYPE GetType() const = 0;
};
-class IFDE_CSSMultiColumnStyle {
+typedef CFX_MassArrayTemplate<IFDE_CSSRule*> CFDE_CSSRuleArray;
+
+class IFDE_CSSStyleRule : public IFDE_CSSRule {
+ public:
+ virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Style; }
+ virtual int32_t CountSelectorLists() const = 0;
+ virtual CFDE_CSSSelector* GetSelectorList(int32_t index) const = 0;
+ virtual CFDE_CSSDeclaration* GetDeclaration() = 0;
+};
+
+class IFDE_CSSMediaRule : public IFDE_CSSRule {
+ public:
+ virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_Media; }
+ virtual uint32_t GetMediaList() const = 0;
+ virtual int32_t CountRules() const = 0;
+ virtual IFDE_CSSRule* GetRule(int32_t index) = 0;
+};
+
+class IFDE_CSSFontFaceRule : public IFDE_CSSRule {
public:
- virtual ~IFDE_CSSMultiColumnStyle() {}
- virtual const FDE_CSSLENGTH& GetColumnCount() const = 0;
- virtual const FDE_CSSLENGTH& GetColumnGap() const = 0;
- virtual FX_ARGB GetColumnRuleColor() const = 0;
- virtual FDE_CSSBORDERSTYLE GetColumnRuleStyle() const = 0;
- virtual const FDE_CSSLENGTH& GetColumnRuleWidth() const = 0;
- virtual const FDE_CSSLENGTH& GetColumnWidth() const = 0;
- virtual void SetColumnCount(const FDE_CSSLENGTH& columnCount) = 0;
- virtual void SetColumnGap(const FDE_CSSLENGTH& columnGap) = 0;
- virtual void SetColumnRuleColor(FX_ARGB dwColumnRuleColor) = 0;
- virtual void SetColumnRuleStyle(FDE_CSSBORDERSTYLE eColumnRuleStyle) = 0;
- virtual void SetColumnRuleWidth(const FDE_CSSLENGTH& columnRuleWidth) = 0;
- virtual void SetColumnWidth(const FDE_CSSLENGTH& columnWidth) = 0;
+ virtual FDE_CSSRULETYPE GetType() const { return FDE_CSSRULETYPE_FontFace; }
+ virtual CFDE_CSSDeclaration* GetDeclaration() = 0;
};
-class IFDE_CSSGeneratedContentStyle {
+
+class IFDE_CSSStyleSheet : public IFX_Unknown {
public:
- virtual ~IFDE_CSSGeneratedContentStyle() {}
- virtual int32_t CountCounters() = 0;
- virtual const FX_WCHAR* GetCounterIdentifier(int32_t index) = 0;
- virtual FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) = 0;
- virtual FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) = 0;
- virtual IFDE_CSSValueList* GetContent() const = 0;
- virtual int32_t CountQuotes() const = 0;
- virtual const FX_WCHAR* GetQuotes(int32_t index) const = 0;
+ static IFDE_CSSStyleSheet* LoadHTMLStandardStyleSheet();
+ static IFDE_CSSStyleSheet* LoadFromStream(
+ const CFX_WideString& szUrl,
+ IFX_Stream* pStream,
+ uint16_t wCodePage,
+ uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
+ static IFDE_CSSStyleSheet* LoadFromBuffer(
+ const CFX_WideString& szUrl,
+ const FX_WCHAR* pBuffer,
+ int32_t iBufSize,
+ uint16_t wCodePage,
+ uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
+ virtual FX_BOOL GetUrl(CFX_WideString& szUrl) = 0;
+ virtual uint32_t GetMediaList() const = 0;
+ virtual uint16_t GetCodePage() const = 0;
+
+ virtual int32_t CountRules() const = 0;
+ virtual IFDE_CSSRule* GetRule(int32_t index) = 0;
};
+typedef CFX_ArrayTemplate<IFDE_CSSStyleSheet*> CFDE_CSSStyleSheetArray;
+
+struct FDE_CSSLENGTH {
+ FDE_CSSLENGTH& Set(FDE_CSSLENGTHUNIT eUnit) {
+ m_iData = eUnit;
+ return *this;
+ }
+ FDE_CSSLENGTH& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
+ m_iData = ((intptr_t)(fValue * 1024.0f) << FDE_CSSUNITBITS) | eUnit;
+ return *this;
+ }
+ FDE_CSSLENGTHUNIT GetUnit() const {
+ return (FDE_CSSLENGTHUNIT)(m_iData & FDE_CSSUNITMASK);
+ }
+ FX_FLOAT GetValue() const { return (m_iData >> FDE_CSSUNITBITS) / 1024.0f; }
+ FX_BOOL NonZero() const { return (m_iData >> FDE_CSSUNITBITS) != 0; }
+
+ private:
+ intptr_t m_iData;
+};
+
+struct FDE_CSSPOINT {
+ FDE_CSSPOINT& Set(FDE_CSSLENGTHUNIT eUnit) {
+ x.Set(eUnit);
+ y.Set(eUnit);
+ return *this;
+ }
+ FDE_CSSPOINT& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
+ x.Set(eUnit, fValue);
+ y.Set(eUnit, fValue);
+ return *this;
+ }
+ FDE_CSSLENGTH x, y;
+};
+
+struct FDE_CSSSIZE {
+ FDE_CSSSIZE& Set(FDE_CSSLENGTHUNIT eUnit) {
+ cx.Set(eUnit);
+ cy.Set(eUnit);
+ return *this;
+ }
+ FDE_CSSSIZE& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
+ cx.Set(eUnit, fValue);
+ cy.Set(eUnit, fValue);
+ return *this;
+ }
+ FDE_CSSLENGTH cx, cy;
+};
+
+struct FDE_CSSRECT {
+ FDE_CSSRECT& Set(FDE_CSSLENGTHUNIT eUnit) {
+ left.Set(eUnit);
+ top.Set(eUnit);
+ right.Set(eUnit);
+ bottom.Set(eUnit);
+ return *this;
+ }
+ FDE_CSSRECT& Set(FDE_CSSLENGTHUNIT eUnit, FX_FLOAT fValue) {
+ left.Set(eUnit, fValue);
+ top.Set(eUnit, fValue);
+ right.Set(eUnit, fValue);
+ bottom.Set(eUnit, fValue);
+ return *this;
+ }
+
+ FDE_CSSLENGTH left, top, right, bottom;
+};
+
class IFDE_CSSFontStyle {
public:
virtual ~IFDE_CSSFontStyle() {}
+
virtual int32_t CountFontFamilies() const = 0;
virtual const FX_WCHAR* GetFontFamily(int32_t index) const = 0;
virtual uint16_t GetFontWeight() const = 0;
@@ -876,206 +845,52 @@ class IFDE_CSSFontStyle {
virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
virtual void SetColor(FX_ARGB dwFontColor) = 0;
};
+
class IFDE_CSSBoundaryStyle {
public:
virtual ~IFDE_CSSBoundaryStyle() {}
- virtual FX_ARGB GetBorderLeftColor() const = 0;
- virtual FX_ARGB GetBorderTopColor() const = 0;
- virtual FX_ARGB GetBorderRightColor() const = 0;
- virtual FX_ARGB GetBorderBottomColor() const = 0;
- virtual FDE_CSSBORDERSTYLE GetBorderLeftStyle() const = 0;
- virtual FDE_CSSBORDERSTYLE GetBorderTopStyle() const = 0;
- virtual FDE_CSSBORDERSTYLE GetBorderRightStyle() const = 0;
- virtual FDE_CSSBORDERSTYLE GetBorderBottomStyle() const = 0;
+
virtual const FDE_CSSRECT* GetBorderWidth() const = 0;
virtual const FDE_CSSRECT* GetMarginWidth() const = 0;
virtual const FDE_CSSRECT* GetPaddingWidth() const = 0;
- virtual void SetBorderLeftColor(FX_ARGB dwBorderColor) = 0;
- virtual void SetBorderTopColor(FX_ARGB dwBorderColor) = 0;
- virtual void SetBorderRightColor(FX_ARGB dwBorderColor) = 0;
- virtual void SetBorderBottomColor(FX_ARGB dwBorderColor) = 0;
-
- virtual void SetBorderLeftStyle(FDE_CSSBORDERSTYLE eBorderStyle) = 0;
- virtual void SetBorderTopStyle(FDE_CSSBORDERSTYLE eBorderStyle) = 0;
- virtual void SetBorderRightStyle(FDE_CSSBORDERSTYLE eBorderStyle) = 0;
- virtual void SetBorderBottomStyle(FDE_CSSBORDERSTYLE eBorderStyle) = 0;
-
- virtual void SetBorderWidth(const FDE_CSSRECT& rect) = 0;
virtual void SetMarginWidth(const FDE_CSSRECT& rect) = 0;
virtual void SetPaddingWidth(const FDE_CSSRECT& rect) = 0;
};
+
class IFDE_CSSPositionStyle {
public:
virtual ~IFDE_CSSPositionStyle() {}
virtual FDE_CSSDISPLAY GetDisplay() const = 0;
- virtual const FDE_CSSSIZE& GetBoxSize() const = 0;
- virtual const FDE_CSSSIZE& GetMinBoxSize() const = 0;
- virtual const FDE_CSSSIZE& GetMaxBoxSize() const = 0;
- virtual FDE_CSSFLOAT GetFloat() const = 0;
- virtual FDE_CSSCLEAR GetClear() const = 0;
- virtual FDE_CSSPOSITION GetPosition() const = 0;
- virtual FDE_CSSLENGTH GetTop() const = 0;
- virtual FDE_CSSLENGTH GetBottom() const = 0;
- virtual FDE_CSSLENGTH GetLeft() const = 0;
- virtual FDE_CSSLENGTH GetRight() const = 0;
- virtual void SetDisplay(FDE_CSSDISPLAY eDisplay) = 0;
- virtual void SetBoxSize(const FDE_CSSSIZE& boxSize) = 0;
- virtual void SetMinBoxSize(const FDE_CSSSIZE& minBoxSize) = 0;
- virtual void SetMaxBoxSize(const FDE_CSSSIZE& maxBoxSize) = 0;
- virtual void SetFloat(FDE_CSSFLOAT eFloat) = 0;
- virtual void SetClear(FDE_CSSCLEAR eClear) = 0;
};
+
class IFDE_CSSParagraphStyle {
public:
virtual ~IFDE_CSSParagraphStyle() {}
+
virtual FX_FLOAT GetLineHeight() const = 0;
- virtual FDE_CSSWHITESPACE GetWhiteSpace() const = 0;
virtual const FDE_CSSLENGTH& GetTextIndent() const = 0;
virtual FDE_CSSTEXTALIGN GetTextAlign() const = 0;
virtual FDE_CSSVERTICALALIGN GetVerticalAlign() const = 0;
virtual FX_FLOAT GetNumberVerticalAlign() const = 0;
- virtual FDE_CSSTEXTTRANSFORM GetTextTransform() const = 0;
virtual uint32_t GetTextDecoration() const = 0;
virtual const FDE_CSSLENGTH& GetLetterSpacing() const = 0;
- virtual const FDE_CSSLENGTH& GetWordSpacing() const = 0;
- virtual FDE_CSSWRITINGMODE GetWritingMode() const = 0;
- virtual FDE_CSSWORDBREAK GetWordBreak() const = 0;
- virtual int32_t GetWidows() const = 0;
- virtual FX_ARGB GetTextEmphasisColor() const = 0;
- virtual FDE_CSSPAGEBREAK GetPageBreakBefore() const = 0;
- virtual FDE_CSSPAGEBREAK GetPageBreakAfter() const = 0;
- virtual FDE_CSSPAGEBREAK GetPageBreakInside() const = 0;
- virtual int32_t GetOrphans() const = 0;
- virtual FDE_CSSLINEBREAK GetLineBreak() const = 0;
- virtual FDE_CSSTEXTEMPHASISMARK GetTextEmphasisMark() const = 0;
- virtual FDE_CSSTEXTEMPHASISFILL GetTextEmphasisFill() const = 0;
- virtual const FX_WCHAR* GetTextEmphasisCustom() const = 0;
- virtual FDE_CSSTEXTCOMBINE GetTextCombineType() const = 0;
- virtual FX_BOOL HasTextCombineNumber() const = 0;
- virtual FX_FLOAT GetTextCombineNumber() const = 0;
virtual void SetLineHeight(FX_FLOAT fLineHeight) = 0;
- virtual void SetWhiteSpace(FDE_CSSWHITESPACE eWhiteSpace) = 0;
virtual void SetTextIndent(const FDE_CSSLENGTH& textIndent) = 0;
virtual void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) = 0;
- virtual void SetVerticalAlign(FDE_CSSVERTICALALIGN eVerticalAlign) = 0;
virtual void SetNumberVerticalAlign(FX_FLOAT fAlign) = 0;
- virtual void SetTextTransform(FDE_CSSTEXTTRANSFORM eTextTransform) = 0;
virtual void SetTextDecoration(uint32_t dwTextDecoration) = 0;
virtual void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) = 0;
- virtual void SetWordSpacing(const FDE_CSSLENGTH& wordSpacing) = 0;
- virtual void SetWritingMode(FDE_CSSWRITINGMODE eWritingMode) = 0;
- virtual void SetWordBreak(FDE_CSSWORDBREAK eWordBreak) = 0;
- virtual void SetWidows(int32_t iWidows) = 0;
- virtual void SetTextEmphasisColor(FX_ARGB dwTextEmphasisColor) = 0;
- virtual void SetPageBreakBefore(FDE_CSSPAGEBREAK ePageBreakBefore) = 0;
- virtual void SetPageBreakAfter(FDE_CSSPAGEBREAK ePageBreakAfter) = 0;
- virtual void SetPageBreakInside(FDE_CSSPAGEBREAK ePageBreakInside) = 0;
- virtual void SetOrphans(int32_t iOrphans) = 0;
- virtual void SetLineBreak(FDE_CSSLINEBREAK eLineBreak) = 0;
-};
-class IFDE_CSSBackgroundStyle {
- public:
- virtual ~IFDE_CSSBackgroundStyle() {}
- virtual FX_ARGB GetBKGColor() const = 0;
- virtual const FX_WCHAR* GetBKGImage() const = 0;
- virtual FDE_CSSBKGREPEAT GetBKGRepeat() const = 0;
- virtual FDE_CSSBKGATTACHMENT GetBKGAttachment() const = 0;
- virtual const FDE_CSSPOINT& GetBKGPosition() const = 0;
- virtual void SetBKGColor(FX_ARGB dwBKGColor) = 0;
- virtual void SetBKGPosition(const FDE_CSSPOINT& bkgPosition) = 0;
-};
-class IFDE_CSSListStyle {
- public:
- virtual ~IFDE_CSSListStyle() {}
- virtual FDE_CSSLISTSTYLETYPE GetListStyleType() const = 0;
- virtual FDE_CSSLISTSTYLEPOSITION GetListStylePosition() const = 0;
- virtual const FX_WCHAR* GetListStyleImage() const = 0;
- virtual void SetListStyleType(FDE_CSSLISTSTYLETYPE eListStyleType) = 0;
- virtual void SetListStylePosition(
- FDE_CSSLISTSTYLEPOSITION eListStylePosition) = 0;
-};
-class IFDE_CSSTableStyle {
- public:
- virtual ~IFDE_CSSTableStyle() {}
- virtual FDE_CSSCAPTIONSIDE GetCaptionSide() const = 0;
-};
-class IFDE_CSSVisualStyle {
- public:
- virtual ~IFDE_CSSVisualStyle() {}
- virtual FDE_CSSVISIBILITY GetVisibility() const = 0;
- virtual FDE_CSSOVERFLOW GetOverflowX() const = 0;
- virtual FDE_CSSOVERFLOW GetOverflowY() const = 0;
- virtual void SetVisibility(FDE_CSSVISIBILITY eVisibility) = 0;
};
+
class IFDE_CSSComputedStyle : public IFX_Unknown {
public:
virtual void Reset() = 0;
- virtual IFDE_CSSFontStyle* GetFontStyles() const = 0;
- virtual IFDE_CSSBoundaryStyle* GetBoundaryStyles() const = 0;
- virtual IFDE_CSSPositionStyle* GetPositionStyles() const = 0;
- virtual IFDE_CSSParagraphStyle* GetParagraphStyles() const = 0;
- virtual IFDE_CSSBackgroundStyle* GetBackgroundStyles() const = 0;
- virtual IFDE_CSSVisualStyle* GetVisualStyles() const = 0;
- virtual IFDE_CSSListStyle* GetListStyles() const = 0;
- virtual IFDE_CSSMultiColumnStyle* GetMultiColumnStyle() const = 0;
- virtual IFDE_CSSTableStyle* GetTableStyle() const = 0;
- virtual IFDE_CSSGeneratedContentStyle* GetGeneratedContentStyle() const = 0;
- virtual IFDE_CSSRubyStyle* GetRubyStyle() const = 0;
+ virtual IFDE_CSSFontStyle* GetFontStyles() = 0;
+ virtual IFDE_CSSBoundaryStyle* GetBoundaryStyles() = 0;
+ virtual IFDE_CSSPositionStyle* GetPositionStyles() = 0;
+ virtual IFDE_CSSParagraphStyle* GetParagraphStyles() = 0;
virtual FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName,
CFX_WideString& wsValue) const = 0;
};
-enum FDE_CSSSTYLESHEETGROUP {
- FDE_CSSSTYLESHEETGROUP_UserAgent,
- FDE_CSSSTYLESHEETGROUP_User,
- FDE_CSSSTYLESHEETGROUP_Author,
- FDE_CSSSTYLESHEETGROUP_MAX,
-};
-enum FDE_CSSSTYLESHEETPRIORITY {
- FDE_CSSSTYLESHEETPRIORITY_High,
- FDE_CSSSTYLESHEETPRIORITY_Mid,
- FDE_CSSSTYLESHEETPRIORITY_Low,
- FDE_CSSSTYLESHEETPRIORITY_MAX,
-};
-class IFDE_CSSTagProvider {
- public:
- virtual ~IFDE_CSSTagProvider() {}
- virtual CFX_WideStringC GetTagName() = 0;
- virtual FX_POSITION GetFirstAttribute() = 0;
- virtual void GetNextAttribute(FX_POSITION& pos,
- CFX_WideStringC& wsAttr,
- CFX_WideStringC& wsValue) = 0;
-};
-class IFDE_CSSAccelerator {
- public:
- virtual ~IFDE_CSSAccelerator() {}
- virtual void OnEnterTag(IFDE_CSSTagProvider* pTag) = 0;
- virtual void OnLeaveTag(IFDE_CSSTagProvider* pTag) = 0;
-};
-class IFDE_CSSStyleSelector {
- public:
- static IFDE_CSSStyleSelector* Create();
- virtual ~IFDE_CSSStyleSelector() {}
- virtual void Release() = 0;
- virtual void SetFontMgr(IFX_FontMgr* pFontMgr) = 0;
- virtual void SetDefFontSize(FX_FLOAT fFontSize) = 0;
- virtual FX_BOOL SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
- IFDE_CSSStyleSheet* pSheet) = 0;
- virtual FX_BOOL SetStyleSheets(FDE_CSSSTYLESHEETGROUP eType,
- const CFDE_CSSStyleSheetArray* pArray) = 0;
- virtual void SetStylePriority(FDE_CSSSTYLESHEETGROUP eType,
- FDE_CSSSTYLESHEETPRIORITY ePriority) = 0;
- virtual void UpdateStyleIndex(uint32_t dwMediaList) = 0;
- virtual IFDE_CSSAccelerator* InitAccelerator() = 0;
- virtual IFDE_CSSComputedStyle* CreateComputedStyle(
- IFDE_CSSComputedStyle* pParentStyle) = 0;
- virtual int32_t MatchDeclarations(
- IFDE_CSSTagProvider* pTag,
- CFDE_CSSDeclarationArray& matchedDecls,
- FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE) = 0;
- virtual void ComputeStyle(IFDE_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle) = 0;
-};
#endif // XFA_FDE_CSS_FDE_CSS_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_csscache.cpp b/chromium/third_party/pdfium/xfa/fde/css/fde_csscache.cpp
index d8fc1a1b194..0b21dcdea35 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_csscache.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_csscache.cpp
@@ -9,124 +9,43 @@
#include <algorithm>
#include "core/fxcrt/include/fx_ext.h"
+#include "xfa/fxfa/app/xfa_textlayout.h"
FDE_CSSCacheItem::FDE_CSSCacheItem(IFDE_CSSStyleSheet* p)
: pStylesheet(p), dwActivity(0) {
- FXSYS_assert(pStylesheet);
+ ASSERT(pStylesheet);
pStylesheet->AddRef();
}
+
FDE_CSSCacheItem::~FDE_CSSCacheItem() {
pStylesheet->Release();
}
-IFDE_CSSStyleSheetCache* IFDE_CSSStyleSheetCache::Create() {
- return new CFDE_CSSStyleSheetCache;
-}
-CFDE_CSSStyleSheetCache::CFDE_CSSStyleSheetCache()
- : m_pFixedStore(NULL), m_iMaxItems(5) {}
-
-CFDE_CSSStyleSheetCache::~CFDE_CSSStyleSheetCache() {
- for (const auto& pair : m_Stylesheets) {
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, pair.second);
- }
- m_Stylesheets.clear();
- if (m_pFixedStore) {
- m_pFixedStore->Release();
- }
-}
-void CFDE_CSSStyleSheetCache::AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet) {
- FXSYS_assert(pStyleSheet != NULL);
- if (m_pFixedStore == NULL) {
- m_pFixedStore =
- FX_CreateAllocator(FX_ALLOCTYPE_Fixed, std::max(10, m_iMaxItems),
- sizeof(FDE_CSSCacheItem));
- FXSYS_assert(m_pFixedStore != NULL);
- }
- auto it = m_Stylesheets.find(szKey);
- if (it != m_Stylesheets.end()) {
- FDE_CSSCacheItem* pItem = it->second;
- if (pItem->pStylesheet != pStyleSheet) {
- pItem->pStylesheet->Release();
- pItem->pStylesheet = pStyleSheet;
- pItem->pStylesheet->AddRef();
- pItem->dwActivity = 0;
- }
- } else {
- while (static_cast<int32_t>(m_Stylesheets.size()) >= m_iMaxItems) {
- RemoveLowestActivityItem();
- }
- m_Stylesheets[szKey] =
- FXTARGET_NewWith(m_pFixedStore) FDE_CSSCacheItem(pStyleSheet);
- }
-}
-IFDE_CSSStyleSheet* CFDE_CSSStyleSheetCache::GetStyleSheet(
- const CFX_ByteStringC& szKey) const {
- auto it = m_Stylesheets.find(szKey);
- if (it == m_Stylesheets.end()) {
- return nullptr;
- }
- FDE_CSSCacheItem* pItem = it->second;
- pItem->dwActivity++;
- pItem->pStylesheet->AddRef();
- return pItem->pStylesheet;
-}
-void CFDE_CSSStyleSheetCache::RemoveStyleSheet(const CFX_ByteStringC& szKey) {
- auto it = m_Stylesheets.find(szKey);
- if (it == m_Stylesheets.end()) {
- return;
- }
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, it->second);
- m_Stylesheets.erase(it);
-}
-void CFDE_CSSStyleSheetCache::RemoveLowestActivityItem() {
- auto found = m_Stylesheets.end();
- for (auto it = m_Stylesheets.begin(); it != m_Stylesheets.end(); ++it) {
- switch (it->first.GetID()) {
- case FXBSTR_ID('#', 'U', 'S', 'E'):
- case FXBSTR_ID('#', 'A', 'G', 'E'):
- continue;
- }
- if (found == m_Stylesheets.end() ||
- it->second->dwActivity > found->second->dwActivity) {
- found = it;
- }
- }
- if (found != m_Stylesheets.end()) {
- FXTARGET_DeleteWith(FDE_CSSCacheItem, m_pFixedStore, found->second);
- m_Stylesheets.erase(found);
- }
-}
FDE_CSSTagCache::FDE_CSSTagCache(FDE_CSSTagCache* parent,
- IFDE_CSSTagProvider* tag)
+ CXFA_CSSTagProvider* tag)
: pTag(tag),
pParent(parent),
dwIDHash(0),
dwTagHash(0),
iClassIndex(0),
dwClassHashs(1) {
- FXSYS_assert(pTag != NULL);
- CFX_WideStringC wsValue, wsName = pTag->GetTagName();
- dwTagHash =
- FX_HashCode_String_GetW(wsName.raw_str(), wsName.GetLength(), TRUE);
- FX_POSITION pos = pTag->GetFirstAttribute();
- while (pos != NULL) {
- pTag->GetNextAttribute(pos, wsName, wsValue);
- uint32_t dwNameHash =
- FX_HashCode_String_GetW(wsName.raw_str(), wsName.GetLength(), TRUE);
- static const uint32_t s_dwIDHash = FX_HashCode_String_GetW(L"id", 2, TRUE);
- static const uint32_t s_dwClassHash =
- FX_HashCode_String_GetW(L"class", 5, TRUE);
+ static const uint32_t s_dwIDHash = FX_HashCode_GetW(L"id", true);
+ static const uint32_t s_dwClassHash = FX_HashCode_GetW(L"class", true);
+ dwTagHash = FX_HashCode_GetW(pTag->GetTagName().AsStringC(), true);
+
+ for (auto it : *pTag) {
+ CFX_WideString wsValue = it.first;
+ CFX_WideString wsName = it.second;
+ uint32_t dwNameHash = FX_HashCode_GetW(wsName.AsStringC(), true);
if (dwNameHash == s_dwClassHash) {
- uint32_t dwHash =
- FX_HashCode_String_GetW(wsValue.raw_str(), wsValue.GetLength());
+ uint32_t dwHash = FX_HashCode_GetW(wsValue.AsStringC(), false);
dwClassHashs.Add(dwHash);
} else if (dwNameHash == s_dwIDHash) {
- dwIDHash =
- FX_HashCode_String_GetW(wsValue.raw_str(), wsValue.GetLength());
+ dwIDHash = FX_HashCode_GetW(wsValue.AsStringC(), false);
}
}
}
+
FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it)
: pTag(it.pTag),
pParent(it.pParent),
@@ -134,17 +53,18 @@ FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it)
dwTagHash(it.dwTagHash),
iClassIndex(0),
dwClassHashs(1) {
- if (it.dwClassHashs.GetSize() > 0) {
+ if (it.dwClassHashs.GetSize() > 0)
dwClassHashs.Copy(it.dwClassHashs);
- }
}
-void CFDE_CSSAccelerator::OnEnterTag(IFDE_CSSTagProvider* pTag) {
+
+void CFDE_CSSAccelerator::OnEnterTag(CXFA_CSSTagProvider* pTag) {
FDE_CSSTagCache* pTop = GetTopElement();
FDE_CSSTagCache item(pTop, pTag);
m_Stack.Push(item);
}
-void CFDE_CSSAccelerator::OnLeaveTag(IFDE_CSSTagProvider* pTag) {
- FXSYS_assert(m_Stack.GetTopElement());
- FXSYS_assert(m_Stack.GetTopElement()->GetTag() == pTag);
+
+void CFDE_CSSAccelerator::OnLeaveTag(CXFA_CSSTagProvider* pTag) {
+ ASSERT(m_Stack.GetTopElement());
+ ASSERT(m_Stack.GetTopElement()->GetTag() == pTag);
m_Stack.Pop();
}
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_csscache.h b/chromium/third_party/pdfium/xfa/fde/css/fde_csscache.h
index 20158b5371c..2cf007db792 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_csscache.h
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_csscache.h
@@ -21,39 +21,18 @@ class FDE_CSSCacheItem : public CFX_Target {
uint32_t dwActivity;
};
-class CFDE_CSSStyleSheetCache : public IFDE_CSSStyleSheetCache,
- public CFX_Target {
- public:
- CFDE_CSSStyleSheetCache();
- ~CFDE_CSSStyleSheetCache();
- virtual void Release() { delete this; }
-
- virtual void SetMaxItems(int32_t iMaxCount = 5) {
- FXSYS_assert(iMaxCount >= 3);
- m_iMaxItems = iMaxCount;
- }
-
- virtual void AddStyleSheet(const CFX_ByteStringC& szKey,
- IFDE_CSSStyleSheet* pStyleSheet);
- virtual IFDE_CSSStyleSheet* GetStyleSheet(const CFX_ByteStringC& szKey) const;
- virtual void RemoveStyleSheet(const CFX_ByteStringC& szKey);
-
- protected:
- void RemoveLowestActivityItem();
- std::map<CFX_ByteString, FDE_CSSCacheItem*> m_Stylesheets;
- IFX_MEMAllocator* m_pFixedStore;
- int32_t m_iMaxItems;
-};
-
class FDE_CSSTagCache : public CFX_Target {
public:
- FDE_CSSTagCache(FDE_CSSTagCache* parent, IFDE_CSSTagProvider* tag);
+ FDE_CSSTagCache(FDE_CSSTagCache* parent, CXFA_CSSTagProvider* tag);
FDE_CSSTagCache(const FDE_CSSTagCache& it);
+
FDE_CSSTagCache* GetParent() const { return pParent; }
- IFDE_CSSTagProvider* GetTag() const { return pTag; }
+ CXFA_CSSTagProvider* GetTag() const { return pTag; }
+
uint32_t HashID() const { return dwIDHash; }
uint32_t HashTag() const { return dwTagHash; }
int32_t CountHashClass() const { return dwClassHashs.GetSize(); }
+
void SetClassIndex(int32_t index) { iClassIndex = index; }
uint32_t HashClass() const {
return iClassIndex < dwClassHashs.GetSize()
@@ -62,7 +41,7 @@ class FDE_CSSTagCache : public CFX_Target {
}
protected:
- IFDE_CSSTagProvider* pTag;
+ CXFA_CSSTagProvider* pTag;
FDE_CSSTagCache* pParent;
uint32_t dwIDHash;
uint32_t dwTagHash;
@@ -71,11 +50,13 @@ class FDE_CSSTagCache : public CFX_Target {
};
typedef CFX_ObjectStackTemplate<FDE_CSSTagCache> CFDE_CSSTagStack;
-class CFDE_CSSAccelerator : public IFDE_CSSAccelerator, public CFX_Target {
+class CFDE_CSSAccelerator : public CFX_Target {
public:
- virtual void OnEnterTag(IFDE_CSSTagProvider* pTag);
- virtual void OnLeaveTag(IFDE_CSSTagProvider* pTag);
+ void OnEnterTag(CXFA_CSSTagProvider* pTag);
+ void OnLeaveTag(CXFA_CSSTagProvider* pTag);
+
void Clear() { m_Stack.RemoveAll(); }
+
FDE_CSSTagCache* GetTopElement() const { return m_Stack.GetTopElement(); }
protected:
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.cpp b/chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.cpp
index 6abe5a7a26b..3b090a26992 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.cpp
@@ -30,7 +30,7 @@ CFX_FloatRect FDE_CSSBoundaryToRect(IFDE_CSSBoundaryStyle* pBoundStyle,
FX_BOOL bPadding,
FX_BOOL bBorder,
FX_BOOL bMargin) {
- FXSYS_assert(pBoundStyle != NULL);
+ ASSERT(pBoundStyle != NULL);
FX_FLOAT fResult;
const FDE_CSSRECT* pRect;
CFX_FloatRect rect(0, 0, 0, 0);
@@ -88,7 +88,7 @@ CFX_FloatRect FDE_CSSBoundaryToRect(IFDE_CSSBoundaryStyle* pBoundStyle,
return rect;
}
uint32_t FDE_CSSFontStyleToFDE(IFDE_CSSFontStyle* pFontStyle) {
- FXSYS_assert(pFontStyle != NULL);
+ ASSERT(pFontStyle != NULL);
uint32_t dwFontStyle = FX_FONTSTYLE_Normal;
if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) {
dwFontStyle |= FX_FONTSTYLE_Italic;
@@ -557,10 +557,10 @@ FDE_LPCCSSPERSUDOTABLE FDE_GetCSSPersudoByEnum(FDE_CSSPERSUDO ePersudo) {
return (ePersudo < FDE_CSSPERSUDO_NONE) ? (g_FDE_CSSPersudoType + ePersudo)
: NULL;
}
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- uint32_t dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
+FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(
+ const CFX_WideStringC& wsName) {
+ ASSERT(!wsName.IsEmpty());
+ uint32_t dwHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd = FDE_CSSPROPERTY_MAX - 1;
int32_t iMid, iStart = 0;
uint32_t dwMid;
@@ -581,10 +581,9 @@ FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName) {
return (eName < FDE_CSSPROPERTY_MAX) ? (g_FDE_CSSProperties + eName) : NULL;
}
FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName(
- const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- uint32_t dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
+ const CFX_WideStringC& wsName) {
+ ASSERT(!wsName.IsEmpty());
+ uint32_t dwHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd = FDE_CSSPROPERTYVALUE_MAX - 1;
int32_t iMid, iStart = 0;
uint32_t dwMid;
@@ -606,10 +605,10 @@ FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum(
return (eName < FDE_CSSPROPERTYVALUE_MAX) ? (g_FDE_CSSPropertyValues + eName)
: NULL;
}
-FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- uint16_t wHash = (uint16_t)FX_HashCode_String_GetW(pszName, iLength, TRUE);
+FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(
+ const CFX_WideStringC& wsName) {
+ ASSERT(!wsName.IsEmpty());
+ uint16_t wHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd =
sizeof(g_FDE_CSSMediaTypes) / sizeof(FDE_CSSMEDIATYPETABLE) - 1;
int32_t iMid, iStart = 0;
@@ -627,10 +626,10 @@ FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName,
} while (iStart <= iEnd);
return NULL;
}
-FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- uint16_t wHash = (uint16_t)FX_HashCode_String_GetW(pszName, iLength, TRUE);
+FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(
+ const CFX_WideStringC& wsName) {
+ ASSERT(!wsName.IsEmpty());
+ uint16_t wHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd =
sizeof(g_FDE_CSSLengthUnits) / sizeof(FDE_CSSLENGTHUNITTABLE) - 1;
int32_t iMid, iStart = 0;
@@ -648,10 +647,9 @@ FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName,
} while (iStart <= iEnd);
return NULL;
}
-FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName,
- int32_t iLength) {
- FXSYS_assert(pszName != NULL && iLength > 0);
- uint32_t dwHash = FX_HashCode_String_GetW(pszName, iLength, TRUE);
+FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const CFX_WideStringC& wsName) {
+ ASSERT(!wsName.IsEmpty());
+ uint32_t dwHash = FX_HashCode_GetW(wsName, true);
int32_t iEnd = sizeof(g_FDE_CSSColors) / sizeof(FDE_CSSCOLORTABLE) - 1;
int32_t iMid, iStart = 0;
uint32_t dwMid;
@@ -672,7 +670,7 @@ FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_FLOAT& fValue,
FDE_CSSPRIMITIVETYPE& eUnit) {
- FXSYS_assert(pszValue != NULL && iValueLen > 0);
+ ASSERT(pszValue != NULL && iValueLen > 0);
int32_t iUsedLen = 0;
fValue = FX_wcstof(pszValue, iValueLen, &iUsedLen);
if (iUsedLen <= 0) {
@@ -684,7 +682,8 @@ FX_BOOL FDE_ParseCSSNumber(const FX_WCHAR* pszValue,
if (iValueLen >= 1 && *pszValue == '%') {
eUnit = FDE_CSSPRIMITIVETYPE_Percent;
} else if (iValueLen == 2) {
- FDE_LPCCSSLENGTHUNITTABLE pUnit = FDE_GetCSSLengthUnitByName(pszValue, 2);
+ FDE_LPCCSSLENGTHUNITTABLE pUnit =
+ FDE_GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2));
if (pUnit != NULL) {
eUnit = (FDE_CSSPRIMITIVETYPE)pUnit->wValue;
}
@@ -696,7 +695,7 @@ FX_BOOL FDE_ParseCSSString(const FX_WCHAR* pszValue,
int32_t iValueLen,
int32_t& iOffset,
int32_t& iLength) {
- FXSYS_assert(pszValue != NULL && iValueLen > 0);
+ ASSERT(pszValue != NULL && iValueLen > 0);
iOffset = 0;
iLength = iValueLen;
if (iValueLen >= 2) {
@@ -712,7 +711,7 @@ FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue,
int32_t iValueLen,
int32_t& iOffset,
int32_t& iLength) {
- FXSYS_assert(pszValue != NULL && iValueLen > 0);
+ ASSERT(pszValue != NULL && iValueLen > 0);
if (iValueLen < 6 || pszValue[iValueLen - 1] != ')' ||
FX_wcsnicmp(L"url(", pszValue, 4)) {
return FALSE;
@@ -727,7 +726,7 @@ FX_BOOL FDE_ParseCSSURI(const FX_WCHAR* pszValue,
FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_ARGB& dwColor) {
- FXSYS_assert(pszValue != NULL && iValueLen > 0);
+ ASSERT(pszValue != NULL && iValueLen > 0);
if (*pszValue == '#') {
switch (iValueLen) {
case 4: {
@@ -770,7 +769,8 @@ FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue,
dwColor = ArgbEncode(255, rgb[0], rgb[1], rgb[2]);
return TRUE;
} else {
- FDE_LPCCSSCOLORTABLE pColor = FDE_GetCSSColorByName(pszValue, iValueLen);
+ FDE_LPCCSSCOLORTABLE pColor =
+ FDE_GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
if (pColor != NULL) {
dwColor = pColor->dwValue;
return TRUE;
@@ -779,7 +779,7 @@ FX_BOOL FDE_ParseCSSColor(const FX_WCHAR* pszValue,
return FALSE;
}
-CFDE_CSSValueList::CFDE_CSSValueList(IFX_MEMAllocator* pStaticStore,
+CFDE_CSSValueList::CFDE_CSSValueList(IFX_MemoryAllocator* pStaticStore,
const CFDE_CSSValueArray& list) {
m_iCount = list.GetSize();
int32_t iByteCount = m_iCount * sizeof(IFDE_CSSValue*);
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.h b/chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.h
index 8d17901d1d9..30e7eb0ee6b 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.h
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_cssdatatable.h
@@ -15,7 +15,7 @@ class CFDE_CSSFunction : public CFX_Target {
public:
CFDE_CSSFunction(const FX_WCHAR* pszFuncName, IFDE_CSSValueList* pArgList)
: m_pArgList(pArgList), m_pszFuncName(pszFuncName) {
- FXSYS_assert(pArgList != NULL);
+ ASSERT(pArgList != NULL);
}
int32_t CountArgs() const { return m_pArgList->CountValues(); }
IFDE_CSSValue* GetArgs(int32_t index) const {
@@ -39,7 +39,7 @@ class CFDE_CSSPrimitiveValue : public IFDE_CSSPrimitiveValue,
: m_eType(eType), m_fNumber(fValue) {}
CFDE_CSSPrimitiveValue(FDE_CSSPRIMITIVETYPE eType, const FX_WCHAR* pValue)
: m_eType(eType), m_pString(pValue) {
- FXSYS_assert(m_pString != NULL);
+ ASSERT(m_pString != NULL);
}
CFDE_CSSPrimitiveValue(CFDE_CSSFunction* pFunction)
: m_eType(FDE_CSSPRIMITIVETYPE_Function), m_pFunction(pFunction) {}
@@ -47,34 +47,34 @@ class CFDE_CSSPrimitiveValue : public IFDE_CSSPrimitiveValue,
virtual FDE_CSSPRIMITIVETYPE GetPrimitiveType() const { return m_eType; }
virtual FX_ARGB GetRGBColor() const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_RGB);
+ ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_RGB);
return m_dwColor;
}
virtual FX_FLOAT GetFloat() const {
- FXSYS_assert(m_eType >= FDE_CSSPRIMITIVETYPE_Number &&
- m_eType <= FDE_CSSPRIMITIVETYPE_PC);
+ ASSERT(m_eType >= FDE_CSSPRIMITIVETYPE_Number &&
+ m_eType <= FDE_CSSPRIMITIVETYPE_PC);
return m_fNumber;
}
virtual const FX_WCHAR* GetString(int32_t& iLength) const {
- FXSYS_assert(m_eType >= FDE_CSSPRIMITIVETYPE_String &&
- m_eType <= FDE_CSSPRIMITIVETYPE_URI);
+ ASSERT(m_eType >= FDE_CSSPRIMITIVETYPE_String &&
+ m_eType <= FDE_CSSPRIMITIVETYPE_URI);
iLength = FXSYS_wcslen(m_pString);
return m_pString;
}
virtual FDE_CSSPROPERTYVALUE GetEnum() const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Enum);
+ ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Enum);
return m_eEnum;
}
virtual const FX_WCHAR* GetFuncName() const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Function);
+ ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function);
return m_pFunction->GetFuncName();
}
virtual int32_t CountArgs() const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Function);
+ ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function);
return m_pFunction->CountArgs();
}
virtual IFDE_CSSValue* GetArgs(int32_t index) const {
- FXSYS_assert(m_eType == FDE_CSSPRIMITIVETYPE_Function);
+ ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function);
return m_pFunction->GetArgs(index);
}
@@ -91,7 +91,7 @@ typedef CFX_ArrayTemplate<IFDE_CSSPrimitiveValue*> CFDE_CSSPrimitiveArray;
typedef CFX_ArrayTemplate<IFDE_CSSValue*> CFDE_CSSValueArray;
class CFDE_CSSValueList : public IFDE_CSSValueList, public CFX_Target {
public:
- CFDE_CSSValueList(IFX_MEMAllocator* pStaticStore,
+ CFDE_CSSValueList(IFX_MemoryAllocator* pStaticStore,
const CFDE_CSSValueArray& list);
virtual int32_t CountValues() const { return m_iCount; }
virtual IFDE_CSSValue* GetValue(int32_t index) const {
@@ -106,7 +106,7 @@ class CFDE_CSSValueListParser : public CFX_Target {
public:
CFDE_CSSValueListParser(const FX_WCHAR* psz, int32_t iLen, FX_WCHAR separator)
: m_Separator(separator), m_pCur(psz), m_pEnd(psz + iLen) {
- FXSYS_assert(psz != NULL && iLen > 0);
+ ASSERT(psz != NULL && iLen > 0);
}
FX_BOOL NextValue(FDE_CSSPRIMITIVETYPE& eType,
const FX_WCHAR*& pStart,
@@ -137,8 +137,7 @@ struct FDE_CSSPROPERTYTABLE {
};
typedef FDE_CSSPROPERTYTABLE const* FDE_LPCCSSPROPERTYTABLE;
-FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const FX_WCHAR* pszName,
- int32_t iLength);
+FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByName(const CFX_WideStringC& wsName);
FDE_LPCCSSPROPERTYTABLE FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY eName);
struct FDE_CSSPROPERTYVALUETABLE {
FDE_CSSPROPERTYVALUE eName;
@@ -148,8 +147,7 @@ struct FDE_CSSPROPERTYVALUETABLE {
typedef FDE_CSSPROPERTYVALUETABLE const* FDE_LPCCSSPROPERTYVALUETABLE;
FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByName(
- const FX_WCHAR* pszName,
- int32_t iLength);
+ const CFX_WideStringC& wsName);
FDE_LPCCSSPROPERTYVALUETABLE FDE_GetCSSPropertyValueByEnum(
FDE_CSSPROPERTYVALUE eName);
struct FDE_CSSMEDIATYPETABLE {
@@ -157,22 +155,22 @@ struct FDE_CSSMEDIATYPETABLE {
uint16_t wValue;
};
typedef FDE_CSSMEDIATYPETABLE const* FDE_LPCCSSMEDIATYPETABLE;
-FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(const FX_WCHAR* pszName,
- int32_t iLength);
+FDE_LPCCSSMEDIATYPETABLE FDE_GetCSSMediaTypeByName(
+ const CFX_WideStringC& wsName);
struct FDE_CSSLENGTHUNITTABLE {
uint16_t wHash;
uint16_t wValue;
};
typedef FDE_CSSLENGTHUNITTABLE const* FDE_LPCCSSLENGTHUNITTABLE;
-FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(const FX_WCHAR* pszName,
- int32_t iLength);
+FDE_LPCCSSLENGTHUNITTABLE FDE_GetCSSLengthUnitByName(
+ const CFX_WideStringC& wsName);
struct FDE_CSSCOLORTABLE {
uint32_t dwHash;
FX_ARGB dwValue;
};
typedef FDE_CSSCOLORTABLE const* FDE_LPCCSSCOLORTABLE;
-FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const FX_WCHAR* pszName,
- int32_t iLength);
+FDE_LPCCSSCOLORTABLE FDE_GetCSSColorByName(const CFX_WideStringC& wsName);
+
struct FDE_CSSPERSUDOTABLE {
FDE_CSSPERSUDO eName;
const FX_WCHAR* pszName;
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.cpp b/chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.cpp
index 5517d85cb22..f4f55fc0dbf 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.cpp
@@ -28,7 +28,7 @@ void CFDE_CSSDeclaration::GetNextProperty(FX_POSITION& pos,
IFDE_CSSValue*& pValue,
FX_BOOL& bImportant) const {
const FDE_CSSPropertyHolder* pHolder = (const FDE_CSSPropertyHolder*)pos;
- FXSYS_assert(pHolder != NULL);
+ ASSERT(pHolder != NULL);
bImportant = pHolder->bImportant;
eProperty = (FDE_CSSPROPERTY)pHolder->eProperty;
pValue = pHolder->pValue;
@@ -52,13 +52,13 @@ const FX_WCHAR* CFDE_CSSDeclaration::CopyToLocal(
const FDE_CSSPROPERTYARGS* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen) {
- FXSYS_assert(iValueLen > 0);
+ ASSERT(iValueLen > 0);
CFX_MapPtrToPtr* pCache = pArgs->pStringCache;
void* pKey = NULL;
if (pCache) {
void* pszCached = NULL;
- pKey =
- (void*)(uintptr_t)FX_HashCode_String_GetW(pszValue, iValueLen, FALSE);
+ pKey = (void*)(uintptr_t)FX_HashCode_GetW(
+ CFX_WideStringC(pszValue, iValueLen), false);
if (pCache->Lookup(pKey, pszCached)) {
return (const FX_WCHAR*)pszCached;
}
@@ -76,7 +76,7 @@ const FX_WCHAR* CFDE_CSSDeclaration::CopyToLocal(
return psz;
}
IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewNumberValue(
- IFX_MEMAllocator* pStaticStore,
+ IFX_MemoryAllocator* pStaticStore,
FDE_CSSPRIMITIVETYPE eUnit,
FX_FLOAT fValue) const {
static CFDE_CSSPrimitiveValue s_ZeroValue(FDE_CSSPRIMITIVETYPE_Number, 0.0f);
@@ -86,11 +86,11 @@ IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewNumberValue(
return FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(eUnit, fValue);
}
inline IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewEnumValue(
- IFX_MEMAllocator* pStaticStore,
+ IFX_MemoryAllocator* pStaticStore,
FDE_CSSPROPERTYVALUE eValue) const {
return FXTARGET_NewWith(pStaticStore) CFDE_CSSPrimitiveValue(eValue);
}
-void CFDE_CSSDeclaration::AddPropertyHolder(IFX_MEMAllocator* pStaticStore,
+void CFDE_CSSDeclaration::AddPropertyHolder(IFX_MemoryAllocator* pStaticStore,
FDE_CSSPROPERTY eProperty,
IFDE_CSSValue* pValue,
FX_BOOL bImportant) {
@@ -110,7 +110,7 @@ void CFDE_CSSDeclaration::AddPropertyHolder(IFX_MEMAllocator* pStaticStore,
FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen) {
- FXSYS_assert(iValueLen > 0);
+ ASSERT(iValueLen > 0);
FX_BOOL bImportant = FALSE;
if (iValueLen >= 10 && pszValue[iValueLen - 10] == '!' &&
FX_wcsnicmp(L"important", pszValue + iValueLen - 9, 9) == 0) {
@@ -168,7 +168,7 @@ FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs,
}
} break;
case FDE_CSSVALUETYPE_Shorthand: {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
IFDE_CSSValue *pColor, *pStyle, *pWidth;
switch (pArgs->pProperty->eName) {
case FDE_CSSPROPERTY_Font:
@@ -260,7 +260,7 @@ FX_BOOL CFDE_CSSDeclaration::AddProperty(const FDE_CSSPROPERTYARGS* pArgs,
return ParseValueListProperty(pArgs, pszValue, iValueLen, bImportant);
}
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
return FALSE;
@@ -298,7 +298,7 @@ IFDE_CSSValue* CFDE_CSSDeclaration::ParseEnum(const FDE_CSSPROPERTYARGS* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen) {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
return pValue ? NewEnumValue(pArgs->pStaticStore, pValue->eName) : NULL;
}
IFDE_CSSValue* CFDE_CSSDeclaration::ParseColor(const FDE_CSSPROPERTYARGS* pArgs,
@@ -371,7 +371,7 @@ IFDE_CSSValue* CFDE_CSSDeclaration::ParseFunction(
switch (ePrimitiveType) {
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSPROPERTYVALUETABLE* pPropertyValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pPropertyValue != NULL) {
argumentArr.Add(
NewEnumValue(pArgs->pStaticStore, pPropertyValue->eName));
@@ -415,7 +415,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseContentProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = (IFX_MEMAllocator*)pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
FDE_CSSPRIMITIVETYPE eType;
CFDE_CSSValueArray list;
@@ -429,7 +429,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseContentProperty(
return FALSE;
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue != NULL) {
switch (pValue->eName) {
case FDE_CSSPROPERTYVALUE_Normal:
@@ -479,7 +479,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseCounterProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
CFDE_CSSValueArray list;
CFDE_CSSValueArray listFull;
@@ -535,7 +535,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseValueListProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
FX_WCHAR separator =
(pArgs->pProperty->eName == FDE_CSSPROPERTY_FontFamily) ? ',' : ' ';
CFDE_CSSValueListParser parser(pszValue, iValueLen, separator);
@@ -563,7 +563,8 @@ FX_BOOL CFDE_CSSDeclaration::ParseValueListProperty(
}
if (dwType & FDE_CSSVALUETYPE_MaybeEnum) {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(
+ CFX_WideStringC(pszValue, iValueLen));
if (pValue != NULL) {
list.Add(NewEnumValue(pStaticStore, pValue->eName));
continue;
@@ -627,13 +628,14 @@ FX_BOOL CFDE_CSSDeclaration::ParseValueListProperty(
}
return FALSE;
}
-FX_BOOL CFDE_CSSDeclaration::Add4ValuesProperty(IFX_MEMAllocator* pStaticStore,
- const CFDE_CSSValueArray& list,
- FX_BOOL bImportant,
- FDE_CSSPROPERTY eLeft,
- FDE_CSSPROPERTY eTop,
- FDE_CSSPROPERTY eRight,
- FDE_CSSPROPERTY eBottom) {
+FX_BOOL CFDE_CSSDeclaration::Add4ValuesProperty(
+ IFX_MemoryAllocator* pStaticStore,
+ const CFDE_CSSValueArray& list,
+ FX_BOOL bImportant,
+ FDE_CSSPROPERTY eLeft,
+ FDE_CSSPROPERTY eTop,
+ FDE_CSSPROPERTY eRight,
+ FDE_CSSPROPERTY eBottom) {
switch (list.GetSize()) {
case 1:
AddPropertyHolder(pStaticStore, eLeft, list[0], bImportant);
@@ -665,7 +667,7 @@ FX_BOOL CFDE_CSSDeclaration::Add4ValuesProperty(IFX_MEMAllocator* pStaticStore,
return FALSE;
}
FX_BOOL CFDE_CSSDeclaration::ParseBorderPropoerty(
- IFX_MEMAllocator* pStaticStore,
+ IFX_MemoryAllocator* pStaticStore,
const FX_WCHAR* pszValue,
int32_t iValueLen,
IFDE_CSSValue*& pColor,
@@ -695,7 +697,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseBorderPropoerty(
break;
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSCOLORTABLE* pColorItem =
- FDE_GetCSSColorByName(pszValue, iValueLen);
+ FDE_GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
if (pColorItem != NULL) {
if (pColor == NULL) {
pColor = FXTARGET_NewWith(pStaticStore)
@@ -704,7 +706,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseBorderPropoerty(
continue;
}
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue == NULL) {
continue;
}
@@ -755,7 +757,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseBorderPropoerty(
}
return TRUE;
}
-void CFDE_CSSDeclaration::AddBorderProperty(IFX_MEMAllocator* pStaticStore,
+void CFDE_CSSDeclaration::AddBorderProperty(IFX_MemoryAllocator* pStaticStore,
IFDE_CSSValue* pColor,
IFDE_CSSValue* pStyle,
IFDE_CSSValue* pWidth,
@@ -772,7 +774,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseListStyleProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
IFDE_CSSPrimitiveValue *pType = NULL, *pImage = NULL, *pPosition = NULL;
FDE_CSSPRIMITIVETYPE eType;
@@ -786,7 +788,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseListStyleProperty(
break;
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue == NULL) {
break;
}
@@ -852,7 +854,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseBackgroundProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
IFDE_CSSPrimitiveValue *pColor = NULL, *pImage = NULL, *pRepeat = NULL;
IFDE_CSSPrimitiveValue *pPosX = NULL, *pPosY = NULL, *pAttachment = NULL;
@@ -878,7 +880,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseBackgroundProperty(
} break;
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue != NULL) {
switch (pValue->eName) {
case FDE_CSSPROPERTYVALUE_None:
@@ -931,7 +933,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseBackgroundProperty(
break;
}
const FDE_CSSCOLORTABLE* pColorItem =
- FDE_GetCSSColorByName(pszValue, iValueLen);
+ FDE_GetCSSColorByName(CFX_WideStringC(pszValue, iValueLen));
if (pColorItem != NULL) {
if (pColor == NULL) {
pColor = FXTARGET_NewWith(pStaticStore)
@@ -991,7 +993,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, '/');
IFDE_CSSPrimitiveValue *pStyle = NULL, *pVariant = NULL, *pWeight = NULL;
IFDE_CSSPrimitiveValue *pFontSize = NULL, *pLineHeight = NULL;
@@ -1001,7 +1003,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseFontProperty(const FDE_CSSPROPERTYARGS* pArgs,
switch (eType) {
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue != NULL) {
switch (pValue->eName) {
case FDE_CSSPROPERTYVALUE_XxSmall:
@@ -1129,7 +1131,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseColumnRuleProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
IFDE_CSSPrimitiveValue* pColumnRuleWidth = NULL;
IFDE_CSSPrimitiveValue* pColumnRuleStyle = NULL;
@@ -1139,7 +1141,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseColumnRuleProperty(
switch (eType) {
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue != NULL) {
switch (pValue->eName) {
case FDE_CSSPROPERTYVALUE_None:
@@ -1227,7 +1229,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseTextEmphasisProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
CFDE_CSSValueArray arrEmphasisStyle;
FDE_CSSPRIMITIVETYPE eType;
@@ -1236,7 +1238,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseTextEmphasisProperty(
switch (eType) {
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue != NULL) {
arrEmphasisStyle.Add(NewEnumValue(pStaticStore, pValue->eName));
continue;
@@ -1280,7 +1282,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseColumnsProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
IFDE_CSSPrimitiveValue* pColumnWidth = NULL;
IFDE_CSSPrimitiveValue* pColumnCount = NULL;
@@ -1289,7 +1291,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseColumnsProperty(
switch (eType) {
case FDE_CSSPRIMITIVETYPE_String: {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue == NULL && pValue->eName == FDE_CSSPROPERTYVALUE_Auto) {
pColumnWidth = NewEnumValue(pStaticStore, pValue->eName);
}
@@ -1333,7 +1335,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseOverflowProperty(
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant) {
- IFX_MEMAllocator* pStaticStore = pArgs->pStaticStore;
+ IFX_MemoryAllocator* pStaticStore = pArgs->pStaticStore;
CFDE_CSSValueListParser parser(pszValue, iValueLen, ' ');
IFDE_CSSPrimitiveValue* pOverflowX = NULL;
IFDE_CSSPrimitiveValue* pOverflowY = NULL;
@@ -1341,7 +1343,7 @@ FX_BOOL CFDE_CSSDeclaration::ParseOverflowProperty(
while (parser.NextValue(eType, pszValue, iValueLen)) {
if (eType == FDE_CSSPRIMITIVETYPE_String) {
const FDE_CSSPROPERTYVALUETABLE* pValue =
- FDE_GetCSSPropertyValueByName(pszValue, iValueLen);
+ FDE_GetCSSPropertyValueByName(CFX_WideStringC(pszValue, iValueLen));
if (pValue != NULL) {
switch (pValue->eName) {
case FDE_CSSOVERFLOW_Visible:
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.h b/chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.h
index 2a3031ea695..4fa6858f979 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.h
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_cssdeclaration.h
@@ -25,29 +25,30 @@ class FDE_CSSCustomProperty : public CFX_Target {
};
struct FDE_CSSPROPERTYARGS {
- IFX_MEMAllocator* pStaticStore;
+ IFX_MemoryAllocator* pStaticStore;
CFX_MapPtrToPtr* pStringCache;
FDE_LPCCSSPROPERTYTABLE pProperty;
};
-class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target {
+class CFDE_CSSDeclaration : public CFX_Target {
public:
CFDE_CSSDeclaration()
- : m_pFirstProperty(NULL),
- m_pLastProperty(NULL),
- m_pFirstCustom(NULL),
- m_pLastCustom(NULL) {}
- virtual IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty,
- FX_BOOL& bImportant) const;
- virtual FX_POSITION GetStartPosition() const;
- virtual void GetNextProperty(FX_POSITION& pos,
- FDE_CSSPROPERTY& eProperty,
- IFDE_CSSValue*& pValue,
- FX_BOOL& bImportant) const;
- virtual FX_POSITION GetStartCustom() const;
- virtual void GetNextCustom(FX_POSITION& pos,
- CFX_WideString& wsName,
- CFX_WideString& wsValue) const;
+ : m_pFirstProperty(nullptr),
+ m_pLastProperty(nullptr),
+ m_pFirstCustom(nullptr),
+ m_pLastCustom(nullptr) {}
+
+ IFDE_CSSValue* GetProperty(FDE_CSSPROPERTY eProperty,
+ FX_BOOL& bImportant) const;
+ FX_POSITION GetStartPosition() const;
+ void GetNextProperty(FX_POSITION& pos,
+ FDE_CSSPROPERTY& eProperty,
+ IFDE_CSSValue*& pValue,
+ FX_BOOL& bImportant) const;
+ FX_POSITION GetStartCustom() const;
+ void GetNextCustom(FX_POSITION& pos,
+ CFX_WideString& wsName,
+ CFX_WideString& wsValue) const;
FX_BOOL AddProperty(const FDE_CSSPROPERTYARGS* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen);
@@ -86,13 +87,13 @@ class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target {
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant);
- FX_BOOL ParseBorderPropoerty(IFX_MEMAllocator* pStaticStore,
+ FX_BOOL ParseBorderPropoerty(IFX_MemoryAllocator* pStaticStore,
const FX_WCHAR* pszValue,
int32_t iValueLen,
IFDE_CSSValue*& pColor,
IFDE_CSSValue*& pStyle,
IFDE_CSSValue*& pWidth) const;
- void AddBorderProperty(IFX_MEMAllocator* pStaticStore,
+ void AddBorderProperty(IFX_MemoryAllocator* pStaticStore,
IFDE_CSSValue* pColor,
IFDE_CSSValue* pStyle,
IFDE_CSSValue* pWidth,
@@ -112,7 +113,7 @@ class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target {
const FX_WCHAR* pszValue,
int32_t iValueLen,
FX_BOOL bImportant);
- FX_BOOL Add4ValuesProperty(IFX_MEMAllocator* pStaticStore,
+ FX_BOOL Add4ValuesProperty(IFX_MemoryAllocator* pStaticStore,
const CFDE_CSSValueArray& list,
FX_BOOL bImportant,
FDE_CSSPROPERTY eLeft,
@@ -140,19 +141,21 @@ class CFDE_CSSDeclaration : public IFDE_CSSDeclaration, public CFX_Target {
const FX_WCHAR* CopyToLocal(const FDE_CSSPROPERTYARGS* pArgs,
const FX_WCHAR* pszValue,
int32_t iValueLen);
- void AddPropertyHolder(IFX_MEMAllocator* pStaticStore,
+ void AddPropertyHolder(IFX_MemoryAllocator* pStaticStore,
FDE_CSSPROPERTY eProperty,
IFDE_CSSValue* pValue,
FX_BOOL bImportant);
- IFDE_CSSPrimitiveValue* NewNumberValue(IFX_MEMAllocator* pStaticStore,
+ IFDE_CSSPrimitiveValue* NewNumberValue(IFX_MemoryAllocator* pStaticStore,
FDE_CSSPRIMITIVETYPE eUnit,
FX_FLOAT fValue) const;
- IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MEMAllocator* pStaticStore,
+ IFDE_CSSPrimitiveValue* NewEnumValue(IFX_MemoryAllocator* pStaticStore,
FDE_CSSPROPERTYVALUE eValue) const;
+
FDE_CSSPropertyHolder* m_pFirstProperty;
FDE_CSSPropertyHolder* m_pLastProperty;
FDE_CSSCustomProperty* m_pFirstCustom;
FDE_CSSCustomProperty* m_pLastCustom;
};
+using CFDE_CSSDeclarationArray = CFX_ArrayTemplate<CFDE_CSSDeclaration*>;
#endif // XFA_FDE_CSS_FDE_CSSDECLARATION_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.cpp b/chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.cpp
index 1a27a7e5c91..05f036b1f36 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.cpp
@@ -7,9 +7,15 @@
#include "xfa/fde/css/fde_cssstyleselector.h"
#include <algorithm>
+#include <memory>
#include "xfa/fde/css/fde_csscache.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
+#include "xfa/fde/css/fde_cssstylesheet.h"
+#include "xfa/fde/css/fde_csssyntax.h"
+#include "xfa/fxfa/app/xfa_textlayout.h"
+
+#define FDE_CSSUNIVERSALHASH ('*')
int32_t CFDE_CSSCounterStyle::FindIndex(const FX_WCHAR* pszIdentifier) {
int32_t iCount = m_arrCounterData.GetSize();
@@ -74,17 +80,9 @@ void CFDE_CSSCounterStyle::UpdateIndex() {
DoUpdateIndex(m_pCounterReset);
m_bIndexDirty = FALSE;
}
-FDE_CSSTEXTEMPHASISMARK CFDE_CSSComputedStyle::GetTextEmphasisMark() const {
- if (m_InheritedData.m_eTextEmphasisMark != FDE_CSSTEXTEMPHASISMARK_Auto) {
- return (FDE_CSSTEXTEMPHASISMARK)m_InheritedData.m_eTextEmphasisMark;
- }
- if (m_InheritedData.m_eWritingMode == FDE_CSSWRITINGMODE_HorizontalTb) {
- return FDE_CSSTEXTEMPHASISMARK_Dot;
- }
- return FDE_CSSTEXTEMPHASISMARK_Sesame;
-}
-FDE_CSSRuleData::FDE_CSSRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl,
+
+FDE_CSSRuleData::FDE_CSSRuleData(CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl,
uint32_t dwPos)
: pSelector(pSel), pDeclaration(pDecl), dwPriority(dwPos), pNext(NULL) {
static const uint32_t s_Specific[5] = {0x00010000, 0x00010000, 0x00100000,
@@ -126,10 +124,10 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
switch (pRule->GetType()) {
case FDE_CSSRULETYPE_Style: {
IFDE_CSSStyleRule* pStyleRule = (IFDE_CSSStyleRule*)pRule;
- IFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
+ CFDE_CSSDeclaration* pDeclaration = pStyleRule->GetDeclaration();
int32_t iSelectors = pStyleRule->CountSelectorLists();
for (int32_t i = 0; i < iSelectors; ++i) {
- IFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
+ CFDE_CSSSelector* pSelector = pStyleRule->GetSelectorList(i);
if (pSelector->GetType() == FDE_CSSSELECTORTYPE_Persudo) {
FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration);
AddRuleTo(m_pPersudoRules, pData);
@@ -140,8 +138,8 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
pDeclaration);
continue;
}
- IFDE_CSSSelector* pNext = pSelector->GetNextSelector();
- if (pNext == NULL) {
+ CFDE_CSSSelector* pNext = pSelector->GetNextSelector();
+ if (!pNext) {
FDE_CSSRuleData* pData = NewRuleData(pSelector, pDeclaration);
AddRuleTo(m_pUniversalRules, pData);
continue;
@@ -159,7 +157,7 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
AddRuleTo(m_pUniversalRules, NewRuleData(pSelector, pDeclaration));
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
}
@@ -180,8 +178,8 @@ void CFDE_CSSRuleCollection::AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
}
void CFDE_CSSRuleCollection::AddRuleTo(CFX_MapPtrToPtr& map,
uint32_t dwKey,
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl) {
+ CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl) {
void* pKey = (void*)(uintptr_t)dwKey;
FDE_CSSRuleData* pData = NewRuleData(pSel, pDecl);
FDE_CSSRuleData* pList = NULL;
@@ -205,15 +203,12 @@ FX_BOOL CFDE_CSSRuleCollection::AddRuleTo(FDE_CSSRuleData*& pList,
}
FDE_CSSRuleData* CFDE_CSSRuleCollection::NewRuleData(
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl) {
+ CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl) {
return FXTARGET_NewWith(m_pStaticStore)
FDE_CSSRuleData(pSel, pDecl, ++m_iSelectors);
}
-IFDE_CSSStyleSelector* IFDE_CSSStyleSelector::Create() {
- return new CFDE_CSSStyleSelector;
-}
CFDE_CSSStyleSelector::CFDE_CSSStyleSelector()
: m_pFontMgr(NULL),
m_fDefFontSize(12.0f),
@@ -226,39 +221,34 @@ CFDE_CSSStyleSelector::CFDE_CSSStyleSelector()
m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_Low] =
FDE_CSSSTYLESHEETGROUP_UserAgent;
}
+
CFDE_CSSStyleSelector::~CFDE_CSSStyleSelector() {
Reset();
- if (m_pInlineStyleStore != NULL) {
- m_pInlineStyleStore->Release();
- }
- if (m_pFixedStyleStore != NULL) {
- m_pFixedStyleStore->Release();
- }
- if (m_pAccelerator != NULL) {
- delete m_pAccelerator;
- }
+ delete m_pInlineStyleStore;
+ delete m_pFixedStyleStore;
+ delete m_pAccelerator;
}
+
void CFDE_CSSStyleSelector::SetFontMgr(IFX_FontMgr* pFontMgr) {
m_pFontMgr = pFontMgr;
}
void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) {
- FXSYS_assert(fFontSize > 0);
+ ASSERT(fFontSize > 0);
m_fDefFontSize = fFontSize;
}
-IFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() {
- if (m_pAccelerator == NULL) {
+
+CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() {
+ if (!m_pAccelerator)
m_pAccelerator = new CFDE_CSSAccelerator;
- FXSYS_assert(m_pAccelerator != NULL);
- }
m_pAccelerator->Clear();
return m_pAccelerator;
}
+
IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle(
IFDE_CSSComputedStyle* pParentStyle) {
- if (m_pFixedStyleStore == NULL) {
- m_pFixedStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 16,
- sizeof(CFDE_CSSComputedStyle));
- FXSYS_assert(m_pFixedStyleStore != NULL);
+ if (!m_pFixedStyleStore) {
+ m_pFixedStyleStore = IFX_MemoryAllocator::Create(
+ FX_ALLOCTYPE_Fixed, 16, sizeof(CFDE_CSSComputedStyle));
}
CFDE_CSSComputedStyle* pStyle = FXTARGET_NewWith(m_pFixedStyleStore)
CFDE_CSSComputedStyle(m_pFixedStyleStore);
@@ -273,7 +263,7 @@ IFDE_CSSComputedStyle* CFDE_CSSStyleSelector::CreateComputedStyle(
}
FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
IFDE_CSSStyleSheet* pSheet) {
- FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX);
+ ASSERT(eType < FDE_CSSSTYLESHEETGROUP_MAX);
CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType];
dest.RemoveAt(0, dest.GetSize());
if (pSheet != NULL) {
@@ -284,7 +274,7 @@ FX_BOOL CFDE_CSSStyleSelector::SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
FX_BOOL CFDE_CSSStyleSelector::SetStyleSheets(
FDE_CSSSTYLESHEETGROUP eType,
const CFDE_CSSStyleSheetArray* pArray) {
- FXSYS_assert(eType < FDE_CSSSTYLESHEETGROUP_MAX);
+ ASSERT(eType < FDE_CSSSTYLESHEETGROUP_MAX);
CFDE_CSSStyleSheetArray& dest = m_SheetGroups[eType];
if (pArray == NULL) {
dest.RemoveAt(0, dest.GetSize());
@@ -300,8 +290,7 @@ void CFDE_CSSStyleSelector::SetStylePriority(
}
void CFDE_CSSStyleSelector::UpdateStyleIndex(uint32_t dwMediaList) {
Reset();
- m_pRuleDataStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0);
- FXSYS_assert(m_pRuleDataStore != NULL);
+ m_pRuleDataStore = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 1024, 0);
for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) {
CFDE_CSSRuleCollection& rules = m_RuleCollection[iGroup];
rules.m_pStaticStore = m_pRuleDataStore;
@@ -312,26 +301,26 @@ void CFDE_CSSStyleSelector::Reset() {
for (int32_t iGroup = 0; iGroup < FDE_CSSSTYLESHEETGROUP_MAX; ++iGroup) {
m_RuleCollection[iGroup].Clear();
}
- if (m_pRuleDataStore != NULL) {
- m_pRuleDataStore->Release();
- m_pRuleDataStore = NULL;
- }
+ delete m_pRuleDataStore;
+ m_pRuleDataStore = nullptr;
}
int32_t CFDE_CSSStyleSelector::MatchDeclarations(
- IFDE_CSSTagProvider* pTag,
+ CXFA_CSSTagProvider* pTag,
CFDE_CSSDeclarationArray& matchedDecls,
FDE_CSSPERSUDO ePersudoType) {
- FXSYS_assert(m_pAccelerator != NULL && pTag != NULL);
+ ASSERT(m_pAccelerator && pTag);
+
FDE_CSSTagCache* pCache = m_pAccelerator->GetTopElement();
- FXSYS_assert(pCache != NULL && pCache->GetTag() == pTag);
+ ASSERT(pCache && pCache->GetTag() == pTag);
+
matchedDecls.RemoveAt(0, matchedDecls.GetSize());
for (int32_t ePriority = FDE_CSSSTYLESHEETPRIORITY_MAX - 1; ePriority >= 0;
--ePriority) {
FDE_CSSSTYLESHEETGROUP eGroup = m_ePriorities[ePriority];
CFDE_CSSRuleCollection& rules = m_RuleCollection[eGroup];
- if (rules.CountSelectors() == 0) {
+ if (rules.CountSelectors() == 0)
continue;
- }
+
if (ePersudoType == FDE_CSSPERSUDO_NONE) {
MatchRules(pCache, rules.GetUniversalRuleData(), ePersudoType);
if (pCache->HashTag()) {
@@ -370,7 +359,7 @@ void CFDE_CSSStyleSelector::MatchRules(FDE_CSSTagCache* pCache,
}
FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache,
- IFDE_CSSSelector* pSel,
+ CFDE_CSSSelector* pSel,
FDE_CSSPERSUDO ePersudoType) {
uint32_t dwHash;
while (pSel != NULL && pCache != NULL) {
@@ -411,7 +400,7 @@ FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache,
}
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
pSel = pSel->GetNextSelector();
@@ -420,67 +409,70 @@ FX_BOOL CFDE_CSSStyleSelector::MatchSelector(FDE_CSSTagCache* pCache,
}
void CFDE_CSSStyleSelector::ComputeStyle(
- IFDE_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
+ CXFA_CSSTagProvider* pTag,
+ const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount,
IFDE_CSSComputedStyle* pDestStyle) {
- FXSYS_assert(iDeclCount >= 0);
- FXSYS_assert(pDestStyle);
- FX_POSITION pos = pTag->GetFirstAttribute();
- if (pos != NULL) {
- if (m_pInlineStyleStore == NULL) {
- m_pInlineStyleStore = FX_CreateAllocator(FX_ALLOCTYPE_Static, 2048, 0);
+ ASSERT(iDeclCount >= 0);
+ ASSERT(pDestStyle);
+
+ static const uint32_t s_dwStyleHash = FX_HashCode_GetW(L"style", true);
+ static const uint32_t s_dwAlignHash = FX_HashCode_GetW(L"align", true);
+
+ if (!pTag->empty()) {
+ if (!m_pInlineStyleStore) {
+ m_pInlineStyleStore =
+ IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 2048, 0);
}
- CFDE_CSSDeclaration* pDecl = NULL;
- CFX_WideStringC wsAttri, wsValue;
- uint32_t dwAttriHash;
- do {
- pTag->GetNextAttribute(pos, wsAttri, wsValue);
- dwAttriHash =
- FX_HashCode_String_GetW(wsAttri.raw_str(), wsAttri.GetLength(), TRUE);
- static const uint32_t s_dwStyleHash =
- FX_HashCode_String_GetW(L"style", 5, TRUE);
- static const uint32_t s_dwAlignHash =
- FX_HashCode_String_GetW(L"align", 5, TRUE);
+ CFDE_CSSDeclaration* pDecl = nullptr;
+ for (auto it : *pTag) {
+ CFX_WideString wsAttri = it.first;
+ CFX_WideString wsValue = it.second;
+ uint32_t dwAttriHash = FX_HashCode_GetW(wsAttri.AsStringC(), true);
if (dwAttriHash == s_dwStyleHash) {
- if (pDecl == NULL) {
+ if (!pDecl)
pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration;
- }
- AppendInlineStyle(pDecl, wsValue.raw_str(), wsValue.GetLength());
+
+ AppendInlineStyle(pDecl, wsValue.c_str(), wsValue.GetLength());
} else if (dwAttriHash == s_dwAlignHash) {
- if (pDecl == NULL) {
+ if (!pDecl)
pDecl = FXTARGET_NewWith(m_pInlineStyleStore) CFDE_CSSDeclaration;
- }
+
FDE_CSSPROPERTYARGS args;
- args.pStringCache = NULL;
+ args.pStringCache = nullptr;
args.pStaticStore = m_pInlineStyleStore;
args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSPROPERTY_TextAlign);
- pDecl->AddProperty(&args, wsValue.raw_str(), wsValue.GetLength());
+ pDecl->AddProperty(&args, wsValue.c_str(), wsValue.GetLength());
}
- } while (pos != NULL);
- if (pDecl != NULL) {
+ }
+
+ if (pDecl) {
CFDE_CSSDeclarationArray decls;
decls.SetSize(iDeclCount + 1);
- IFDE_CSSDeclaration** ppInline = decls.GetData();
+ CFDE_CSSDeclaration** ppInline = decls.GetData();
FXSYS_memcpy(ppInline, ppDeclArray,
- iDeclCount * sizeof(IFDE_CSSDeclaration*));
+ iDeclCount * sizeof(CFDE_CSSDeclaration*));
ppInline[iDeclCount++] = pDecl;
- ApplyDeclarations(TRUE, (const IFDE_CSSDeclaration**)ppInline, iDeclCount,
- pDestStyle);
- ApplyDeclarations(FALSE, (const IFDE_CSSDeclaration**)ppInline,
+ ApplyDeclarations(TRUE, const_cast<const CFDE_CSSDeclaration**>(ppInline),
+ iDeclCount, pDestStyle);
+ ApplyDeclarations(FALSE,
+ const_cast<const CFDE_CSSDeclaration**>(ppInline),
iDeclCount, pDestStyle);
return;
}
}
+
if (iDeclCount > 0) {
- FXSYS_assert(ppDeclArray != NULL);
+ ASSERT(ppDeclArray);
+
ApplyDeclarations(TRUE, ppDeclArray, iDeclCount, pDestStyle);
ApplyDeclarations(FALSE, ppDeclArray, iDeclCount, pDestStyle);
}
}
+
void CFDE_CSSStyleSelector::ApplyDeclarations(
FX_BOOL bPriority,
- const IFDE_CSSDeclaration** ppDeclArray,
+ const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount,
IFDE_CSSComputedStyle* pDestStyle) {
CFDE_CSSComputedStyle* pComputedStyle = (CFDE_CSSComputedStyle*)pDestStyle;
@@ -506,7 +498,7 @@ void CFDE_CSSStyleSelector::ApplyDeclarations(
}
} else {
CFDE_CSSDeclarationArray importants;
- const IFDE_CSSDeclaration* pDecl = NULL;
+ const CFDE_CSSDeclaration* pDecl = nullptr;
FDE_CSSPROPERTY eProp;
FX_POSITION pos;
for (i = 0; i < iDeclCount; ++i) {
@@ -520,7 +512,7 @@ void CFDE_CSSStyleSelector::ApplyDeclarations(
ApplyProperty(eProp, pVal, pComputedStyle);
} else if (importants.GetSize() == 0 ||
importants[importants.GetUpperBound()] != pDecl) {
- importants.Add((IFDE_CSSDeclaration*)pDecl);
+ importants.Add(const_cast<CFDE_CSSDeclaration*>(pDecl));
}
}
}
@@ -546,46 +538,43 @@ void CFDE_CSSStyleSelector::ApplyDeclarations(
void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
const FX_WCHAR* psz,
int32_t iLen) {
- FXSYS_assert(pDecl != NULL && psz != NULL && iLen > 0);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
+ ASSERT(pDecl && psz && iLen > 0);
+ std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+ if (!pSyntax->Init(psz, iLen, 32, TRUE))
return;
- }
- if (pSyntax->Init(psz, iLen, 32, TRUE)) {
- int32_t iLen;
- const FX_WCHAR* psz;
- FDE_CSSPROPERTYARGS args;
- args.pStringCache = NULL;
- args.pStaticStore = m_pInlineStyleStore;
- args.pProperty = NULL;
- CFX_WideString wsName;
- for (;;) {
- FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse();
- if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) {
- psz = pSyntax->GetCurrentString(iLen);
- args.pProperty = FDE_GetCSSPropertyByName(psz, iLen);
- if (args.pProperty == NULL) {
- wsName = CFX_WideStringC(psz, iLen);
- }
- } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) {
- if (args.pProperty != NULL) {
- psz = pSyntax->GetCurrentString(iLen);
- if (iLen > 0) {
- pDecl->AddProperty(&args, psz, iLen);
- }
- } else if (iLen > 0) {
- psz = pSyntax->GetCurrentString(iLen);
- if (iLen > 0) {
- pDecl->AddProperty(&args, wsName, wsName.GetLength(), psz, iLen);
- }
+
+ int32_t iLen2;
+ const FX_WCHAR* psz2;
+ FDE_CSSPROPERTYARGS args;
+ args.pStringCache = nullptr;
+ args.pStaticStore = m_pInlineStyleStore;
+ args.pProperty = nullptr;
+ CFX_WideString wsName;
+ while (1) {
+ FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse();
+ if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ args.pProperty = FDE_GetCSSPropertyByName(CFX_WideStringC(psz2, iLen2));
+ if (!args.pProperty)
+ wsName = CFX_WideStringC(psz2, iLen2);
+ } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) {
+ if (args.pProperty) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ if (iLen2 > 0)
+ pDecl->AddProperty(&args, psz2, iLen2);
+ } else if (iLen2 > 0) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ if (iLen2 > 0) {
+ pDecl->AddProperty(&args, wsName.c_str(), wsName.GetLength(), psz2,
+ iLen2);
}
- } else {
- break;
}
+ } else {
+ break;
}
}
- pSyntax->Release();
}
+
#define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData)
#define FDE_CSSINHERITS (pComputedStyle->m_InheritedData)
#define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize)
@@ -1129,7 +1118,7 @@ void CFDE_CSSStyleSelector::ApplyProperty(
}
}
} else {
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
}
}
FX_FLOAT CFDE_CSSStyleSelector::ApplyNumber(FDE_CSSPRIMITIVETYPE eUnit,
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.h b/chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.h
index 2652e3f8ea7..cb54aaed7fb 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.h
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_cssstyleselector.h
@@ -16,16 +16,18 @@
#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/crt/fgas_system.h"
-#define FDE_CSSUNIVERSALHASH ('*')
+class CFDE_CSSAccelerator;
+class CFDE_CSSComputedStyle;
+class CXFA_CSSTagProvider;
class FDE_CSSRuleData : public CFX_Target {
public:
- FDE_CSSRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl,
+ FDE_CSSRuleData(CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl,
uint32_t dwPos);
- IFDE_CSSSelector* pSelector;
- IFDE_CSSDeclaration* pDeclaration;
+ CFDE_CSSSelector* pSelector;
+ CFDE_CSSDeclaration* pDeclaration;
uint32_t dwPriority;
FDE_CSSRuleData* pNext;
};
@@ -38,6 +40,7 @@ class CFDE_CSSRuleCollection : public CFX_Target {
m_pPersudoRules(nullptr),
m_iSelectors(0) {}
~CFDE_CSSRuleCollection() { Clear(); }
+
void AddRulesFrom(const CFDE_CSSStyleSheetArray& sheets,
uint32_t dwMediaList,
IFX_FontMgr* pFontMgr);
@@ -64,7 +67,8 @@ class CFDE_CSSRuleCollection : public CFX_Target {
}
FDE_CSSRuleData* GetUniversalRuleData() { return m_pUniversalRules; }
FDE_CSSRuleData* GetPersudoRuleData() { return m_pPersudoRules; }
- IFX_MEMAllocator* m_pStaticStore;
+
+ IFX_MemoryAllocator* m_pStaticStore;
protected:
void AddRulesFrom(IFDE_CSSStyleSheet* pStyleSheet,
@@ -73,11 +77,11 @@ class CFDE_CSSRuleCollection : public CFX_Target {
IFX_FontMgr* pFontMgr);
void AddRuleTo(CFX_MapPtrToPtr& map,
uint32_t dwKey,
- IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl);
+ CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl);
FX_BOOL AddRuleTo(FDE_CSSRuleData*& pList, FDE_CSSRuleData* pData);
- FDE_CSSRuleData* NewRuleData(IFDE_CSSSelector* pSel,
- IFDE_CSSDeclaration* pDecl);
+ FDE_CSSRuleData* NewRuleData(CFDE_CSSSelector* pSel,
+ CFDE_CSSDeclaration* pDecl);
CFX_MapPtrToPtr m_IDRules;
CFX_MapPtrToPtr m_TagRules;
CFX_MapPtrToPtr m_ClassRules;
@@ -85,35 +89,32 @@ class CFDE_CSSRuleCollection : public CFX_Target {
FDE_CSSRuleData* m_pPersudoRules;
int32_t m_iSelectors;
};
-class CFDE_CSSAccelerator;
-class CFDE_CSSComputedStyle;
-class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target {
+
+class CFDE_CSSStyleSelector : public CFX_Target {
public:
CFDE_CSSStyleSelector();
- ~CFDE_CSSStyleSelector();
- virtual void Release() { delete this; }
-
- virtual void SetFontMgr(IFX_FontMgr* pFontMgr);
- virtual void SetDefFontSize(FX_FLOAT fFontSize);
-
- virtual FX_BOOL SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
- IFDE_CSSStyleSheet* pSheet);
- virtual FX_BOOL SetStyleSheets(FDE_CSSSTYLESHEETGROUP eType,
- const CFDE_CSSStyleSheetArray* pArray);
- virtual void SetStylePriority(FDE_CSSSTYLESHEETGROUP eType,
- FDE_CSSSTYLESHEETPRIORITY ePriority);
- virtual void UpdateStyleIndex(uint32_t dwMediaList);
- virtual IFDE_CSSAccelerator* InitAccelerator();
- virtual IFDE_CSSComputedStyle* CreateComputedStyle(
+ ~CFDE_CSSStyleSelector() override;
+
+ void SetFontMgr(IFX_FontMgr* pFontMgr);
+ void SetDefFontSize(FX_FLOAT fFontSize);
+
+ FX_BOOL SetStyleSheet(FDE_CSSSTYLESHEETGROUP eType,
+ IFDE_CSSStyleSheet* pSheet);
+ FX_BOOL SetStyleSheets(FDE_CSSSTYLESHEETGROUP eType,
+ const CFDE_CSSStyleSheetArray* pArray);
+ void SetStylePriority(FDE_CSSSTYLESHEETGROUP eType,
+ FDE_CSSSTYLESHEETPRIORITY ePriority);
+ void UpdateStyleIndex(uint32_t dwMediaList);
+ CFDE_CSSAccelerator* InitAccelerator();
+ IFDE_CSSComputedStyle* CreateComputedStyle(
IFDE_CSSComputedStyle* pParentStyle);
- virtual int32_t MatchDeclarations(
- IFDE_CSSTagProvider* pTag,
- CFDE_CSSDeclarationArray& matchedDecls,
- FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE);
- virtual void ComputeStyle(IFDE_CSSTagProvider* pTag,
- const IFDE_CSSDeclaration** ppDeclArray,
- int32_t iDeclCount,
- IFDE_CSSComputedStyle* pDestStyle);
+ int32_t MatchDeclarations(CXFA_CSSTagProvider* pTag,
+ CFDE_CSSDeclarationArray& matchedDecls,
+ FDE_CSSPERSUDO ePersudoType = FDE_CSSPERSUDO_NONE);
+ void ComputeStyle(CXFA_CSSTagProvider* pTag,
+ const CFDE_CSSDeclaration** ppDeclArray,
+ int32_t iDeclCount,
+ IFDE_CSSComputedStyle* pDestStyle);
protected:
void Reset();
@@ -121,13 +122,13 @@ class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target {
FDE_CSSRuleData* pList,
FDE_CSSPERSUDO ePersudoType);
FX_BOOL MatchSelector(FDE_CSSTagCache* pCache,
- IFDE_CSSSelector* pSel,
+ CFDE_CSSSelector* pSel,
FDE_CSSPERSUDO ePersudoType);
void AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
const FX_WCHAR* psz,
int32_t iLen);
void ApplyDeclarations(FX_BOOL bPriority,
- const IFDE_CSSDeclaration** ppDeclArray,
+ const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount,
IFDE_CSSComputedStyle* pDestStyle);
void ApplyProperty(FDE_CSSPROPERTY eProperty,
@@ -176,14 +177,15 @@ class CFDE_CSSStyleSelector : public IFDE_CSSStyleSelector, public CFX_Target {
FDE_CSSRUBYOVERHANG ToRubyOverhang(FDE_CSSPROPERTYVALUE eValue);
FDE_CSSRUBYPOSITION ToRubyPosition(FDE_CSSPROPERTYVALUE eValue);
FDE_CSSRUBYSPAN ToRubySpan(FDE_CSSPROPERTYVALUE eValue);
+
IFX_FontMgr* m_pFontMgr;
FX_FLOAT m_fDefFontSize;
- IFX_MEMAllocator* m_pRuleDataStore;
+ IFX_MemoryAllocator* m_pRuleDataStore;
CFDE_CSSStyleSheetArray m_SheetGroups[FDE_CSSSTYLESHEETGROUP_MAX];
CFDE_CSSRuleCollection m_RuleCollection[FDE_CSSSTYLESHEETGROUP_MAX];
FDE_CSSSTYLESHEETGROUP m_ePriorities[FDE_CSSSTYLESHEETPRIORITY_MAX];
- IFX_MEMAllocator* m_pInlineStyleStore;
- IFX_MEMAllocator* m_pFixedStyleStore;
+ IFX_MemoryAllocator* m_pInlineStyleStore;
+ IFX_MemoryAllocator* m_pFixedStyleStore;
CFDE_CSSAccelerator* m_pAccelerator;
std::vector<FDE_CSSRuleData*> m_MatchedRules;
};
@@ -209,27 +211,33 @@ struct FDE_CSSCOUNTERDATA {
class CFDE_CSSCounterStyle {
public:
- CFDE_CSSCounterStyle() : m_pCounterInc(NULL), m_pCounterReset(NULL) {}
+ CFDE_CSSCounterStyle() : m_pCounterInc(nullptr), m_pCounterReset(nullptr) {}
+
void SetCounterIncrementList(IFDE_CSSValueList* pList) {
m_pCounterInc = pList;
m_bIndexDirty = TRUE;
}
+
void SetCounterResetList(IFDE_CSSValueList* pList) {
m_pCounterReset = pList;
m_bIndexDirty = TRUE;
}
+
int32_t CountCounters() {
UpdateIndex();
return m_arrCounterData.GetSize();
}
+
FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) {
UpdateIndex();
return m_arrCounterData.ElementAt(index).GetCounterIncrement(iValue);
}
+
FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) {
UpdateIndex();
return m_arrCounterData.ElementAt(index).GetCounterReset(iValue);
}
+
const FX_WCHAR* GetCounterIdentifier(int32_t index) {
UpdateIndex();
return m_arrCounterData.ElementAt(index).m_pszIdent;
@@ -239,11 +247,13 @@ class CFDE_CSSCounterStyle {
void UpdateIndex();
void DoUpdateIndex(IFDE_CSSValueList* pList);
int32_t FindIndex(const FX_WCHAR* pszIdentifier);
+
IFDE_CSSValueList* m_pCounterInc;
IFDE_CSSValueList* m_pCounterReset;
CFX_ArrayTemplate<FDE_CSSCOUNTERDATA> m_arrCounterData;
FX_BOOL m_bIndexDirty;
};
+
class CFDE_CSSInheritedData {
public:
void Reset() {
@@ -259,6 +269,7 @@ class CFDE_CSSInheritedData {
m_bTextEmphasisColorCurrent = TRUE;
m_iOrphans = 2;
}
+
const FX_WCHAR* m_pszListStyleImage;
FDE_CSSLENGTH m_LetterSpacing;
FDE_CSSLENGTH m_WordSpacing;
@@ -292,6 +303,7 @@ class CFDE_CSSInheritedData {
uint8_t m_eRubyOverhang : 2;
uint8_t m_eRubyPosition : 2;
};
+
class CFDE_CSSNonInheritedData {
public:
void Reset() {
@@ -365,74 +377,55 @@ class CFDE_CSSNonInheritedData {
uint32_t m_bColumnRuleColorSame : 1;
uint32_t m_bHasTextCombineNumber : 1;
};
+
class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle,
- public IFDE_CSSFontStyle,
public IFDE_CSSBoundaryStyle,
+ public IFDE_CSSFontStyle,
public IFDE_CSSPositionStyle,
public IFDE_CSSParagraphStyle,
- public IFDE_CSSBackgroundStyle,
- public IFDE_CSSVisualStyle,
- public IFDE_CSSListStyle,
- public IFDE_CSSMultiColumnStyle,
- public IFDE_CSSGeneratedContentStyle,
- public IFDE_CSSTableStyle,
- public IFDE_CSSRubyStyle,
public CFX_Target {
public:
- CFDE_CSSComputedStyle(IFX_MEMAllocator* pAlloc)
+ CFDE_CSSComputedStyle(IFX_MemoryAllocator* pAlloc)
: m_dwRefCount(1), m_pAllocator(pAlloc) {}
+
~CFDE_CSSComputedStyle() {}
- virtual uint32_t AddRef() { return ++m_dwRefCount; }
- virtual uint32_t Release() {
+
+ // IFX_Unknown:
+ uint32_t AddRef() override { return ++m_dwRefCount; }
+
+ uint32_t Release() override {
uint32_t dwRefCount = --m_dwRefCount;
if (dwRefCount == 0) {
- if (m_NonInheritedData.m_pCounterStyle != NULL) {
- delete m_NonInheritedData.m_pCounterStyle;
- }
+ delete m_NonInheritedData.m_pCounterStyle;
FXTARGET_DeleteWith(CFDE_CSSComputedStyle, m_pAllocator, this);
}
return dwRefCount;
}
- virtual void Reset() {
+ // IFDE_CSSComputedStyle:
+ void Reset() override {
m_InheritedData.Reset();
m_NonInheritedData.Reset();
}
- virtual IFDE_CSSFontStyle* GetFontStyles() const {
- return (IFDE_CSSFontStyle * const) this;
- }
- virtual IFDE_CSSBoundaryStyle* GetBoundaryStyles() const {
- return (IFDE_CSSBoundaryStyle * const) this;
- }
- virtual IFDE_CSSPositionStyle* GetPositionStyles() const {
- return (IFDE_CSSPositionStyle * const) this;
- }
- virtual IFDE_CSSParagraphStyle* GetParagraphStyles() const {
- return (IFDE_CSSParagraphStyle * const) this;
- }
- virtual IFDE_CSSBackgroundStyle* GetBackgroundStyles() const {
- return (IFDE_CSSBackgroundStyle * const) this;
- }
- virtual IFDE_CSSVisualStyle* GetVisualStyles() const {
- return (IFDE_CSSVisualStyle * const) this;
- }
- virtual IFDE_CSSListStyle* GetListStyles() const {
- return (IFDE_CSSListStyle * const) this;
- }
- virtual IFDE_CSSTableStyle* GetTableStyle() const {
- return (IFDE_CSSTableStyle * const) this;
+
+ IFDE_CSSFontStyle* GetFontStyles() override {
+ return static_cast<IFDE_CSSFontStyle*>(this);
}
- virtual IFDE_CSSMultiColumnStyle* GetMultiColumnStyle() const {
- return (IFDE_CSSMultiColumnStyle * const) this;
+
+ IFDE_CSSBoundaryStyle* GetBoundaryStyles() override {
+ return static_cast<IFDE_CSSBoundaryStyle*>(this);
}
- virtual IFDE_CSSGeneratedContentStyle* GetGeneratedContentStyle() const {
- return (IFDE_CSSGeneratedContentStyle * const) this;
+
+ IFDE_CSSPositionStyle* GetPositionStyles() override {
+ return static_cast<IFDE_CSSPositionStyle*>(this);
}
- virtual IFDE_CSSRubyStyle* GetRubyStyle() const {
- return (IFDE_CSSRubyStyle * const) this;
+
+ IFDE_CSSParagraphStyle* GetParagraphStyles() override {
+ return static_cast<IFDE_CSSParagraphStyle*>(this);
}
- virtual FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName,
- CFX_WideString& wsValue) const {
+
+ FX_BOOL GetCustomStyle(const CFX_WideStringC& wsName,
+ CFX_WideString& wsValue) const override {
for (int32_t i = m_CustomProperties.GetSize() - 2; i > -1; i -= 2) {
if (wsName == m_CustomProperties[i]) {
wsValue = m_CustomProperties[i + 1];
@@ -441,457 +434,151 @@ class CFDE_CSSComputedStyle : public IFDE_CSSComputedStyle,
}
return FALSE;
}
- virtual FDE_CSSRUBYALIGN GetRubyAlign() const {
- return (FDE_CSSRUBYALIGN)m_InheritedData.m_eRubyAlign;
- }
- virtual FDE_CSSRUBYPOSITION GetRubyPosition() const {
- return (FDE_CSSRUBYPOSITION)m_InheritedData.m_eRubyPosition;
- }
- virtual FDE_CSSRUBYOVERHANG GetRubyOverhang() const {
- return (FDE_CSSRUBYOVERHANG)m_InheritedData.m_eRubyOverhang;
- }
- virtual FDE_CSSRUBYSPAN GetRubySpanType() const {
- return m_NonInheritedData.m_pRubySpan == NULL ? FDE_CSSRUBYSPAN_None
- : FDE_CSSRUBYSPAN_Attr;
- }
- virtual IFDE_CSSValue* GetRubySpanAttr() const {
- return m_NonInheritedData.m_pRubySpan;
- }
- virtual FDE_CSSCAPTIONSIDE GetCaptionSide() const {
- return (FDE_CSSCAPTIONSIDE)m_InheritedData.m_eCaptionSide;
- }
- virtual int32_t CountCounters() {
- return (m_NonInheritedData.m_pCounterStyle == NULL)
- ? 0
- : m_NonInheritedData.m_pCounterStyle->CountCounters();
- }
- virtual const FX_WCHAR* GetCounterIdentifier(int32_t index) {
- return m_NonInheritedData.m_pCounterStyle->GetCounterIdentifier(index);
- }
- virtual FX_BOOL GetCounterReset(int32_t index, int32_t& iValue) {
- return m_NonInheritedData.m_pCounterStyle->GetCounterReset(index, iValue);
- }
- virtual FX_BOOL GetCounterIncrement(int32_t index, int32_t& iValue) {
- return m_NonInheritedData.m_pCounterStyle->GetCounterIncrement(index,
- iValue);
- }
- virtual IFDE_CSSValueList* GetContent() const {
- return m_NonInheritedData.m_pContentList;
- }
- virtual int32_t CountQuotes() const {
- return m_InheritedData.m_pQuotes == NULL
- ? 0
- : m_InheritedData.m_pQuotes->CountValues();
- }
- virtual const FX_WCHAR* GetQuotes(int32_t index) const {
- FXSYS_assert(m_InheritedData.m_pQuotes != NULL &&
- m_InheritedData.m_pQuotes->CountValues() > index);
- return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pQuotes->GetValue(
- index)))
- ->GetString(index);
- }
- virtual const FDE_CSSLENGTH& GetColumnCount() const {
- return m_NonInheritedData.m_ColumnCount;
- }
- virtual const FDE_CSSLENGTH& GetColumnGap() const {
- return m_NonInheritedData.m_ColumnGap;
- }
- virtual FX_ARGB GetColumnRuleColor() const {
- return m_NonInheritedData.m_bColumnRuleColorSame
- ? m_InheritedData.m_dwFontColor
- : m_NonInheritedData.m_dwColumnRuleColor;
- }
- virtual FDE_CSSBORDERSTYLE GetColumnRuleStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eColumnRuleStyle;
- }
- virtual const FDE_CSSLENGTH& GetColumnRuleWidth() const {
- return m_NonInheritedData.m_ColumnRuleWidth;
- }
- virtual const FDE_CSSLENGTH& GetColumnWidth() const {
- return m_NonInheritedData.m_ColumnWidth;
- }
- virtual void SetColumnCount(const FDE_CSSLENGTH& columnCount) {
- m_NonInheritedData.m_ColumnCount = columnCount;
- }
- virtual void SetColumnGap(const FDE_CSSLENGTH& columnGap) {
- m_NonInheritedData.m_ColumnGap = columnGap;
- }
- virtual void SetColumnRuleColor(FX_ARGB dwColumnRuleColor) {
- m_NonInheritedData.m_dwColumnRuleColor = dwColumnRuleColor,
- m_NonInheritedData.m_bColumnRuleColorSame = FALSE;
- }
- virtual void SetColumnRuleStyle(FDE_CSSBORDERSTYLE eColumnRuleStyle) {
- m_NonInheritedData.m_eColumnRuleStyle = eColumnRuleStyle;
- }
- virtual void SetColumnRuleWidth(const FDE_CSSLENGTH& columnRuleWidth) {
- m_NonInheritedData.m_ColumnRuleWidth = columnRuleWidth;
- }
- virtual void SetColumnWidth(const FDE_CSSLENGTH& columnWidth) {
- m_NonInheritedData.m_ColumnWidth = columnWidth;
- }
- virtual int32_t CountFontFamilies() const {
+
+ // IFDE_CSSFontStyle:
+ int32_t CountFontFamilies() const override {
return m_InheritedData.m_pFontFamily
? m_InheritedData.m_pFontFamily->CountValues()
: 0;
}
- virtual const FX_WCHAR* GetFontFamily(int32_t index) const {
- return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pFontFamily->GetValue(
- index)))
+
+ const FX_WCHAR* GetFontFamily(int32_t index) const override {
+ return (static_cast<IFDE_CSSPrimitiveValue*>(
+ m_InheritedData.m_pFontFamily->GetValue(index)))
->GetString(index);
}
- virtual uint16_t GetFontWeight() const {
+
+ uint16_t GetFontWeight() const override {
return m_InheritedData.m_wFontWeight;
}
- virtual FDE_CSSFONTVARIANT GetFontVariant() const {
- return (FDE_CSSFONTVARIANT)m_InheritedData.m_eFontVariant;
+
+ FDE_CSSFONTVARIANT GetFontVariant() const override {
+ return static_cast<FDE_CSSFONTVARIANT>(m_InheritedData.m_eFontVariant);
}
- virtual FDE_CSSFONTSTYLE GetFontStyle() const {
- return (FDE_CSSFONTSTYLE)m_InheritedData.m_eFontStyle;
+
+ FDE_CSSFONTSTYLE GetFontStyle() const override {
+ return static_cast<FDE_CSSFONTSTYLE>(m_InheritedData.m_eFontStyle);
}
- virtual FX_FLOAT GetFontSize() const { return m_InheritedData.m_fFontSize; }
- virtual FX_ARGB GetColor() const { return m_InheritedData.m_dwFontColor; }
- virtual void SetFontWeight(uint16_t wFontWeight) {
+
+ FX_FLOAT GetFontSize() const override { return m_InheritedData.m_fFontSize; }
+
+ FX_ARGB GetColor() const override { return m_InheritedData.m_dwFontColor; }
+
+ void SetFontWeight(uint16_t wFontWeight) override {
m_InheritedData.m_wFontWeight = wFontWeight;
}
- virtual void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) {
+
+ void SetFontVariant(FDE_CSSFONTVARIANT eFontVariant) override {
m_InheritedData.m_eFontVariant = eFontVariant;
}
- virtual void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) {
+
+ void SetFontStyle(FDE_CSSFONTSTYLE eFontStyle) override {
m_InheritedData.m_eFontStyle = eFontStyle;
}
- virtual void SetFontSize(FX_FLOAT fFontSize) {
+
+ void SetFontSize(FX_FLOAT fFontSize) override {
m_InheritedData.m_fFontSize = fFontSize;
}
- virtual void SetColor(FX_ARGB dwFontColor) {
- m_InheritedData.m_dwFontColor = dwFontColor;
- }
- virtual FX_ARGB GetBorderLeftColor() const {
- return m_NonInheritedData.m_dwBDRLeftColor;
- }
- virtual FX_ARGB GetBorderTopColor() const {
- return m_NonInheritedData.m_dwBDRTopColor;
- }
- virtual FX_ARGB GetBorderRightColor() const {
- return m_NonInheritedData.m_dwBDRRightColor;
- }
- virtual FX_ARGB GetBorderBottomColor() const {
- return m_NonInheritedData.m_dwBDRBottomColor;
- }
- virtual FDE_CSSBORDERSTYLE GetBorderLeftStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRLeftStyle;
- }
- virtual FDE_CSSBORDERSTYLE GetBorderTopStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRTopStyle;
- }
- virtual FDE_CSSBORDERSTYLE GetBorderRightStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRRightStyle;
- }
- virtual FDE_CSSBORDERSTYLE GetBorderBottomStyle() const {
- return (FDE_CSSBORDERSTYLE)m_NonInheritedData.m_eBDRBottomStyle;
+ void SetColor(FX_ARGB dwFontColor) override {
+ m_InheritedData.m_dwFontColor = dwFontColor;
}
- virtual const FDE_CSSRECT* GetBorderWidth() const {
+ // IFDE_CSSBoundaryStyle:
+ const FDE_CSSRECT* GetBorderWidth() const override {
return m_NonInheritedData.m_bHasBorder ? &(m_NonInheritedData.m_BorderWidth)
- : NULL;
+ : nullptr;
}
- virtual const FDE_CSSRECT* GetMarginWidth() const {
+
+ const FDE_CSSRECT* GetMarginWidth() const override {
return m_NonInheritedData.m_bHasMargin ? &(m_NonInheritedData.m_MarginWidth)
- : NULL;
+ : nullptr;
}
- virtual const FDE_CSSRECT* GetPaddingWidth() const {
+
+ const FDE_CSSRECT* GetPaddingWidth() const override {
return m_NonInheritedData.m_bHasPadding
? &(m_NonInheritedData.m_PaddingWidth)
- : NULL;
- }
- virtual void SetBorderLeftColor(FX_ARGB dwBorderColor) {
- m_NonInheritedData.m_dwBDRLeftColor = dwBorderColor;
- }
- virtual void SetBorderTopColor(FX_ARGB dwBorderColor) {
- m_NonInheritedData.m_dwBDRTopColor = dwBorderColor;
- }
- virtual void SetBorderRightColor(FX_ARGB dwBorderColor) {
- m_NonInheritedData.m_dwBDRRightColor = dwBorderColor;
- }
- virtual void SetBorderBottomColor(FX_ARGB dwBorderColor) {
- m_NonInheritedData.m_dwBDRBottomColor = dwBorderColor;
+ : nullptr;
}
- virtual void SetBorderLeftStyle(FDE_CSSBORDERSTYLE eBorderStyle) {
- m_NonInheritedData.m_eBDRLeftStyle = eBorderStyle;
- }
- virtual void SetBorderTopStyle(FDE_CSSBORDERSTYLE eBorderStyle) {
- m_NonInheritedData.m_eBDRTopStyle = eBorderStyle;
- }
- virtual void SetBorderRightStyle(FDE_CSSBORDERSTYLE eBorderStyle) {
- m_NonInheritedData.m_eBDRRightStyle = eBorderStyle;
- }
- virtual void SetBorderBottomStyle(FDE_CSSBORDERSTYLE eBorderStyle) {
- m_NonInheritedData.m_eBDRBottomStyle = eBorderStyle;
- }
-
- virtual void SetBorderWidth(const FDE_CSSRECT& rect) {
- m_NonInheritedData.m_BorderWidth = rect;
- m_NonInheritedData.m_bHasBorder = TRUE;
- }
- virtual void SetMarginWidth(const FDE_CSSRECT& rect) {
+ void SetMarginWidth(const FDE_CSSRECT& rect) override {
m_NonInheritedData.m_MarginWidth = rect;
m_NonInheritedData.m_bHasMargin = TRUE;
}
- virtual void SetPaddingWidth(const FDE_CSSRECT& rect) {
+
+ void SetPaddingWidth(const FDE_CSSRECT& rect) override {
m_NonInheritedData.m_PaddingWidth = rect;
m_NonInheritedData.m_bHasPadding = TRUE;
}
- virtual FDE_CSSDISPLAY GetDisplay() const {
- return (FDE_CSSDISPLAY)m_NonInheritedData.m_eDisplay;
- }
- virtual const FDE_CSSSIZE& GetBoxSize() const {
- return m_NonInheritedData.m_BoxSize;
- }
- virtual const FDE_CSSSIZE& GetMinBoxSize() const {
- return m_NonInheritedData.m_MinBoxSize;
- }
- virtual const FDE_CSSSIZE& GetMaxBoxSize() const {
- return m_NonInheritedData.m_MaxBoxSize;
- }
- virtual FDE_CSSFLOAT GetFloat() const {
- return (FDE_CSSFLOAT)m_NonInheritedData.m_eFloat;
- }
- virtual FDE_CSSCLEAR GetClear() const {
- return (FDE_CSSCLEAR)m_NonInheritedData.m_eClear;
- }
- virtual FDE_CSSPOSITION GetPosition() const {
- return (FDE_CSSPOSITION)m_NonInheritedData.m_ePosition;
- }
- virtual FDE_CSSLENGTH GetTop() const { return m_NonInheritedData.m_Top; }
- virtual FDE_CSSLENGTH GetBottom() const {
- return m_NonInheritedData.m_Bottom;
- }
- virtual FDE_CSSLENGTH GetLeft() const { return m_NonInheritedData.m_Left; }
- virtual FDE_CSSLENGTH GetRight() const { return m_NonInheritedData.m_Right; }
- virtual void SetDisplay(FDE_CSSDISPLAY eDisplay) {
- m_NonInheritedData.m_eDisplay = eDisplay;
- }
- virtual void SetBoxSize(const FDE_CSSSIZE& size) {
- m_NonInheritedData.m_BoxSize = size;
- }
- virtual void SetMinBoxSize(const FDE_CSSSIZE& size) {
- m_NonInheritedData.m_MinBoxSize = size;
+ // IFDE_CSSPositionStyle:
+ FDE_CSSDISPLAY GetDisplay() const override {
+ return static_cast<FDE_CSSDISPLAY>(m_NonInheritedData.m_eDisplay);
}
- virtual void SetMaxBoxSize(const FDE_CSSSIZE& size) {
- m_NonInheritedData.m_MaxBoxSize = size;
- }
- virtual void SetFloat(FDE_CSSFLOAT eFloat) {
- m_NonInheritedData.m_eFloat = eFloat;
- }
- virtual void SetClear(FDE_CSSCLEAR eClear) {
- m_NonInheritedData.m_eClear = eClear;
- }
- virtual FX_FLOAT GetLineHeight() const {
+
+ // IFDE_CSSParagraphStyle:
+ FX_FLOAT GetLineHeight() const override {
return m_InheritedData.m_fLineHeight;
}
- virtual FDE_CSSWHITESPACE GetWhiteSpace() const {
- return (FDE_CSSWHITESPACE)m_InheritedData.m_eWhiteSpace;
- }
- virtual const FDE_CSSLENGTH& GetTextIndent() const {
+
+ const FDE_CSSLENGTH& GetTextIndent() const override {
return m_InheritedData.m_TextIndent;
}
- virtual FDE_CSSTEXTALIGN GetTextAlign() const {
- return (FDE_CSSTEXTALIGN)m_InheritedData.m_eTextAligh;
+
+ FDE_CSSTEXTALIGN GetTextAlign() const override {
+ return static_cast<FDE_CSSTEXTALIGN>(m_InheritedData.m_eTextAligh);
}
- virtual FDE_CSSVERTICALALIGN GetVerticalAlign() const {
- return (FDE_CSSVERTICALALIGN)m_NonInheritedData.m_eVerticalAlign;
+
+ FDE_CSSVERTICALALIGN GetVerticalAlign() const override {
+ return static_cast<FDE_CSSVERTICALALIGN>(
+ m_NonInheritedData.m_eVerticalAlign);
}
- virtual FX_FLOAT GetNumberVerticalAlign() const {
+
+ FX_FLOAT GetNumberVerticalAlign() const override {
return m_NonInheritedData.m_fVerticalAlign;
}
- virtual FDE_CSSTEXTTRANSFORM GetTextTransform() const {
- return (FDE_CSSTEXTTRANSFORM)m_InheritedData.m_eTextTransform;
- }
- virtual uint32_t GetTextDecoration() const {
+
+ uint32_t GetTextDecoration() const override {
return m_NonInheritedData.m_dwTextDecoration;
}
- virtual const FDE_CSSLENGTH& GetLetterSpacing() const {
+
+ const FDE_CSSLENGTH& GetLetterSpacing() const override {
return m_InheritedData.m_LetterSpacing;
}
- virtual const FDE_CSSLENGTH& GetWordSpacing() const {
- return m_InheritedData.m_WordSpacing;
- }
- virtual FDE_CSSWRITINGMODE GetWritingMode() const {
- return (FDE_CSSWRITINGMODE)m_InheritedData.m_eWritingMode;
- }
- virtual FDE_CSSWORDBREAK GetWordBreak() const {
- return (FDE_CSSWORDBREAK)m_InheritedData.m_eWordBreak;
- }
- virtual int32_t GetWidows() const { return m_InheritedData.m_iWidows; }
- virtual FX_ARGB GetTextEmphasisColor() const {
- return m_InheritedData.m_bTextEmphasisColorCurrent
- ? m_InheritedData.m_dwFontColor
- : m_InheritedData.m_dwTextEmphasisColor;
- }
- virtual FDE_CSSPAGEBREAK GetPageBreakBefore() const {
- return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakBefore;
- }
- virtual FDE_CSSPAGEBREAK GetPageBreakAfter() const {
- return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakAfter;
- }
- virtual FDE_CSSPAGEBREAK GetPageBreakInside() const {
- return (FDE_CSSPAGEBREAK)m_NonInheritedData.m_ePageBreakInside;
- }
- virtual int32_t GetOrphans() const { return m_InheritedData.m_iOrphans; }
- virtual FDE_CSSLINEBREAK GetLineBreak() const {
- return (FDE_CSSLINEBREAK)m_InheritedData.m_eLineBreak;
- }
- virtual FDE_CSSTEXTEMPHASISMARK GetTextEmphasisMark() const;
- virtual FDE_CSSTEXTEMPHASISFILL GetTextEmphasisFill() const {
- return (FDE_CSSTEXTEMPHASISFILL)m_InheritedData.m_eTextEmphasisFill;
- }
- virtual const FX_WCHAR* GetTextEmphasisCustom() const {
- FXSYS_assert(m_InheritedData.m_eTextEmphasisMark ==
- FDE_CSSTEXTEMPHASISMARK_Custom);
- return m_InheritedData.m_pszTextEmphasisCustomMark;
- }
- virtual FDE_CSSTEXTCOMBINE GetTextCombineType() const {
- return (FDE_CSSTEXTCOMBINE)m_NonInheritedData.m_eTextCombine;
- }
- virtual FX_BOOL HasTextCombineNumber() const {
- return m_NonInheritedData.m_bHasTextCombineNumber;
- }
- virtual FX_FLOAT GetTextCombineNumber() const {
- FXSYS_assert(m_NonInheritedData.m_eTextCombine ==
- FDE_CSSTEXTCOMBINE_Horizontal);
- return m_NonInheritedData.m_fTextCombineNumber;
- }
- virtual void SetLineHeight(FX_FLOAT fLineHeight) {
+
+ void SetLineHeight(FX_FLOAT fLineHeight) override {
m_InheritedData.m_fLineHeight = fLineHeight;
}
- virtual void SetWhiteSpace(FDE_CSSWHITESPACE eWhiteSpace) {
- m_InheritedData.m_eWhiteSpace = eWhiteSpace;
- }
- virtual void SetTextIndent(const FDE_CSSLENGTH& textIndent) {
+
+ void SetTextIndent(const FDE_CSSLENGTH& textIndent) override {
m_InheritedData.m_TextIndent = textIndent;
}
- virtual void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) {
+
+ void SetTextAlign(FDE_CSSTEXTALIGN eTextAlign) override {
m_InheritedData.m_eTextAligh = eTextAlign;
}
- virtual void SetVerticalAlign(FDE_CSSVERTICALALIGN eVerticalAlign) {
- m_NonInheritedData.m_eVerticalAlign = eVerticalAlign;
- }
- virtual void SetNumberVerticalAlign(FX_FLOAT fAlign) {
+
+ void SetNumberVerticalAlign(FX_FLOAT fAlign) override {
m_NonInheritedData.m_eVerticalAlign = FDE_CSSVERTICALALIGN_Number,
m_NonInheritedData.m_fVerticalAlign = fAlign;
}
- virtual void SetTextTransform(FDE_CSSTEXTTRANSFORM eTextTransform) {
- m_InheritedData.m_eTextTransform = eTextTransform;
- }
- virtual void SetTextDecoration(uint32_t dwTextDecoration) {
+
+ void SetTextDecoration(uint32_t dwTextDecoration) override {
m_NonInheritedData.m_dwTextDecoration = dwTextDecoration;
}
- virtual void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) {
+
+ void SetLetterSpacing(const FDE_CSSLENGTH& letterSpacing) override {
m_InheritedData.m_LetterSpacing = letterSpacing;
}
- virtual void SetWordSpacing(const FDE_CSSLENGTH& wordSpacing) {
- m_InheritedData.m_WordSpacing = wordSpacing;
- }
- virtual void SetWritingMode(FDE_CSSWRITINGMODE eWritingMode) {
- m_InheritedData.m_eWritingMode = eWritingMode;
- }
- virtual void SetWordBreak(FDE_CSSWORDBREAK eWordBreak) {
- m_InheritedData.m_eWordBreak = eWordBreak;
- }
- virtual void SetWidows(int32_t iWidows) {
- m_InheritedData.m_iWidows = iWidows;
- }
- virtual void SetTextEmphasisColor(FX_ARGB dwTextEmphasisColor) {
- m_InheritedData.m_dwTextEmphasisColor = dwTextEmphasisColor,
- m_InheritedData.m_bTextEmphasisColorCurrent = FALSE;
- }
- virtual void SetPageBreakBefore(FDE_CSSPAGEBREAK ePageBreakBefore) {
- m_NonInheritedData.m_ePageBreakBefore = ePageBreakBefore;
- }
- virtual void SetPageBreakAfter(FDE_CSSPAGEBREAK ePageBreakAfter) {
- m_NonInheritedData.m_ePageBreakAfter = ePageBreakAfter;
- }
- virtual void SetPageBreakInside(FDE_CSSPAGEBREAK ePageBreakInside) {
- m_NonInheritedData.m_ePageBreakInside = ePageBreakInside;
- }
- virtual void SetOrphans(int32_t iOrphans) {
- m_InheritedData.m_iOrphans = iOrphans;
- }
- virtual void SetLineBreak(FDE_CSSLINEBREAK eLineBreak) {
- m_InheritedData.m_eLineBreak = eLineBreak;
- }
- virtual FX_ARGB GetBKGColor() const {
- return m_NonInheritedData.m_dwBKGColor;
- }
- virtual const FX_WCHAR* GetBKGImage() const {
- return m_NonInheritedData.m_pszBKGImage;
- }
- virtual const FDE_CSSPOINT& GetBKGPosition() const {
- return m_NonInheritedData.m_BKGPosition;
- }
- virtual FDE_CSSBKGREPEAT GetBKGRepeat() const {
- return (FDE_CSSBKGREPEAT)m_NonInheritedData.m_eBKGRepeat;
- }
- virtual FDE_CSSBKGATTACHMENT GetBKGAttachment() const {
- return (FDE_CSSBKGATTACHMENT)m_NonInheritedData.m_eBKGAttachment;
- }
- virtual void SetBKGColor(FX_ARGB dwBKGColor) {
- m_NonInheritedData.m_dwBKGColor = dwBKGColor;
- }
- virtual void SetBKGPosition(const FDE_CSSPOINT& bkgPosition) {
- m_NonInheritedData.m_BKGPosition = bkgPosition;
- }
- virtual FDE_CSSVISIBILITY GetVisibility() const {
- return (FDE_CSSVISIBILITY)m_InheritedData.m_eVisibility;
- }
- virtual FDE_CSSOVERFLOW GetOverflowX() const {
- return (FDE_CSSOVERFLOW)m_NonInheritedData.m_eOverflowX;
- }
- virtual FDE_CSSOVERFLOW GetOverflowY() const {
- return (FDE_CSSOVERFLOW)m_NonInheritedData.m_eOverflowY;
- }
- virtual int32_t CountCursorUrls() const {
- return m_InheritedData.m_pCursorUris == NULL
- ? 0
- : m_InheritedData.m_pCursorUris->CountValues();
- }
- virtual const FX_WCHAR* GetCursorUrl(int32_t index) const {
- FXSYS_assert(m_InheritedData.m_pCursorUris != NULL);
- return ((IFDE_CSSPrimitiveValue*)(m_InheritedData.m_pCursorUris->GetValue(
- index)))
- ->GetString(index);
- }
- virtual FDE_CSSCURSOR GetCursorType() const {
- return m_InheritedData.m_eCursor;
- }
- virtual void SetVisibility(FDE_CSSVISIBILITY eVisibility) {
- m_InheritedData.m_eVisibility = eVisibility;
- }
- virtual FDE_CSSLISTSTYLETYPE GetListStyleType() const {
- return (FDE_CSSLISTSTYLETYPE)m_NonInheritedData.m_eListStyleType;
- }
- virtual FDE_CSSLISTSTYLEPOSITION GetListStylePosition() const {
- return (FDE_CSSLISTSTYLEPOSITION)m_NonInheritedData.m_eListStylePosition;
- }
- virtual const FX_WCHAR* GetListStyleImage() const {
- return m_InheritedData.m_pszListStyleImage;
- }
- virtual void SetListStyleType(FDE_CSSLISTSTYLETYPE eListStyleType) {
- m_NonInheritedData.m_eListStyleType = eListStyleType;
- }
- virtual void SetListStylePosition(
- FDE_CSSLISTSTYLEPOSITION eListStylePosition) {
- m_NonInheritedData.m_eListStylePosition = eListStylePosition;
- }
+
void AddCustomStyle(const CFX_WideString& wsName,
const CFX_WideString& wsValue) {
m_CustomProperties.Add(wsName);
m_CustomProperties.Add(wsValue);
}
+
uint32_t m_dwRefCount;
- IFX_MEMAllocator* m_pAllocator;
+ IFX_MemoryAllocator* m_pAllocator;
CFDE_CSSInheritedData m_InheritedData;
CFDE_CSSNonInheritedData m_NonInheritedData;
CFX_WideStringArray m_CustomProperties;
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.cpp b/chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.cpp
index bc27545dca2..b07031c3549 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.cpp
@@ -6,12 +6,14 @@
#include "xfa/fde/css/fde_cssstylesheet.h"
+#include <memory>
+
#include "xfa/fde/css/fde_cssdatatable.h"
#include "xfa/fde/css/fde_csssyntax.h"
#include "xfa/fgas/crt/fgas_codepage.h"
IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadHTMLStandardStyleSheet() {
- static const FX_WCHAR* s_pStyle =
+ static const FX_WCHAR s_pStyle[] =
L"html,address,blockquote,body,dd,div,dl,dt,fieldset,form,frame,frameset,"
L"h1,h2,h3,h4,h5,h6,noframes,ol,p,ul,center,dir,hr,menu,pre{display:"
L"block}"
@@ -75,7 +77,7 @@ CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(uint32_t dwMediaList)
m_wRefCount(1),
m_dwMediaList(dwMediaList),
m_pAllocator(NULL) {
- FXSYS_assert(m_dwMediaList > 0);
+ ASSERT(m_dwMediaList > 0);
}
CFDE_CSSStyleSheet::~CFDE_CSSStyleSheet() {
Reset();
@@ -94,17 +96,15 @@ void CFDE_CSSStyleSheet::Reset() {
((CFDE_CSSFontFaceRule*)pRule)->~CFDE_CSSFontFaceRule();
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
}
m_RuleArray.RemoveAll();
m_Selectors.RemoveAll();
m_StringCache.RemoveAll();
- if (m_pAllocator) {
- m_pAllocator->Release();
- m_pAllocator = NULL;
- }
+ delete m_pAllocator;
+ m_pAllocator = nullptr;
}
uint32_t CFDE_CSSStyleSheet::AddRef() {
return ++m_wRefCount;
@@ -122,44 +122,36 @@ int32_t CFDE_CSSStyleSheet::CountRules() const {
IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
return m_RuleArray.GetAt(index);
}
+
FX_BOOL CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl,
IFX_Stream* pStream,
uint16_t wCodePage) {
- FXSYS_assert(pStream != NULL);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
- return FALSE;
- }
- if (pStream->GetCodePage() != wCodePage) {
+ std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+ if (pStream->GetCodePage() != wCodePage)
pStream->SetCodePage(wCodePage);
- }
- FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax);
- pSyntax->Release();
+
+ FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax.get());
m_wCodePage = wCodePage;
m_szUrl = szUrl;
return bRet;
}
+
FX_BOOL CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl,
const FX_WCHAR* pBuffer,
int32_t iBufSize,
uint16_t wCodePage) {
- FXSYS_assert(pBuffer != NULL && iBufSize > 0);
- IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create();
- if (pSyntax == NULL) {
- return FALSE;
- }
- FX_BOOL bRet = pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax);
- pSyntax->Release();
+ ASSERT(pBuffer && iBufSize > 0);
+ std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+ FX_BOOL bRet =
+ pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax.get());
m_wCodePage = wCodePage;
m_szUrl = szUrl;
return bRet;
}
-FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax) {
+
+FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax) {
Reset();
- m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 1024, 0);
- if (m_pAllocator == NULL) {
- return FALSE;
- }
+ m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 1024, 0);
FDE_CSSSYNTAXSTATUS eStatus;
do {
switch (eStatus = pSyntax->DoSyntaxParse()) {
@@ -187,7 +179,7 @@ FX_BOOL CFDE_CSSStyleSheet::LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax) {
return eStatus != FDE_CSSSYNTAXSTATUS_Error;
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
- IFDE_CSSSyntaxParser* pSyntax) {
+ CFDE_CSSSyntaxParser* pSyntax) {
uint32_t dwMediaList = 0;
CFDE_CSSMediaRule* pMediaRule = NULL;
for (;;) {
@@ -196,7 +188,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
int32_t iLen;
const FX_WCHAR* psz = pSyntax->GetCurrentString(iLen);
FDE_LPCCSSMEDIATYPETABLE pMediaType =
- FDE_GetCSSMediaTypeByName(psz, iLen);
+ FDE_GetCSSMediaTypeByName(CFX_WideStringC(psz, iLen));
if (pMediaType != NULL) {
dwMediaList |= pMediaType->wValue;
}
@@ -226,7 +218,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadMediaRule(
}
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
- IFDE_CSSSyntaxParser* pSyntax,
+ CFDE_CSSSyntaxParser* pSyntax,
CFDE_CSSRuleArray& ruleArray) {
m_Selectors.RemoveAt(0, m_Selectors.GetSize());
CFDE_CSSStyleRule* pStyleRule = NULL;
@@ -241,7 +233,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
switch (pSyntax->DoSyntaxParse()) {
case FDE_CSSSYNTAXSTATUS_Selector: {
pszValue = pSyntax->GetCurrentString(iValueLen);
- IFDE_CSSSelector* pSelector =
+ CFDE_CSSSelector* pSelector =
CFDE_CSSSelector::FromString(m_pAllocator, pszValue, iValueLen);
if (pSelector != NULL) {
m_Selectors.Add(pSelector);
@@ -249,7 +241,8 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
} break;
case FDE_CSSSYNTAXSTATUS_PropertyName:
pszValue = pSyntax->GetCurrentString(iValueLen);
- propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen);
+ propertyArgs.pProperty =
+ FDE_GetCSSPropertyByName(CFX_WideStringC(pszValue, iValueLen));
if (propertyArgs.pProperty == NULL) {
wsName = CFX_WideStringC(pszValue, iValueLen);
}
@@ -264,8 +257,9 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
} else if (iValueLen > 0) {
pszValue = pSyntax->GetCurrentString(iValueLen);
if (iValueLen > 0) {
- pStyleRule->GetDeclImp().AddProperty(
- &propertyArgs, wsName, wsName.GetLength(), pszValue, iValueLen);
+ pStyleRule->GetDeclImp().AddProperty(&propertyArgs, wsName.c_str(),
+ wsName.GetLength(), pszValue,
+ iValueLen);
}
}
break;
@@ -291,7 +285,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadStyleRule(
}
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
- IFDE_CSSSyntaxParser* pSyntax,
+ CFDE_CSSSyntaxParser* pSyntax,
CFDE_CSSRuleArray& ruleArray) {
CFDE_CSSFontFaceRule* pFontFaceRule = NULL;
const FX_WCHAR* pszValue = NULL;
@@ -304,7 +298,8 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
switch (pSyntax->DoSyntaxParse()) {
case FDE_CSSSYNTAXSTATUS_PropertyName:
pszValue = pSyntax->GetCurrentString(iValueLen);
- propertyArgs.pProperty = FDE_GetCSSPropertyByName(pszValue, iValueLen);
+ propertyArgs.pProperty =
+ FDE_GetCSSPropertyByName(CFX_WideStringC(pszValue, iValueLen));
break;
case FDE_CSSSYNTAXSTATUS_PropertyValue:
if (propertyArgs.pProperty != NULL) {
@@ -329,7 +324,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadFontFaceRule(
return FDE_CSSSYNTAXSTATUS_None;
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule(
- IFDE_CSSSyntaxParser* pSyntax) {
+ CFDE_CSSSyntaxParser* pSyntax) {
for (;;) {
switch (pSyntax->DoSyntaxParse()) {
case FDE_CSSSYNTAXSTATUS_ImportClose:
@@ -341,11 +336,11 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadImportRule(
}
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::LoadPageRule(
- IFDE_CSSSyntaxParser* pSyntax) {
+ CFDE_CSSSyntaxParser* pSyntax) {
return SkipRuleSet(pSyntax);
}
FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet(
- IFDE_CSSSyntaxParser* pSyntax) {
+ CFDE_CSSSyntaxParser* pSyntax) {
for (;;) {
switch (pSyntax->DoSyntaxParse()) {
case FDE_CSSSYNTAXSTATUS_Selector:
@@ -360,12 +355,12 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSStyleSheet::SkipRuleSet(
}
return FDE_CSSSYNTAXSTATUS_None;
}
-void CFDE_CSSStyleRule::SetSelector(IFX_MEMAllocator* pStaticStore,
+void CFDE_CSSStyleRule::SetSelector(IFX_MemoryAllocator* pStaticStore,
const CFDE_CSSSelectorArray& list) {
- FXSYS_assert(m_ppSelector == NULL);
+ ASSERT(m_ppSelector == NULL);
m_iSelectors = list.GetSize();
- m_ppSelector = (IFDE_CSSSelector**)pStaticStore->Alloc(
- m_iSelectors * sizeof(IFDE_CSSSelector*));
+ m_ppSelector = static_cast<CFDE_CSSSelector**>(
+ pStaticStore->Alloc(m_iSelectors * sizeof(CFDE_CSSSelector*)));
for (int32_t i = 0; i < m_iSelectors; ++i) {
m_ppSelector[i] = list.GetAt(i);
}
@@ -378,7 +373,7 @@ CFDE_CSSMediaRule::~CFDE_CSSMediaRule() {
((CFDE_CSSStyleRule*)pRule)->~CFDE_CSSStyleRule();
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
}
@@ -387,7 +382,7 @@ inline FX_BOOL FDE_IsCSSChar(FX_WCHAR wch) {
return (wch >= 'a' && wch <= 'z') || (wch >= 'A' && wch <= 'Z');
}
int32_t FDE_GetCSSPersudoLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
- FXSYS_assert(*psz == ':');
+ ASSERT(*psz == ':');
const FX_WCHAR* pStart = psz;
while (psz < pEnd) {
FX_WCHAR wch = *psz;
@@ -412,10 +407,11 @@ int32_t FDE_GetCSSNameLen(const FX_WCHAR* psz, const FX_WCHAR* pEnd) {
}
return psz - pStart;
}
-IFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
- const FX_WCHAR* psz,
- int32_t iLen) {
- FXSYS_assert(pStaticStore != NULL && psz != NULL && iLen > 0);
+CFDE_CSSSelector* CFDE_CSSSelector::FromString(
+ IFX_MemoryAllocator* pStaticStore,
+ const FX_WCHAR* psz,
+ int32_t iLen) {
+ ASSERT(pStaticStore != NULL && psz != NULL && iLen > 0);
const FX_WCHAR* pStart = psz;
const FX_WCHAR* pEnd = psz + iLen;
for (; psz < pEnd; ++psz) {
@@ -433,7 +429,7 @@ IFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
if (wch == '.' || wch == '#') {
if (psz == pStart || psz[-1] == ' ') {
CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, L"*", 1, TRUE);
+ CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, L"*", 1, true);
if (p == NULL) {
return NULL;
}
@@ -443,7 +439,7 @@ IFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
}
pFirst = pLast = p;
}
- FXSYS_assert(pLast != NULL);
+ ASSERT(pLast != NULL);
int32_t iNameLen = FDE_GetCSSNameLen(++psz, pEnd);
if (iNameLen == 0) {
return NULL;
@@ -451,7 +447,7 @@ IFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
FDE_CSSSELECTORTYPE eType =
wch == '.' ? FDE_CSSSELECTORTYPE_Class : FDE_CSSSELECTORTYPE_ID;
CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSSelector(eType, psz, iNameLen, FALSE);
+ CFDE_CSSSelector(eType, psz, iNameLen, false);
if (p == NULL) {
return NULL;
}
@@ -465,7 +461,7 @@ IFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
return NULL;
}
CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, psz, iNameLen, TRUE);
+ CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Element, psz, iNameLen, true);
if (p == NULL) {
return NULL;
}
@@ -483,7 +479,7 @@ IFDE_CSSSelector* CFDE_CSSSelector::FromString(IFX_MEMAllocator* pStaticStore,
return NULL;
}
CFDE_CSSSelector* p = FXTARGET_NewWith(pStaticStore)
- CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Persudo, psz, iNameLen, TRUE);
+ CFDE_CSSSelector(FDE_CSSSELECTORTYPE_Persudo, psz, iNameLen, true);
if (p == NULL) {
return NULL;
}
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.h b/chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.h
index 8ae8bd53931..a78ae487bb5 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.h
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_cssstylesheet.h
@@ -10,27 +10,29 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
-class CFDE_CSSSelector : public IFDE_CSSSelector, public CFX_Target {
+class CFDE_CSSSyntaxParser;
+
+class CFDE_CSSSelector : public CFX_Target {
public:
CFDE_CSSSelector(FDE_CSSSELECTORTYPE eType,
const FX_WCHAR* psz,
int32_t iLen,
- FX_BOOL bIgnoreCase)
+ bool bIgnoreCase)
: m_eType(eType),
- m_dwHash(FX_HashCode_String_GetW(psz, iLen, bIgnoreCase)),
- m_pNext(NULL) {}
+ m_dwHash(FX_HashCode_GetW(CFX_WideStringC(psz, iLen), bIgnoreCase)),
+ m_pNext(nullptr) {}
virtual FDE_CSSSELECTORTYPE GetType() const { return m_eType; }
virtual uint32_t GetNameHash() const { return m_dwHash; }
- virtual IFDE_CSSSelector* GetNextSelector() const { return m_pNext; }
- static IFDE_CSSSelector* FromString(IFX_MEMAllocator* pStaticStore,
+ virtual CFDE_CSSSelector* GetNextSelector() const { return m_pNext; }
+ static CFDE_CSSSelector* FromString(IFX_MemoryAllocator* pStaticStore,
const FX_WCHAR* psz,
int32_t iLen);
- void SetNext(IFDE_CSSSelector* pNext) { m_pNext = pNext; }
+ void SetNext(CFDE_CSSSelector* pNext) { m_pNext = pNext; }
protected:
- static CFDE_CSSSelector* ParseSelector(IFX_MEMAllocator* pStaticStore,
+ static CFDE_CSSSelector* ParseSelector(IFX_MemoryAllocator* pStaticStore,
const FX_WCHAR* psz,
int32_t& iOff,
int32_t iLen,
@@ -38,27 +40,26 @@ class CFDE_CSSSelector : public IFDE_CSSSelector, public CFX_Target {
void SetType(FDE_CSSSELECTORTYPE eType) { m_eType = eType; }
FDE_CSSSELECTORTYPE m_eType;
uint32_t m_dwHash;
- IFDE_CSSSelector* m_pNext;
+ CFDE_CSSSelector* m_pNext;
};
-typedef CFX_ArrayTemplate<IFDE_CSSSelector*> CFDE_CSSSelectorArray;
+typedef CFX_ArrayTemplate<CFDE_CSSSelector*> CFDE_CSSSelectorArray;
+
class CFDE_CSSStyleRule : public IFDE_CSSStyleRule, public CFX_Target {
public:
CFDE_CSSStyleRule() : m_ppSelector(NULL), m_iSelectors(0) {}
- virtual int32_t CountSelectorLists() const { return m_iSelectors; }
- virtual IFDE_CSSSelector* GetSelectorList(int32_t index) const {
+ int32_t CountSelectorLists() const override { return m_iSelectors; }
+ CFDE_CSSSelector* GetSelectorList(int32_t index) const override {
return m_ppSelector[index];
}
- virtual IFDE_CSSDeclaration* GetDeclaration() const {
- return (IFDE_CSSDeclaration*)&m_Declaration;
- }
+ CFDE_CSSDeclaration* GetDeclaration() override { return &m_Declaration; }
CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; }
- void SetSelector(IFX_MEMAllocator* pStaticStore,
+ void SetSelector(IFX_MemoryAllocator* pStaticStore,
const CFDE_CSSSelectorArray& list);
protected:
CFDE_CSSDeclaration m_Declaration;
- IFDE_CSSSelector** m_ppSelector;
+ CFDE_CSSSelector** m_ppSelector;
int32_t m_iSelectors;
};
class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target {
@@ -80,9 +81,7 @@ class CFDE_CSSMediaRule : public IFDE_CSSMediaRule, public CFX_Target {
};
class CFDE_CSSFontFaceRule : public IFDE_CSSFontFaceRule, public CFX_Target {
public:
- virtual IFDE_CSSDeclaration* GetDeclaration() const {
- return (IFDE_CSSDeclaration*)&m_Declaration;
- }
+ CFDE_CSSDeclaration* GetDeclaration() override { return &m_Declaration; }
CFDE_CSSDeclaration& GetDeclImp() { return m_Declaration; }
protected:
@@ -119,19 +118,19 @@ class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target {
protected:
void Reset();
- FX_BOOL LoadFromSyntax(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadStyleRule(IFDE_CSSSyntaxParser* pSyntax,
+ FX_BOOL LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS LoadStyleRule(CFDE_CSSSyntaxParser* pSyntax,
CFDE_CSSRuleArray& ruleArray);
- FDE_CSSSYNTAXSTATUS LoadImportRule(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadPageRule(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadMediaRule(IFDE_CSSSyntaxParser* pSyntax);
- FDE_CSSSYNTAXSTATUS LoadFontFaceRule(IFDE_CSSSyntaxParser* pSyntax,
+ FDE_CSSSYNTAXSTATUS LoadImportRule(CFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS LoadPageRule(CFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS LoadMediaRule(CFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS LoadFontFaceRule(CFDE_CSSSyntaxParser* pSyntax,
CFDE_CSSRuleArray& ruleArray);
- FDE_CSSSYNTAXSTATUS SkipRuleSet(IFDE_CSSSyntaxParser* pSyntax);
+ FDE_CSSSYNTAXSTATUS SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax);
uint16_t m_wCodePage;
uint16_t m_wRefCount;
uint32_t m_dwMediaList;
- IFX_MEMAllocator* m_pAllocator;
+ IFX_MemoryAllocator* m_pAllocator;
CFDE_CSSRuleArray m_RuleArray;
CFX_WideString m_szUrl;
CFDE_CSSSelectorArray m_Selectors;
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.cpp b/chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.cpp
index 8a905f69b49..26ddaf727ae 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.cpp
@@ -22,9 +22,6 @@ inline FX_BOOL FDE_IsSelectorStart(FX_WCHAR wch) {
};
#endif
-IFDE_CSSSyntaxParser* IFDE_CSSSyntaxParser::Create() {
- return new CFDE_CSSSyntaxParser;
-}
CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser()
: m_pStream(NULL),
m_iStreamPos(0),
@@ -41,7 +38,7 @@ FX_BOOL CFDE_CSSSyntaxParser::Init(IFX_Stream* pStream,
int32_t iCSSPlaneSize,
int32_t iTextDataSize,
FX_BOOL bOnlyDeclaration) {
- FXSYS_assert(pStream != NULL && iCSSPlaneSize > 0 && iTextDataSize > 0);
+ ASSERT(pStream != NULL && iCSSPlaneSize > 0 && iTextDataSize > 0);
Reset(bOnlyDeclaration);
if (!m_TextData.EstimateSize(iTextDataSize)) {
return FALSE;
@@ -56,7 +53,7 @@ FX_BOOL CFDE_CSSSyntaxParser::Init(const FX_WCHAR* pBuffer,
int32_t iBufferSize,
int32_t iTextDatSize,
FX_BOOL bOnlyDeclaration) {
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0 && iTextDatSize > 0);
+ ASSERT(pBuffer != NULL && iBufferSize > 0 && iTextDatSize > 0);
Reset(bOnlyDeclaration);
if (!m_TextData.EstimateSize(iTextDatSize)) {
return FALSE;
@@ -358,7 +355,7 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSSyntaxParser::DoSyntaxParse() {
m_TextPlane.MoveNext();
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
}
@@ -434,7 +431,7 @@ FX_BOOL CFDE_CSSTextBuf::AttachBuffer(const FX_WCHAR* pBuffer,
return m_bExtBuf = TRUE;
}
FX_BOOL CFDE_CSSTextBuf::EstimateSize(int32_t iAllocSize) {
- FXSYS_assert(iAllocSize > 0);
+ ASSERT(iAllocSize > 0);
Clear();
m_bExtBuf = FALSE;
return ExpandBuf(iAllocSize);
@@ -443,7 +440,7 @@ int32_t CFDE_CSSTextBuf::LoadFromStream(IFX_Stream* pTxtStream,
int32_t iStreamOffset,
int32_t iMaxChars,
FX_BOOL& bEOS) {
- FXSYS_assert(iStreamOffset >= 0 && iMaxChars > 0);
+ ASSERT(iStreamOffset >= 0 && iMaxChars > 0);
Clear();
m_bExtBuf = FALSE;
if (!ExpandBuf(iMaxChars)) {
@@ -474,7 +471,7 @@ FX_BOOL CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
return TRUE;
}
void CFDE_CSSTextBuf::Subtract(int32_t iStart, int32_t iLength) {
- FXSYS_assert(iStart >= 0 && iLength > 0);
+ ASSERT(iStart >= 0 && iLength > 0);
if (iLength > m_iDatLen - iStart) {
iLength = m_iDatLen - iStart;
}
diff --git a/chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.h b/chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.h
index 0f97604073f..a4e92490554 100644
--- a/chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.h
+++ b/chromium/third_party/pdfium/xfa/fde/css/fde_csssyntax.h
@@ -74,21 +74,21 @@ enum FDE_CSSSYNTAXMODE {
FDE_CSSSYNTAXMODE_PropertyValue,
};
-class CFDE_CSSSyntaxParser : public IFDE_CSSSyntaxParser, public CFX_Target {
+class CFDE_CSSSyntaxParser : public CFX_Target {
public:
CFDE_CSSSyntaxParser();
- ~CFDE_CSSSyntaxParser();
- virtual void Release() { delete this; }
- virtual FX_BOOL Init(IFX_Stream* pStream,
- int32_t iCSSPlaneSize,
- int32_t iTextDataSize = 32,
- FX_BOOL bOnlyDeclaration = FALSE);
- virtual FX_BOOL Init(const FX_WCHAR* pBuffer,
- int32_t iBufferSize,
- int32_t iTextDatSize = 32,
- FX_BOOL bOnlyDeclaration = FALSE);
- virtual FDE_CSSSYNTAXSTATUS DoSyntaxParse();
- virtual const FX_WCHAR* GetCurrentString(int32_t& iLength) const;
+ ~CFDE_CSSSyntaxParser() override;
+
+ FX_BOOL Init(IFX_Stream* pStream,
+ int32_t iCSSPlaneSize,
+ int32_t iTextDataSize = 32,
+ FX_BOOL bOnlyDeclaration = FALSE);
+ FX_BOOL Init(const FX_WCHAR* pBuffer,
+ int32_t iBufferSize,
+ int32_t iTextDatSize = 32,
+ FX_BOOL bOnlyDeclaration = FALSE);
+ FDE_CSSSYNTAXSTATUS DoSyntaxParse();
+ const FX_WCHAR* GetCurrentString(int32_t& iLength) const;
protected:
void Reset(FX_BOOL bOnlyDeclaration);
@@ -104,6 +104,7 @@ class CFDE_CSSSyntaxParser : public IFDE_CSSSyntaxParser, public CFX_Target {
void DisableCharset() { m_dwCheck = FDE_CSSSYNTAXCHECK_AllowImport; }
FX_BOOL IsImportEnabled() const;
void DisableImport() { m_dwCheck = 0; }
+
IFX_Stream* m_pStream;
int32_t m_iStreamPos;
int32_t m_iPlaneSize;
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_brush.h b/chromium/third_party/pdfium/xfa/fde/fde_brush.h
deleted file mode 100644
index cfa40a055f2..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_brush.h
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FDE_FDE_BRUSH_H_
-#define XFA_FDE_FDE_BRUSH_H_
-
-#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
-
-class IFDE_Image;
-
-#define FDE_BRUSHTYPE_Unknown -1
-#define FDE_BRUSHTYPE_Solid 0
-#define FDE_BRUSHTYPE_Hatch 1
-#define FDE_BRUSHTYPE_Texture 2
-#define FDE_BRUSHTYPE_LinearGradient 3
-#define FDE_BRUSHTYPE_MAX 3
-#define FDE_WRAPMODE_Tile 0
-#define FDE_WRAPMODE_TileFlipX 1
-#define FDE_WRAPMODE_TileFlipY 2
-#define FDE_WRAPMODE_TileFlipXY 3
-#define FDE_WRAPMODE_Clamp 4
-
-struct FDE_GRADIENTCOLOR {
- FX_FLOAT pos;
- FX_ARGB color;
-};
-typedef CFX_ArrayTemplate<FDE_GRADIENTCOLOR> CFDE_GradientColors;
-
-class IFDE_Brush {
- public:
- static IFDE_Brush* Create(int32_t iType);
- virtual ~IFDE_Brush() {}
- virtual void Release() = 0;
- virtual int32_t GetType() const = 0;
-};
-
-class IFDE_SolidBrush : public IFDE_Brush {
- public:
- virtual FX_ARGB GetColor() const = 0;
- virtual void SetColor(FX_ARGB color) = 0;
- virtual const CFX_Matrix& GetMatrix() const = 0;
- virtual void ResetMatrix() = 0;
- virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) = 0;
- virtual void RotateMatrix(FX_FLOAT fRadian) = 0;
- virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) = 0;
- virtual void ConcatMatrix(const CFX_Matrix& matrix) = 0;
- virtual void SetMatrix(const CFX_Matrix& matrix) = 0;
-};
-
-#define FDE_HATCHSTYLE_Horizontal 0
-#define FDE_HATCHSTYLE_Vertical 1
-#define FDE_HATCHSTYLE_ForwardDiagonal 2
-#define FDE_HATCHSTYLE_BackwardDiagonal 3
-#define FDE_HATCHSTYLE_Cross 4
-#define FDE_HATCHSTYLE_DiagonalCross 5
-#define FDE_HATCHSTYLE_05Percent 6
-#define FDE_HATCHSTYLE_10Percent 7
-#define FDE_HATCHSTYLE_20Percent 8
-#define FDE_HATCHSTYLE_25Percent 9
-#define FDE_HATCHSTYLE_30Percent 10
-#define FDE_HATCHSTYLE_40Percent 11
-#define FDE_HATCHSTYLE_50Percent 12
-#define FDE_HATCHSTYLE_60Percent 13
-#define FDE_HATCHSTYLE_70Percent 14
-#define FDE_HATCHSTYLE_75Percent 15
-#define FDE_HATCHSTYLE_80Percent 16
-#define FDE_HATCHSTYLE_90Percent 17
-#define FDE_HATCHSTYLE_LightDownwardDiagonal 18
-#define FDE_HATCHSTYLE_LightUpwardDiagonal 19
-#define FDE_HATCHSTYLE_DarkDownwardDiagonal 20
-#define FDE_HATCHSTYLE_DarkUpwardDiagonal 21
-#define FDE_HATCHSTYLE_WideDownwardDiagonal 22
-#define FDE_HATCHSTYLE_WideUpwardDiagonal 23
-#define FDE_HATCHSTYLE_LightVertical 24
-#define FDE_HATCHSTYLE_LightHorizontal 25
-#define FDE_HATCHSTYLE_NarrowVertical 26
-#define FDE_HATCHSTYLE_NarrowHorizontal 27
-#define FDE_HATCHSTYLE_DarkVertical 28
-#define FDE_HATCHSTYLE_DarkHorizontal 29
-#define FDE_HATCHSTYLE_DashedDownwardDiagonal 30
-#define FDE_HATCHSTYLE_DashedUpwardDiagonal 31
-#define FDE_HATCHSTYLE_DashedHorizontal 32
-#define FDE_HATCHSTYLE_DashedVertical 33
-#define FDE_HATCHSTYLE_SmallConfetti 34
-#define FDE_HATCHSTYLE_LargeConfetti 35
-#define FDE_HATCHSTYLE_ZigZag 36
-#define FDE_HATCHSTYLE_Wave 37
-#define FDE_HATCHSTYLE_DiagonalBrick 38
-#define FDE_HATCHSTYLE_HorizontalBrick 39
-#define FDE_HATCHSTYLE_Weave 40
-#define FDE_HATCHSTYLE_Plaid 41
-#define FDE_HATCHSTYLE_Divot 42
-#define FDE_HATCHSTYLE_DottedGrid 43
-#define FDE_HATCHSTYLE_DottedDiamond 44
-#define FDE_HATCHSTYLE_Shingle 45
-#define FDE_HATCHSTYLE_Trellis 46
-#define FDE_HATCHSTYLE_Sphere 47
-#define FDE_HATCHSTYLE_SmallGrid 48
-#define FDE_HATCHSTYLE_SmallCheckerBoard 49
-#define FDE_HATCHSTYLE_LargeCheckerBoard 50
-#define FDE_HATCHSTYLE_OutlinedDiamond 51
-#define FDE_HATCHSTYLE_SolidDiamond 52
-#define FDE_HATCHSTYLE_Total 53
-#define FDE_HATCHSTYLE_LargeGrid FDE_HATCHSTYLE_Cross
-#define FDE_HATCHSTYLE_Min FDE_HATCHSTYLE_Horizontal
-#define FDE_HATCHSTYLE_Max (FDE_HATCHSTYLE_Total - 1)
-
-class IFDE_HatchBrush : public IFDE_Brush {
- public:
- virtual FX_ARGB GetColor(FX_BOOL bForegroundColor) const = 0;
- virtual void SetColor(FX_ARGB color, FX_BOOL bForegroundColor) = 0;
- virtual int32_t GetHatchStyle() const = 0;
- virtual FX_BOOL SetHatchStyle(int32_t iHatchStyle) = 0;
-};
-
-class IFDE_TextureBrush : public IFDE_Brush {
- public:
- virtual IFDE_Image* GetImage() const = 0;
- virtual void SetImage(IFDE_Image* pImage, FX_BOOL bAutoRelease) = 0;
- virtual int32_t GetWrapMode() const = 0;
- virtual void SetWrapMode(int32_t iWrapMode) = 0;
-};
-
-#define FDE_LINEARGRADIENTMODE_Horizontal 0
-#define FDE_LINEARGRADIENTMODE_Vertical 1
-#define FDE_LINEARGRADIENTMODE_ForwardDiagonal 2
-#define FDE_LINEARGRADIENTMODE_BackwardDiagonal 3
-
-class IFDE_LinearGradientBrush : public IFDE_Brush {
- public:
- virtual void GetLinearPoints(CFX_PointF& startingPoint,
- CFX_PointF& endingPoint) const = 0;
- virtual void SetLinearPoints(const CFX_PointF& startingPoint,
- const CFX_PointF& endingPoint) = 0;
- virtual void GetLinearColors(FX_ARGB& startingColor,
- FX_ARGB& endingColor) const = 0;
- virtual void SetLinearColors(const FX_ARGB& startingColor,
- const FX_ARGB& endingColor) = 0;
- virtual int32_t CountGradientColors() const = 0;
- virtual FX_BOOL GetGradientColors(CFDE_GradientColors& colors) const = 0;
- virtual FX_BOOL SetGradientColors(const CFDE_GradientColors& colors) = 0;
- virtual int32_t GetWrapMode() const = 0;
- virtual void SetWrapMode(int32_t iWrapMode) = 0;
-};
-
-#endif // XFA_FDE_FDE_BRUSH_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_devbasic.cpp b/chromium/third_party/pdfium/xfa/fde/fde_devbasic.cpp
deleted file mode 100644
index c85b125f732..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_devbasic.cpp
+++ /dev/null
@@ -1,550 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fde/fde_devbasic.h"
-
-#include <cstdint>
-
-#include "xfa/fde/fde_brush.h"
-
-static const FDE_HATCHDATA gs_HatchBitmapData[FDE_HATCHSTYLE_Total] = {
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x80, 0x80, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00,
- 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00,
- 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x40, 0x40, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00,
- 0x01, 0x01, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00,
- 0x40, 0x40, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
- 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x10, 0x10, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00,
- 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00,
- 0x42, 0x42, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00,
- 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
- 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00,
- 0x81, 0x81, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x11, 0x11, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00,
- 0xaa, 0xaa, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00,
- 0xaa, 0xaa, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x11, 0x11, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x51, 0x51, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0xaa, 0xaa, 0x00, 0x00, 0x15, 0x15, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x51, 0x51, 0x00, 0x00,
- 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x15, 0x15, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0xbb, 0xbb, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0xee, 0xee, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xbb, 0xbb, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00,
- 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00,
- 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00,
- 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00,
- 0x77, 0x77, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00,
- 0xdd, 0xdd, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0xdd, 0xdd, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x77, 0x77, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xdd, 0xdd, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0xfe, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xef, 0xef, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0xef, 0xef, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0xf7, 0xf7, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xf7, 0xf7, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x7f, 0x7f, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x11, 0x11, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x11, 0x11, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00,
- 0x33, 0x33, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00,
- 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00,
- 0xcc, 0xcc, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00,
- 0xcc, 0xcc, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x33, 0x33, 0x00, 0x00,
- 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00,
- 0x33, 0x33, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xc1, 0xc1, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00,
- 0x38, 0x38, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00,
- 0x07, 0x07, 0x00, 0x00, 0x83, 0x83, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00,
- 0xe0, 0xe0, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00,
- 0x1c, 0x1c, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x83, 0x83, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x83, 0x83, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00,
- 0x1c, 0x1c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00,
- 0xe0, 0xe0, 0x00, 0x00, 0xc1, 0xc1, 0x00, 0x00, 0x83, 0x83, 0x00, 0x00,
- 0x07, 0x07, 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00,
- 0x38, 0x38, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00,
- 0xc1, 0xc1, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00,
- 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00,
- 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00,
- 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00,
- 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x00,
- 0xcc, 0xcc, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x44, 0x44, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x44, 0x44, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x80, 0x80, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00,
- 0x02, 0x02, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
- 0x20, 0x20, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00,
- 0x10, 0x10, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00,
- 0x04, 0x04, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xb1, 0xb1, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
- 0x1b, 0x1b, 0x00, 0x00, 0xd8, 0xd8, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00,
- 0x0c, 0x0c, 0x00, 0x00, 0x8d, 0x8d, 0x00, 0x00, 0xb1, 0xb1, 0x00, 0x00,
- 0x30, 0x30, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x1b, 0x1b, 0x00, 0x00,
- 0xd8, 0xd8, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00,
- 0x8d, 0x8d, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00,
- 0x18, 0x18, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00,
- 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00,
- 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
- 0x81, 0x81, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00,
- 0x18, 0x18, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00,
- 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
- 0x25, 0x25, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x25, 0x25, 0x00, 0x00,
- 0xc0, 0xc0, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00,
- 0x42, 0x42, 0x00, 0x00, 0x81, 0x81, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
- 0x02, 0x02, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x18, 0x18, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x42, 0x42, 0x00, 0x00,
- 0x81, 0x81, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x88, 0x88, 0x00, 0x00, 0x54, 0x54, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x45, 0x45, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x14, 0x14, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x51, 0x51, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x54, 0x54, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x45, 0x45, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x14, 0x14, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x51, 0x51, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00,
- 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x55, 0x55, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
- 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00,
- 0xf0, 0xf0, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
- 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x01, 0x01, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x03, 0x03, 0x00, 0x00, 0x84, 0x84, 0x00, 0x00, 0x48, 0x48, 0x00, 0x00,
- 0x30, 0x30, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00,
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
- 0x84, 0x84, 0x00, 0x00, 0x48, 0x48, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00,
- 0x0c, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x01, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x77, 0x77, 0x00, 0x00, 0x89, 0x89, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00,
- 0x8f, 0x8f, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0x98, 0x98, 0x00, 0x00,
- 0xf8, 0xf8, 0x00, 0x00, 0xf8, 0xf8, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00,
- 0x89, 0x89, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00, 0x8f, 0x8f, 0x00, 0x00,
- 0x77, 0x77, 0x00, 0x00, 0x98, 0x98, 0x00, 0x00, 0xf8, 0xf8, 0x00, 0x00,
- 0xf8, 0xf8, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00,
- 0x88, 0x88, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00,
- 0x66, 0x66, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00,
- 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x99, 0x99, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00,
- 0x99, 0x99, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00,
- 0xf0, 0xf0, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00,
- 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00,
- 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xf0, 0xf0, 0x00, 0x00,
- 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00,
- 0x0f, 0x0f, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x82, 0x82, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00,
- 0x10, 0x10, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00,
- 0x82, 0x82, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x82, 0x82, 0x00, 0x00,
- 0x44, 0x44, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,
- 0x28, 0x28, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x82, 0x82, 0x00, 0x00,
- 0x01, 0x01, 0x00, 0x00,
- }},
- {16,
- 16,
- {
- 0x10, 0x10, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00,
- 0xfe, 0xfe, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00,
- 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,
- 0x38, 0x38, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00,
- 0x7c, 0x7c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- }},
-};
-FDE_LPCHATCHDATA FDE_DEVGetHatchData(int32_t iHatchStyle) {
- if (iHatchStyle < FDE_HATCHSTYLE_Min || iHatchStyle > FDE_HATCHSTYLE_Max) {
- return NULL;
- }
- return &gs_HatchBitmapData[iHatchStyle];
-}
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_devbasic.h b/chromium/third_party/pdfium/xfa/fde/fde_devbasic.h
deleted file mode 100644
index 9c9b25dd3ef..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_devbasic.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FDE_FDE_DEVBASIC_H_
-#define XFA_FDE_FDE_DEVBASIC_H_
-
-#include <cstdint>
-
-struct FDE_HATCHDATA {
- int32_t iWidth;
- int32_t iHeight;
- uint8_t MaskBits[64];
-};
-typedef FDE_HATCHDATA const* FDE_LPCHATCHDATA;
-FDE_LPCHATCHDATA FDE_DEVGetHatchData(int32_t iHatchStyle);
-
-#endif // XFA_FDE_FDE_DEVBASIC_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_gedevice.cpp b/chromium/third_party/pdfium/xfa/fde/fde_gedevice.cpp
index 1338dc4a8e0..f99dc6c2019 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_gedevice.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/fde_gedevice.cpp
@@ -8,95 +8,72 @@
#include <algorithm>
-#include "xfa/fde/fde_brush.h"
-#include "xfa/fde/fde_devbasic.h"
-#include "xfa/fde/fde_geobject.h"
-#include "xfa/fde/fde_image.h"
-#include "xfa/fde/fde_pen.h"
+#include "xfa/fde/cfde_path.h"
+#include "xfa/fde/fde_object.h"
+#include "xfa/fgas/font/fgas_font.h"
-FX_BOOL FDE_GetStockHatchMask(int32_t iHatchStyle, CFX_DIBitmap& hatchMask) {
- FDE_LPCHATCHDATA pData = FDE_DEVGetHatchData(iHatchStyle);
- if (!pData) {
- return FALSE;
- }
- hatchMask.Create(pData->iWidth, pData->iHeight, FXDIB_1bppMask);
- FXSYS_memcpy(hatchMask.GetBuffer(), pData->MaskBits,
- hatchMask.GetPitch() * pData->iHeight);
- return TRUE;
-}
-
-IFDE_RenderDevice* IFDE_RenderDevice::Create(CFX_DIBitmap* pBitmap,
- FX_BOOL bRgbByteOrder) {
- if (pBitmap == NULL) {
- return NULL;
- }
- CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
- pDevice->Attach(pBitmap, 0, bRgbByteOrder);
- return new CFDE_FxgeDevice(pDevice, TRUE);
-}
-IFDE_RenderDevice* IFDE_RenderDevice::Create(CFX_RenderDevice* pDevice) {
- return pDevice ? new CFDE_FxgeDevice(pDevice, FALSE) : nullptr;
-}
-CFDE_FxgeDevice::CFDE_FxgeDevice(CFX_RenderDevice* pDevice,
- FX_BOOL bOwnerDevice)
+CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice,
+ FX_BOOL bOwnerDevice)
: m_pDevice(pDevice),
m_bOwnerDevice(bOwnerDevice),
- m_pCharPos(NULL),
+ m_pCharPos(nullptr),
m_iCharCount(0) {
- FXSYS_assert(pDevice != NULL);
+ ASSERT(pDevice);
+
FX_RECT rt = m_pDevice->GetClipBox();
m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(),
(FX_FLOAT)rt.Height());
}
-CFDE_FxgeDevice::~CFDE_FxgeDevice() {
+
+CFDE_RenderDevice::~CFDE_RenderDevice() {
FX_Free(m_pCharPos);
if (m_bOwnerDevice)
delete m_pDevice;
}
-int32_t CFDE_FxgeDevice::GetWidth() const {
+int32_t CFDE_RenderDevice::GetWidth() const {
return m_pDevice->GetWidth();
}
-int32_t CFDE_FxgeDevice::GetHeight() const {
+int32_t CFDE_RenderDevice::GetHeight() const {
return m_pDevice->GetHeight();
}
-FDE_HDEVICESTATE CFDE_FxgeDevice::SaveState() {
+FDE_HDEVICESTATE CFDE_RenderDevice::SaveState() {
m_pDevice->SaveState();
return NULL;
}
-void CFDE_FxgeDevice::RestoreState(FDE_HDEVICESTATE hState) {
+void CFDE_RenderDevice::RestoreState(FDE_HDEVICESTATE hState) {
m_pDevice->RestoreState();
const FX_RECT& rt = m_pDevice->GetClipBox();
m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(),
(FX_FLOAT)rt.Height());
}
-FX_BOOL CFDE_FxgeDevice::SetClipRect(const CFX_RectF& rtClip) {
+FX_BOOL CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) {
m_rtClip = rtClip;
return m_pDevice->SetClip_Rect(FX_RECT((int32_t)FXSYS_floor(rtClip.left),
(int32_t)FXSYS_floor(rtClip.top),
(int32_t)FXSYS_ceil(rtClip.right()),
(int32_t)FXSYS_ceil(rtClip.bottom())));
}
-const CFX_RectF& CFDE_FxgeDevice::GetClipRect() {
+const CFX_RectF& CFDE_RenderDevice::GetClipRect() {
return m_rtClip;
}
-FX_BOOL CFDE_FxgeDevice::SetClipPath(const IFDE_Path* pClip) {
+FX_BOOL CFDE_RenderDevice::SetClipPath(const CFDE_Path* pClip) {
return FALSE;
}
-IFDE_Path* CFDE_FxgeDevice::GetClipPath() const {
+CFDE_Path* CFDE_RenderDevice::GetClipPath() const {
return NULL;
}
-FX_FLOAT CFDE_FxgeDevice::GetDpiX() const {
+FX_FLOAT CFDE_RenderDevice::GetDpiX() const {
return 96;
}
-FX_FLOAT CFDE_FxgeDevice::GetDpiY() const {
+FX_FLOAT CFDE_RenderDevice::GetDpiY() const {
return 96;
}
-FX_BOOL CFDE_FxgeDevice::DrawImage(CFX_DIBSource* pDib,
- const CFX_RectF* pSrcRect,
- const CFX_RectF& dstRect,
- const CFX_Matrix* pImgMatrix,
- const CFX_Matrix* pDevMatrix) {
- FXSYS_assert(pDib != NULL);
+FX_BOOL CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib,
+ const CFX_RectF* pSrcRect,
+ const CFX_RectF& dstRect,
+ const CFX_Matrix* pImgMatrix,
+ const CFX_Matrix* pDevMatrix) {
+ ASSERT(pDib != NULL);
CFX_RectF srcRect;
if (pSrcRect) {
srcRect = *pSrcRect;
@@ -127,105 +104,106 @@ FX_BOOL CFDE_FxgeDevice::DrawImage(CFX_DIBSource* pDib,
m_pDevice->CancelDIBits(handle);
return handle != NULL;
}
-FX_BOOL CFDE_FxgeDevice::DrawString(IFDE_Brush* pBrush,
- IFX_Font* pFont,
- const FXTEXT_CHARPOS* pCharPos,
- int32_t iCount,
- FX_FLOAT fFontSize,
- const CFX_Matrix* pMatrix) {
- FXSYS_assert(pBrush != NULL && pFont != NULL && pCharPos != NULL &&
- iCount > 0);
+FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush,
+ IFX_Font* pFont,
+ const FXTEXT_CHARPOS* pCharPos,
+ int32_t iCount,
+ FX_FLOAT fFontSize,
+ const CFX_Matrix* pMatrix) {
+ ASSERT(pBrush != NULL && pFont != NULL && pCharPos != NULL && iCount > 0);
CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache();
CFX_Font* pFxFont = (CFX_Font*)pFont->GetDevFont();
- switch (pBrush->GetType()) {
- case FDE_BRUSHTYPE_Solid: {
- FX_ARGB argb = ((IFDE_SolidBrush*)pBrush)->GetColor();
- if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 &&
- !pFxFont->IsItalic()) {
- FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
- FX_FLOAT* pAM;
- for (int32_t i = 0; i < iCount; ++i) {
- static const FX_FLOAT mc = 0.267949f;
- pAM = pCP->m_AdjustMatrix;
- pAM[2] = mc * pAM[0] + pAM[2];
- pAM[3] = mc * pAM[1] + pAM[3];
- pCP++;
- }
- }
- FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
- IFX_Font* pCurFont = NULL;
- IFX_Font* pSTFont = NULL;
- FXTEXT_CHARPOS* pCurCP = NULL;
- int32_t iCurCount = 0;
-#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- uint32_t dwFontStyle = pFont->GetFontStyles();
- CFX_Font FxFont;
- CFX_SubstFont SubstFxFont;
- FxFont.SetSubstFont(&SubstFxFont);
- SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
- SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight;
- SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
- SubstFxFont.m_bItlicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic);
-#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- for (int32_t i = 0; i < iCount; ++i) {
- pSTFont = pFont->GetSubstFont((int32_t)pCP->m_GlyphIndex);
- pCP->m_GlyphIndex &= 0x00FFFFFF;
- pCP->m_bFontStyle = FALSE;
- if (pCurFont != pSTFont) {
- if (pCurFont != NULL) {
- pFxFont = (CFX_Font*)pCurFont->GetDevFont();
+
+ FX_ARGB argb = pBrush->GetColor();
+ if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 &&
+ !pFxFont->IsItalic()) {
+ FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
+ FX_FLOAT* pAM;
+ for (int32_t i = 0; i < iCount; ++i) {
+ static const FX_FLOAT mc = 0.267949f;
+ pAM = pCP->m_AdjustMatrix;
+ pAM[2] = mc * pAM[0] + pAM[2];
+ pAM[3] = mc * pAM[1] + pAM[3];
+ pCP++;
+ }
+ }
+ FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos;
+ IFX_Font* pCurFont = NULL;
+ IFX_Font* pSTFont = NULL;
+ FXTEXT_CHARPOS* pCurCP = NULL;
+ int32_t iCurCount = 0;
+
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- FxFont.SetFace(pFxFont->GetFace());
- m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, pCache,
- -fFontSize, (const CFX_Matrix*)pMatrix,
- argb, FXTEXT_CLEARTYPE);
-#else
- m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache,
- -fFontSize, (const CFX_Matrix*)pMatrix,
- argb, FXTEXT_CLEARTYPE);
+ uint32_t dwFontStyle = pFont->GetFontStyles();
+ CFX_Font FxFont;
+ CFX_SubstFont SubstFxFont;
+ FxFont.SetSubstFont(&SubstFxFont);
+ SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400;
+ SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight;
+ SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0;
+ SubstFxFont.m_bItlicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic);
#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- }
- pCurFont = pSTFont;
- pCurCP = pCP;
- iCurCount = 1;
- } else {
- iCurCount++;
- }
- pCP++;
- }
- if (pCurFont != NULL && iCurCount) {
+
+ for (int32_t i = 0; i < iCount; ++i) {
+ pSTFont = pFont->GetSubstFont((int32_t)pCP->m_GlyphIndex);
+ pCP->m_GlyphIndex &= 0x00FFFFFF;
+ pCP->m_bFontStyle = FALSE;
+ if (pCurFont != pSTFont) {
+ if (pCurFont != NULL) {
pFxFont = (CFX_Font*)pCurFont->GetDevFont();
+
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
FxFont.SetFace(pFxFont->GetFace());
- FX_BOOL bRet = m_pDevice->DrawNormalText(
- iCurCount, pCurCP, &FxFont, pCache, -fFontSize,
- (const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE);
- FxFont.SetSubstFont(nullptr);
- FxFont.SetFace(nullptr);
- return bRet;
+ m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, pCache,
+ -fFontSize, (const CFX_Matrix*)pMatrix, argb,
+ FXTEXT_CLEARTYPE);
#else
- return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache,
- -fFontSize, (const CFX_Matrix*)pMatrix,
- argb, FXTEXT_CLEARTYPE);
+ m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache,
+ -fFontSize, (const CFX_Matrix*)pMatrix, argb,
+ FXTEXT_CLEARTYPE);
#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
}
+ pCurFont = pSTFont;
+ pCurCP = pCP;
+ iCurCount = 1;
+ } else {
+ iCurCount++;
+ }
+ pCP++;
+ }
+ if (pCurFont != NULL && iCurCount) {
+ pFxFont = (CFX_Font*)pCurFont->GetDevFont();
+
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- FxFont.SetSubstFont(nullptr);
- FxFont.SetFace(nullptr);
+ FxFont.SetFace(pFxFont->GetFace());
+ FX_BOOL bRet = m_pDevice->DrawNormalText(
+ iCurCount, pCurCP, &FxFont, pCache, -fFontSize,
+ (const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE);
+ FxFont.SetSubstFont(nullptr);
+ FxFont.SetFace(nullptr);
+ return bRet;
+#else
+ return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache,
+ -fFontSize, (const CFX_Matrix*)pMatrix,
+ argb, FXTEXT_CLEARTYPE);
#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- return TRUE;
- } break;
- default:
- return FALSE;
}
+
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+ FxFont.SetSubstFont(nullptr);
+ FxFont.SetFace(nullptr);
+#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+
+ return TRUE;
}
-FX_BOOL CFDE_FxgeDevice::DrawBezier(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointF& pt1,
- const CFX_PointF& pt2,
- const CFX_PointF& pt3,
- const CFX_PointF& pt4,
- const CFX_Matrix* pMatrix) {
+
+FX_BOOL CFDE_RenderDevice::DrawBezier(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointF& pt1,
+ const CFX_PointF& pt2,
+ const CFX_PointF& pt3,
+ const CFX_PointF& pt4,
+ const CFX_Matrix* pMatrix) {
CFX_PointsF points;
points.Add(pt1);
points.Add(pt2);
@@ -235,45 +213,45 @@ FX_BOOL CFDE_FxgeDevice::DrawBezier(IFDE_Pen* pPen,
path.AddBezier(points);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::DrawCurve(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- FX_BOOL bClosed,
- FX_FLOAT fTension,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointsF& points,
+ FX_BOOL bClosed,
+ FX_FLOAT fTension,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddCurve(points, bClosed, fTension);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::DrawEllipse(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_RectF& rect,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddEllipse(rect);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::DrawLines(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointsF& points,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddLines(points);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::DrawLine(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointF& pt1,
- const CFX_PointF& pt2,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointF& pt1,
+ const CFX_PointF& pt2,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddLine(pt1, pt2);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::DrawPath(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const IFDE_Path* pPath,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFDE_Path* pPath,
+ const CFX_Matrix* pMatrix) {
CFDE_Path* pGePath = (CFDE_Path*)pPath;
if (pGePath == NULL) {
return FALSE;
@@ -285,289 +263,74 @@ FX_BOOL CFDE_FxgeDevice::DrawPath(IFDE_Pen* pPen,
return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix,
&graphState, 0, pPen->GetColor(), 0);
}
-FX_BOOL CFDE_FxgeDevice::DrawPolygon(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointsF& points,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddPolygon(points);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::DrawRectangle(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_RectF& rect,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddRectangle(rect);
return DrawPath(pPen, fPenWidth, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::FillClosedCurve(IFDE_Brush* pBrush,
- const CFX_PointsF& points,
- FX_FLOAT fTension,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush,
+ const CFX_PointsF& points,
+ FX_FLOAT fTension,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddCurve(points, TRUE, fTension);
return FillPath(pBrush, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::FillEllipse(IFDE_Brush* pBrush,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush,
+ const CFX_RectF& rect,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddEllipse(rect);
return FillPath(pBrush, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::FillPolygon(IFDE_Brush* pBrush,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush,
+ const CFX_PointsF& points,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddPolygon(points);
return FillPath(pBrush, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::FillRectangle(IFDE_Brush* pBrush,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix) {
+FX_BOOL CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush,
+ const CFX_RectF& rect,
+ const CFX_Matrix* pMatrix) {
CFDE_Path path;
path.AddRectangle(rect);
return FillPath(pBrush, &path, pMatrix);
}
-FX_BOOL CFDE_FxgeDevice::CreatePen(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- CFX_GraphStateData& graphState) {
- if (pPen == NULL) {
+FX_BOOL CFDE_RenderDevice::CreatePen(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ CFX_GraphStateData& graphState) {
+ if (!pPen)
return FALSE;
- }
- graphState.m_LineCap = (CFX_GraphStateData::LineCap)pPen->GetLineCap();
- graphState.m_LineJoin = (CFX_GraphStateData::LineJoin)pPen->GetLineJoin();
+
+ graphState.m_LineCap = CFX_GraphStateData::LineCapButt;
+ graphState.m_LineJoin = CFX_GraphStateData::LineJoinMiter;
graphState.m_LineWidth = fPenWidth;
- graphState.m_MiterLimit = pPen->GetMiterLimit();
- graphState.m_DashPhase = pPen->GetDashPhase();
- CFX_FloatArray dashArray;
- switch (pPen->GetDashStyle()) {
- case FDE_DASHSTYLE_Dash:
- dashArray.Add(3);
- dashArray.Add(1);
- break;
- case FDE_DASHSTYLE_Dot:
- dashArray.Add(1);
- dashArray.Add(1);
- break;
- case FDE_DASHSTYLE_DashDot:
- dashArray.Add(3);
- dashArray.Add(1);
- dashArray.Add(1);
- dashArray.Add(1);
- break;
- case FDE_DASHSTYLE_DashDotDot:
- dashArray.Add(3);
- dashArray.Add(1);
- dashArray.Add(1);
- dashArray.Add(1);
- dashArray.Add(1);
- dashArray.Add(1);
- break;
- case FDE_DASHSTYLE_Customized:
- pPen->GetDashArray(dashArray);
- break;
- }
- int32_t iDashCount = dashArray.GetSize();
- if (iDashCount > 0) {
- graphState.SetDashCount(iDashCount);
- for (int32_t i = 0; i < iDashCount; ++i) {
- graphState.m_DashArray[i] = dashArray[i] * fPenWidth;
- }
- }
+ graphState.m_MiterLimit = 10;
+ graphState.m_DashPhase = 0;
return TRUE;
}
-typedef FX_BOOL (CFDE_FxgeDevice::*pfFillPath)(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix);
-static const pfFillPath gs_FillPath[] = {
- &CFDE_FxgeDevice::FillSolidPath, &CFDE_FxgeDevice::FillHatchPath,
- &CFDE_FxgeDevice::FillTexturePath, &CFDE_FxgeDevice::FillLinearGradientPath,
-};
-FX_BOOL CFDE_FxgeDevice::FillPath(IFDE_Brush* pBrush,
- const IFDE_Path* pPath,
- const CFX_Matrix* pMatrix) {
+
+FX_BOOL CFDE_RenderDevice::FillPath(CFDE_Brush* pBrush,
+ const CFDE_Path* pPath,
+ const CFX_Matrix* pMatrix) {
CFDE_Path* pGePath = (CFDE_Path*)pPath;
- if (pGePath == NULL) {
- return FALSE;
- }
- if (pBrush == NULL) {
- return FALSE;
- }
- int32_t iType = pBrush->GetType();
- if (iType < 0 || iType > FDE_BRUSHTYPE_MAX) {
- return FALSE;
- }
- return (this->*gs_FillPath[iType])(pBrush, &pGePath->m_Path, pMatrix);
-}
-FX_BOOL CFDE_FxgeDevice::FillSolidPath(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix) {
- FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Solid);
- IFDE_SolidBrush* pSolidBrush = (IFDE_SolidBrush*)pBrush;
- return m_pDevice->DrawPath(pPath, (const CFX_Matrix*)pMatrix, NULL,
- pSolidBrush->GetColor(), 0, FXFILL_WINDING);
-}
-FX_BOOL CFDE_FxgeDevice::FillHatchPath(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix) {
- FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Hatch);
- IFDE_HatchBrush* pHatchBrush = (IFDE_HatchBrush*)pBrush;
- int32_t iStyle = pHatchBrush->GetHatchStyle();
- if (iStyle < FDE_HATCHSTYLE_Min || iStyle > FDE_HATCHSTYLE_Max) {
+ if (!pGePath)
return FALSE;
- }
- CFX_DIBitmap mask;
- if (!FDE_GetStockHatchMask(iStyle, mask)) {
+ if (!pBrush)
return FALSE;
- }
- FX_ARGB dwForeColor = pHatchBrush->GetColor(TRUE);
- FX_ARGB dwBackColor = pHatchBrush->GetColor(FALSE);
- CFX_FloatRect rectf = pPath->GetBoundingBox();
- if (pMatrix) {
- rectf.Transform((const CFX_Matrix*)pMatrix);
- }
- FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top),
- FXSYS_round(rectf.right), FXSYS_round(rectf.bottom));
- m_pDevice->SaveState();
- m_pDevice->StartRendering();
- m_pDevice->SetClip_PathFill(pPath, (const CFX_Matrix*)pMatrix,
- FXFILL_WINDING);
- m_pDevice->FillRect(&rect, dwBackColor);
- for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight())
- for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) {
- m_pDevice->SetBitMask(&mask, i, j, dwForeColor);
- }
- m_pDevice->EndRendering();
- m_pDevice->RestoreState();
- return TRUE;
+ return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr,
+ pBrush->GetColor(), 0, FXFILL_WINDING);
}
-FX_BOOL CFDE_FxgeDevice::FillTexturePath(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix) {
- FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Texture);
- IFDE_TextureBrush* pTextureBrush = static_cast<IFDE_TextureBrush*>(pBrush);
- IFDE_Image* pImage = pTextureBrush->GetImage();
- if (!pImage)
- return FALSE;
- CFX_Size size(pImage->GetImageWidth(), pImage->GetImageHeight());
- CFX_DIBitmap bmp;
- bmp.Create(size.x, size.y, FXDIB_Argb);
- if (!pImage->StartLoadImage(&bmp, 0, 0, size.x, size.y, 0, 0, size.x,
- size.y)) {
- return FALSE;
- }
- if (pImage->DoLoadImage() < 100) {
- return FALSE;
- }
- pImage->StopLoadImage();
- return WrapTexture(pTextureBrush->GetWrapMode(), &bmp, pPath, pMatrix);
-}
-FX_BOOL CFDE_FxgeDevice::WrapTexture(int32_t iWrapMode,
- const CFX_DIBitmap* pBitmap,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix) {
- CFX_FloatRect rectf = pPath->GetBoundingBox();
- if (pMatrix) {
- rectf.Transform((const CFX_Matrix*)pMatrix);
- }
- FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top),
- FXSYS_round(rectf.right), FXSYS_round(rectf.bottom));
- rect.Normalize();
- if (rect.IsEmpty()) {
- return FALSE;
- }
- m_pDevice->SaveState();
- m_pDevice->StartRendering();
- m_pDevice->SetClip_PathFill(pPath, (const CFX_Matrix*)pMatrix,
- FXFILL_WINDING);
- switch (iWrapMode) {
- case FDE_WRAPMODE_Tile:
- case FDE_WRAPMODE_TileFlipX:
- case FDE_WRAPMODE_TileFlipY:
- case FDE_WRAPMODE_TileFlipXY: {
- FX_BOOL bFlipX = iWrapMode == FDE_WRAPMODE_TileFlipXY ||
- iWrapMode == FDE_WRAPMODE_TileFlipX;
- FX_BOOL bFlipY = iWrapMode == FDE_WRAPMODE_TileFlipXY ||
- iWrapMode == FDE_WRAPMODE_TileFlipY;
- const CFX_DIBitmap* pFlip[2][2];
- pFlip[0][0] = pBitmap;
- pFlip[0][1] = bFlipX ? pBitmap->FlipImage(TRUE, FALSE) : pBitmap;
- pFlip[1][0] = bFlipY ? pBitmap->FlipImage(FALSE, TRUE) : pBitmap;
- pFlip[1][1] =
- (bFlipX || bFlipY) ? pBitmap->FlipImage(bFlipX, bFlipY) : pBitmap;
- int32_t iCounterY = 0;
- for (int32_t j = rect.top; j < rect.bottom; j += pBitmap->GetHeight()) {
- int32_t indexY = iCounterY++ % 2;
- int32_t iCounterX = 0;
- for (int32_t i = rect.left; i < rect.right; i += pBitmap->GetWidth()) {
- int32_t indexX = iCounterX++ % 2;
- m_pDevice->SetDIBits(pFlip[indexY][indexX], i, j);
- }
- }
- if (pFlip[0][1] != pFlip[0][0]) {
- delete pFlip[0][1];
- }
- if (pFlip[1][0] != pFlip[0][0]) {
- delete pFlip[1][0];
- }
- if (pFlip[1][1] != pFlip[0][0]) {
- delete pFlip[1][1];
- }
- } break;
- case FDE_WRAPMODE_Clamp: {
- m_pDevice->SetDIBits(pBitmap, rect.left, rect.bottom);
- } break;
- }
- m_pDevice->EndRendering();
- m_pDevice->RestoreState();
- return TRUE;
-}
-FX_BOOL CFDE_FxgeDevice::FillLinearGradientPath(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix) {
- FXSYS_assert(pPath && pBrush &&
- pBrush->GetType() == FDE_BRUSHTYPE_LinearGradient);
- IFDE_LinearGradientBrush* pLinearBrush = (IFDE_LinearGradientBrush*)pBrush;
- CFX_PointF pt0, pt1;
- pLinearBrush->GetLinearPoints(pt0, pt1);
- CFX_VectorF fDiagonal(pt0, pt1);
- FX_FLOAT fTheta = FXSYS_atan2(fDiagonal.y, fDiagonal.x);
- FX_FLOAT fLength = fDiagonal.Length();
- FX_FLOAT fTotalX = fLength / FXSYS_cos(fTheta);
- FX_FLOAT fTotalY = fLength / FXSYS_cos(FX_PI / 2 - fTheta);
- FX_FLOAT fSteps = std::max(fTotalX, fTotalY);
- FX_FLOAT dx = fTotalX / fSteps;
- FX_FLOAT dy = fTotalY / fSteps;
- FX_ARGB cr0, cr1;
- pLinearBrush->GetLinearColors(cr0, cr1);
- FX_FLOAT a0 = FXARGB_A(cr0);
- FX_FLOAT r0 = FXARGB_R(cr0);
- FX_FLOAT g0 = FXARGB_G(cr0);
- FX_FLOAT b0 = FXARGB_B(cr0);
- FX_FLOAT da = (FXARGB_A(cr1) - a0) / fSteps;
- FX_FLOAT dr = (FXARGB_R(cr1) - r0) / fSteps;
- FX_FLOAT dg = (FXARGB_G(cr1) - g0) / fSteps;
- FX_FLOAT db = (FXARGB_B(cr1) - b0) / fSteps;
- CFX_DIBitmap bmp;
- bmp.Create(FXSYS_round(FXSYS_fabs(fDiagonal.x)),
- FXSYS_round(FXSYS_fabs(fDiagonal.y)), FXDIB_Argb);
- CFX_FxgeDevice dev;
- dev.Attach(&bmp);
- pt1 = pt0;
- int32_t iSteps = FXSYS_round(FXSYS_ceil(fSteps));
- while (--iSteps >= 0) {
- cr0 = ArgbEncode(FXSYS_round(a0), FXSYS_round(r0), FXSYS_round(g0),
- FXSYS_round(b0));
- dev.DrawCosmeticLine(pt0.x, pt0.y, pt1.x, pt1.y, cr0);
- pt1.x += dx;
- pt0.y += dy;
- a0 += da;
- r0 += dr;
- g0 += dg;
- b0 += db;
- }
- return WrapTexture(pLinearBrush->GetWrapMode(), &bmp, pPath, pMatrix);
-}
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_gedevice.h b/chromium/third_party/pdfium/xfa/fde/fde_gedevice.h
index 68467395e6b..f69e4d106ca 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_gedevice.h
+++ b/chromium/third_party/pdfium/xfa/fde/fde_gedevice.h
@@ -7,111 +7,107 @@
#ifndef XFA_FDE_FDE_GEDEVICE_H_
#define XFA_FDE_FDE_GEDEVICE_H_
-#include "xfa/fde/fde_renderdevice.h"
+#include "core/fxge/include/fx_ge.h"
#include "xfa/fgas/crt/fgas_memory.h"
-class CFDE_FxgeDevice : public IFDE_RenderDevice, public CFX_Target {
+typedef struct FDE_HDEVICESTATE_ { void* pData; } * FDE_HDEVICESTATE;
+
+class CFDE_Brush;
+class CFDE_Path;
+class CFDE_Pen;
+class CFX_RenderDevice;
+class IFX_Font;
+
+class CFDE_RenderDevice : public CFX_Target {
public:
- CFDE_FxgeDevice(CFX_RenderDevice* pDevice, FX_BOOL bOwnerDevice);
- ~CFDE_FxgeDevice();
- virtual void Release() { delete this; }
+ CFDE_RenderDevice(CFX_RenderDevice* pDevice, FX_BOOL bOwnerDevice);
+ ~CFDE_RenderDevice() override;
- virtual int32_t GetWidth() const;
- virtual int32_t GetHeight() const;
- virtual FDE_HDEVICESTATE SaveState();
- virtual void RestoreState(FDE_HDEVICESTATE hState);
- virtual FX_BOOL SetClipPath(const IFDE_Path* pClip);
- virtual IFDE_Path* GetClipPath() const;
- virtual FX_BOOL SetClipRect(const CFX_RectF& rtClip);
- virtual const CFX_RectF& GetClipRect();
+ int32_t GetWidth() const;
+ int32_t GetHeight() const;
+ FDE_HDEVICESTATE SaveState();
+ void RestoreState(FDE_HDEVICESTATE hState);
+ FX_BOOL SetClipPath(const CFDE_Path* pClip);
+ CFDE_Path* GetClipPath() const;
+ FX_BOOL SetClipRect(const CFX_RectF& rtClip);
+ const CFX_RectF& GetClipRect();
- virtual FX_FLOAT GetDpiX() const;
- virtual FX_FLOAT GetDpiY() const;
+ FX_FLOAT GetDpiX() const;
+ FX_FLOAT GetDpiY() const;
- virtual FX_BOOL DrawImage(CFX_DIBSource* pDib,
- const CFX_RectF* pSrcRect,
- const CFX_RectF& dstRect,
- const CFX_Matrix* pImgMatrix = NULL,
- const CFX_Matrix* pDevMatrix = NULL);
- virtual FX_BOOL DrawString(IFDE_Brush* pBrush,
- IFX_Font* pFont,
- const FXTEXT_CHARPOS* pCharPos,
- int32_t iCount,
- FX_FLOAT fFontSize,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL DrawBezier(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointF& pt1,
- const CFX_PointF& pt2,
- const CFX_PointF& pt3,
- const CFX_PointF& pt4,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL DrawCurve(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- FX_BOOL bClosed,
- FX_FLOAT fTension = 0.5f,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL DrawEllipse(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL DrawLines(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL DrawLine(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointF& pt1,
- const CFX_PointF& pt2,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL DrawPath(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const IFDE_Path* pPath,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL DrawPolygon(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL DrawRectangle(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL FillClosedCurve(IFDE_Brush* pBrush,
- const CFX_PointsF& points,
- FX_FLOAT fTension = 0.5f,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL FillEllipse(IFDE_Brush* pBrush,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL FillPath(IFDE_Brush* pBrush,
- const IFDE_Path* pPath,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL FillPolygon(IFDE_Brush* pBrush,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL FillRectangle(IFDE_Brush* pBrush,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix = NULL);
- FX_BOOL FillSolidPath(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix);
- FX_BOOL FillHatchPath(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix);
- FX_BOOL FillTexturePath(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix);
- FX_BOOL FillLinearGradientPath(IFDE_Brush* pBrush,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix);
- FX_BOOL DrawSolidString(IFDE_Brush* pBrush,
+ FX_BOOL DrawImage(CFX_DIBSource* pDib,
+ const CFX_RectF* pSrcRect,
+ const CFX_RectF& dstRect,
+ const CFX_Matrix* pImgMatrix = NULL,
+ const CFX_Matrix* pDevMatrix = NULL);
+ FX_BOOL DrawString(CFDE_Brush* pBrush,
+ IFX_Font* pFont,
+ const FXTEXT_CHARPOS* pCharPos,
+ int32_t iCount,
+ FX_FLOAT fFontSize,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL DrawBezier(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointF& pt1,
+ const CFX_PointF& pt2,
+ const CFX_PointF& pt3,
+ const CFX_PointF& pt4,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL DrawCurve(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointsF& points,
+ FX_BOOL bClosed,
+ FX_FLOAT fTension = 0.5f,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL DrawEllipse(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_RectF& rect,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL DrawLines(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointsF& points,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL DrawLine(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointF& pt1,
+ const CFX_PointF& pt2,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL DrawPath(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFDE_Path* pPath,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL DrawPolygon(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_PointsF& points,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL DrawRectangle(CFDE_Pen* pPen,
+ FX_FLOAT fPenWidth,
+ const CFX_RectF& rect,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL FillClosedCurve(CFDE_Brush* pBrush,
+ const CFX_PointsF& points,
+ FX_FLOAT fTension = 0.5f,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL FillEllipse(CFDE_Brush* pBrush,
+ const CFX_RectF& rect,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL FillPath(CFDE_Brush* pBrush,
+ const CFDE_Path* pPath,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL FillPolygon(CFDE_Brush* pBrush,
+ const CFX_PointsF& points,
+ const CFX_Matrix* pMatrix = NULL);
+ FX_BOOL FillRectangle(CFDE_Brush* pBrush,
+ const CFX_RectF& rect,
+ const CFX_Matrix* pMatrix = NULL);
+
+ FX_BOOL DrawSolidString(CFDE_Brush* pBrush,
IFX_Font* pFont,
const FXTEXT_CHARPOS* pCharPos,
int32_t iCount,
FX_FLOAT fFontSize,
const CFX_Matrix* pMatrix);
- FX_BOOL DrawStringPath(IFDE_Brush* pBrush,
+ FX_BOOL DrawStringPath(CFDE_Brush* pBrush,
IFX_Font* pFont,
const FXTEXT_CHARPOS* pCharPos,
int32_t iCount,
@@ -119,13 +115,10 @@ class CFDE_FxgeDevice : public IFDE_RenderDevice, public CFX_Target {
const CFX_Matrix* pMatrix);
protected:
- FX_BOOL CreatePen(IFDE_Pen* pPen,
+ FX_BOOL CreatePen(CFDE_Pen* pPen,
FX_FLOAT fPenWidth,
CFX_GraphStateData& graphState);
- FX_BOOL WrapTexture(int32_t iWrapMode,
- const CFX_DIBitmap* pBitmap,
- const CFX_PathData* pPath,
- const CFX_Matrix* pMatrix);
+
CFX_RenderDevice* m_pDevice;
CFX_RectF m_rtClip;
FX_BOOL m_bOwnerDevice;
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_geobject.h b/chromium/third_party/pdfium/xfa/fde/fde_geobject.h
deleted file mode 100644
index 11819154ab9..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_geobject.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FDE_FDE_GEOBJECT_H_
-#define XFA_FDE_FDE_GEOBJECT_H_
-
-#include "core/include/fxge/fx_ge.h"
-#include "xfa/fde/fde_path.h"
-#include "xfa/fgas/crt/fgas_memory.h"
-
-class CFDE_Path : public IFDE_Path, public CFX_Target {
- public:
- virtual void Release() { delete this; }
-
- virtual FX_BOOL StartFigure();
- virtual FX_BOOL CloseFigure();
-
- virtual void AddBezier(const CFX_PointsF& points);
- virtual void AddBeziers(const CFX_PointsF& points);
- virtual void AddCurve(const CFX_PointsF& points,
- FX_BOOL bClosed,
- FX_FLOAT fTension = 0.5f);
- virtual void AddEllipse(const CFX_RectF& rect);
- virtual void AddLines(const CFX_PointsF& points);
- virtual void AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2);
- virtual void AddPath(const IFDE_Path* pSrc, FX_BOOL bConnect);
- virtual void AddPolygon(const CFX_PointsF& points);
- virtual void AddRectangle(const CFX_RectF& rect);
- virtual void GetBBox(CFX_RectF& bbox) const;
- virtual void GetBBox(CFX_RectF& bbox,
- FX_FLOAT fLineWidth,
- FX_FLOAT fMiterLimit) const;
- FX_PATHPOINT* AddPoints(int32_t iCount);
- FX_PATHPOINT* GetLastPoint(int32_t iCount = 1) const;
- FX_BOOL FigureClosed() const;
- void MoveTo(FX_FLOAT fx, FX_FLOAT fy);
- void LineTo(FX_FLOAT fx, FX_FLOAT fy);
- void BezierTo(const CFX_PointF& p1,
- const CFX_PointF& p2,
- const CFX_PointF& p3);
- void ArcTo(FX_BOOL bStart,
- const CFX_RectF& rect,
- FX_FLOAT startAngle,
- FX_FLOAT endAngle);
- void MoveTo(const CFX_PointF& p0) { MoveTo(p0.x, p0.y); }
- void LineTo(const CFX_PointF& p1) { LineTo(p1.x, p1.y); }
- void GetCurveTangents(const CFX_PointsF& points,
- CFX_PointsF& tangents,
- FX_BOOL bClosed,
- FX_FLOAT fTension) const;
- CFX_PathData m_Path;
-};
-
-#endif // XFA_FDE_FDE_GEOBJECT_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_image.h b/chromium/third_party/pdfium/xfa/fde/fde_image.h
deleted file mode 100644
index 011f2323708..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_image.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FDE_FDE_IMAGE_H_
-#define XFA_FDE_FDE_IMAGE_H_
-
-#include "xfa/fgas/crt/fgas_memory.h"
-#include "xfa/fgas/crt/fgas_stream.h"
-#include "xfa/fgas/crt/fgas_utils.h"
-
-class IFDE_Image {
- public:
- virtual ~IFDE_Image() {}
- virtual void Release() = 0;
- virtual FX_BOOL LoadImage() = 0;
- virtual void FreeImage() = 0;
- virtual int32_t CountFrames() const = 0;
- virtual FX_BOOL LoadFrame(int32_t index) = 0;
- virtual CFX_DIBitmap* GetFrameImage() = 0;
- virtual int32_t GetImageFormat() const = 0;
- virtual int32_t GetImageWidth() const = 0;
- virtual int32_t GetImageHeight() const = 0;
- virtual int32_t GetDelayTime(int32_t iFrameIndex) const = 0;
- virtual int32_t GetLoopCount() const = 0;
- virtual FX_BOOL StartLoadImage(CFX_DIBitmap* pDIBitmap,
- int32_t dibX,
- int32_t dibY,
- int32_t dibCX,
- int32_t dibCY,
- int32_t imgX,
- int32_t imgY,
- int32_t imgCX,
- int32_t imgCY,
- int32_t iFrameIndex = 0) = 0;
- virtual int32_t DoLoadImage(IFX_Pause* pPause = NULL) = 0;
- virtual void StopLoadImage() = 0;
-};
-
-#endif // XFA_FDE_FDE_IMAGE_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_iterator.cpp b/chromium/third_party/pdfium/xfa/fde/fde_iterator.cpp
index 097be1d01f7..53d86e85201 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_iterator.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/fde_iterator.cpp
@@ -8,61 +8,65 @@
#include "xfa/fgas/crt/fgas_utils.h"
-IFDE_VisualSetIterator* IFDE_VisualSetIterator::Create() {
- return new CFDE_VisualSetIterator;
-}
CFDE_VisualSetIterator::CFDE_VisualSetIterator() : m_dwFilter(0) {}
+
CFDE_VisualSetIterator::~CFDE_VisualSetIterator() {
m_CanvasStack.RemoveAll();
}
+
FX_BOOL CFDE_VisualSetIterator::AttachCanvas(IFDE_CanvasSet* pCanvas) {
- FXSYS_assert(pCanvas != NULL);
+ ASSERT(pCanvas);
+
m_CanvasStack.RemoveAll();
FDE_CANVASITEM canvas;
- canvas.hCanvas = NULL;
+ canvas.hCanvas = nullptr;
canvas.pCanvas = pCanvas;
- canvas.hPos = pCanvas->GetFirstPosition(NULL);
- if (canvas.hPos == NULL) {
+ canvas.hPos = pCanvas->GetFirstPosition(nullptr);
+ if (!canvas.hPos)
return FALSE;
- }
+
return m_CanvasStack.Push(canvas) == 0;
}
+
FX_BOOL CFDE_VisualSetIterator::FilterObjects(uint32_t dwObjects) {
- if (m_CanvasStack.GetSize() == 0) {
+ if (m_CanvasStack.GetSize() == 0)
return FALSE;
- }
- while (m_CanvasStack.GetSize() > 1) {
+
+ while (m_CanvasStack.GetSize() > 1)
m_CanvasStack.Pop();
- }
- m_dwFilter = dwObjects & ~(uint32_t)FDE_VISUALOBJ_Widget;
- if (dwObjects & FDE_VISUALOBJ_Widget) {
- m_dwFilter |= 0xFF00;
- }
+
+ m_dwFilter = dwObjects;
+
FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement();
- FXSYS_assert(pCanvas != NULL && pCanvas->pCanvas != NULL);
- pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition(NULL);
- return pCanvas->hPos != NULL;
+ ASSERT(pCanvas && pCanvas->pCanvas);
+
+ pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition(nullptr);
+ return !!pCanvas->hPos;
}
+
void CFDE_VisualSetIterator::Reset() {
FilterObjects(m_dwFilter);
}
+
FDE_HVISUALOBJ CFDE_VisualSetIterator::GetNext(IFDE_VisualSet*& pVisualSet,
FDE_HVISUALOBJ* phCanvasObj,
IFDE_CanvasSet** ppCanvasSet) {
while (m_CanvasStack.GetSize() > 0) {
FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement();
- FXSYS_assert(pCanvas != NULL && pCanvas->pCanvas != NULL);
- if (pCanvas->hPos == NULL) {
- if (m_CanvasStack.GetSize() == 1) {
+ ASSERT(pCanvas && pCanvas->pCanvas);
+
+ if (!pCanvas->hPos) {
+ if (m_CanvasStack.GetSize() == 1)
break;
- }
+
m_CanvasStack.Pop();
continue;
}
do {
FDE_HVISUALOBJ hObj = pCanvas->pCanvas->GetNext(
pCanvas->hCanvas, pCanvas->hPos, pVisualSet);
- FXSYS_assert(hObj != NULL);
+ ASSERT(hObj);
+
FDE_VISUALOBJTYPE eType = pVisualSet->GetType();
if (eType == FDE_VISUALOBJ_Canvas) {
FDE_CANVASITEM canvas;
@@ -72,27 +76,21 @@ FDE_HVISUALOBJ CFDE_VisualSetIterator::GetNext(IFDE_VisualSet*& pVisualSet,
m_CanvasStack.Push(canvas);
break;
}
- uint32_t dwObj =
- (eType == FDE_VISUALOBJ_Widget)
- ? (uint32_t)((IFDE_WidgetSet*)pVisualSet)->GetWidgetType(hObj)
- : (uint32_t)eType;
+ uint32_t dwObj = (uint32_t)eType;
if ((m_dwFilter & dwObj) != 0) {
- if (ppCanvasSet) {
+ if (ppCanvasSet)
*ppCanvasSet = pCanvas->pCanvas;
- }
- if (phCanvasObj) {
+ if (phCanvasObj)
*phCanvasObj = pCanvas->hCanvas;
- }
return hObj;
}
- } while (pCanvas->hPos != NULL);
- }
- if (ppCanvasSet) {
- *ppCanvasSet = NULL;
+ } while (pCanvas->hPos);
}
- if (phCanvasObj) {
- *phCanvasObj = NULL;
- }
- pVisualSet = NULL;
- return NULL;
+ if (ppCanvasSet)
+ *ppCanvasSet = nullptr;
+ if (phCanvasObj)
+ *phCanvasObj = nullptr;
+
+ pVisualSet = nullptr;
+ return nullptr;
}
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_iterator.h b/chromium/third_party/pdfium/xfa/fde/fde_iterator.h
index 5a0e7566a0f..4f3fdf3f297 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_iterator.h
+++ b/chromium/third_party/pdfium/xfa/fde/fde_iterator.h
@@ -9,6 +9,7 @@
#include "xfa/fde/fde_visualset.h"
#include "xfa/fgas/crt/fgas_memory.h"
+#include "xfa/fgas/crt/fgas_utils.h"
struct FDE_CANVASITEM {
IFDE_CanvasSet* pCanvas;
@@ -16,20 +17,18 @@ struct FDE_CANVASITEM {
FX_POSITION hPos;
};
-class CFDE_VisualSetIterator : public IFDE_VisualSetIterator,
- public CFX_Target {
+class CFDE_VisualSetIterator : public CFX_Target {
public:
CFDE_VisualSetIterator();
- ~CFDE_VisualSetIterator();
- virtual void Release() { delete this; }
+ ~CFDE_VisualSetIterator() override;
- virtual FX_BOOL AttachCanvas(IFDE_CanvasSet* pCanvas);
- virtual FX_BOOL FilterObjects(uint32_t dwObjects = 0xFFFFFFFF);
+ FX_BOOL AttachCanvas(IFDE_CanvasSet* pCanvas);
+ FX_BOOL FilterObjects(uint32_t dwObjects = 0xFFFFFFFF);
- virtual void Reset();
- virtual FDE_HVISUALOBJ GetNext(IFDE_VisualSet*& pVisualSet,
- FDE_HVISUALOBJ* phCanvasObj = NULL,
- IFDE_CanvasSet** ppCanvasSet = NULL);
+ void Reset();
+ FDE_HVISUALOBJ GetNext(IFDE_VisualSet*& pVisualSet,
+ FDE_HVISUALOBJ* phCanvasObj = NULL,
+ IFDE_CanvasSet** ppCanvasSet = NULL);
protected:
uint32_t m_dwFilter;
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_object.cpp b/chromium/third_party/pdfium/xfa/fde/fde_object.cpp
deleted file mode 100644
index 92b9f8af1f9..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_object.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fde/fde_object.h"
-
-IFDE_Pen* IFDE_Pen::Create() {
- return new CFDE_Pen();
-}
-IFDE_Brush* IFDE_Brush::Create(int32_t iType) {
- switch (iType) {
- case FDE_BRUSHTYPE_Solid:
- return new CFDE_SolidBrush;
- case FDE_BRUSHTYPE_Hatch:
- return new CFDE_HatchBrush;
- case FDE_BRUSHTYPE_Texture:
- return new CFDE_TextureBrush;
- case FDE_BRUSHTYPE_LinearGradient:
- return new CFDE_LinearBrush;
- default:
- return NULL;
- }
-}
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_object.h b/chromium/third_party/pdfium/xfa/fde/fde_object.h
index ae7b95aa328..7df5de26385 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_object.h
+++ b/chromium/third_party/pdfium/xfa/fde/fde_object.h
@@ -9,238 +9,30 @@
#include <cstdint>
-#include "core/include/fxge/fx_dib.h"
-#include "xfa/fde/fde_brush.h"
-#include "xfa/fde/fde_pen.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fgas/crt/fgas_memory.h"
-class CFDE_Pen : public IFDE_Pen, public CFX_Target {
+class CFDE_Brush : public CFX_Target {
public:
- CFDE_Pen()
- : m_Color(0),
- m_iLineCap(0),
- m_iLineJoin(0),
- m_iDashStyle(0),
- m_fDashPhase(0),
- m_fMiterLimit(10),
- m_bAutoRelease(FALSE),
- m_pBrush(NULL) {}
+ CFDE_Brush() : m_Color(0xFF000000) {}
- ~CFDE_Pen() {
- if (m_pBrush && m_bAutoRelease) {
- m_pBrush->Release();
- }
- }
- virtual void Release() { delete this; }
-
- virtual int32_t GetType() const {
- return m_pBrush ? m_pBrush->GetType() : FDE_PENTYPE_SolidColor;
- }
-
- virtual FX_ARGB GetColor() const { return m_Color; }
- virtual void SetColor(FX_ARGB color) { m_Color = color; }
- virtual IFDE_Brush* GetBrush() const { return m_pBrush; }
- virtual void SetBrush(IFDE_Brush* pBrush, FX_BOOL bAutoRelease) {
- m_bAutoRelease = bAutoRelease;
- m_pBrush = pBrush;
- if (m_pBrush && m_pBrush->GetType() == FDE_BRUSHTYPE_Solid) {
- m_Color = ((IFDE_SolidBrush*)m_pBrush)->GetColor();
- }
- }
- virtual int32_t GetLineCap() const { return m_iLineCap; }
- virtual void SetLineCap(int32_t iLineCap) { m_iLineCap = iLineCap; }
- virtual int32_t GetDashStyle() const { return m_iDashStyle; }
- virtual void SetDashStyle(int32_t iDashStyle) { m_iDashStyle = iDashStyle; }
- virtual FX_FLOAT GetDashPhase() const { return m_fDashPhase; }
- virtual void SetDashPhase(FX_FLOAT fPhase) { m_fDashPhase = fPhase; }
- virtual int32_t CountDashArray() const { return m_DashArray.GetSize(); }
- virtual int32_t GetDashArray(CFX_FloatArray& dashArray) const {
- dashArray.Copy(m_DashArray);
- return dashArray.GetSize();
- }
- virtual void SetDashArray(const CFX_FloatArray& dashArray) {
- m_DashArray.Copy(dashArray);
- }
- virtual int32_t GetLineJoin() const { return m_iLineJoin; }
- virtual void SetLineJoin(int32_t iLineJoin) { m_iLineJoin = iLineJoin; }
- virtual FX_FLOAT GetMiterLimit() const { return m_fMiterLimit; }
- virtual void SetMiterLimit(FX_FLOAT fMiterLimit) {
- m_fMiterLimit = fMiterLimit;
- }
- virtual int32_t CountCompoundPatterns() const {
- return m_CompoundPatterns.GetSize();
- }
- virtual FX_BOOL GetCompoundPatterns(
- CFDE_CompoundPatterns& compoundPatterns) const {
- return compoundPatterns.Copy(m_CompoundPatterns), TRUE;
- }
- virtual FX_BOOL SetCompoundPatterns(
- const CFDE_CompoundPatterns& compoundPatterns) {
- return m_CompoundPatterns.Copy(compoundPatterns), TRUE;
- }
-
- FX_ARGB m_Color;
- int32_t m_iLineCap;
- int32_t m_iLineJoin;
- int32_t m_iDashStyle;
- FX_FLOAT m_fDashPhase;
- FX_FLOAT m_fMiterLimit;
- FX_BOOL m_bAutoRelease;
- IFDE_Brush* m_pBrush;
- CFX_FloatArray m_DashArray;
- CFDE_CompoundPatterns m_CompoundPatterns;
-};
-class CFDE_SolidBrush : public IFDE_SolidBrush, public CFX_Target {
- public:
- CFDE_SolidBrush() : m_Color(0xFF000000) { m_Matrix.SetIdentity(); }
-
- virtual void Release() { delete this; }
- virtual int32_t GetType() const { return FDE_BRUSHTYPE_Solid; }
- virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; }
- virtual void ResetMatrix() { m_Matrix.SetIdentity(); }
- virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) {
- m_Matrix.Translate(dx, dy);
- }
- virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); }
- virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); }
- virtual void ConcatMatrix(const CFX_Matrix& matrix) {
- m_Matrix.Concat(matrix);
- }
- virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
- virtual FX_ARGB GetColor() const { return m_Color; }
- virtual void SetColor(FX_ARGB color) { m_Color = color; }
+ FX_ARGB GetColor() const { return m_Color; }
+ void SetColor(FX_ARGB color) { m_Color = color; }
+ private:
FX_ARGB m_Color;
- CFX_Matrix m_Matrix;
};
-class CFDE_HatchBrush : public IFDE_HatchBrush, public CFX_Target {
- public:
- CFDE_HatchBrush() : m_iStyle(-1), m_BackColor(0), m_ForeColor(0) {
- m_Matrix.SetIdentity();
- }
-
- virtual void Release() { delete this; }
- virtual int32_t GetType() const { return FDE_BRUSHTYPE_Hatch; }
- virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; }
- virtual void ResetMatrix() { m_Matrix.SetIdentity(); }
- virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) {
- m_Matrix.Translate(dx, dy);
- }
- virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); }
- virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); }
- virtual void ConcatMatrix(const CFX_Matrix& matrix) {
- m_Matrix.Concat(matrix);
- }
- virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
- virtual FX_ARGB GetColor(FX_BOOL bForegroundColor) const {
- return bForegroundColor ? m_ForeColor : m_BackColor;
- }
- virtual void SetColor(FX_ARGB color, FX_BOOL bForegroundColor) {
- if (bForegroundColor) {
- m_ForeColor = color;
- } else {
- m_BackColor = color;
- }
- }
- virtual int32_t GetHatchStyle() const { return m_iStyle; }
- virtual FX_BOOL SetHatchStyle(int32_t iHatchStyle) {
- m_iStyle = iHatchStyle;
- return m_iStyle >= FDE_HATCHSTYLE_Min && m_iStyle <= FDE_HATCHSTYLE_Max;
- }
- int32_t m_iStyle;
- FX_ARGB m_BackColor;
- FX_ARGB m_ForeColor;
- CFX_Matrix m_Matrix;
-};
-class CFDE_TextureBrush : public IFDE_TextureBrush, public CFX_Target {
+class CFDE_Pen : public CFX_Target {
public:
- CFDE_TextureBrush() : m_iWrap(0), m_pImage(NULL), m_bAutoRelease(FALSE) {
- m_Matrix.SetIdentity();
- }
+ CFDE_Pen() : m_Color(0) {}
+ ~CFDE_Pen() {}
- virtual void Release() { delete this; }
- virtual int32_t GetType() const { return FDE_BRUSHTYPE_Texture; }
- virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; }
- virtual void ResetMatrix() { m_Matrix.SetIdentity(); }
- virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) {
- m_Matrix.Translate(dx, dy);
- }
- virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); }
- virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); }
- virtual void ConcatMatrix(const CFX_Matrix& matrix) {
- m_Matrix.Concat(matrix);
- }
- virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
- virtual IFDE_Image* GetImage() const { return m_pImage; }
- virtual void SetImage(IFDE_Image* pImage, FX_BOOL bAutoRelease) {
- m_pImage = pImage;
- m_bAutoRelease = bAutoRelease;
- }
- virtual int32_t GetWrapMode() const { return m_iWrap; }
- virtual void SetWrapMode(int32_t iWrapMode) { m_iWrap = iWrapMode; }
- int32_t m_iWrap;
- IFDE_Image* m_pImage;
- FX_BOOL m_bAutoRelease;
- CFX_Matrix m_Matrix;
-};
-class CFDE_LinearBrush : public IFDE_LinearGradientBrush, public CFX_Target {
- public:
- CFDE_LinearBrush() : m_EndColor(0), m_StartColor(0), m_iWrapMode(0) {
- m_StartPoint.x = m_StartPoint.y = m_EndPoint.x = m_EndPoint.y = 0;
- m_Matrix.SetIdentity();
- }
-
- virtual void Release() { delete this; }
- virtual int32_t GetType() const { return FDE_BRUSHTYPE_LinearGradient; }
- virtual const CFX_Matrix& GetMatrix() const { return m_Matrix; }
- virtual void ResetMatrix() { m_Matrix.SetIdentity(); }
- virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) {
- m_Matrix.Translate(dx, dy);
- }
- virtual void RotateMatrix(FX_FLOAT fRadian) { m_Matrix.Rotate(fRadian); }
- virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) { m_Matrix.Scale(sx, sy); }
- virtual void ConcatMatrix(const CFX_Matrix& matrix) {
- m_Matrix.Concat(matrix);
- }
- virtual void SetMatrix(const CFX_Matrix& matrix) { m_Matrix = matrix; }
- virtual void GetLinearPoints(CFX_PointF& startingPoint,
- CFX_PointF& endingPoint) const {
- startingPoint = m_StartPoint;
- endingPoint = m_EndPoint;
- }
- virtual void SetLinearPoints(const CFX_PointF& startingPoint,
- const CFX_PointF& endingPoint) {
- m_StartPoint = startingPoint;
- m_EndPoint = endingPoint;
- }
- virtual void GetLinearColors(FX_ARGB& startingColor,
- FX_ARGB& endingColor) const {
- startingColor = m_StartColor;
- endingColor = m_EndColor;
- }
- virtual void SetLinearColors(const FX_ARGB& startingColor,
- const FX_ARGB& endingColor) {
- m_StartColor = startingColor;
- m_EndColor = endingColor;
- }
- virtual int32_t CountGradientColors() const { return m_GradColors.GetSize(); }
- virtual FX_BOOL GetGradientColors(CFDE_GradientColors& colors) const {
- return colors.Copy(m_GradColors), TRUE;
- }
- virtual FX_BOOL SetGradientColors(const CFDE_GradientColors& colors) {
- return m_GradColors.Copy(colors), TRUE;
- }
+ FX_ARGB GetColor() const { return m_Color; }
+ void SetColor(FX_ARGB color) { m_Color = color; }
- virtual int32_t GetWrapMode() const { return m_iWrapMode; }
- virtual void SetWrapMode(int32_t iWrapMode) { m_iWrapMode = iWrapMode; }
- CFX_PointF m_EndPoint;
- CFX_PointF m_StartPoint;
- FX_ARGB m_EndColor;
- FX_ARGB m_StartColor;
- CFDE_GradientColors m_GradColors;
- int32_t m_iWrapMode;
- CFX_Matrix m_Matrix;
+ private:
+ FX_ARGB m_Color;
};
#endif // XFA_FDE_FDE_OBJECT_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_path.h b/chromium/third_party/pdfium/xfa/fde/fde_path.h
deleted file mode 100644
index 41d2a66e0ac..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_path.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FDE_FDE_PATH_H_
-#define XFA_FDE_FDE_PATH_H_
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class IFDE_Path {
- public:
- static IFDE_Path* Create();
- virtual ~IFDE_Path() {}
- virtual void Release() = 0;
- virtual FX_BOOL StartFigure() = 0;
- virtual FX_BOOL CloseFigure() = 0;
- virtual void AddBezier(const CFX_PointsF& points) = 0;
- virtual void AddBeziers(const CFX_PointsF& points) = 0;
- virtual void AddCurve(const CFX_PointsF& points,
- FX_BOOL bClosed,
- FX_FLOAT fTension = 0.5f) = 0;
- virtual void AddEllipse(const CFX_RectF& rect) = 0;
- virtual void AddLines(const CFX_PointsF& points) = 0;
- virtual void AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2) = 0;
- virtual void AddPath(const IFDE_Path* pSrc, FX_BOOL bConnect) = 0;
- virtual void AddPolygon(const CFX_PointsF& points) = 0;
- virtual void AddRectangle(const CFX_RectF& rect) = 0;
- virtual void GetBBox(CFX_RectF& bbox) const = 0;
- virtual void GetBBox(CFX_RectF& bbox,
- FX_FLOAT fLineWidth,
- FX_FLOAT fMiterLimit) const = 0;
-};
-
-#endif // XFA_FDE_FDE_PATH_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_pen.h b/chromium/third_party/pdfium/xfa/fde/fde_pen.h
deleted file mode 100644
index 4dfdd8ac22d..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_pen.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FDE_FDE_PEN_H_
-#define XFA_FDE_FDE_PEN_H_
-
-class IFDE_Pen;
-
-#define FDE_PENTYPE_Unknown FDE_BRUSHTYPE_Unknown
-#define FDE_PENTYPE_SolidColor FDE_BRUSHTYPE_Solid
-#define FDE_PENTYPE_HatchBrush FDE_BRUSHTYPE_Hatch
-#define FDE_PENTYPE_TextureBrush FDE_BRUSHTYPE_Texture
-#define FDE_PENTYPE_LinearGradient FDE_BRUSHTYPE_LinearGradient
-#define FDE_PENTYPE_MAX FDE_BRUSHTYPE_MAX
-
-#define FDE_DASHSTYLE_Solid 0
-#define FDE_DASHSTYLE_Dash 1
-#define FDE_DASHSTYLE_Dot 2
-#define FDE_DASHSTYLE_DashDot 3
-#define FDE_DASHSTYLE_DashDotDot 4
-#define FDE_DASHSTYLE_Customized 5
-
-#define FDE_LINEJOIN_Miter 0
-#define FDE_LINEJOIN_Round 1
-#define FDE_LINEJOIN_Bevel 2
-
-#define FDE_LINECAP_Flat 0
-#define FDE_LINECAP_Round 1
-#define FDE_LINECAP_Square 2
-
-struct FDE_COMPOUNDPATTERN {
- FX_FLOAT pos;
- FX_FLOAT width;
-};
-typedef CFX_ArrayTemplate<FDE_COMPOUNDPATTERN> CFDE_CompoundPatterns;
-
-class IFDE_Pen {
- public:
- static IFDE_Pen* Create();
- virtual ~IFDE_Pen() {}
- virtual void Release() = 0;
- virtual int32_t GetType() const = 0;
- virtual FX_ARGB GetColor() const = 0;
- virtual void SetColor(FX_ARGB color) = 0;
- virtual IFDE_Brush* GetBrush() const = 0;
- virtual void SetBrush(IFDE_Brush* pBrush, FX_BOOL bAutoRelease) = 0;
- virtual int32_t GetLineCap() const = 0;
- virtual void SetLineCap(int32_t iLineCap) = 0;
- virtual int32_t GetDashStyle() const = 0;
- virtual void SetDashStyle(int32_t iDashStyle) = 0;
- virtual FX_FLOAT GetDashPhase() const = 0;
- virtual void SetDashPhase(FX_FLOAT fPhase) = 0;
- virtual int32_t CountDashArray() const = 0;
- virtual int32_t GetDashArray(CFX_FloatArray& dashArray) const = 0;
- virtual void SetDashArray(const CFX_FloatArray& dashArray) = 0;
- virtual int32_t GetLineJoin() const = 0;
- virtual void SetLineJoin(int32_t iLineJoin) = 0;
- virtual FX_FLOAT GetMiterLimit() const = 0;
- virtual void SetMiterLimit(FX_FLOAT fMiterLimit) = 0;
- virtual int32_t CountCompoundPatterns() const = 0;
- virtual FX_BOOL GetCompoundPatterns(
- CFDE_CompoundPatterns& compoundPatterns) const = 0;
- virtual FX_BOOL SetCompoundPatterns(
- const CFDE_CompoundPatterns& compoundPatterns) = 0;
-};
-
-#endif // XFA_FDE_FDE_PEN_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_render.cpp b/chromium/third_party/pdfium/xfa/fde/fde_render.cpp
index 17bf20afbd2..074a851e9f0 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_render.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/fde_render.cpp
@@ -6,137 +6,51 @@
#include "xfa/fde/fde_render.h"
-#include "xfa/fde/fde_renderdevice.h"
+#include "xfa/fde/fde_gedevice.h"
+#include "xfa/fde/fde_object.h"
#include "xfa/fgas/crt/fgas_memory.h"
#define FDE_PATHRENDER_Stroke 1
#define FDE_PATHRENDER_Fill 2
-namespace {
-
-class CFDE_RenderContext : public IFDE_RenderContext, public CFX_Target {
- public:
- CFDE_RenderContext();
- virtual ~CFDE_RenderContext();
- virtual void Release() { delete this; }
- virtual FX_BOOL StartRender(IFDE_RenderDevice* pRenderDevice,
- IFDE_CanvasSet* pCanvasSet,
- const CFX_Matrix& tmDoc2Device);
- virtual FDE_RENDERSTATUS GetStatus() const { return m_eStatus; }
- virtual FDE_RENDERSTATUS DoRender(IFX_Pause* pPause = NULL);
- virtual void StopRender();
- void RenderPath(IFDE_PathSet* pPathSet, FDE_HVISUALOBJ hPath);
- void RenderText(IFDE_TextSet* pTextSet, FDE_HVISUALOBJ hText);
- FX_BOOL ApplyClip(IFDE_VisualSet* pVisualSet,
- FDE_HVISUALOBJ hObj,
- FDE_HDEVICESTATE& hState);
- void RestoreClip(FDE_HDEVICESTATE hState);
-
- protected:
- FDE_RENDERSTATUS m_eStatus;
- IFDE_RenderDevice* m_pRenderDevice;
- IFDE_SolidBrush* m_pSolidBrush;
- CFX_Matrix m_Transform;
- FXTEXT_CHARPOS* m_pCharPos;
- int32_t m_iCharPosCount;
- IFDE_VisualSetIterator* m_pIterator;
-};
-
-} // namespace
-
-void FDE_GetPageMatrix(CFX_Matrix& pageMatrix,
- const CFX_RectF& docPageRect,
- const CFX_Rect& devicePageRect,
- int32_t iRotate,
- uint32_t dwCoordinatesType) {
- FXSYS_assert(iRotate >= 0 && iRotate <= 3);
- FX_BOOL bFlipX = (dwCoordinatesType & 0x01) != 0;
- FX_BOOL bFlipY = (dwCoordinatesType & 0x02) != 0;
- CFX_Matrix m;
- m.Set((bFlipX ? -1.0f : 1.0f), 0, 0, (bFlipY ? -1.0f : 1.0f), 0, 0);
- if (iRotate == 0 || iRotate == 2) {
- m.a *= (FX_FLOAT)devicePageRect.width / docPageRect.width;
- m.d *= (FX_FLOAT)devicePageRect.height / docPageRect.height;
- } else {
- m.a *= (FX_FLOAT)devicePageRect.height / docPageRect.width;
- m.d *= (FX_FLOAT)devicePageRect.width / docPageRect.height;
- }
- m.Rotate(iRotate * 1.57079632675f);
- switch (iRotate) {
- case 0:
- m.e = bFlipX ? (FX_FLOAT)devicePageRect.right()
- : (FX_FLOAT)devicePageRect.left;
- m.f = bFlipY ? (FX_FLOAT)devicePageRect.bottom()
- : (FX_FLOAT)devicePageRect.top;
- break;
- case 1:
- m.e = bFlipY ? (FX_FLOAT)devicePageRect.left
- : (FX_FLOAT)devicePageRect.right();
- m.f = bFlipX ? (FX_FLOAT)devicePageRect.bottom()
- : (FX_FLOAT)devicePageRect.top;
- break;
- case 2:
- m.e = bFlipX ? (FX_FLOAT)devicePageRect.left
- : (FX_FLOAT)devicePageRect.right();
- m.f = bFlipY ? (FX_FLOAT)devicePageRect.top
- : (FX_FLOAT)devicePageRect.bottom();
- break;
- case 3:
- m.e = bFlipY ? (FX_FLOAT)devicePageRect.right()
- : (FX_FLOAT)devicePageRect.left;
- m.f = bFlipX ? (FX_FLOAT)devicePageRect.top
- : (FX_FLOAT)devicePageRect.bottom();
- break;
- default:
- break;
- }
- pageMatrix = m;
-}
-IFDE_RenderContext* IFDE_RenderContext::Create() {
- return new CFDE_RenderContext;
-}
CFDE_RenderContext::CFDE_RenderContext()
: m_eStatus(FDE_RENDERSTATUS_Reset),
- m_pRenderDevice(NULL),
- m_pSolidBrush(NULL),
+ m_pRenderDevice(nullptr),
m_Transform(),
- m_pCharPos(NULL),
- m_iCharPosCount(0),
- m_pIterator(NULL) {
+ m_pCharPos(nullptr),
+ m_iCharPosCount(0) {
m_Transform.SetIdentity();
}
+
CFDE_RenderContext::~CFDE_RenderContext() {
StopRender();
}
-FX_BOOL CFDE_RenderContext::StartRender(IFDE_RenderDevice* pRenderDevice,
+
+FX_BOOL CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice,
IFDE_CanvasSet* pCanvasSet,
const CFX_Matrix& tmDoc2Device) {
- if (m_pRenderDevice != NULL) {
+ if (m_pRenderDevice)
return FALSE;
- }
- if (pRenderDevice == NULL) {
+ if (!pRenderDevice)
return FALSE;
- }
- if (pCanvasSet == NULL) {
+ if (!pCanvasSet)
return FALSE;
- }
m_eStatus = FDE_RENDERSTATUS_Paused;
m_pRenderDevice = pRenderDevice;
m_Transform = tmDoc2Device;
- if (m_pIterator == NULL) {
- m_pIterator = IFDE_VisualSetIterator::Create();
- FXSYS_assert(m_pIterator != NULL);
- }
+ if (!m_pIterator)
+ m_pIterator.reset(new CFDE_VisualSetIterator);
+
return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
}
+
FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) {
- if (m_pRenderDevice == NULL) {
+ if (!m_pRenderDevice)
return FDE_RENDERSTATUS_Failed;
- }
- if (m_pIterator == NULL) {
+ if (!m_pIterator)
return FDE_RENDERSTATUS_Failed;
- }
+
FDE_RENDERSTATUS eStatus = FDE_RENDERSTATUS_Paused;
CFX_Matrix rm;
rm.SetReverse(m_Transform);
@@ -153,129 +67,88 @@ FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) {
int32_t iCount = 0;
while (TRUE) {
hVisualObj = m_pIterator->GetNext(pVisualSet);
- if (hVisualObj == NULL || pVisualSet == NULL) {
+ if (!hVisualObj || !pVisualSet) {
eStatus = FDE_RENDERSTATUS_Done;
break;
}
rtObj.Empty();
pVisualSet->GetRect(hVisualObj, rtObj);
- if (!rtDocClip.IntersectWith(rtObj)) {
+ if (!rtDocClip.IntersectWith(rtObj))
continue;
- }
+
switch (pVisualSet->GetType()) {
case FDE_VISUALOBJ_Text:
RenderText((IFDE_TextSet*)pVisualSet, hVisualObj);
iCount += 5;
break;
- case FDE_VISUALOBJ_Path:
- RenderPath((IFDE_PathSet*)pVisualSet, hVisualObj);
- iCount += 20;
- break;
- case FDE_VISUALOBJ_Widget:
- iCount += 10;
- break;
case FDE_VISUALOBJ_Canvas:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
default:
break;
}
- if (iCount >= 100 && pPause != NULL && pPause->NeedToPauseNow()) {
+ if (iCount >= 100 && pPause && pPause->NeedToPauseNow()) {
eStatus = FDE_RENDERSTATUS_Paused;
break;
}
}
return m_eStatus = eStatus;
}
+
void CFDE_RenderContext::StopRender() {
m_eStatus = FDE_RENDERSTATUS_Reset;
m_pRenderDevice = nullptr;
m_Transform.SetIdentity();
- if (m_pIterator) {
- m_pIterator->Release();
- m_pIterator = nullptr;
- }
- if (m_pSolidBrush) {
- m_pSolidBrush->Release();
- m_pSolidBrush = nullptr;
- }
+ m_pIterator.reset();
+ m_pBrush.reset();
FX_Free(m_pCharPos);
m_pCharPos = nullptr;
m_iCharPosCount = 0;
}
+
void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
FDE_HVISUALOBJ hText) {
- FXSYS_assert(m_pRenderDevice != NULL);
- FXSYS_assert(pTextSet != NULL && hText != NULL);
+ ASSERT(m_pRenderDevice);
+ ASSERT(pTextSet && hText);
+
IFX_Font* pFont = pTextSet->GetFont(hText);
- if (pFont == NULL) {
+ if (!pFont)
return;
- }
- int32_t iCount = pTextSet->GetDisplayPos(hText, NULL, FALSE);
- if (iCount < 1) {
+
+ int32_t iCount = pTextSet->GetDisplayPos(hText, nullptr, FALSE);
+ if (iCount < 1)
return;
- }
- if (m_pSolidBrush == NULL) {
- m_pSolidBrush = (IFDE_SolidBrush*)IFDE_Brush::Create(FDE_BRUSHTYPE_Solid);
- if (m_pSolidBrush == NULL) {
- return;
- }
- }
- if (m_pCharPos == NULL) {
+
+ if (!m_pBrush)
+ m_pBrush.reset(new CFDE_Brush);
+
+ if (!m_pCharPos)
m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount);
- } else if (m_iCharPosCount < iCount) {
+ else if (m_iCharPosCount < iCount)
m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iCount);
- }
- if (m_iCharPosCount < iCount) {
+
+ if (m_iCharPosCount < iCount)
m_iCharPosCount = iCount;
- }
+
iCount = pTextSet->GetDisplayPos(hText, m_pCharPos, FALSE);
FX_FLOAT fFontSize = pTextSet->GetFontSize(hText);
FX_ARGB dwColor = pTextSet->GetFontColor(hText);
- m_pSolidBrush->SetColor(dwColor);
+ m_pBrush->SetColor(dwColor);
FDE_HDEVICESTATE hState;
FX_BOOL bClip = ApplyClip(pTextSet, hText, hState);
- m_pRenderDevice->DrawString(m_pSolidBrush, pFont, m_pCharPos, iCount,
+ m_pRenderDevice->DrawString(m_pBrush.get(), pFont, m_pCharPos, iCount,
fFontSize, &m_Transform);
- if (bClip) {
+ if (bClip)
RestoreClip(hState);
- }
-}
-void CFDE_RenderContext::RenderPath(IFDE_PathSet* pPathSet,
- FDE_HVISUALOBJ hPath) {
- FXSYS_assert(m_pRenderDevice != NULL);
- FXSYS_assert(pPathSet != NULL && hPath != NULL);
- IFDE_Path* pPath = pPathSet->GetPath(hPath);
- if (pPath == NULL) {
- return;
- }
- FDE_HDEVICESTATE hState;
- FX_BOOL bClip = ApplyClip(pPathSet, hPath, hState);
- int32_t iRenderMode = pPathSet->GetRenderMode(hPath);
- if (iRenderMode & FDE_PATHRENDER_Stroke) {
- IFDE_Pen* pPen = pPathSet->GetPen(hPath);
- FX_FLOAT fWidth = pPathSet->GetPenWidth(hPath);
- if (pPen != NULL && fWidth > 0) {
- m_pRenderDevice->DrawPath(pPen, fWidth, pPath, &m_Transform);
- }
- }
- if (iRenderMode & FDE_PATHRENDER_Fill) {
- IFDE_Brush* pBrush = pPathSet->GetBrush(hPath);
- if (pBrush != NULL) {
- m_pRenderDevice->FillPath(pBrush, pPath, &m_Transform);
- }
- }
- if (bClip) {
- RestoreClip(hState);
- }
}
+
FX_BOOL CFDE_RenderContext::ApplyClip(IFDE_VisualSet* pVisualSet,
FDE_HVISUALOBJ hObj,
FDE_HDEVICESTATE& hState) {
CFX_RectF rtClip;
- if (!pVisualSet->GetClip(hObj, rtClip)) {
+ if (!pVisualSet->GetClip(hObj, rtClip))
return FALSE;
- }
+
CFX_RectF rtObj;
pVisualSet->GetRect(hObj, rtObj);
rtClip.Offset(rtObj.left, rtObj.top);
@@ -285,6 +158,7 @@ FX_BOOL CFDE_RenderContext::ApplyClip(IFDE_VisualSet* pVisualSet,
hState = m_pRenderDevice->SaveState();
return m_pRenderDevice->SetClipRect(rtClip);
}
+
void CFDE_RenderContext::RestoreClip(FDE_HDEVICESTATE hState) {
m_pRenderDevice->RestoreState(hState);
}
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_render.h b/chromium/third_party/pdfium/xfa/fde/fde_render.h
index 99e4bbe9638..1a80bce9265 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_render.h
+++ b/chromium/third_party/pdfium/xfa/fde/fde_render.h
@@ -7,16 +7,15 @@
#ifndef XFA_FDE_FDE_RENDER_H_
#define XFA_FDE_FDE_RENDER_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
+#include "xfa/fde/fde_gedevice.h"
+#include "xfa/fde/fde_iterator.h"
#include "xfa/fde/fde_visualset.h"
-class IFDE_RenderDevice;
+class CFDE_RenderDevice;
-void FDE_GetPageMatrix(CFX_Matrix& pageMatrix,
- const CFX_RectF& docPageRect,
- const CFX_Rect& devicePageRect,
- int32_t iRotate,
- uint32_t dwCoordinatesType = 0);
enum FDE_RENDERSTATUS {
FDE_RENDERSTATUS_Reset = 0,
FDE_RENDERSTATUS_Paused,
@@ -24,17 +23,31 @@ enum FDE_RENDERSTATUS {
FDE_RENDERSTATUS_Failed,
};
-class IFDE_RenderContext {
+class CFDE_RenderContext : public CFX_Target {
public:
- static IFDE_RenderContext* Create();
- virtual ~IFDE_RenderContext() {}
- virtual void Release() = 0;
- virtual FX_BOOL StartRender(IFDE_RenderDevice* pRenderDevice,
- IFDE_CanvasSet* pCanvasSet,
- const CFX_Matrix& tmDoc2Device) = 0;
- virtual FDE_RENDERSTATUS GetStatus() const = 0;
- virtual FDE_RENDERSTATUS DoRender(IFX_Pause* pPause = NULL) = 0;
- virtual void StopRender() = 0;
+ CFDE_RenderContext();
+ ~CFDE_RenderContext() override;
+
+ FX_BOOL StartRender(CFDE_RenderDevice* pRenderDevice,
+ IFDE_CanvasSet* pCanvasSet,
+ const CFX_Matrix& tmDoc2Device);
+ FDE_RENDERSTATUS GetStatus() const { return m_eStatus; }
+ FDE_RENDERSTATUS DoRender(IFX_Pause* pPause = nullptr);
+ void StopRender();
+ void RenderText(IFDE_TextSet* pTextSet, FDE_HVISUALOBJ hText);
+ FX_BOOL ApplyClip(IFDE_VisualSet* pVisualSet,
+ FDE_HVISUALOBJ hObj,
+ FDE_HDEVICESTATE& hState);
+ void RestoreClip(FDE_HDEVICESTATE hState);
+
+ protected:
+ FDE_RENDERSTATUS m_eStatus;
+ CFDE_RenderDevice* m_pRenderDevice;
+ CFX_Matrix m_Transform;
+ FXTEXT_CHARPOS* m_pCharPos;
+ int32_t m_iCharPosCount;
+ std::unique_ptr<CFDE_Brush> m_pBrush;
+ std::unique_ptr<CFDE_VisualSetIterator> m_pIterator;
};
#endif // XFA_FDE_FDE_RENDER_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_renderdevice.h b/chromium/third_party/pdfium/xfa/fde/fde_renderdevice.h
deleted file mode 100644
index 58da7759fac..00000000000
--- a/chromium/third_party/pdfium/xfa/fde/fde_renderdevice.h
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FDE_FDE_RENDERDEVICE_H_
-#define XFA_FDE_FDE_RENDERDEVICE_H_
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/include/fxge/fx_font.h"
-#include "core/include/fxge/fx_ge.h"
-#include "xfa/fde/fde_path.h"
-#include "xfa/fgas/font/fgas_font.h"
-
-class IFDE_Pen;
-class IFDE_Brush;
-class CFX_DIBitmap;
-class CFX_DIBSource;
-
-typedef struct FDE_HDEVICESTATE_ { void* pData; } * FDE_HDEVICESTATE;
-
-class IFDE_RenderDevice {
- public:
- static IFDE_RenderDevice* Create(CFX_DIBitmap* pBitmap,
- FX_BOOL bRgbByteOrder = FALSE);
- static IFDE_RenderDevice* Create(CFX_RenderDevice* pDevice);
- virtual ~IFDE_RenderDevice() {}
- virtual void Release() = 0;
-
- virtual int32_t GetWidth() const = 0;
- virtual int32_t GetHeight() const = 0;
- virtual FDE_HDEVICESTATE SaveState() = 0;
- virtual void RestoreState(FDE_HDEVICESTATE hState) = 0;
- virtual FX_BOOL SetClipPath(const IFDE_Path* pClip) = 0;
- virtual IFDE_Path* GetClipPath() const = 0;
- virtual FX_BOOL SetClipRect(const CFX_RectF& rtClip) = 0;
- virtual const CFX_RectF& GetClipRect() = 0;
-
- virtual FX_FLOAT GetDpiX() const = 0;
- virtual FX_FLOAT GetDpiY() const = 0;
-
- virtual FX_BOOL DrawImage(CFX_DIBSource* pDib,
- const CFX_RectF* pSrcRect,
- const CFX_RectF& dstRect,
- const CFX_Matrix* pImgMatrix = NULL,
- const CFX_Matrix* pDevMatrix = NULL) = 0;
- virtual FX_BOOL DrawString(IFDE_Brush* pBrush,
- IFX_Font* pFont,
- const FXTEXT_CHARPOS* pCharPos,
- int32_t iCount,
- FX_FLOAT fFontSize,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL DrawBezier(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointF& pt1,
- const CFX_PointF& pt2,
- const CFX_PointF& pt3,
- const CFX_PointF& pt4,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL DrawCurve(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- FX_BOOL bClosed,
- FX_FLOAT fTension = 0.5f,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL DrawEllipse(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL DrawLines(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL DrawLine(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointF& pt1,
- const CFX_PointF& pt2,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL DrawPath(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const IFDE_Path* pPath,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL DrawPolygon(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL DrawRectangle(IFDE_Pen* pPen,
- FX_FLOAT fPenWidth,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL FillClosedCurve(IFDE_Brush* pBrush,
- const CFX_PointsF& points,
- FX_FLOAT fTension = 0.5f,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL FillEllipse(IFDE_Brush* pBrush,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL FillPath(IFDE_Brush* pBrush,
- const IFDE_Path* pPath,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL FillPolygon(IFDE_Brush* pBrush,
- const CFX_PointsF& points,
- const CFX_Matrix* pMatrix = NULL) = 0;
- virtual FX_BOOL FillRectangle(IFDE_Brush* pBrush,
- const CFX_RectF& rect,
- const CFX_Matrix* pMatrix = NULL) = 0;
-};
-
-#endif // XFA_FDE_FDE_RENDERDEVICE_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/fde_visualset.h b/chromium/third_party/pdfium/xfa/fde/fde_visualset.h
index 5dc7f84cb76..64f98b9b232 100644
--- a/chromium/third_party/pdfium/xfa/fde/fde_visualset.h
+++ b/chromium/third_party/pdfium/xfa/fde/fde_visualset.h
@@ -9,20 +9,16 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
-#include "core/include/fxge/fx_ge.h"
-#include "xfa/fde/fde_brush.h"
-#include "xfa/fde/fde_image.h"
-#include "xfa/fde/fde_path.h"
-#include "xfa/fde/fde_pen.h"
+#include "core/fxge/include/fx_dib.h"
+#include "core/fxge/include/fx_ge.h"
+#include "xfa/fde/cfde_path.h"
+#include "xfa/fde/fde_object.h"
+#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/font/fgas_font.h"
enum FDE_VISUALOBJTYPE {
FDE_VISUALOBJ_Canvas = 0x00,
- FDE_VISUALOBJ_Text = 0x01,
- FDE_VISUALOBJ_Image = 0x02,
- FDE_VISUALOBJ_Path = 0x04,
- FDE_VISUALOBJ_Widget = 0x08,
+ FDE_VISUALOBJ_Text = 0x01
};
typedef struct FDE_HVISUALOBJ_ { void* pData; } const* FDE_HVISUALOBJ;
@@ -61,63 +57,4 @@ class IFDE_TextSet : public IFDE_VisualSet {
CFX_RectFArray& rtArray) = 0;
};
-struct FDE_IMAGEFILTERPARAMS : public CFX_Target {
- int32_t iFilterType;
-};
-
-class IFDE_ImageSet : public IFDE_VisualSet {
- public:
- virtual IFDE_Image* GetImage(FDE_HVISUALOBJ hImage) = 0;
- virtual FX_POSITION GetFirstFilterPosition(FDE_HVISUALOBJ hImage) = 0;
- virtual const FDE_IMAGEFILTERPARAMS* GetNextFilter(FDE_HVISUALOBJ hImage,
- FX_POSITION& pos) = 0;
-};
-
-class IFDE_PathSet : public IFDE_VisualSet {
- public:
- virtual IFDE_Path* GetPath(FDE_HVISUALOBJ hPath) = 0;
- virtual int32_t GetFillMode(FDE_HVISUALOBJ hPath) = 0;
- virtual int32_t GetRenderMode(FDE_HVISUALOBJ hPath) = 0;
- virtual IFDE_Pen* GetPen(FDE_HVISUALOBJ hPath) = 0;
- virtual FX_FLOAT GetPenWidth(FDE_HVISUALOBJ hPath) = 0;
- virtual IFDE_Brush* GetBrush(FDE_HVISUALOBJ hPath) = 0;
-};
-
-enum FDE_WIDGETOBJ {
- FDE_WIDGETOBJ_Unknown = 0x0000,
- FDE_WIDGETOBJ_Anchor = 0x0100,
- FDE_WIDGETOBJ_NamedDest = 0x0200,
- FDE_WIDGETOBJ_HyperLink = 0x0400,
-};
-
-class IFDE_WidgetSet : public IFDE_VisualSet {
- public:
- virtual FDE_WIDGETOBJ GetWidgetType(FDE_HVISUALOBJ hWidget) = 0;
- virtual FX_FLOAT GetFloat(FDE_HVISUALOBJ hWidget,
- int32_t iParameter,
- FX_FLOAT fDefVal = 0.0f) = 0;
- virtual int32_t GetInteger(FDE_HVISUALOBJ hWidget,
- int32_t iParameter,
- int32_t iDefVal = 0) = 0;
- virtual FX_BOOL GetString(FDE_HVISUALOBJ hWidget,
- int32_t iParameter,
- CFX_WideString& wsValue) = 0;
- virtual FX_BOOL GetRects(FDE_HVISUALOBJ hWidget,
- int32_t iParameter,
- CFX_RectFArray& rects) = 0;
-};
-
-class IFDE_VisualSetIterator {
- public:
- static IFDE_VisualSetIterator* Create();
- virtual ~IFDE_VisualSetIterator() {}
- virtual void Release() = 0;
- virtual FX_BOOL AttachCanvas(IFDE_CanvasSet* pCanvas) = 0;
- virtual FX_BOOL FilterObjects(uint32_t dwObjects = 0xFFFFFFFF) = 0;
- virtual void Reset() = 0;
- virtual FDE_HVISUALOBJ GetNext(IFDE_VisualSet*& pVisualSet,
- FDE_HVISUALOBJ* phCanvasObj = NULL,
- IFDE_CanvasSet** ppCanvasSet = NULL) = 0;
-};
-
#endif // XFA_FDE_FDE_VISUALSET_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/tto/fde_textout.cpp b/chromium/third_party/pdfium/xfa/fde/tto/fde_textout.cpp
index a0753c450e8..ca108de92c7 100644
--- a/chromium/third_party/pdfium/xfa/fde/tto/fde_textout.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/tto/fde_textout.cpp
@@ -10,181 +10,13 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fde/fde_brush.h"
-#include "xfa/fde/fde_pen.h"
-#include "xfa/fde/fde_renderdevice.h"
+#include "xfa/fde/cfde_path.h"
+#include "xfa/fde/fde_gedevice.h"
+#include "xfa/fde/fde_object.h"
#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/layout/fgas_textbreak.h"
-namespace {
-
-struct FDE_TTOPIECE {
- public:
- int32_t iStartChar;
- int32_t iChars;
- uint32_t dwCharStyles;
- CFX_RectF rtPiece;
-};
-typedef FDE_TTOPIECE* FDE_LPTTOPIECE;
-typedef CFX_MassArrayTemplate<FDE_TTOPIECE> CFDE_TTOPieceArray;
-
-class CFDE_TTOLine : public CFX_Target {
- public:
- CFDE_TTOLine();
- CFDE_TTOLine(const CFDE_TTOLine& ttoLine);
- ~CFDE_TTOLine();
- int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece);
- int32_t GetSize() const;
- FDE_LPTTOPIECE GetPtrAt(int32_t index);
- void RemoveLast(int32_t iCount);
- void RemoveAll(FX_BOOL bLeaveMemory);
- FX_BOOL m_bNewReload;
- CFDE_TTOPieceArray m_pieces;
-
- protected:
- int32_t m_iPieceCount;
-};
-typedef CFX_ObjectMassArrayTemplate<CFDE_TTOLine> CFDE_TTOLineArray;
-
-class CFDE_TextOut : public IFDE_TextOut, public CFX_Target {
- public:
- CFDE_TextOut();
- ~CFDE_TextOut();
- virtual void Release() { delete this; }
- virtual void SetFont(IFX_Font* pFont);
- virtual void SetFontSize(FX_FLOAT fFontSize);
- virtual void SetTextColor(FX_ARGB color);
- virtual void SetStyles(uint32_t dwStyles);
- virtual void SetTabWidth(FX_FLOAT fTabWidth);
- virtual void SetEllipsisString(const CFX_WideString& wsEllipsis);
- virtual void SetParagraphBreakChar(FX_WCHAR wch);
- virtual void SetAlignment(int32_t iAlignment);
- virtual void SetLineSpace(FX_FLOAT fLineSpace);
- virtual void SetDIBitmap(CFX_DIBitmap* pDIB);
- virtual void SetRenderDevice(CFX_RenderDevice* pDevice);
- virtual void SetClipRect(const CFX_Rect& rtClip);
- virtual void SetClipRect(const CFX_RectF& rtClip);
- virtual void SetMatrix(const CFX_Matrix& matrix);
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance);
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_Size& size);
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_SizeF& size);
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_Rect& rect);
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_RectF& rect);
-
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- int32_t x,
- int32_t y);
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- FX_FLOAT x,
- FX_FLOAT y);
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_Rect& rect);
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_RectF& rect);
-
- virtual void SetLogicClipRect(const CFX_RectF& rtClip);
- virtual void CalcLogicSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_SizeF& size);
- virtual void CalcLogicSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_RectF& rect);
- virtual void DrawLogicText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- FX_FLOAT x,
- FX_FLOAT y);
- virtual void DrawLogicText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_RectF& rect);
- virtual int32_t GetTotalLines();
-
- protected:
- void CalcTextSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect);
- FX_BOOL RetrieveLineWidth(uint32_t dwBreakStatus,
- FX_FLOAT& fStartPos,
- FX_FLOAT& fWidth,
- FX_FLOAT& fHeight);
- void SetLineWidth(CFX_RectF& rect);
- void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_RectF& rect,
- const CFX_RectF& rtClip);
- void LoadText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect);
- void LoadEllipsis();
- void ExpandBuffer(int32_t iSize, int32_t iType);
- void RetrieveEllPieces(int32_t*& pCharWidths);
-
- void Reload(const CFX_RectF& rect);
- void ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect);
- FX_BOOL RetriecePieces(uint32_t dwBreakStatus,
- int32_t& iStartChar,
- int32_t& iPieceWidths,
- FX_BOOL bReload,
- const CFX_RectF& rect);
- void AppendPiece(const FDE_TTOPIECE& ttoPiece,
- FX_BOOL bNeedReload,
- FX_BOOL bEnd);
- void ReplaceWidthEllipsis();
- void DoAlignment(const CFX_RectF& rect);
- void OnDraw(const CFX_RectF& rtClip);
- int32_t GetDisplayPos(FDE_LPTTOPIECE pPiece);
- int32_t GetCharRects(FDE_LPTTOPIECE pPiece);
-
- void ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr);
- void DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen);
-
- IFX_TxtBreak* m_pTxtBreak;
- IFX_Font* m_pFont;
- FX_FLOAT m_fFontSize;
- FX_FLOAT m_fLineSpace;
- FX_FLOAT m_fLinePos;
- FX_FLOAT m_fTolerance;
- int32_t m_iAlignment;
- int32_t m_iTxtBkAlignment;
- int32_t* m_pCharWidths;
- int32_t m_iChars;
- int32_t* m_pEllCharWidths;
- int32_t m_iEllChars;
- FX_WCHAR m_wParagraphBkChar;
- FX_ARGB m_TxtColor;
- uint32_t m_dwStyles;
- uint32_t m_dwTxtBkStyles;
- CFX_WideString m_wsEllipsis;
- FX_BOOL m_bElliChanged;
- int32_t m_iEllipsisWidth;
- CFX_WideString m_wsText;
- CFX_RectF m_rtClip;
- CFX_RectF m_rtLogicClip;
- CFX_Matrix m_Matrix;
- CFDE_TTOLineArray m_ttoLines;
- int32_t m_iCurLine;
- int32_t m_iCurPiece;
- int32_t m_iTotalLines;
- FXTEXT_CHARPOS* m_pCharPos;
- int32_t m_iCharPosSize;
- IFDE_RenderDevice* m_pRenderDevice;
- CFX_Int32Array m_hotKeys;
- CFX_RectFArray m_rectArray;
-};
-
-} // namespace
-
-IFDE_TextOut* IFDE_TextOut::Create() {
- return new CFDE_TextOut;
-}
CFDE_TextOut::CFDE_TextOut()
: m_pFont(NULL),
m_fFontSize(12.0f),
@@ -208,10 +40,8 @@ CFDE_TextOut::CFDE_TextOut()
m_iCurPiece(0),
m_iTotalLines(0),
m_pCharPos(NULL),
- m_iCharPosSize(0),
- m_pRenderDevice(NULL) {
- m_pTxtBreak = IFX_TxtBreak::Create(FX_TXTBREAKPOLICY_None);
- FXSYS_assert(m_pTxtBreak != NULL);
+ m_iCharPosSize(0) {
+ m_pTxtBreak = new CFX_TxtBreak(FX_TXTBREAKPOLICY_None);
m_Matrix.SetIdentity();
m_rtClip.Reset();
m_rtLogicClip.Reset();
@@ -222,19 +52,16 @@ CFDE_TextOut::~CFDE_TextOut() {
}
FX_Free(m_pCharWidths);
FX_Free(m_pEllCharWidths);
- if (m_pRenderDevice) {
- m_pRenderDevice->Release();
- }
FX_Free(m_pCharPos);
m_ttoLines.RemoveAll();
}
void CFDE_TextOut::SetFont(IFX_Font* pFont) {
- FXSYS_assert(pFont);
+ ASSERT(pFont);
m_pFont = pFont;
m_pTxtBreak->SetFont(pFont);
}
void CFDE_TextOut::SetFontSize(FX_FLOAT fFontSize) {
- FXSYS_assert(fFontSize > 0);
+ ASSERT(fFontSize > 0);
m_fFontSize = fFontSize;
m_pTxtBreak->SetFontSize(fFontSize);
}
@@ -266,7 +93,7 @@ void CFDE_TextOut::SetStyles(uint32_t dwStyles) {
m_pTxtBreak->SetLayoutStyles(m_dwTxtBkStyles);
}
void CFDE_TextOut::SetTabWidth(FX_FLOAT fTabWidth) {
- FXSYS_assert(fTabWidth > 1.0f);
+ ASSERT(fTabWidth > 1.0f);
m_pTxtBreak->SetTabWidth(fTabWidth, FALSE);
}
void CFDE_TextOut::SetEllipsisString(const CFX_WideString& wsEllipsis) {
@@ -297,23 +124,23 @@ void CFDE_TextOut::SetAlignment(int32_t iAlignment) {
m_pTxtBreak->SetAlignment(m_iTxtBkAlignment);
}
void CFDE_TextOut::SetLineSpace(FX_FLOAT fLineSpace) {
- FXSYS_assert(fLineSpace > 1.0f);
+ ASSERT(fLineSpace > 1.0f);
m_fLineSpace = fLineSpace;
}
void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) {
- FXSYS_assert(pDIB != NULL);
- if (m_pRenderDevice != NULL) {
- m_pRenderDevice->Release();
- }
- m_pRenderDevice = IFDE_RenderDevice::Create(pDIB);
+ ASSERT(pDIB);
+
+ m_pRenderDevice.reset();
+ CFX_FxgeDevice* device = new CFX_FxgeDevice;
+ device->Attach(pDIB, 0, FALSE);
+ m_pRenderDevice.reset(new CFDE_RenderDevice(device, FALSE));
}
+
void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
- FXSYS_assert(pDevice != NULL);
- if (m_pRenderDevice != NULL) {
- m_pRenderDevice->Release();
- }
- m_pRenderDevice = IFDE_RenderDevice::Create(pDevice);
+ ASSERT(pDevice);
+ m_pRenderDevice.reset(new CFDE_RenderDevice(pDevice, FALSE));
}
+
void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {
m_rtClip.Set((FX_FLOAT)rtClip.left, (FX_FLOAT)rtClip.top,
(FX_FLOAT)rtClip.Width(), (FX_FLOAT)rtClip.Height());
@@ -398,7 +225,7 @@ void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr,
void CFDE_TextOut::CalcTextSize(const FX_WCHAR* pwsStr,
int32_t iLength,
CFX_RectF& rect) {
- FXSYS_assert(m_pFont != NULL && m_fFontSize >= 1.0f);
+ ASSERT(m_pFont != NULL && m_fFontSize >= 1.0f);
SetLineWidth(rect);
m_iTotalLines = 0;
const FX_WCHAR* pStr = pwsStr;
@@ -560,7 +387,7 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
int32_t iLength,
const CFX_RectF& rect,
const CFX_RectF& rtClip) {
- FXSYS_assert(m_pFont != NULL && m_fFontSize >= 1.0f);
+ ASSERT(m_pFont != NULL && m_fFontSize >= 1.0f);
if (pwsStr == NULL || iLength < 1) {
return;
}
@@ -573,7 +400,7 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr,
}
m_pTxtBreak->SetLineWidth(fLineWidth);
m_ttoLines.RemoveAll(TRUE);
- m_wsText.Empty();
+ m_wsText.clear();
LoadText(pwsStr, iLength, rect);
if (m_dwStyles & FDE_TTOSTYLE_Ellipsis) {
ReplaceWidthEllipsis();
@@ -626,7 +453,7 @@ void CFDE_TextOut::LoadEllipsis() {
return;
}
ExpandBuffer(iLength, 1);
- const FX_WCHAR* pStr = (const FX_WCHAR*)m_wsEllipsis;
+ const FX_WCHAR* pStr = m_wsEllipsis.c_str();
int32_t* pCharWidths = m_pEllCharWidths;
uint32_t dwBreakStatus;
FX_WCHAR wch;
@@ -836,7 +663,7 @@ void CFDE_TextOut::ReplaceWidthEllipsis() {
int32_t iCharCount = 0;
int32_t iPiece = pLine->GetSize();
while (iPiece-- > 0) {
- FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(iPiece);
+ FDE_TTOPIECE* pPiece = pLine->GetPtrAt(iPiece);
if (pPiece == NULL) {
break;
}
@@ -875,10 +702,10 @@ void CFDE_TextOut::Reload(const CFX_RectF& rect) {
}
}
void CFDE_TextOut::ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect) {
- const FX_WCHAR* pwsStr = (const FX_WCHAR*)m_wsText;
+ const FX_WCHAR* pwsStr = m_wsText.c_str();
FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
int32_t iPieceWidths = 0;
- FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(0);
+ FDE_TTOPIECE* pPiece = pLine->GetPtrAt(0);
int32_t iStartChar = pPiece->iStartChar;
m_fLinePos = bVertical ? pPiece->rtPiece.left : pPiece->rtPiece.top;
int32_t iPieceCount = pLine->GetSize();
@@ -913,7 +740,7 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
return;
}
CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iLines - 1);
- FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(0);
+ FDE_TTOPIECE* pPiece = pLine->GetPtrAt(0);
if (pPiece == NULL) {
return;
}
@@ -933,7 +760,7 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i);
int32_t iPieces = pLine->GetSize();
for (int32_t j = 0; j < iPieces; j++) {
- FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(j);
+ FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j);
if (bVertical) {
pPiece->rtPiece.left += fInc;
} else {
@@ -943,17 +770,16 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
}
}
void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
- if (m_pRenderDevice == NULL) {
+ if (!m_pRenderDevice)
return;
- }
+
int32_t iLines = m_ttoLines.GetSize();
- if (iLines < 1) {
+ if (iLines < 1)
return;
- }
- IFDE_SolidBrush* pBrush =
- (IFDE_SolidBrush*)IFDE_Brush::Create(FDE_BRUSHTYPE_Solid);
+
+ CFDE_Brush* pBrush = new CFDE_Brush;
pBrush->SetColor(m_TxtColor);
- IFDE_Pen* pPen = NULL;
+ CFDE_Pen* pPen = NULL;
FDE_HDEVICESTATE hDev = m_pRenderDevice->SaveState();
if (rtClip.Width() > 0.0f && rtClip.Height() > 0.0f) {
m_pRenderDevice->SetClipRect(rtClip);
@@ -962,7 +788,7 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i);
int32_t iPieces = pLine->GetSize();
for (int32_t j = 0; j < iPieces; j++) {
- FDE_LPTTOPIECE pPiece = pLine->GetPtrAt(j);
+ FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j);
if (pPiece == NULL) {
continue;
}
@@ -975,52 +801,49 @@ void CFDE_TextOut::OnDraw(const CFX_RectF& rtClip) {
}
}
m_pRenderDevice->RestoreState(hDev);
- if (pBrush) {
- pBrush->Release();
- }
- if (pPen) {
- pPen->Release();
- }
+ delete pBrush;
+ delete pPen;
}
-int32_t CFDE_TextOut::GetDisplayPos(FDE_LPTTOPIECE pPiece) {
- FX_TXTRUN tr;
- ToTextRun(pPiece, tr);
+
+int32_t CFDE_TextOut::GetDisplayPos(FDE_TTOPIECE* pPiece) {
+ FX_TXTRUN tr = ToTextRun(pPiece);
ExpandBuffer(tr.iLength, 2);
return m_pTxtBreak->GetDisplayPos(&tr, m_pCharPos);
}
-int32_t CFDE_TextOut::GetCharRects(FDE_LPTTOPIECE pPiece) {
- FX_TXTRUN tr;
- ToTextRun(pPiece, tr);
+
+int32_t CFDE_TextOut::GetCharRects(const FDE_TTOPIECE* pPiece) {
+ FX_TXTRUN tr = ToTextRun(pPiece);
m_rectArray.RemoveAll();
return m_pTxtBreak->GetCharRects(&tr, m_rectArray);
}
-void CFDE_TextOut::ToTextRun(const FDE_LPTTOPIECE pPiece, FX_TXTRUN& tr) {
- tr.pAccess = NULL;
- tr.pIdentity = NULL;
- tr.pStr = (const FX_WCHAR*)m_wsText + pPiece->iStartChar;
+
+FX_TXTRUN CFDE_TextOut::ToTextRun(const FDE_TTOPIECE* pPiece) {
+ FX_TXTRUN tr;
+ tr.wsStr = m_wsText + pPiece->iStartChar;
tr.pWidths = m_pCharWidths + pPiece->iStartChar;
tr.iLength = pPiece->iChars;
tr.pFont = m_pFont;
tr.fFontSize = m_fFontSize;
tr.dwStyles = m_dwTxtBkStyles;
- tr.iCharRotation = 0;
tr.dwCharStyles = pPiece->dwCharStyles;
tr.wLineBreakChar = m_wParagraphBkChar;
tr.pRect = &pPiece->rtPiece;
+ return tr;
}
-void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen) {
+
+void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen) {
FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline);
FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout);
FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey);
FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
- if (!bUnderLine && !bStrikeOut && !bHotKey) {
+ if (!bUnderLine && !bStrikeOut && !bHotKey)
return;
- }
- if (pPen == NULL) {
- pPen = IFDE_Pen::Create();
+
+ if (!pPen) {
+ pPen = new CFDE_Pen;
pPen->SetColor(m_TxtColor);
}
- IFDE_Path* pPath = IFDE_Path::Create();
+ std::unique_ptr<CFDE_Path> pPath(new CFDE_Path);
int32_t iLineCount = 0;
CFX_RectF rtText = pPiece->rtPiece;
CFX_PointF pt1, pt2;
@@ -1080,19 +903,21 @@ void CFDE_TextOut::DrawLine(const FDE_LPTTOPIECE pPiece, IFDE_Pen*& pPen) {
}
}
}
- if (iLineCount > 0) {
- m_pRenderDevice->DrawPath(pPen, 1, pPath, &m_Matrix);
- }
- pPath->Release();
+ if (iLineCount > 0)
+ m_pRenderDevice->DrawPath(pPen, 1, pPath.get(), &m_Matrix);
}
+
CFDE_TTOLine::CFDE_TTOLine()
: m_bNewReload(FALSE), m_pieces(5), m_iPieceCount(0) {}
+
CFDE_TTOLine::CFDE_TTOLine(const CFDE_TTOLine& ttoLine) : m_pieces(5) {
m_bNewReload = ttoLine.m_bNewReload;
m_iPieceCount = ttoLine.m_iPieceCount;
m_pieces.Copy(ttoLine.m_pieces);
}
+
CFDE_TTOLine::~CFDE_TTOLine() {}
+
int32_t CFDE_TTOLine::AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece) {
if (index >= m_iPieceCount) {
index = m_pieces.Add(ttoPiece) + 1;
@@ -1106,7 +931,7 @@ int32_t CFDE_TTOLine::AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece) {
int32_t CFDE_TTOLine::GetSize() const {
return m_iPieceCount;
}
-FDE_LPTTOPIECE CFDE_TTOLine::GetPtrAt(int32_t index) {
+FDE_TTOPIECE* CFDE_TTOLine::GetPtrAt(int32_t index) {
if (index >= m_iPieceCount) {
return NULL;
}
diff --git a/chromium/third_party/pdfium/xfa/fde/tto/fde_textout.h b/chromium/third_party/pdfium/xfa/fde/tto/fde_textout.h
index 159850e0f2e..91f03e8d9b8 100644
--- a/chromium/third_party/pdfium/xfa/fde/tto/fde_textout.h
+++ b/chromium/third_party/pdfium/xfa/fde/tto/fde_textout.h
@@ -7,9 +7,14 @@
#ifndef XFA_FDE_TTO_FDE_TEXTOUT_H_
#define XFA_FDE_TTO_FDE_TEXTOUT_H_
-#include "core/include/fxge/fx_dib.h"
-#include "core/include/fxge/fx_ge.h"
+#include <memory>
+
+#include "core/fxge/include/fx_dib.h"
+#include "core/fxge/include/fx_ge.h"
+#include "xfa/fde/fde_object.h"
+#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/layout/fgas_textbreak.h"
#define FDE_TTOSTYLE_Underline 0x0001
#define FDE_TTOSTYLE_Strikeout 0x0002
@@ -36,67 +41,148 @@
#define FDE_TTOALIGNMENT_BottomRight 10
#define FDE_TTOALIGNMENT_BottomAuto 11
-class IFDE_TextOut {
+class CFDE_RenderDevice;
+class CFX_TxtBreak;
+
+struct FDE_TTOPIECE {
+ int32_t iStartChar;
+ int32_t iChars;
+ uint32_t dwCharStyles;
+ CFX_RectF rtPiece;
+};
+typedef CFX_MassArrayTemplate<FDE_TTOPIECE> CFDE_TTOPieceArray;
+
+class CFDE_TTOLine : public CFX_Target {
+ public:
+ CFDE_TTOLine();
+ CFDE_TTOLine(const CFDE_TTOLine& ttoLine);
+ ~CFDE_TTOLine();
+ int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece);
+ int32_t GetSize() const;
+ FDE_TTOPIECE* GetPtrAt(int32_t index);
+ void RemoveLast(int32_t iCount);
+ void RemoveAll(FX_BOOL bLeaveMemory);
+
+ FX_BOOL m_bNewReload;
+ CFDE_TTOPieceArray m_pieces;
+
+ protected:
+ int32_t m_iPieceCount;
+};
+typedef CFX_ObjectMassArrayTemplate<CFDE_TTOLine> CFDE_TTOLineArray;
+
+class CFDE_TextOut : public CFX_Target {
public:
- static IFDE_TextOut* Create();
- virtual ~IFDE_TextOut() {}
- virtual void Release() = 0;
- virtual void SetFont(IFX_Font* pFont) = 0;
- virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
- virtual void SetTextColor(FX_ARGB color) = 0;
- virtual void SetStyles(uint32_t dwStyles) = 0;
- virtual void SetTabWidth(FX_FLOAT fTabWidth) = 0;
- virtual void SetEllipsisString(const CFX_WideString& wsEllipsis) = 0;
- virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0;
- virtual void SetAlignment(int32_t iAlignment) = 0;
- virtual void SetLineSpace(FX_FLOAT fLineSpace) = 0;
- virtual void SetDIBitmap(CFX_DIBitmap* pDIB) = 0;
- virtual void SetRenderDevice(CFX_RenderDevice* pDevice) = 0;
- virtual void SetClipRect(const CFX_Rect& rtClip) = 0;
- virtual void SetClipRect(const CFX_RectF& rtClip) = 0;
- virtual void SetMatrix(const CFX_Matrix& matrix) = 0;
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_Size& size) = 0;
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_SizeF& size) = 0;
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_Rect& rect) = 0;
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_RectF& rect) = 0;
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- int32_t x,
- int32_t y) = 0;
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- FX_FLOAT x,
- FX_FLOAT y) = 0;
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_Rect& rect) = 0;
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_RectF& rect) = 0;
- virtual void SetLogicClipRect(const CFX_RectF& rtClip) = 0;
- virtual void CalcLogicSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_SizeF& size) = 0;
- virtual void CalcLogicSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_RectF& rect) = 0;
- virtual void DrawLogicText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- FX_FLOAT x,
- FX_FLOAT y) = 0;
- virtual void DrawLogicText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_RectF& rect) = 0;
- virtual int32_t GetTotalLines() = 0;
+ CFDE_TextOut();
+ ~CFDE_TextOut() override;
+
+ void SetFont(IFX_Font* pFont);
+ void SetFontSize(FX_FLOAT fFontSize);
+ void SetTextColor(FX_ARGB color);
+ void SetStyles(uint32_t dwStyles);
+ void SetTabWidth(FX_FLOAT fTabWidth);
+ void SetEllipsisString(const CFX_WideString& wsEllipsis);
+ void SetParagraphBreakChar(FX_WCHAR wch);
+ void SetAlignment(int32_t iAlignment);
+ void SetLineSpace(FX_FLOAT fLineSpace);
+ void SetDIBitmap(CFX_DIBitmap* pDIB);
+ void SetRenderDevice(CFX_RenderDevice* pDevice);
+ void SetClipRect(const CFX_Rect& rtClip);
+ void SetClipRect(const CFX_RectF& rtClip);
+ void SetMatrix(const CFX_Matrix& matrix);
+ void SetLineBreakTolerance(FX_FLOAT fTolerance);
+ void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Size& size);
+ void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size);
+ void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Rect& rect);
+ void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect);
+
+ void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, int32_t x, int32_t y);
+ void DrawText(const FX_WCHAR* pwsStr,
+ int32_t iLength,
+ FX_FLOAT x,
+ FX_FLOAT y);
+ void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_Rect& rect);
+ void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect);
+
+ void SetLogicClipRect(const CFX_RectF& rtClip);
+ void CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size);
+ void CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect);
+ void DrawLogicText(const FX_WCHAR* pwsStr,
+ int32_t iLength,
+ FX_FLOAT x,
+ FX_FLOAT y);
+ void DrawLogicText(const FX_WCHAR* pwsStr,
+ int32_t iLength,
+ const CFX_RectF& rect);
+ int32_t GetTotalLines();
+
+ protected:
+ void CalcTextSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect);
+ FX_BOOL RetrieveLineWidth(uint32_t dwBreakStatus,
+ FX_FLOAT& fStartPos,
+ FX_FLOAT& fWidth,
+ FX_FLOAT& fHeight);
+ void SetLineWidth(CFX_RectF& rect);
+ void DrawText(const FX_WCHAR* pwsStr,
+ int32_t iLength,
+ const CFX_RectF& rect,
+ const CFX_RectF& rtClip);
+ void LoadText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect);
+ void LoadEllipsis();
+ void ExpandBuffer(int32_t iSize, int32_t iType);
+ void RetrieveEllPieces(int32_t*& pCharWidths);
+
+ void Reload(const CFX_RectF& rect);
+ void ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect);
+ FX_BOOL RetriecePieces(uint32_t dwBreakStatus,
+ int32_t& iStartChar,
+ int32_t& iPieceWidths,
+ FX_BOOL bReload,
+ const CFX_RectF& rect);
+ void AppendPiece(const FDE_TTOPIECE& ttoPiece,
+ FX_BOOL bNeedReload,
+ FX_BOOL bEnd);
+ void ReplaceWidthEllipsis();
+ void DoAlignment(const CFX_RectF& rect);
+ void OnDraw(const CFX_RectF& rtClip);
+ int32_t GetDisplayPos(FDE_TTOPIECE* pPiece);
+ int32_t GetCharRects(const FDE_TTOPIECE* pPiece);
+
+ FX_TXTRUN ToTextRun(const FDE_TTOPIECE* pPiece);
+ void DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen);
+
+ CFX_TxtBreak* m_pTxtBreak;
+ IFX_Font* m_pFont;
+ FX_FLOAT m_fFontSize;
+ FX_FLOAT m_fLineSpace;
+ FX_FLOAT m_fLinePos;
+ FX_FLOAT m_fTolerance;
+ int32_t m_iAlignment;
+ int32_t m_iTxtBkAlignment;
+ int32_t* m_pCharWidths;
+ int32_t m_iChars;
+ int32_t* m_pEllCharWidths;
+ int32_t m_iEllChars;
+ FX_WCHAR m_wParagraphBkChar;
+ FX_ARGB m_TxtColor;
+ uint32_t m_dwStyles;
+ uint32_t m_dwTxtBkStyles;
+ CFX_WideString m_wsEllipsis;
+ FX_BOOL m_bElliChanged;
+ int32_t m_iEllipsisWidth;
+ CFX_WideString m_wsText;
+ CFX_RectF m_rtClip;
+ CFX_RectF m_rtLogicClip;
+ CFX_Matrix m_Matrix;
+ CFDE_TTOLineArray m_ttoLines;
+ int32_t m_iCurLine;
+ int32_t m_iCurPiece;
+ int32_t m_iTotalLines;
+ FXTEXT_CHARPOS* m_pCharPos;
+ int32_t m_iCharPosSize;
+ std::unique_ptr<CFDE_RenderDevice> m_pRenderDevice;
+ CFX_Int32Array m_hotKeys;
+ CFX_RectFArray m_rectArray;
};
#endif // XFA_FDE_TTO_FDE_TEXTOUT_H_
diff --git a/chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.cpp b/chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.cpp
index 25c4c5abe5c..9e99deb9720 100644
--- a/chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
+#include "core/fxcrt/include/fx_safe_types.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fgas/crt/fgas_system.h"
@@ -121,7 +122,7 @@ int32_t CFDE_XMLNode::GetChildNodeIndex(CFDE_XMLNode* pNode) const {
CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath,
int32_t iLength,
FX_BOOL bQualifiedName) const {
- FXSYS_assert(pPath != NULL);
+ ASSERT(pPath != NULL);
if (iLength < 0) {
iLength = FXSYS_wcslen(pPath);
}
@@ -178,7 +179,7 @@ CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath,
return pFind->GetPath(pStart, iLength, bQualifiedName);
}
int32_t CFDE_XMLNode::InsertChildNode(CFDE_XMLNode* pNode, int32_t index) {
- FXSYS_assert(pNode != NULL);
+ ASSERT(pNode != NULL);
pNode->m_pParent = this;
if (m_pChild == NULL) {
m_pChild = pNode;
@@ -206,7 +207,7 @@ int32_t CFDE_XMLNode::InsertChildNode(CFDE_XMLNode* pNode, int32_t index) {
return iCount;
}
void CFDE_XMLNode::RemoveChildNode(CFDE_XMLNode* pNode) {
- FXSYS_assert(m_pChild != NULL && pNode != NULL);
+ ASSERT(m_pChild != NULL && pNode != NULL);
if (m_pChild == pNode) {
m_pChild = pNode->m_pNext;
} else {
@@ -327,7 +328,7 @@ int32_t CFDE_XMLNode::GetNodeLevel() const {
}
FX_BOOL CFDE_XMLNode::InsertNodeItem(CFDE_XMLNode::NodeItem eItem,
CFDE_XMLNode* pNode) {
- FXSYS_assert(pNode != NULL);
+ ASSERT(pNode != NULL);
switch (eItem) {
case CFDE_XMLNode::NextSibling: {
pNode->m_pParent = m_pParent;
@@ -381,7 +382,7 @@ CFDE_XMLNode* CFDE_XMLNode::Clone(FX_BOOL bRecursive) {
}
void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
- FXSYS_assert(pXMLStream != NULL && pNode != NULL);
+ ASSERT(pXMLStream != NULL && pNode != NULL);
switch (pNode->GetType()) {
case FDE_XMLNODE_Instruction: {
CFX_WideString ws;
@@ -397,10 +398,10 @@ void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) {
ws += L"UTF-8";
}
ws += L"\"?>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} else {
- ws.Format(L"<?%s", (const FX_WCHAR*)pInstruction->m_wsTarget);
- pXMLStream->WriteString(ws, ws.GetLength());
+ ws.Format(L"<?%s", pInstruction->m_wsTarget.c_str());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
CFX_WideStringArray& attributes = pInstruction->m_Attributes;
int32_t i, iCount = attributes.GetSize();
CFX_WideString wsValue;
@@ -416,7 +417,7 @@ void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) {
wsValue.Replace(L"\"", L"&quot;");
ws += wsValue;
ws += L"\"";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
CFX_WideStringArray& targetdata = pInstruction->m_TargetData;
iCount = targetdata.GetSize();
@@ -424,17 +425,17 @@ void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) {
ws = L" \"";
ws += targetdata[i];
ws += L"\"";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
ws = L"?>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
} break;
case FDE_XMLNODE_Element: {
CFX_WideString ws;
ws = L"<";
ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes;
int32_t iCount = attributes.GetSize();
CFX_WideString wsValue;
@@ -450,14 +451,14 @@ void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) {
wsValue.Replace(L"\"", L"&quot;");
ws += wsValue;
ws += L"\"";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
if (pNode->m_pChild == NULL) {
ws = L"\n/>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} else {
ws = L"\n>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
CFDE_XMLNode* pChild = pNode->m_pChild;
while (pChild != NULL) {
pChild->SaveXMLNode(pXMLStream);
@@ -466,7 +467,7 @@ void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) {
ws = L"</";
ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
ws += L"\n>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
} break;
case FDE_XMLNODE_Text: {
@@ -476,13 +477,13 @@ void CFDE_XMLNode::SaveXMLNode(IFX_Stream* pXMLStream) {
ws.Replace(L">", L"&gt;");
ws.Replace(L"\'", L"&apos;");
ws.Replace(L"\"", L"&quot;");
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} break;
case FDE_XMLNODE_CharData: {
CFX_WideString ws = L"<![CDATA[";
ws += ((CFDE_XMLCharData*)pNode)->m_wsCharData;
ws += L"]]>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} break;
case FDE_XMLNODE_Unknown:
break;
@@ -508,7 +509,7 @@ void CFDE_XMLNode::CloneChildren(CFDE_XMLNode* pClone) {
CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget)
: m_wsTarget(wsTarget) {
- FXSYS_assert(m_wsTarget.GetLength() > 0);
+ ASSERT(m_wsTarget.GetLength() > 0);
}
CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) {
CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget);
@@ -529,7 +530,7 @@ FX_BOOL CFDE_XMLInstruction::GetAttribute(int32_t index,
CFX_WideString& wsAttriName,
CFX_WideString& wsAttriValue) const {
int32_t iCount = m_Attributes.GetSize();
- FXSYS_assert(index > -1 && index < iCount / 2);
+ ASSERT(index > -1 && index < iCount / 2);
for (int32_t i = 0; i < iCount; i += 2) {
if (index == 0) {
wsAttriName = m_Attributes[i];
@@ -563,7 +564,7 @@ void CFDE_XMLInstruction::GetString(const FX_WCHAR* pwsAttriName,
}
void CFDE_XMLInstruction::SetString(const CFX_WideString& wsAttriName,
const CFX_WideString& wsAttriValue) {
- FXSYS_assert(wsAttriName.GetLength() > 0);
+ ASSERT(wsAttriName.GetLength() > 0);
int32_t iCount = m_Attributes.GetSize();
for (int32_t i = 0; i < iCount; i += 2) {
if (m_Attributes[i].Compare(wsAttriName) == 0) {
@@ -580,7 +581,7 @@ int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName,
int32_t iCount = m_Attributes.GetSize();
for (int32_t i = 0; i < iCount; i += 2) {
if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return FXSYS_wtoi((const FX_WCHAR*)m_Attributes[i + 1]);
+ return FXSYS_wtoi(m_Attributes[i + 1].c_str());
}
}
return iDefValue;
@@ -596,7 +597,7 @@ FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName,
int32_t iCount = m_Attributes.GetSize();
for (int32_t i = 0; i < iCount; i += 2) {
if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return FX_wcstof((const FX_WCHAR*)m_Attributes[i + 1]);
+ return FX_wcstof(m_Attributes[i + 1].c_str());
}
}
return fDefValue;
@@ -637,7 +638,7 @@ void CFDE_XMLInstruction::RemoveData(int32_t index) {
CFDE_XMLElement::CFDE_XMLElement(const CFX_WideString& wsTag)
: CFDE_XMLNode(), m_wsTag(wsTag), m_Attributes() {
- FXSYS_assert(m_wsTag.GetLength() > 0);
+ ASSERT(m_wsTag.GetLength() > 0);
}
CFDE_XMLElement::~CFDE_XMLElement() {
m_Attributes.RemoveAll();
@@ -681,7 +682,7 @@ void CFDE_XMLElement::GetLocalTagName(CFX_WideString& wsTag) const {
void CFDE_XMLElement::GetNamespacePrefix(CFX_WideString& wsPrefix) const {
FX_STRSIZE iFind = m_wsTag.Find(L':', 0);
if (iFind < 0) {
- wsPrefix.Empty();
+ wsPrefix.clear();
} else {
wsPrefix = m_wsTag.Left(iFind);
}
@@ -693,18 +694,18 @@ void CFDE_XMLElement::GetNamespaceURI(CFX_WideString& wsNamespace) const {
wsAttri += L":";
wsAttri += wsPrefix;
}
- wsNamespace.Empty();
+ wsNamespace.clear();
CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
while (pNode != NULL) {
if (pNode->GetType() != FDE_XMLNODE_Element) {
break;
}
CFDE_XMLElement* pElement = (CFDE_XMLElement*)pNode;
- if (!pElement->HasAttribute(wsAttri)) {
+ if (!pElement->HasAttribute(wsAttri.c_str())) {
pNode = pNode->GetNodeItem(CFDE_XMLNode::Parent);
continue;
}
- pElement->GetString(wsAttri, wsNamespace);
+ pElement->GetString(wsAttri.c_str(), wsNamespace);
break;
}
}
@@ -715,7 +716,7 @@ FX_BOOL CFDE_XMLElement::GetAttribute(int32_t index,
CFX_WideString& wsAttriName,
CFX_WideString& wsAttriValue) const {
int32_t iCount = m_Attributes.GetSize();
- FXSYS_assert(index > -1 && index < iCount / 2);
+ ASSERT(index > -1 && index < iCount / 2);
for (int32_t i = 0; i < iCount; i += 2) {
if (index == 0) {
wsAttriName = m_Attributes[i];
@@ -749,7 +750,7 @@ void CFDE_XMLElement::GetString(const FX_WCHAR* pwsAttriName,
}
void CFDE_XMLElement::SetString(const CFX_WideString& wsAttriName,
const CFX_WideString& wsAttriValue) {
- FXSYS_assert(wsAttriName.GetLength() > 0);
+ ASSERT(wsAttriName.GetLength() > 0);
int32_t iCount = m_Attributes.GetSize();
for (int32_t i = 0; i < iCount; i += 2) {
if (m_Attributes[i].Compare(wsAttriName) == 0) {
@@ -766,7 +767,7 @@ int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName,
int32_t iCount = m_Attributes.GetSize();
for (int32_t i = 0; i < iCount; i += 2) {
if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return FXSYS_wtoi((const FX_WCHAR*)m_Attributes[i + 1]);
+ return FXSYS_wtoi(m_Attributes[i + 1].c_str());
}
}
return iDefValue;
@@ -782,7 +783,7 @@ FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName,
int32_t iCount = m_Attributes.GetSize();
for (int32_t i = 0; i < iCount; i += 2) {
if (m_Attributes[i].Compare(pwsAttriName) == 0) {
- return FX_wcstof((const FX_WCHAR*)m_Attributes[i + 1]);
+ return FX_wcstof(m_Attributes[i + 1].c_str());
}
}
return fDefValue;
@@ -819,7 +820,7 @@ void CFDE_XMLElement::GetTextData(CFX_WideString& wsText) const {
}
pChild = pChild->m_pNext;
}
- wsText = buffer.GetWideString();
+ wsText = buffer.AsStringC();
}
void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) {
if (wsText.GetLength() < 1) {
@@ -931,7 +932,7 @@ int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) {
if (m_iStatus >= 100) {
return m_iStatus;
}
- FXSYS_assert(m_pXMLParser != NULL);
+ ASSERT(m_pXMLParser != NULL);
return m_iStatus = m_pXMLParser->DoParser(pPause);
}
void CFDE_XMLDoc::CloseXML() {
@@ -939,7 +940,7 @@ void CFDE_XMLDoc::CloseXML() {
}
void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode;
- FXSYS_assert(pXMLStream != NULL && pNode != NULL);
+ ASSERT(pXMLStream != NULL && pNode != NULL);
switch (pNode->GetType()) {
case FDE_XMLNODE_Instruction: {
CFX_WideString ws;
@@ -955,10 +956,10 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
ws += L"UTF-8";
}
ws += L"\"?>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} else {
- ws.Format(L"<?%s", (const FX_WCHAR*)pInstruction->m_wsTarget);
- pXMLStream->WriteString(ws, ws.GetLength());
+ ws.Format(L"<?%s", pInstruction->m_wsTarget.c_str());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
CFX_WideStringArray& attributes = pInstruction->m_Attributes;
int32_t i, iCount = attributes.GetSize();
CFX_WideString wsValue;
@@ -974,7 +975,7 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
wsValue.Replace(L"\"", L"&quot;");
ws += wsValue;
ws += L"\"";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
CFX_WideStringArray& targetdata = pInstruction->m_TargetData;
iCount = targetdata.GetSize();
@@ -982,17 +983,17 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
ws = L" \"";
ws += targetdata[i];
ws += L"\"";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
ws = L"?>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
} break;
case FDE_XMLNODE_Element: {
CFX_WideString ws;
ws = L"<";
ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
CFX_WideStringArray& attributes = ((CFDE_XMLElement*)pNode)->m_Attributes;
int32_t iCount = attributes.GetSize();
CFX_WideString wsValue;
@@ -1008,14 +1009,14 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
wsValue.Replace(L"\"", L"&quot;");
ws += wsValue;
ws += L"\"";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
if (pNode->m_pChild == NULL) {
ws = L"\n/>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} else {
ws = L"\n>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
CFDE_XMLNode* pChild = pNode->m_pChild;
while (pChild != NULL) {
SaveXMLNode(pXMLStream, static_cast<CFDE_XMLNode*>(pChild));
@@ -1024,7 +1025,7 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
ws = L"</";
ws += ((CFDE_XMLElement*)pNode)->m_wsTag;
ws += L"\n>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
}
} break;
case FDE_XMLNODE_Text: {
@@ -1034,13 +1035,13 @@ void CFDE_XMLDoc::SaveXMLNode(IFX_Stream* pXMLStream, CFDE_XMLNode* pINode) {
ws.Replace(L">", L"&gt;");
ws.Replace(L"\'", L"&apos;");
ws.Replace(L"\"", L"&quot;");
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} break;
case FDE_XMLNODE_CharData: {
CFX_WideString ws = L"<![CDATA[";
ws += ((CFDE_XMLCharData*)pNode)->m_wsCharData;
ws += L"]]>";
- pXMLStream->WriteString(ws, ws.GetLength());
+ pXMLStream->WriteString(ws.c_str(), ws.GetLength());
} break;
case FDE_XMLNODE_Unknown:
break;
@@ -1053,8 +1054,8 @@ void CFDE_XMLDoc::SaveXML(IFX_Stream* pXMLStream, FX_BOOL bSaveBOM) {
m_pStream->Seek(FX_STREAMSEEK_Begin, 0);
pXMLStream = m_pStream;
}
- FXSYS_assert((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Text) != 0);
- FXSYS_assert((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Write) != 0);
+ ASSERT((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Text) != 0);
+ ASSERT((pXMLStream->GetAccessModes() & FX_STREAMACCESS_Write) != 0);
uint16_t wCodePage = pXMLStream->GetCodePage();
if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
wCodePage != FX_CODEPAGE_UTF8) {
@@ -1086,8 +1087,8 @@ CFDE_XMLDOMParser::CFDE_XMLDOMParser(CFDE_XMLNode* pRoot,
}
CFDE_XMLDOMParser::~CFDE_XMLDOMParser() {
m_NodeStack.RemoveAll();
- m_ws1.Empty();
- m_ws2.Empty();
+ m_ws1.clear();
+ m_ws2.clear();
}
int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) {
@@ -1132,7 +1133,7 @@ int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) {
m_pParser->GetTargetName(m_ws1);
m_pChild = new CFDE_XMLInstruction(m_ws1);
m_pParent->InsertChildNode(m_pChild);
- m_ws1.Empty();
+ m_ws1.clear();
break;
case FDE_XmlSyntaxResult::TagName:
m_pParser->GetTagName(m_ws1);
@@ -1155,7 +1156,7 @@ int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) {
} else if (m_pChild->GetType() == FDE_XMLNODE_Instruction) {
((CFDE_XMLInstruction*)m_pChild)->SetString(m_ws1, m_ws2);
}
- m_ws1.Empty();
+ m_ws1.clear();
break;
case FDE_XmlSyntaxResult::Text:
m_pParser->GetTextData(m_ws1);
@@ -1180,7 +1181,7 @@ int32_t CFDE_XMLDOMParser::DoParser(IFX_Pause* pPause) {
}
m_pParser->GetTargetData(m_ws1);
((CFDE_XMLInstruction*)m_pChild)->AppendData(m_ws1);
- m_ws1.Empty();
+ m_ws1.clear();
break;
default:
break;
@@ -1205,8 +1206,8 @@ CFDE_XMLSAXParser::CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler,
m_ws2() {}
CFDE_XMLSAXParser::~CFDE_XMLSAXParser() {
m_TagStack.RemoveAll();
- m_ws1.Empty();
- m_ws2.Empty();
+ m_ws1.clear();
+ m_ws2.clear();
}
int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
FDE_XmlSyntaxResult syntaxParserResult;
@@ -1247,7 +1248,7 @@ int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
Push(xmlTag);
m_pHandler->OnTagEnter(m_pHandler, FDE_XMLNODE_Instruction,
m_pTagTop->wsTagName);
- m_ws1.Empty();
+ m_ws1.clear();
} break;
case FDE_XmlSyntaxResult::TagName: {
m_pParser->GetTargetName(m_ws1);
@@ -1270,7 +1271,7 @@ int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
if (m_pTagTop->eType == FDE_XMLNODE_Element) {
m_pHandler->OnAttribute(m_pHandler, m_ws1, m_ws2);
}
- m_ws1.Empty();
+ m_ws1.clear();
break;
case FDE_XmlSyntaxResult::CData:
m_pParser->GetTextData(m_ws1);
@@ -1283,7 +1284,7 @@ int32_t CFDE_XMLSAXParser::DoParser(IFX_Pause* pPause) {
case FDE_XmlSyntaxResult::TargetData:
m_pParser->GetTargetData(m_ws1);
m_pHandler->OnData(m_pHandler, FDE_XMLNODE_Instruction, m_ws1);
- m_ws1.Empty();
+ m_ws1.clear();
break;
default:
break;
@@ -1328,7 +1329,7 @@ FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) {
return pBlock;
}
iIndexInBlock = iRealIndex % m_iAllocStep;
- return (FX_WCHAR*)m_BlockArray[iRealIndex / m_iAllocStep];
+ return m_BlockArray[iRealIndex / m_iAllocStep];
}
FX_BOOL CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) {
ClearBuffer();
@@ -1355,7 +1356,7 @@ void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) {
m_iBufferSize += m_iAllocStep;
} while (--iNewBlocks);
}
- FX_WCHAR* pTextData = (FX_WCHAR*)m_BlockArray[iBlockIndex];
+ FX_WCHAR* pTextData = m_BlockArray[iBlockIndex];
*(pTextData + iInnerIndex) = ch;
if (m_iDataLength <= iIndex) {
m_iDataLength = iIndex + 1;
@@ -1380,7 +1381,7 @@ int32_t CFDE_BlockBuffer::DeleteTextChars(int32_t iCount, FX_BOOL bDirection) {
void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData,
int32_t iStart,
int32_t iLength) const {
- wsTextData.Empty();
+ wsTextData.clear();
int32_t iMaybeDataLength = m_iBufferSize - 1 - m_iStartPosition;
if (iStart < 0 || iStart > iMaybeDataLength) {
return;
@@ -1412,7 +1413,7 @@ void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData,
if (i == iEndBlockIndex) {
iCopyLength -= ((m_iAllocStep - 1) - iEndInnerIndex);
}
- FX_WCHAR* pBlockBuf = (FX_WCHAR*)m_BlockArray[i];
+ FX_WCHAR* pBlockBuf = m_BlockArray[i];
FXSYS_memcpy(pBuf + iPointer, pBlockBuf + iBufferPointer,
iCopyLength * sizeof(FX_WCHAR));
iPointer += iCopyLength;
@@ -1422,7 +1423,7 @@ void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData,
void CFDE_BlockBuffer::TextDataIndex2BufIndex(const int32_t iIndex,
int32_t& iBlockIndex,
int32_t& iInnerIndex) const {
- FXSYS_assert(iIndex >= 0);
+ ASSERT(iIndex >= 0);
int32_t iRealIndex = m_iStartPosition + iIndex;
iBlockIndex = iRealIndex / m_iAllocStep;
iInnerIndex = iRealIndex % m_iAllocStep;
@@ -1432,7 +1433,6 @@ void CFDE_BlockBuffer::ClearBuffer() {
int32_t iSize = m_BlockArray.GetSize();
for (int32_t i = 0; i < iSize; i++) {
FX_Free(m_BlockArray[i]);
- m_BlockArray[i] = NULL;
}
m_BlockArray.RemoveAll();
}
@@ -1467,18 +1467,26 @@ CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser()
void CFDE_XMLSyntaxParser::Init(IFX_Stream* pStream,
int32_t iXMLPlaneSize,
int32_t iTextDataSize) {
- FXSYS_assert(m_pStream == NULL && m_pBuffer == NULL);
- FXSYS_assert(pStream != NULL && iXMLPlaneSize > 0);
+ ASSERT(m_pStream == NULL && m_pBuffer == NULL);
+ ASSERT(pStream != NULL && iXMLPlaneSize > 0);
int32_t iStreamLength = pStream->GetLength();
- FXSYS_assert(iStreamLength > 0);
+ ASSERT(iStreamLength > 0);
m_pStream = pStream;
m_iXMLPlaneSize = std::min(iXMLPlaneSize, iStreamLength);
uint8_t bom[4];
m_iCurrentPos = m_pStream->GetBOM(bom);
- FXSYS_assert(m_pBuffer == NULL);
- m_pBuffer = FX_Alloc(FX_WCHAR, m_iXMLPlaneSize);
+ ASSERT(m_pBuffer == NULL);
+
+ FX_SAFE_INT32 alloc_size_safe = m_iXMLPlaneSize;
+ alloc_size_safe += 1; // For NUL.
+ if (!alloc_size_safe.IsValid() || alloc_size_safe.ValueOrDie() <= 0) {
+ m_syntaxParserResult = FDE_XmlSyntaxResult::Error;
+ return;
+ }
+
+ m_pBuffer = FX_Alloc(FX_WCHAR, alloc_size_safe.ValueOrDie());
m_pStart = m_pEnd = m_pBuffer;
- FXSYS_assert(!m_BlockBuffer.IsInitialized());
+ ASSERT(!m_BlockBuffer.IsInitialized());
m_BlockBuffer.InitBuffer();
m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock);
m_iParsedBytes = m_iParsedChars = 0;
@@ -1490,7 +1498,7 @@ FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() {
m_syntaxParserResult == FDE_XmlSyntaxResult::EndOfString) {
return m_syntaxParserResult;
}
- FXSYS_assert(m_pStream && m_pBuffer && m_BlockBuffer.IsInitialized());
+ ASSERT(m_pStream && m_pBuffer && m_BlockBuffer.IsInitialized());
int32_t iStreamLength = m_pStream->GetLength();
int32_t iPos;
diff --git a/chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.h b/chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.h
index 396423a0c13..bad970e5bef 100644
--- a/chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.h
+++ b/chromium/third_party/pdfium/xfa/fde/xml/fde_xml_imp.h
@@ -284,7 +284,7 @@ class CFDE_BlockBuffer : public CFX_Target {
int32_t& iBlockIndex,
int32_t& iInnerIndex) const;
void ClearBuffer();
- CFX_PtrArray m_BlockArray;
+ CFX_ArrayTemplate<FX_WCHAR*> m_BlockArray;
int32_t m_iDataLength;
int32_t m_iBufferSize;
int32_t m_iAllocStep;
diff --git a/chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.cpp b/chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.cpp
index 6f638dde092..def92012e0b 100644
--- a/chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.cpp
+++ b/chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.cpp
@@ -8,9 +8,14 @@
#include <algorithm>
-#include "xfa/fee/ifde_txtedtbuf.h"
#include "xfa/fee/ifde_txtedtengine.h"
+namespace {
+
+const int kDefaultChunkSize = 1024;
+
+} // namespace
+
#define FDE_DEFCHUNKCOUNT 2
#define FDE_TXTEDT_FORMATBLOCK_BGN 0xFFF9
#define FDE_TXTEDT_FORMATBLOCK_END 0xFFFB
@@ -22,50 +27,47 @@ CFDE_TxtEdtBufIter::CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias)
m_nCurIndex(0),
m_nIndex(0),
m_Alias(wcAlias) {
- FXSYS_assert(m_pBuf);
+ ASSERT(m_pBuf);
}
+
CFDE_TxtEdtBufIter::~CFDE_TxtEdtBufIter() {}
-void CFDE_TxtEdtBufIter::Release() {
- delete this;
-}
+
FX_BOOL CFDE_TxtEdtBufIter::Next(FX_BOOL bPrev) {
if (bPrev) {
if (m_nIndex == 0) {
return FALSE;
}
- FXSYS_assert(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
- CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunk = NULL;
+ ASSERT(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
+ CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunk = nullptr;
if (m_nCurIndex > 0) {
m_nCurIndex--;
} else {
while (m_nCurChunk > 0) {
--m_nCurChunk;
- lpChunk =
- (CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk];
+ lpChunk = m_pBuf->m_Chunks[m_nCurChunk];
if (lpChunk->nUsed > 0) {
m_nCurIndex = lpChunk->nUsed - 1;
break;
}
}
}
- FXSYS_assert(m_nCurChunk >= 0);
+ ASSERT(m_nCurChunk >= 0);
m_nIndex--;
return TRUE;
} else {
if (m_nIndex >= (m_pBuf->m_nTotal - 1)) {
return FALSE;
}
- FXSYS_assert(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
- CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunk =
- (CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk];
+ ASSERT(m_nCurChunk < m_pBuf->m_Chunks.GetSize());
+ CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunk = m_pBuf->m_Chunks[m_nCurChunk];
if (lpChunk->nUsed != (m_nCurIndex + 1)) {
m_nCurIndex++;
} else {
int32_t nEnd = m_pBuf->m_Chunks.GetSize() - 1;
while (m_nCurChunk < nEnd) {
m_nCurChunk++;
- CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER lpChunkTemp =
- (CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk];
+ CFDE_TxtEdtBuf::FDE_CHUNKHEADER* lpChunkTemp =
+ m_pBuf->m_Chunks[m_nCurChunk];
if (lpChunkTemp->nUsed > 0) {
m_nCurIndex = 0;
break;
@@ -77,7 +79,7 @@ FX_BOOL CFDE_TxtEdtBufIter::Next(FX_BOOL bPrev) {
}
}
void CFDE_TxtEdtBufIter::SetAt(int32_t nIndex) {
- FXSYS_assert(nIndex >= 0 && nIndex < m_pBuf->m_nTotal);
+ ASSERT(nIndex >= 0 && nIndex < m_pBuf->m_nTotal);
CFDE_TxtEdtBuf::FDE_CHUNKPLACE cp;
m_pBuf->Index2CP(nIndex, cp);
m_nIndex = nIndex;
@@ -88,10 +90,9 @@ int32_t CFDE_TxtEdtBufIter::GetAt() const {
return m_nIndex;
}
FX_WCHAR CFDE_TxtEdtBufIter::GetChar() {
- FXSYS_assert(m_nIndex >= 0 && m_nIndex < m_pBuf->m_nTotal);
+ ASSERT(m_nIndex >= 0 && m_nIndex < m_pBuf->m_nTotal);
if (m_Alias == 0 || m_nIndex == (m_pBuf->m_nTotal - 1)) {
- return ((CFDE_TxtEdtBuf::FDE_LPCHUNKHEADER)m_pBuf->m_Chunks[m_nCurChunk])
- ->wChars[m_nCurIndex];
+ return m_pBuf->m_Chunks[m_nCurChunk]->wChars[m_nCurIndex];
}
return m_Alias;
}
@@ -106,12 +107,13 @@ IFX_CharIter* CFDE_TxtEdtBufIter::Clone() {
pIter->m_Alias = m_Alias;
return pIter;
}
-CFDE_TxtEdtBuf::CFDE_TxtEdtBuf(int32_t nDefChunkSize)
- : m_nChunkSize(nDefChunkSize),
+
+CFDE_TxtEdtBuf::CFDE_TxtEdtBuf()
+ : m_nChunkSize(kDefaultChunkSize),
m_nTotal(0),
m_bChanged(FALSE),
m_pAllocator(NULL) {
- FXSYS_assert(m_nChunkSize);
+ ASSERT(m_nChunkSize);
ResetChunkBuffer(FDE_DEFCHUNKCOUNT, m_nChunkSize);
}
void CFDE_TxtEdtBuf::Release() {
@@ -119,11 +121,11 @@ void CFDE_TxtEdtBuf::Release() {
}
CFDE_TxtEdtBuf::~CFDE_TxtEdtBuf() {
Clear(TRUE);
- m_pAllocator->Release();
+ delete m_pAllocator;
m_Chunks.RemoveAll();
}
FX_BOOL CFDE_TxtEdtBuf::SetChunkSize(int32_t nChunkSize) {
- FXSYS_assert(nChunkSize);
+ ASSERT(nChunkSize);
ResetChunkBuffer(FDE_DEFCHUNKCOUNT, nChunkSize);
return TRUE;
}
@@ -134,15 +136,16 @@ int32_t CFDE_TxtEdtBuf::GetTextLength() const {
return m_nTotal;
}
void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) {
- FXSYS_assert(!wsText.IsEmpty());
+ ASSERT(!wsText.IsEmpty());
Clear(FALSE);
int32_t nTextLength = wsText.GetLength();
int32_t nNeedCount =
((nTextLength - 1) / m_nChunkSize + 1) - m_Chunks.GetSize();
int32_t i = 0;
for (i = 0; i < nNeedCount; i++) {
- FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc(
- sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR));
+ FDE_CHUNKHEADER* lpChunk =
+ static_cast<FDE_CHUNKHEADER*>(m_pAllocator->Alloc(
+ sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)));
lpChunk->nUsed = 0;
m_Chunks.Add(lpChunk);
}
@@ -154,7 +157,7 @@ void CFDE_TxtEdtBuf::SetText(const CFX_WideString& wsText) {
if (nLeave < nCopyedLength) {
nCopyedLength = nLeave;
}
- FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[i];
+ FDE_CHUNKHEADER* lpChunk = m_Chunks[i];
FXSYS_memcpy(lpChunk->wChars, lpSrcBuf, nCopyedLength * sizeof(FX_WCHAR));
nLeave -= nCopyedLength;
lpSrcBuf += nCopyedLength;
@@ -167,19 +170,19 @@ void CFDE_TxtEdtBuf::GetText(CFX_WideString& wsText) const {
GetRange(wsText, 0, m_nTotal);
}
FX_WCHAR CFDE_TxtEdtBuf::GetCharByIndex(int32_t nIndex) const {
- FXSYS_assert(nIndex >= 0 && nIndex < GetTextLength());
- FDE_LPCHUNKHEADER pChunkHeader = NULL;
+ ASSERT(nIndex >= 0 && nIndex < GetTextLength());
+ FDE_CHUNKHEADER* pChunkHeader = nullptr;
int32_t nTotal = 0;
int32_t nCount = m_Chunks.GetSize();
int32_t i = 0;
for (i = 0; i < nCount; i++) {
- pChunkHeader = (FDE_LPCHUNKHEADER)m_Chunks[i];
+ pChunkHeader = m_Chunks[i];
nTotal += pChunkHeader->nUsed;
if (nTotal > nIndex) {
break;
}
}
- FXSYS_assert(pChunkHeader);
+ ASSERT(pChunkHeader);
return pChunkHeader->wChars[pChunkHeader->nUsed - (nTotal - nIndex)];
}
void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
@@ -191,7 +194,7 @@ void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
int32_t nCount = m_Chunks.GetSize();
FX_WCHAR* lpDstBuf = wsText.GetBuffer(nLength);
int32_t nChunkIndex = cp.nChunkIndex;
- FDE_LPCHUNKHEADER lpChunkHeader = (FDE_LPCHUNKHEADER)m_Chunks[nChunkIndex];
+ FDE_CHUNKHEADER* lpChunkHeader = m_Chunks[nChunkIndex];
int32_t nCopyLength = lpChunkHeader->nUsed - cp.nCharIndex;
FX_WCHAR* lpSrcBuf = lpChunkHeader->wChars + cp.nCharIndex;
while (nLeave > 0) {
@@ -203,7 +206,7 @@ void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
if (nChunkIndex >= nCount) {
break;
}
- lpChunkHeader = (FDE_LPCHUNKHEADER)m_Chunks[nChunkIndex];
+ lpChunkHeader = m_Chunks[nChunkIndex];
lpSrcBuf = lpChunkHeader->wChars;
nLeave -= nCopyLength;
lpDstBuf += nCopyLength;
@@ -214,14 +217,15 @@ void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
void CFDE_TxtEdtBuf::Insert(int32_t nPos,
const FX_WCHAR* lpText,
int32_t nLength) {
- FXSYS_assert(nPos >= 0 && nPos <= m_nTotal);
+ ASSERT(nPos >= 0 && nPos <= m_nTotal);
FDE_CHUNKPLACE cp;
Index2CP(nPos, cp);
int32_t nLengthTemp = nLength;
if (cp.nCharIndex != 0) {
- FDE_LPCHUNKHEADER lpNewChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc(
- sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR));
- FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cp.nChunkIndex];
+ FDE_CHUNKHEADER* lpNewChunk =
+ static_cast<FDE_CHUNKHEADER*>(m_pAllocator->Alloc(
+ sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)));
+ FDE_CHUNKHEADER* lpChunk = m_Chunks[cp.nChunkIndex];
int32_t nCopy = lpChunk->nUsed - cp.nCharIndex;
FXSYS_memcpy(lpNewChunk->wChars, lpChunk->wChars + cp.nCharIndex,
nCopy * sizeof(FX_WCHAR));
@@ -232,7 +236,7 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos,
cp.nCharIndex = 0;
}
if (cp.nChunkIndex != 0) {
- FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cp.nChunkIndex - 1];
+ FDE_CHUNKHEADER* lpChunk = m_Chunks[cp.nChunkIndex - 1];
if (lpChunk->nUsed != m_nChunkSize) {
cp.nChunkIndex--;
int32_t nFree = m_nChunkSize - lpChunk->nUsed;
@@ -246,9 +250,10 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos,
}
}
while (nLengthTemp > 0) {
- FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc(
- sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR));
- FXSYS_assert(lpChunk);
+ FDE_CHUNKHEADER* lpChunk =
+ static_cast<FDE_CHUNKHEADER*>(m_pAllocator->Alloc(
+ sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)));
+ ASSERT(lpChunk);
int32_t nCopy = std::min(nLengthTemp, m_nChunkSize);
FXSYS_memcpy(lpChunk->wChars, lpText, nCopy * sizeof(FX_WCHAR));
lpText += nCopy;
@@ -261,11 +266,11 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos,
m_bChanged = TRUE;
}
void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) {
- FXSYS_assert(nLength > 0 && nIndex >= 0 && nIndex + nLength <= m_nTotal);
+ ASSERT(nLength > 0 && nIndex >= 0 && nIndex + nLength <= m_nTotal);
FDE_CHUNKPLACE cpEnd;
Index2CP(nIndex + nLength - 1, cpEnd);
m_nTotal -= nLength;
- FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cpEnd.nChunkIndex];
+ FDE_CHUNKHEADER* lpChunk = m_Chunks[cpEnd.nChunkIndex];
int32_t nFirstPart = cpEnd.nCharIndex + 1;
int32_t nMovePart = lpChunk->nUsed - nFirstPart;
if (nMovePart != 0) {
@@ -277,7 +282,7 @@ void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) {
cpEnd.nChunkIndex--;
}
while (nLength > 0) {
- lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cpEnd.nChunkIndex];
+ lpChunk = m_Chunks[cpEnd.nChunkIndex];
int32_t nDeleted = std::min(lpChunk->nUsed, nLength);
lpChunk->nUsed -= nDeleted;
if (lpChunk->nUsed == 0) {
@@ -300,7 +305,7 @@ void CFDE_TxtEdtBuf::Clear(FX_BOOL bRelease) {
m_Chunks.RemoveAll();
} else {
while (i < nCount) {
- ((FDE_LPCHUNKHEADER)m_Chunks[i++])->nUsed = 0;
+ m_Chunks[i++]->nUsed = 0;
}
}
m_nTotal = 0;
@@ -319,7 +324,7 @@ FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) {
}
int32_t i = 0;
for (; i < nCount; i++) {
- FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[i];
+ FDE_CHUNKHEADER* lpChunk = m_Chunks[i];
if (lpChunk->nUsed == 0) {
m_pAllocator->Free(lpChunk);
m_Chunks.RemoveAt(i);
@@ -327,13 +332,13 @@ FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) {
--nCount;
}
}
- if (pPause != NULL && pPause->NeedToPauseNow()) {
+ if (pPause && pPause->NeedToPauseNow())
return FALSE;
- }
- FDE_LPCHUNKHEADER lpPreChunk = (FDE_LPCHUNKHEADER)m_Chunks[0];
- FDE_LPCHUNKHEADER lpCurChunk = NULL;
+
+ FDE_CHUNKHEADER* lpPreChunk = m_Chunks[0];
+ FDE_CHUNKHEADER* lpCurChunk = nullptr;
for (i = 1; i < nCount; i++) {
- lpCurChunk = (FDE_LPCHUNKHEADER)m_Chunks[i];
+ lpCurChunk = m_Chunks[i];
if (lpPreChunk->nUsed + lpCurChunk->nUsed <= m_nChunkSize) {
FXSYS_memcpy(lpPreChunk->wChars + lpPreChunk->nUsed, lpCurChunk->wChars,
lpCurChunk->nUsed * sizeof(FX_WCHAR));
@@ -354,22 +359,19 @@ FX_BOOL CFDE_TxtEdtBuf::Optimize(IFX_Pause* pPause) {
}
void CFDE_TxtEdtBuf::ResetChunkBuffer(int32_t nDefChunkCount,
int32_t nChunkSize) {
- FXSYS_assert(nChunkSize);
- FXSYS_assert(nDefChunkCount);
- if (m_pAllocator) {
- m_pAllocator->Release();
- m_pAllocator = NULL;
- }
+ ASSERT(nChunkSize);
+ ASSERT(nDefChunkCount);
+ delete m_pAllocator;
+ m_pAllocator = nullptr;
m_Chunks.RemoveAll();
m_nChunkSize = nChunkSize;
int32_t nChunkLength =
sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR);
- m_pAllocator =
- FX_CreateAllocator(FX_ALLOCTYPE_Fixed, nDefChunkCount, nChunkLength);
- FXSYS_assert(m_pAllocator);
- FDE_LPCHUNKHEADER lpChunkHeader =
- (FDE_LPCHUNKHEADER)m_pAllocator->Alloc(nChunkLength);
- FXSYS_assert(lpChunkHeader);
+ m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, nDefChunkCount,
+ nChunkLength);
+ FDE_CHUNKHEADER* lpChunkHeader =
+ static_cast<FDE_CHUNKHEADER*>(m_pAllocator->Alloc(nChunkLength));
+ ASSERT(lpChunkHeader);
lpChunkHeader->nUsed = 0;
m_Chunks.Add(lpChunkHeader);
m_nTotal = 0;
@@ -378,26 +380,26 @@ int32_t CFDE_TxtEdtBuf::CP2Index(const FDE_CHUNKPLACE& cp) const {
int32_t nTotal = cp.nCharIndex;
int32_t i = 0;
for (i = 0; i < cp.nChunkIndex; i++) {
- nTotal += ((FDE_LPCHUNKHEADER)m_Chunks[i])->nUsed;
+ nTotal += m_Chunks[i]->nUsed;
}
return nTotal;
}
void CFDE_TxtEdtBuf::Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const {
- FXSYS_assert(nIndex <= GetTextLength());
+ ASSERT(nIndex <= GetTextLength());
if (nIndex == m_nTotal) {
cp.nChunkIndex = m_Chunks.GetSize() - 1;
- cp.nCharIndex = ((FDE_LPCHUNKHEADER)m_Chunks[cp.nChunkIndex])->nUsed;
+ cp.nCharIndex = m_Chunks[cp.nChunkIndex]->nUsed;
return;
}
int32_t i = 0;
int32_t nTotal = 0;
int32_t nCount = m_Chunks.GetSize();
for (; i < nCount; i++) {
- nTotal += ((FDE_LPCHUNKHEADER)m_Chunks[i])->nUsed;
+ nTotal += m_Chunks[i]->nUsed;
if (nTotal > nIndex) {
break;
}
}
cp.nChunkIndex = i;
- cp.nCharIndex = ((FDE_LPCHUNKHEADER)m_Chunks[i])->nUsed - (nTotal - nIndex);
+ cp.nCharIndex = m_Chunks[i]->nUsed - (nTotal - nIndex);
}
diff --git a/chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.h b/chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.h
index e0598f5244d..bcfb66a0a1d 100644
--- a/chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.h
+++ b/chromium/third_party/pdfium/xfa/fee/fde_txtedtbuf.h
@@ -7,27 +7,22 @@
#ifndef XFA_FEE_FDE_TXTEDTBUF_H_
#define XFA_FEE_FDE_TXTEDTBUF_H_
-#include "xfa/fee/ifde_txtedtbuf.h"
#include "xfa/fee/ifde_txtedtengine.h"
#include "xfa/fgas/crt/fgas_memory.h"
-class IFX_CharIter;
class CFDE_TxtEdtBuf;
class CFDE_TxtEdtBufIter : public IFX_CharIter {
public:
CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias = 0);
+ ~CFDE_TxtEdtBufIter() override;
- virtual void Release();
- virtual FX_BOOL Next(FX_BOOL bPrev = FALSE);
- virtual FX_WCHAR GetChar();
- virtual void SetAt(int32_t nIndex);
- virtual int32_t GetAt() const;
- virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const;
- virtual IFX_CharIter* Clone();
-
- protected:
- ~CFDE_TxtEdtBufIter();
+ FX_BOOL Next(FX_BOOL bPrev = FALSE) override;
+ FX_WCHAR GetChar() override;
+ void SetAt(int32_t nIndex) override;
+ int32_t GetAt() const override;
+ FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const override;
+ IFX_CharIter* Clone() override;
private:
CFDE_TxtEdtBuf* m_pBuf;
@@ -36,47 +31,44 @@ class CFDE_TxtEdtBufIter : public IFX_CharIter {
int32_t m_nIndex;
FX_WCHAR m_Alias;
};
-class CFDE_TxtEdtBuf : public IFDE_TxtEdtBuf {
+
+class CFDE_TxtEdtBuf {
+ public:
+ CFDE_TxtEdtBuf();
+
+ void Release();
+ FX_BOOL SetChunkSize(int32_t nChunkSize);
+ int32_t GetChunkSize() const;
+ int32_t GetTextLength() const;
+ void SetText(const CFX_WideString& wsText);
+ void GetText(CFX_WideString& wsText) const;
+ FX_WCHAR GetCharByIndex(int32_t nIndex) const;
+ void GetRange(CFX_WideString& wsText,
+ int32_t nBegin,
+ int32_t nCount = -1) const;
+
+ void Insert(int32_t nPos, const FX_WCHAR* lpText, int32_t nLength = 1);
+ void Delete(int32_t nIndex, int32_t nLength = 1);
+ void Clear(FX_BOOL bRelease = TRUE);
+
+ FX_BOOL Optimize(IFX_Pause* pPause = nullptr);
+
+ protected:
+ ~CFDE_TxtEdtBuf();
+
+ private:
friend class CFDE_TxtEdtBufIter;
- struct _FDE_CHUNKHEADER {
+
+ struct FDE_CHUNKHEADER {
int32_t nUsed;
FX_WCHAR wChars[1];
};
- typedef _FDE_CHUNKHEADER FDE_CHUNKHEADER;
- typedef _FDE_CHUNKHEADER* FDE_LPCHUNKHEADER;
- struct _FDE_CHUNKPLACE {
+
+ struct FDE_CHUNKPLACE {
int32_t nChunkIndex;
int32_t nCharIndex;
};
- typedef _FDE_CHUNKPLACE FDE_CHUNKPLACE;
- typedef _FDE_CHUNKPLACE* FDE_LPCHUNKPLACE;
- public:
- CFDE_TxtEdtBuf(int32_t nDefChunkSize = FDE_DEFCHUNKLENGTH);
-
- virtual void Release();
- virtual FX_BOOL SetChunkSize(int32_t nChunkSize);
- virtual int32_t GetChunkSize() const;
- virtual int32_t GetTextLength() const;
- virtual void SetText(const CFX_WideString& wsText);
- virtual void GetText(CFX_WideString& wsText) const;
- virtual FX_WCHAR GetCharByIndex(int32_t nIndex) const;
- virtual void GetRange(CFX_WideString& wsText,
- int32_t nBegine,
- int32_t nCount = -1) const;
-
- virtual void Insert(int32_t nPos,
- const FX_WCHAR* lpText,
- int32_t nLength = 1);
- virtual void Delete(int32_t nIndex, int32_t nLength = 1);
- virtual void Clear(FX_BOOL bRelease = TRUE);
-
- virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL);
-
- protected:
- virtual ~CFDE_TxtEdtBuf();
-
- private:
void ResetChunkBuffer(int32_t nDefChunkCount, int32_t nChunkSize);
int32_t CP2Index(const FDE_CHUNKPLACE& cp) const;
void Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const;
@@ -85,8 +77,8 @@ class CFDE_TxtEdtBuf : public IFDE_TxtEdtBuf {
int32_t m_nTotal;
FX_BOOL m_bChanged;
- CFX_PtrArray m_Chunks;
- IFX_MEMAllocator* m_pAllocator;
+ CFX_ArrayTemplate<FDE_CHUNKHEADER*> m_Chunks;
+ IFX_MemoryAllocator* m_pAllocator;
};
#endif // XFA_FEE_FDE_TXTEDTBUF_H_
diff --git a/chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.cpp b/chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.cpp
index 5cdb55cfaf9..826f0ce62c7 100644
--- a/chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.cpp
+++ b/chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.cpp
@@ -7,13 +7,13 @@
#include "xfa/fee/fde_txtedtengine.h"
#include <algorithm>
+#include <memory>
#include "xfa/fde/tto/fde_textout.h"
-#include "xfa/fee/fde_txtedtbuf.h"
#include "xfa/fee/fde_txtedtparag.h"
-#include "xfa/fee/ifde_txtedtbuf.h"
#include "xfa/fee/ifde_txtedtengine.h"
#include "xfa/fee/ifde_txtedtpage.h"
+#include "xfa/fwl/basewidget/fwl_editimp.h"
#define FDE_PAGEWIDTH_MAX 0xFFFF
#define FDE_TXTPLATESIZE (1024 * 12)
@@ -21,9 +21,6 @@
#define FDE_TXTEDT_DORECORD_INS 0
#define FDE_TXTEDT_DORECORD_DEL 1
-IFDE_TxtEdtEngine* IFDE_TxtEdtEngine::Create() {
- return new CFDE_TxtEdtEngine();
-}
CFDE_TxtEdtEngine::CFDE_TxtEdtEngine()
: m_pTextBreak(nullptr),
m_nPageLineCount(20),
@@ -63,15 +60,15 @@ void CFDE_TxtEdtEngine::Release() {
delete this;
}
void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) {
- if (m_pTextBreak == NULL) {
- m_pTextBreak = IFX_TxtBreak::Create(FX_TXTBREAKPOLICY_None);
- }
+ if (!m_pTextBreak)
+ m_pTextBreak = new CFX_TxtBreak(FX_TXTBREAKPOLICY_None);
+
FXSYS_memcpy(&m_Param, &params, sizeof(FDE_TXTEDTPARAMS));
m_wLineEnd = params.wLineBreakChar;
m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto);
UpdateTxtBreak();
}
-const FDE_TXTEDTPARAMS* CFDE_TxtEdtEngine::GetEditParams() const {
+FDE_TXTEDTPARAMS* CFDE_TxtEdtEngine::GetEditParams() {
return &m_Param;
}
int32_t CFDE_TxtEdtEngine::CountPages() const {
@@ -167,7 +164,7 @@ int32_t CFDE_TxtEdtEngine::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
if (IsLocked()) {
return 0;
}
- FXSYS_assert(nIndex >= 0 && nIndex <= GetTextBufLength());
+ ASSERT(nIndex >= 0 && nIndex <= GetTextBufLength());
if (m_PagePtrArray.GetSize() <= m_nCaretPage) {
return 0;
}
@@ -329,7 +326,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
int32_t nTotalLength = GetTextBufLength();
int32_t nCount = m_SelRangePtrArr.GetSize();
for (int32_t i = 0; i < nCount; i++) {
- FDE_LPTXTEDTSELRANGE lpSelRange = m_SelRangePtrArr.GetAt(i);
+ FDE_TXTEDTSELRANGE* lpSelRange = m_SelRangePtrArr.GetAt(i);
nTotalLength -= lpSelRange->nCount;
}
int32_t nExpectLength = nTotalLength + nLength;
@@ -391,7 +388,7 @@ int32_t CFDE_TxtEdtEngine::Insert(int32_t nStart,
new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength);
CFX_ByteString bsDoRecord;
pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsByteStringC());
+ m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsStringC());
pRecord->Release();
}
GetText(m_ChangeInfo.wsPrevText, 0);
@@ -454,7 +451,7 @@ int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, FX_BOOL bBackspace) {
new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange);
CFX_ByteString bsDoRecord;
pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsByteStringC());
+ m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsStringC());
pRecord->Release();
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
@@ -538,7 +535,7 @@ void CFDE_TxtEdtEngine::SetAliasChar(FX_WCHAR wcAlias) {
}
void CFDE_TxtEdtEngine::RemoveSelRange(int32_t nStart, int32_t nCount) {
- FDE_LPTXTEDTSELRANGE lpTemp = NULL;
+ FDE_TXTEDTSELRANGE* lpTemp = nullptr;
int32_t nRangeCount = m_SelRangePtrArr.GetSize();
int32_t i = 0;
for (i = 0; i < nRangeCount; i++) {
@@ -557,17 +554,17 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
}
int32_t nSize = m_SelRangePtrArr.GetSize();
if (nSize <= 0) {
- FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE;
+ FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE;
lpSelRange->nStart = nStart;
lpSelRange->nCount = nCount;
m_SelRangePtrArr.Add(lpSelRange);
m_Param.pEventSink->On_SelChanged(this);
return;
}
- FDE_LPTXTEDTSELRANGE lpTemp = NULL;
+ FDE_TXTEDTSELRANGE* lpTemp = nullptr;
lpTemp = m_SelRangePtrArr[nSize - 1];
if (nStart >= lpTemp->nStart + lpTemp->nCount) {
- FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE;
+ FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE;
lpSelRange->nStart = nStart;
lpSelRange->nCount = nCount;
m_SelRangePtrArr.Add(lpSelRange);
@@ -602,7 +599,7 @@ void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
}
}
if (nRangeCnt == 0) {
- FDE_LPTXTEDTSELRANGE lpSelRange = new FDE_TXTEDTSELRANGE;
+ FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE;
lpSelRange->nStart = nStart;
lpSelRange->nCount = nCount;
m_SelRangePtrArr.InsertAt(nRangeBgn, lpSelRange);
@@ -627,22 +624,16 @@ int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t& nStart) {
nStart = m_SelRangePtrArr[nIndex]->nStart;
return m_SelRangePtrArr[nIndex]->nCount;
}
+
void CFDE_TxtEdtEngine::ClearSelection() {
int32_t nCount = m_SelRangePtrArr.GetSize();
- FDE_LPTXTEDTSELRANGE lpRange = NULL;
- int32_t i = 0;
- for (i = 0; i < nCount; i++) {
- lpRange = m_SelRangePtrArr[i];
- if (lpRange != NULL) {
- delete lpRange;
- lpRange = NULL;
- }
- }
+ for (int i = 0; i < nCount; ++i)
+ delete m_SelRangePtrArr[i];
m_SelRangePtrArr.RemoveAll();
- if (nCount && m_Param.pEventSink) {
+ if (nCount && m_Param.pEventSink)
m_Param.pEventSink->On_SelChanged(this);
- }
}
+
FX_BOOL CFDE_TxtEdtEngine::Redo(const CFX_ByteStringC& bsRedo) {
if (IsLocked()) {
return FALSE;
@@ -651,7 +642,7 @@ FX_BOOL CFDE_TxtEdtEngine::Redo(const CFX_ByteStringC& bsRedo) {
return FALSE;
}
IFDE_TxtEdtDoRecord* pDoRecord = IFDE_TxtEdtDoRecord::Create(bsRedo);
- FXSYS_assert(pDoRecord);
+ ASSERT(pDoRecord);
if (pDoRecord == NULL) {
return FALSE;
}
@@ -667,7 +658,7 @@ FX_BOOL CFDE_TxtEdtEngine::Undo(const CFX_ByteStringC& bsUndo) {
return FALSE;
}
IFDE_TxtEdtDoRecord* pDoRecord = IFDE_TxtEdtDoRecord::Create(bsUndo);
- FXSYS_assert(pDoRecord);
+ ASSERT(pDoRecord);
if (pDoRecord == NULL) {
return FALSE;
}
@@ -689,7 +680,7 @@ int32_t CFDE_TxtEdtEngine::DoLayout(IFX_Pause* pPause) {
for (; m_nLayoutPos < nCount; m_nLayoutPos++) {
pParag = m_ParagPtrArray[m_nLayoutPos];
pParag->CalcLines();
- nLineCount += pParag->m_nLineCount;
+ nLineCount += pParag->GetLineCount();
if ((pPause != NULL) && (nLineCount > m_nPageLineCount) &&
pPause->NeedToPauseNow()) {
m_nLineCount += nLineCount;
@@ -715,13 +706,13 @@ void CFDE_TxtEdtEngine::EndLayout() {
FX_BOOL CFDE_TxtEdtEngine::Optimize(IFX_Pause* pPause) {
return m_pTxtBuf->Optimize(pPause);
}
-IFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const {
- return (IFDE_TxtEdtBuf*)m_pTxtBuf;
+CFDE_TxtEdtBuf* CFDE_TxtEdtEngine::GetTextBuf() const {
+ return m_pTxtBuf;
}
int32_t CFDE_TxtEdtEngine::GetTextBufLength() const {
return m_pTxtBuf->GetTextLength() - 1;
}
-IFX_TxtBreak* CFDE_TxtEdtEngine::GetTextBreak() const {
+CFX_TxtBreak* CFDE_TxtEdtEngine::GetTextBreak() const {
return m_pTextBreak;
}
int32_t CFDE_TxtEdtEngine::GetLineCount() const {
@@ -733,7 +724,7 @@ int32_t CFDE_TxtEdtEngine::GetPageLineCount() const {
int32_t CFDE_TxtEdtEngine::CountParags() const {
return m_ParagPtrArray.GetSize();
}
-IFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const {
+CFDE_TxtEdtParag* CFDE_TxtEdtEngine::GetParag(int32_t nParagIndex) const {
return m_ParagPtrArray[nParagIndex];
}
IFX_CharIter* CFDE_TxtEdtEngine::CreateCharIter() {
@@ -752,12 +743,12 @@ int32_t CFDE_TxtEdtEngine::Line2Parag(int32_t nStartParag,
int32_t i = nStartParag;
for (; i < nCount; i++) {
pParag = m_ParagPtrArray[i];
- nLineTotal += pParag->m_nLineCount;
+ nLineTotal += pParag->GetLineCount();
if (nLineTotal > nLineIndex) {
break;
}
}
- nStartLine = nLineTotal - pParag->m_nLineCount;
+ nStartLine = nLineTotal - pParag->GetLineCount();
return i;
}
void CFDE_TxtEdtEngine::GetPreDeleteText(CFX_WideString& wsText,
@@ -812,20 +803,20 @@ void CFDE_TxtEdtEngine::GetPreReplaceText(CFX_WideString& wsText,
void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
const FX_WCHAR* lpText,
int32_t nLength) {
- FXSYS_assert(nLength > 0);
+ ASSERT(nLength > 0);
FDE_TXTEDTPARAGPOS ParagPos;
TextPos2ParagPos(nStart, ParagPos);
m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
int32_t nParagCount = m_ParagPtrArray.GetSize();
int32_t i = 0;
- for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++) {
- m_ParagPtrArray[i]->m_nCharStart += nLength;
- }
+ for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++)
+ m_ParagPtrArray[i]->IncrementStartIndex(nLength);
+
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex];
- int32_t nReserveLineCount = pParag->m_nLineCount;
- int32_t nReserveCharStart = pParag->m_nCharStart;
+ int32_t nReserveLineCount = pParag->GetLineCount();
+ int32_t nReserveCharStart = pParag->GetStartIndex();
int32_t nLeavePart = ParagPos.nCharIndex;
- int32_t nCutPart = pParag->m_nCharCount - ParagPos.nCharIndex;
+ int32_t nCutPart = pParag->GetTextLength() - ParagPos.nCharIndex;
int32_t nTextStart = 0;
FX_WCHAR wCurChar = L' ';
const FX_WCHAR* lpPos = lpText;
@@ -835,30 +826,30 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
wCurChar = *lpPos;
if (wCurChar == m_wLineEnd) {
if (bFirst) {
- pParag->m_nCharCount = nLeavePart + (i - nTextStart + 1);
- pParag->m_nLineCount = -1;
- nReserveCharStart += pParag->m_nCharCount;
+ pParag->SetTextLength(nLeavePart + (i - nTextStart + 1));
+ pParag->SetLineCount(-1);
+ nReserveCharStart += pParag->GetTextLength();
bFirst = FALSE;
} else {
pParag = new CFDE_TxtEdtParag(this);
- pParag->m_nLineCount = -1;
- pParag->m_nCharCount = i - nTextStart + 1;
- pParag->m_nCharStart = nReserveCharStart;
+ pParag->SetLineCount(-1);
+ pParag->SetTextLength(i - nTextStart + 1);
+ pParag->SetStartIndex(nReserveCharStart);
m_ParagPtrArray.InsertAt(++nParagIndex, pParag);
- nReserveCharStart += pParag->m_nCharCount;
+ nReserveCharStart += pParag->GetTextLength();
}
nTextStart = i + 1;
}
}
if (bFirst) {
- pParag->m_nCharCount += nLength;
- pParag->m_nLineCount = -1;
+ pParag->IncrementTextLength(nLength);
+ pParag->SetLineCount(-1);
bFirst = FALSE;
} else {
pParag = new CFDE_TxtEdtParag(this);
- pParag->m_nLineCount = -1;
- pParag->m_nCharCount = nLength - nTextStart + nCutPart;
- pParag->m_nCharStart = nReserveCharStart;
+ pParag->SetLineCount(-1);
+ pParag->SetTextLength(nLength - nTextStart + nCutPart);
+ pParag->SetStartIndex(nReserveCharStart);
m_ParagPtrArray.InsertAt(++nParagIndex, pParag);
}
m_pTxtBuf->Insert(nStart, lpText, nLength);
@@ -866,7 +857,7 @@ void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
for (i = ParagPos.nParagIndex; i <= nParagIndex; i++) {
pParag = m_ParagPtrArray[i];
pParag->CalcLines();
- nTotalLineCount += pParag->m_nLineCount;
+ nTotalLineCount += pParag->GetLineCount();
}
m_nLineCount += nTotalLineCount - nReserveLineCount;
m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
@@ -878,14 +869,14 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
nCount = m_pTxtBuf->GetTextLength() - nStart;
}
int32_t nEnd = nStart + nCount - 1;
- FXSYS_assert(nStart >= 0 && nEnd < m_pTxtBuf->GetTextLength());
+ ASSERT(nStart >= 0 && nEnd < m_pTxtBuf->GetTextLength());
m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0);
FDE_TXTEDTPARAGPOS ParagPosBgn, ParagPosEnd;
TextPos2ParagPos(nStart, ParagPosBgn);
TextPos2ParagPos(nEnd, ParagPosEnd);
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPosEnd.nParagIndex];
FX_BOOL bLastParag = FALSE;
- if (ParagPosEnd.nCharIndex == pParag->m_nCharCount - 1) {
+ if (ParagPosEnd.nCharIndex == pParag->GetTextLength() - 1) {
if (ParagPosEnd.nParagIndex < m_ParagPtrArray.GetSize() - 1) {
ParagPosEnd.nParagIndex++;
} else {
@@ -898,28 +889,27 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
for (i = ParagPosBgn.nParagIndex; i <= ParagPosEnd.nParagIndex; i++) {
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[i];
pParag->CalcLines();
- nTotalLineCount += pParag->m_nLineCount;
- nTotalCharCount += pParag->m_nCharCount;
+ nTotalLineCount += pParag->GetLineCount();
+ nTotalCharCount += pParag->GetTextLength();
}
m_pTxtBuf->Delete(nStart, nCount);
int32_t nNextParagIndex = (ParagPosBgn.nCharIndex == 0 && bLastParag)
? ParagPosBgn.nParagIndex
: (ParagPosBgn.nParagIndex + 1);
for (i = nNextParagIndex; i <= ParagPosEnd.nParagIndex; i++) {
- CFDE_TxtEdtParag* pParag = m_ParagPtrArray[nNextParagIndex];
- delete pParag;
+ delete m_ParagPtrArray[nNextParagIndex];
m_ParagPtrArray.RemoveAt(nNextParagIndex);
}
if (!(bLastParag && ParagPosBgn.nCharIndex == 0)) {
pParag = m_ParagPtrArray[ParagPosBgn.nParagIndex];
- pParag->m_nCharCount = nTotalCharCount - nCount;
+ pParag->SetTextLength(nTotalCharCount - nCount);
pParag->CalcLines();
- nTotalLineCount -= pParag->m_nLineCount;
+ nTotalLineCount -= pParag->GetTextLength();
}
int32_t nParagCount = m_ParagPtrArray.GetSize();
- for (i = nNextParagIndex; i < nParagCount; i++) {
- m_ParagPtrArray[i]->m_nCharStart -= nCount;
- }
+ for (i = nNextParagIndex; i < nParagCount; i++)
+ m_ParagPtrArray[i]->DecrementStartIndex(nCount);
+
m_nLineCount -= nTotalLineCount;
UpdatePages();
int32_t nPageCount = CountPages();
@@ -931,11 +921,11 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
int32_t nCount,
FX_BOOL bSel) {
- FXSYS_assert(nStart >= 0);
+ ASSERT(nStart >= 0);
if (nCount == -1) {
nCount = GetTextLength() - nStart;
}
- FXSYS_assert((nStart + nCount) <= m_pTxtBuf->GetTextLength());
+ ASSERT((nStart + nCount) <= m_pTxtBuf->GetTextLength());
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
CFX_WideString wsRange;
@@ -944,7 +934,7 @@ void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
this, nStart, m_nCaret, wsRange, bSel);
CFX_ByteString bsDoRecord;
pRecord->Serialize(bsDoRecord);
- m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsByteStringC());
+ m_Param.pEventSink->On_AddDoRecord(this, bsDoRecord.AsStringC());
pRecord->Release();
}
m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
@@ -964,33 +954,30 @@ void CFDE_TxtEdtEngine::RebuildParagraphs() {
FX_WCHAR wChar = L' ';
int32_t nParagStart = 0;
int32_t nIndex = 0;
- IFX_CharIter* pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)m_pTxtBuf);
+ std::unique_ptr<IFX_CharIter> pIter(
+ new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(m_pTxtBuf)));
pIter->SetAt(0);
do {
wChar = pIter->GetChar();
nIndex = pIter->GetAt();
if (wChar == m_wLineEnd) {
CFDE_TxtEdtParag* pParag = new CFDE_TxtEdtParag(this);
- pParag->m_nCharStart = nParagStart;
- pParag->m_nCharCount = nIndex - nParagStart + 1;
- pParag->m_nLineCount = -1;
+ pParag->SetStartIndex(nParagStart);
+ pParag->SetTextLength(nIndex - nParagStart + 1);
+ pParag->SetLineCount(-1);
m_ParagPtrArray.Add(pParag);
nParagStart = nIndex + 1;
}
} while (pIter->Next());
- pIter->Release();
}
+
void CFDE_TxtEdtEngine::RemoveAllParags() {
int32_t nCount = m_ParagPtrArray.GetSize();
- int32_t i = 0;
- for (i = 0; i < nCount; i++) {
- CFDE_TxtEdtParag* pParag = m_ParagPtrArray[i];
- if (pParag) {
- delete pParag;
- }
- }
+ for (int i = 0; i < nCount; ++i)
+ delete m_ParagPtrArray[i];
m_ParagPtrArray.RemoveAll();
}
+
void CFDE_TxtEdtEngine::RemoveAllPages() {
int32_t nCount = m_PagePtrArray.GetSize();
int32_t i = 0;
@@ -1012,22 +999,22 @@ void CFDE_TxtEdtEngine::UpdateParags() {
int32_t i = 0;
for (i = 0; i < nCount; i++) {
pParag = m_ParagPtrArray[i];
- if (pParag->m_nLineCount == -1) {
+ if (pParag->GetLineCount() == -1)
pParag->CalcLines();
- }
- nLineCount += pParag->m_nLineCount;
+
+ nLineCount += pParag->GetLineCount();
}
m_nLineCount = nLineCount;
}
void CFDE_TxtEdtEngine::UpdatePages() {
- if (m_nLineCount == 0) {
+ if (m_nLineCount == 0)
return;
- }
+
int32_t nPageCount = (m_nLineCount - 1) / (m_nPageLineCount) + 1;
int32_t nSize = m_PagePtrArray.GetSize();
- if (nSize == nPageCount) {
+ if (nSize == nPageCount)
return;
- }
+
if (nSize > nPageCount) {
IFDE_TxtEdtPage* pPage = NULL;
int32_t i = 0;
@@ -1038,7 +1025,6 @@ void CFDE_TxtEdtEngine::UpdatePages() {
}
m_PagePtrArray.RemoveAt(i);
}
- m_Param.pEventSink->On_PageCountChanged(this);
return;
}
if (nSize < nPageCount) {
@@ -1048,7 +1034,6 @@ void CFDE_TxtEdtEngine::UpdatePages() {
pPage = IFDE_TxtEdtPage::Create(this, i);
m_PagePtrArray.Add(pPage);
}
- m_Param.pEventSink->On_PageCountChanged(this);
return;
}
}
@@ -1195,7 +1180,7 @@ void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) {
CFX_ArrayTemplate<int32_t> PosArr;
int32_t nLength = wsText.GetLength();
int32_t i = 0;
- FX_WCHAR* lpPos = (FX_WCHAR*)(const FX_WCHAR*)wsText;
+ FX_WCHAR* lpPos = const_cast<FX_WCHAR*>(wsText.c_str());
for (i = 0; i < nLength; i++, lpPos++) {
if (*lpPos == m_wLineEnd) {
*lpPos = wc;
@@ -1226,7 +1211,7 @@ void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) {
wsText = wsTemp;
} else {
int32_t nLength = wsText.GetLength();
- FX_WCHAR* lpBuf = (FX_WCHAR*)(const FX_WCHAR*)wsText;
+ FX_WCHAR* lpBuf = const_cast<FX_WCHAR*>(wsText.c_str());
for (int32_t i = 0; i < nLength; i++, lpBuf++) {
if (*lpBuf == m_wLineEnd) {
*lpBuf = wc;
@@ -1235,8 +1220,8 @@ void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) {
}
}
int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) {
- FXSYS_assert(nIndex >= 0);
- FXSYS_assert(nIndex <= m_pTxtBuf->GetTextLength());
+ ASSERT(nIndex >= 0);
+ ASSERT(nIndex <= m_pTxtBuf->GetTextLength());
if (m_nCaretPage >= 0) {
IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage];
m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0);
@@ -1254,31 +1239,30 @@ int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) {
int32_t i = 0;
for (i = 0; i < nParagCount; i++) {
pParag = m_ParagPtrArray[i];
- if (pParag->m_nCharStart <= nIndex &&
- nIndex < (pParag->m_nCharStart + pParag->m_nCharCount)) {
+ if (pParag->GetStartIndex() <= nIndex &&
+ nIndex < (pParag->GetStartIndex() + pParag->GetTextLength())) {
break;
}
- nLineCount += pParag->m_nLineCount;
+ nLineCount += pParag->GetLineCount();
}
pParag->LoadParag();
int32_t nLineStart = -1;
int32_t nLineCharCount = -1;
- for (i = 0; i < pParag->m_nLineCount; i++) {
+ for (i = 0; i < pParag->GetLineCount(); i++) {
pParag->GetLineRange(i, nLineStart, nLineCharCount);
if (nLineStart <= nIndex && nIndex < (nLineStart + nLineCharCount)) {
break;
}
}
- FXSYS_assert(i < pParag->m_nLineCount);
+ ASSERT(i < pParag->GetLineCount());
nLineCount += (i + 1);
m_nCaretPage = (nLineCount - 1) / m_nPageLineCount + 1 - 1;
- m_Param.pEventSink->On_PageChange(this, m_nCaretPage);
pParag->UnloadParag();
return m_nCaretPage;
}
void CFDE_TxtEdtEngine::TextPos2ParagPos(int32_t nIndex,
FDE_TXTEDTPARAGPOS& ParagPos) const {
- FXSYS_assert(nIndex >= 0 && nIndex < m_pTxtBuf->GetTextLength());
+ ASSERT(nIndex >= 0 && nIndex < m_pTxtBuf->GetTextLength());
int32_t nCount = m_ParagPtrArray.GetSize();
int32_t nBgn = 0;
int32_t nMid = 0;
@@ -1286,9 +1270,9 @@ void CFDE_TxtEdtEngine::TextPos2ParagPos(int32_t nIndex,
while (nEnd > nBgn) {
nMid = (nBgn + nEnd) / 2;
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[nMid];
- if (nIndex < pParag->m_nCharStart) {
+ if (nIndex < pParag->GetStartIndex()) {
nEnd = nMid - 1;
- } else if (nIndex >= (pParag->m_nCharStart + pParag->m_nCharCount)) {
+ } else if (nIndex >= (pParag->GetStartIndex() + pParag->GetTextLength())) {
nBgn = nMid + 1;
} else {
break;
@@ -1297,11 +1281,11 @@ void CFDE_TxtEdtEngine::TextPos2ParagPos(int32_t nIndex,
if (nBgn == nEnd) {
nMid = nBgn;
}
- FXSYS_assert(nIndex >= m_ParagPtrArray[nMid]->m_nCharStart &&
- (nIndex < m_ParagPtrArray[nMid]->m_nCharStart +
- m_ParagPtrArray[nMid]->m_nCharCount));
+ ASSERT(nIndex >= m_ParagPtrArray[nMid]->GetStartIndex() &&
+ (nIndex < m_ParagPtrArray[nMid]->GetStartIndex() +
+ m_ParagPtrArray[nMid]->GetTextLength()));
ParagPos.nParagIndex = nMid;
- ParagPos.nCharIndex = nIndex - m_ParagPtrArray[nMid]->m_nCharStart;
+ ParagPos.nCharIndex = nIndex - m_ParagPtrArray[nMid]->GetStartIndex();
}
int32_t CFDE_TxtEdtEngine::MoveForward(FX_BOOL& bBefore) {
if (m_nCaret == m_pTxtBuf->GetTextLength() - 1) {
@@ -1353,7 +1337,6 @@ FX_BOOL CFDE_TxtEdtEngine::MoveUp(CFX_PointF& ptCaret) {
} else {
m_nCaretPage--;
}
- m_Param.pEventSink->On_PageChange(this, m_nCaretPage);
ptCaret.x -= rtContent.left;
IFDE_TxtEdtPage* pCurPage = GetPage(m_nCaretPage);
ptCaret.x += pCurPage->GetContentsBox().right();
@@ -1367,7 +1350,6 @@ FX_BOOL CFDE_TxtEdtEngine::MoveUp(CFX_PointF& ptCaret) {
}
ptCaret.y -= rtContent.top;
m_nCaretPage--;
- m_Param.pEventSink->On_PageChange(this, m_nCaretPage);
IFDE_TxtEdtPage* pCurPage = GetPage(m_nCaretPage);
ptCaret.y += pCurPage->GetContentsBox().bottom();
}
@@ -1397,7 +1379,6 @@ FX_BOOL CFDE_TxtEdtEngine::MoveDown(CFX_PointF& ptCaret) {
} else {
m_nCaretPage++;
}
- m_Param.pEventSink->On_PageChange(this, m_nCaretPage);
ptCaret.x -= rtContent.right();
IFDE_TxtEdtPage* pCurPage = GetPage(m_nCaretPage);
ptCaret.x += pCurPage->GetContentsBox().left;
@@ -1411,7 +1392,6 @@ FX_BOOL CFDE_TxtEdtEngine::MoveDown(CFX_PointF& ptCaret) {
}
ptCaret.y -= rtContent.bottom();
m_nCaretPage++;
- m_Param.pEventSink->On_PageChange(this, m_nCaretPage);
IFDE_TxtEdtPage* pCurPage = GetPage(m_nCaretPage);
ptCaret.y += pCurPage->GetContentsBox().top;
}
@@ -1424,7 +1404,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveLineStart() {
TextPos2ParagPos(nIndex, ParagPos);
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex];
pParag->LoadParag();
- int32_t nLineCount = pParag->m_nLineCount;
+ int32_t nLineCount = pParag->GetLineCount();
int32_t i = 0;
int32_t nStart = 0;
int32_t nCount = 0;
@@ -1444,7 +1424,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveLineEnd() {
TextPos2ParagPos(nIndex, ParagPos);
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex];
pParag->LoadParag();
- int32_t nLineCount = pParag->m_nLineCount;
+ int32_t nLineCount = pParag->GetLineCount();
int32_t i = 0;
int32_t nStart = 0;
int32_t nCount = 0;
@@ -1455,7 +1435,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveLineEnd() {
}
}
nIndex = nStart + nCount - 1;
- FXSYS_assert(nIndex <= GetTextBufLength());
+ ASSERT(nIndex <= GetTextBufLength());
FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nIndex);
FX_BOOL bBefore = FALSE;
if (nIndex <= GetTextBufLength()) {
@@ -1479,7 +1459,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveParagStart() {
FDE_TXTEDTPARAGPOS ParagPos;
TextPos2ParagPos(nIndex, ParagPos);
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex];
- UpdateCaretRect(pParag->m_nCharStart, TRUE);
+ UpdateCaretRect(pParag->GetStartIndex(), TRUE);
return TRUE;
}
FX_BOOL CFDE_TxtEdtEngine::MoveParagEnd() {
@@ -1487,7 +1467,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveParagEnd() {
FDE_TXTEDTPARAGPOS ParagPos;
TextPos2ParagPos(nIndex, ParagPos);
CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex];
- nIndex = pParag->m_nCharStart + pParag->m_nCharCount - 1;
+ nIndex = pParag->GetStartIndex() + pParag->GetTextLength() - 1;
FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nIndex);
if (wChar == L'\n' && nIndex > 0) {
nIndex--;
@@ -1509,7 +1489,7 @@ FX_BOOL CFDE_TxtEdtEngine::MoveEnd() {
}
FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
- IFDE_TextOut* pTextOut = IFDE_TextOut::Create();
+ std::unique_ptr<CFDE_TextOut> pTextOut(new CFDE_TextOut);
pTextOut->SetLineSpace(m_Param.fLineSpace);
pTextOut->SetFont(m_Param.pFont);
pTextOut->SetFontSize(m_Param.fFontSize);
@@ -1527,8 +1507,7 @@ FX_BOOL CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
}
pTextOut->SetStyles(dwStyle);
wsText += L"\n";
- pTextOut->CalcLogicSize(wsText, wsText.GetLength(), rcText);
- pTextOut->Release();
+ pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(), rcText);
wsText.Delete(wsText.GetLength() - 1);
if ((m_Param.dwMode & FDE_TEXTEDITMODE_LimitArea_Horz) &&
(rcText.width > m_Param.fPlateWidth)) {
@@ -1610,8 +1589,7 @@ void CFDE_TxtEdtEngine::DeleteSelect() {
int32_t nSelCount;
while (nCountRange > 0) {
nSelCount = GetSelRange(--nCountRange, nSelStart);
- FDE_LPTXTEDTSELRANGE lpTemp = m_SelRangePtrArr[nCountRange];
- delete lpTemp;
+ delete m_SelRangePtrArr[nCountRange];
m_SelRangePtrArr.RemoveAt(nCountRange);
DeleteRange_DoRecord(nSelStart, nSelCount, TRUE);
}
@@ -1622,20 +1600,21 @@ void CFDE_TxtEdtEngine::DeleteSelect() {
return;
}
}
+
IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create(
const CFX_ByteStringC& bsDoRecord) {
- const FX_CHAR* lpBuf = bsDoRecord.c_str();
- int32_t nType = *((int32_t*)lpBuf);
- switch (nType) {
+ const uint32_t* lpBuf =
+ reinterpret_cast<const uint32_t*>(bsDoRecord.raw_str());
+ switch (*lpBuf) {
case FDE_TXTEDT_DORECORD_INS:
return new CFDE_TxtEdtDoRecord_Insert(bsDoRecord);
case FDE_TXTEDT_DORECORD_DEL:
return new CFDE_TxtEdtDoRecord_DeleteRange(bsDoRecord);
default:
- break;
+ return nullptr;
}
- return NULL;
}
+
CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert(
const CFX_ByteStringC& bsDoRecord) {
Deserialize(bsDoRecord);
@@ -1646,7 +1625,7 @@ CFDE_TxtEdtDoRecord_Insert::CFDE_TxtEdtDoRecord_Insert(
const FX_WCHAR* lpText,
int32_t nLength)
: m_pEngine(pEngine), m_nCaret(nCaret) {
- FXSYS_assert(pEngine);
+ ASSERT(pEngine);
FX_WCHAR* lpBuffer = m_wsInsert.GetBuffer(nLength);
FXSYS_memcpy(lpBuffer, lpText, nLength * sizeof(FX_WCHAR));
m_wsInsert.ReleaseBuffer();
@@ -1690,12 +1669,10 @@ void CFDE_TxtEdtDoRecord_Insert::Serialize(CFX_ByteString& bsDoRecord) const {
}
void CFDE_TxtEdtDoRecord_Insert::Deserialize(
const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader(
- reinterpret_cast<const uint8_t*>(bsDoRecord.c_str()),
- bsDoRecord.GetLength());
+ CFX_ArchiveLoader ArchiveLoader(bsDoRecord.raw_str(), bsDoRecord.GetLength());
int32_t nType = 0;
ArchiveLoader >> nType;
- FXSYS_assert(nType == FDE_TXTEDT_DORECORD_INS);
+ ASSERT(nType == FDE_TXTEDT_DORECORD_INS);
int32_t nEngine = 0;
ArchiveLoader >> nEngine;
m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
@@ -1717,7 +1694,7 @@ CFDE_TxtEdtDoRecord_DeleteRange::CFDE_TxtEdtDoRecord_DeleteRange(
m_nIndex(nIndex),
m_nCaret(nCaret),
m_wsRange(wsRange) {
- FXSYS_assert(pEngine);
+ ASSERT(pEngine);
}
CFDE_TxtEdtDoRecord_DeleteRange::~CFDE_TxtEdtDoRecord_DeleteRange() {}
void CFDE_TxtEdtDoRecord_DeleteRange::Release() {
@@ -1767,12 +1744,10 @@ void CFDE_TxtEdtDoRecord_DeleteRange::Serialize(
}
void CFDE_TxtEdtDoRecord_DeleteRange::Deserialize(
const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader(
- reinterpret_cast<const uint8_t*>(bsDoRecord.c_str()),
- bsDoRecord.GetLength());
+ CFX_ArchiveLoader ArchiveLoader(bsDoRecord.raw_str(), bsDoRecord.GetLength());
int32_t nType = 0;
ArchiveLoader >> nType;
- FXSYS_assert(nType == FDE_TXTEDT_DORECORD_DEL);
+ ASSERT(nType == FDE_TXTEDT_DORECORD_DEL);
int32_t nEngine = 0;
ArchiveLoader >> nEngine;
m_pEngine = (CFDE_TxtEdtEngine*)(uintptr_t)nEngine;
diff --git a/chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.h b/chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.h
index 947570e4a47..4671bf549a6 100644
--- a/chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.h
+++ b/chromium/third_party/pdfium/xfa/fee/fde_txtedtengine.h
@@ -8,10 +8,11 @@
#define XFA_FEE_FDE_TXTEDTENGINE_H_
#include "core/fxcrt/include/fx_string.h"
-#include "xfa/fee/ifde_txtedtbuf.h"
+#include "xfa/fee/fde_txtedtbuf.h"
#include "xfa/fee/ifde_txtedtengine.h"
+#include "xfa/fgas/layout/fgas_textbreak.h"
-class IFX_TxtBreak;
+class CFX_TxtBreak;
class IFX_CharIter;
class CFDE_TxtEdtParag;
class CFDE_TxtEdtDoRecord_Insert;
@@ -27,85 +28,66 @@ class IFDE_TxtEdtDoRecord {
virtual void Serialize(CFX_ByteString& bsDoRecord) const = 0;
};
-class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine {
- friend class CFDE_TxtEdtDoRecord_Insert;
- friend class CFDE_TxtEdtDoRecord_DeleteRange;
- friend class CFDE_TxtEdtPage;
- struct _FDE_TXTEDTSELRANGE {
- int32_t nStart;
- int32_t nCount;
- };
- typedef _FDE_TXTEDTSELRANGE FDE_TXTEDTSELRANGE;
- typedef _FDE_TXTEDTSELRANGE* FDE_LPTXTEDTSELRANGE;
- struct _FDE_TXTEDTPARAGPOS {
- int32_t nParagIndex;
- int32_t nCharIndex;
- };
- typedef _FDE_TXTEDTPARAGPOS FDE_TXTEDTPARAGPOS;
- typedef _FDE_TXTEDTPARAGPOS* FDE_LPTXTEDTPARAGPOS;
-
+class CFDE_TxtEdtEngine {
public:
CFDE_TxtEdtEngine();
- virtual void Release();
-
- virtual void SetEditParams(const FDE_TXTEDTPARAMS& params);
- virtual const FDE_TXTEDTPARAMS* GetEditParams() const;
-
- virtual int32_t CountPages() const;
- virtual IFDE_TxtEdtPage* GetPage(int32_t nIndex);
-
- virtual FX_BOOL SetBufChunkSize(int32_t nChunkSize);
- virtual void SetTextByStream(IFX_Stream* pStream);
- virtual void SetText(const CFX_WideString& wsText);
- virtual int32_t GetTextLength() const;
- virtual void GetText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount = -1);
- virtual void ClearText();
-
- virtual int32_t GetCaretRect(CFX_RectF& rtCaret) const;
- virtual int32_t GetCaretPos() const;
- virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore);
- virtual int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
- FX_BOOL bShift = FALSE,
- FX_BOOL bCtrl = FALSE);
- virtual void Lock();
- virtual void Unlock();
- virtual FX_BOOL IsLocked() const;
-
- virtual int32_t Insert(int32_t nStart,
- const FX_WCHAR* lpText,
- int32_t nLength);
- virtual int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE);
- virtual int32_t DeleteRange(int32_t nStart, int32_t nCount = -1);
- virtual int32_t Replace(int32_t nStart,
- int32_t nLength,
- const CFX_WideString& wsReplace);
- virtual void SetLimit(int32_t nLimit);
- virtual void SetAliasChar(FX_WCHAR wcAlias);
+ void Release();
+
+ void SetEditParams(const FDE_TXTEDTPARAMS& params);
+ FDE_TXTEDTPARAMS* GetEditParams();
+
+ int32_t CountPages() const;
+ IFDE_TxtEdtPage* GetPage(int32_t nIndex);
+
+ FX_BOOL SetBufChunkSize(int32_t nChunkSize);
+ void SetTextByStream(IFX_Stream* pStream);
+ void SetText(const CFX_WideString& wsText);
+ int32_t GetTextLength() const;
+ void GetText(CFX_WideString& wsText, int32_t nStart, int32_t nCount = -1);
+ void ClearText();
+
+ int32_t GetCaretRect(CFX_RectF& rtCaret) const;
+ int32_t GetCaretPos() const;
+ int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore);
+ int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
+ FX_BOOL bShift = FALSE,
+ FX_BOOL bCtrl = FALSE);
+ void Lock();
+ void Unlock();
+ FX_BOOL IsLocked() const;
+
+ int32_t Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength);
+ int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE);
+ int32_t DeleteRange(int32_t nStart, int32_t nCount = -1);
+ int32_t Replace(int32_t nStart,
+ int32_t nLength,
+ const CFX_WideString& wsReplace);
+
+ void SetLimit(int32_t nLimit);
+ void SetAliasChar(FX_WCHAR wcAlias);
void RemoveSelRange(int32_t nStart, int32_t nCount = -1);
- virtual void AddSelRange(int32_t nStart, int32_t nCount = -1);
- virtual int32_t CountSelRanges();
- virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
- virtual void ClearSelection();
+ void AddSelRange(int32_t nStart, int32_t nCount = -1);
+ int32_t CountSelRanges();
+ int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
+ void ClearSelection();
- virtual FX_BOOL Redo(const CFX_ByteStringC& bsRedo);
- virtual FX_BOOL Undo(const CFX_ByteStringC& bsUndo);
+ FX_BOOL Redo(const CFX_ByteStringC& bsRedo);
+ FX_BOOL Undo(const CFX_ByteStringC& bsUndo);
- virtual int32_t StartLayout();
- virtual int32_t DoLayout(IFX_Pause* pPause);
- virtual void EndLayout();
+ int32_t StartLayout();
+ int32_t DoLayout(IFX_Pause* pPause);
+ void EndLayout();
- virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL);
- virtual int32_t CountParags() const;
- virtual IFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const;
- virtual IFX_CharIter* CreateCharIter();
- IFDE_TxtEdtBuf* GetTextBuf() const;
+ FX_BOOL Optimize(IFX_Pause* pPause = NULL);
+ int32_t CountParags() const;
+ CFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const;
+ IFX_CharIter* CreateCharIter();
+ CFDE_TxtEdtBuf* GetTextBuf() const;
int32_t GetTextBufLength() const;
- IFX_TxtBreak* GetTextBreak() const;
+ CFX_TxtBreak* GetTextBreak() const;
int32_t GetLineCount() const;
int32_t GetPageLineCount() const;
@@ -116,9 +98,23 @@ class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine {
FX_WCHAR GetAliasChar() const { return m_wcAliasChar; }
protected:
- virtual ~CFDE_TxtEdtEngine();
+ ~CFDE_TxtEdtEngine();
private:
+ friend class CFDE_TxtEdtDoRecord_Insert;
+ friend class CFDE_TxtEdtDoRecord_DeleteRange;
+ friend class CFDE_TxtEdtPage;
+
+ struct FDE_TXTEDTSELRANGE {
+ int32_t nStart;
+ int32_t nCount;
+ };
+
+ struct FDE_TXTEDTPARAGPOS {
+ int32_t nParagIndex;
+ int32_t nCharIndex;
+ };
+
void Inner_Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength);
void GetPreDeleteText(CFX_WideString& wsText,
int32_t nIndex,
@@ -172,12 +168,12 @@ class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine {
FX_BOOL IsSelect();
void DeleteSelect();
- IFDE_TxtEdtBuf* m_pTxtBuf;
- IFX_TxtBreak* m_pTextBreak;
+ CFDE_TxtEdtBuf* m_pTxtBuf;
+ CFX_TxtBreak* m_pTextBreak;
FDE_TXTEDTPARAMS m_Param;
CFX_ArrayTemplate<IFDE_TxtEdtPage*> m_PagePtrArray;
CFX_ArrayTemplate<CFDE_TxtEdtParag*> m_ParagPtrArray;
- CFX_ArrayTemplate<FDE_LPTXTEDTSELRANGE> m_SelRangePtrArr;
+ CFX_ArrayTemplate<FDE_TXTEDTSELRANGE*> m_SelRangePtrArr;
int32_t m_nPageLineCount;
int32_t m_nLineCount;
int32_t m_nAnchorPos;
diff --git a/chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.cpp b/chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.cpp
index f75fcd1426d..87d128ad562 100644
--- a/chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.cpp
+++ b/chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.cpp
@@ -12,13 +12,12 @@
#include "xfa/fee/fde_txtedtengine.h"
#include "xfa/fee/fde_txtedtparag.h"
#include "xfa/fee/fx_wordbreak/fx_wordbreak.h"
-#include "xfa/fee/ifde_txtedtbuf.h"
#include "xfa/fee/ifde_txtedtengine.h"
#include "xfa/fee/ifde_txtedtpage.h"
#define FDE_TXTEDT_TOLERANCE 0.1f
-IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(IFDE_TxtEdtEngine* pEngine,
+IFDE_TxtEdtPage* IFDE_TxtEdtPage::Create(CFDE_TxtEdtEngine* pEngine,
int32_t nIndex) {
return (IFDE_TxtEdtPage*)new CFDE_TxtEdtPage(pEngine, nIndex);
}
@@ -76,13 +75,11 @@ int32_t CFDE_TxtEdtTextSet::GetDisplayPos(FDE_HVISUALOBJ hText,
}
CFDE_TxtEdtEngine* pEngine = (CFDE_TxtEdtEngine*)(m_pPage->GetEngine());
const FDE_TXTEDTPARAMS* pTextParams = pEngine->GetEditParams();
- IFX_TxtBreak* pBreak = pEngine->GetTextBreak();
+ CFX_TxtBreak* pBreak = pEngine->GetTextBreak();
uint32_t dwLayoutStyle = pBreak->GetLayoutStyles();
FX_TXTRUN tr;
tr.pAccess = m_pPage;
tr.pIdentity = (void*)hText;
- tr.pStr = NULL;
- tr.pWidths = NULL;
tr.iLength = nLength;
tr.pFont = pTextParams->pFont;
tr.fFontSize = pTextParams->fFontSize;
@@ -114,8 +111,6 @@ int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText,
FX_TXTRUN tr;
tr.pAccess = m_pPage;
tr.pIdentity = (void*)hText;
- tr.pStr = NULL;
- tr.pWidths = NULL;
tr.iLength = nLength;
tr.pFont = pTextParams->pFont;
tr.fFontSize = pTextParams->fFontSize;
@@ -126,7 +121,7 @@ int32_t CFDE_TxtEdtTextSet::GetCharRects_Impl(FDE_HVISUALOBJ hText,
tr.wLineBreakChar = pTextParams->wLineBreakChar;
return pEngine->GetTextBreak()->GetCharRects(&tr, rtArray, bBBox);
}
-CFDE_TxtEdtPage::CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
+CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
: m_pIter(nullptr),
m_pTextSet(nullptr),
m_pBgnParag(nullptr),
@@ -143,26 +138,18 @@ CFDE_TxtEdtPage::CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nPageIndex)
FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF));
m_pEditEngine = (CFDE_TxtEdtEngine*)pEngine;
}
+
CFDE_TxtEdtPage::~CFDE_TxtEdtPage() {
m_PieceMassArr.RemoveAll(TRUE);
- if (m_pTextSet) {
- delete m_pTextSet;
- m_pTextSet = NULL;
- }
- if (m_pCharWidth) {
- delete[] m_pCharWidth;
- m_pCharWidth = NULL;
- }
- if (m_pIter != NULL) {
- m_pIter->Release();
- m_pIter = NULL;
- }
+ delete m_pTextSet;
+ delete[] m_pCharWidth;
}
+
void CFDE_TxtEdtPage::Release() {
delete this;
}
-IFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const {
- return (IFDE_TxtEdtEngine*)m_pEditEngine;
+CFDE_TxtEdtEngine* CFDE_TxtEdtPage::GetEngine() const {
+ return m_pEditEngine;
}
FDE_VISUALOBJTYPE CFDE_TxtEdtPage::GetType() {
return FDE_VISUALOBJ_Text;
@@ -183,8 +170,8 @@ FX_BOOL CFDE_TxtEdtPage::GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) {
int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
CFX_RectF& rect,
FX_BOOL bBBox) const {
- FXSYS_assert(m_nRefCount > 0);
- FXSYS_assert(nIndex >= 0 && nIndex < m_nCharCount);
+ ASSERT(m_nRefCount > 0);
+ ASSERT(nIndex >= 0 && nIndex < m_nCharCount);
if (m_nRefCount < 1) {
return 0;
}
@@ -203,7 +190,7 @@ int32_t CFDE_TxtEdtPage::GetCharRect(int32_t nIndex,
return pPiece->nBidiLevel;
}
}
- FXSYS_assert(0);
+ ASSERT(0);
return 0;
}
int32_t CFDE_TxtEdtPage::GetCharIndex(const CFX_PointF& fPoint,
@@ -359,7 +346,7 @@ int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) {
if (m_nRefCount < 0) {
return -1;
}
- IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
+ CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
FX_BOOL bBefore;
int32_t nIndex = GetCharIndex(fPoint, bBefore);
if (nIndex == m_pEditEngine->GetTextBufLength()) {
@@ -368,13 +355,11 @@ int32_t CFDE_TxtEdtPage::SelectWord(const CFX_PointF& fPoint, int32_t& nCount) {
if (nIndex < 0) {
return -1;
}
- IFX_WordBreak* pIter = FX_WordBreak_Create();
+ std::unique_ptr<CFX_WordBreak> pIter(new CFX_WordBreak);
pIter->Attach(new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf));
pIter->SetAt(nIndex);
nCount = pIter->GetWordLength();
- int32_t nRet = pIter->GetWordPos();
- pIter->Release();
- return nRet;
+ return pIter->GetWordPos();
}
FX_BOOL CFDE_TxtEdtPage::IsLoaded(const CFX_RectF* pClipBox) {
return m_bLoaded;
@@ -385,17 +370,15 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
m_nRefCount++;
return m_nRefCount;
}
- IFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
+ CFDE_TxtEdtBuf* pBuf = m_pEditEngine->GetTextBuf();
const FDE_TXTEDTPARAMS* pParams = m_pEditEngine->GetEditParams();
- if (m_pIter != NULL) {
- m_pIter->Release();
- }
FX_WCHAR wcAlias = 0;
if (pParams->dwMode & FDE_TEXTEDITMODE_Password) {
wcAlias = m_pEditEngine->GetAliasChar();
}
- m_pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pBuf, wcAlias);
- IFX_TxtBreak* pBreak = m_pEditEngine->GetTextBreak();
+ m_pIter.reset(
+ new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pBuf), wcAlias));
+ CFX_TxtBreak* pBreak = m_pEditEngine->GetTextBreak();
pBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
pBreak->ClearBreakPieces();
int32_t nPageLineCount = m_pEditEngine->GetPageLineCount();
@@ -440,7 +423,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
m_nCharCount = nPageEnd - nPageStart + 1;
FX_BOOL bReload = FALSE;
FX_FLOAT fDefCharWidth = 0;
- IFX_CharIter* pIter = m_pIter->Clone();
+ std::unique_ptr<IFX_CharIter> pIter(m_pIter->Clone());
pIter->SetAt(nPageStart);
m_pIter->SetAt(nPageStart);
FX_BOOL bFirstPiece = TRUE;
@@ -554,37 +537,31 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
FDE_TEXTEDITPIECE* pPiece = m_PieceMassArr.GetPtrAt(nCount - 1);
pPiece->rtPiece.height = pParams->fFontSize;
}
- pIter->Release();
m_nRefCount = 1;
m_bLoaded = TRUE;
return 0;
}
+
void CFDE_TxtEdtPage::UnloadPage(const CFX_RectF* pClipBox) {
- FXSYS_assert(m_nRefCount > 0);
+ ASSERT(m_nRefCount > 0);
m_nRefCount--;
- if (m_nRefCount == 0) {
- m_PieceMassArr.RemoveAll();
- if (m_pTextSet) {
- delete m_pTextSet;
- m_pTextSet = NULL;
- }
- if (m_pCharWidth) {
- delete[] m_pCharWidth;
- m_pCharWidth = NULL;
- }
- if (m_pBgnParag) {
- m_pBgnParag->UnloadParag();
- }
- if (m_pEndParag) {
- m_pEndParag->UnloadParag();
- }
- if (m_pIter) {
- m_pIter->Release();
- m_pIter = NULL;
- }
- m_pBgnParag = NULL;
- m_pEndParag = NULL;
- }
+ if (m_nRefCount != 0)
+ return;
+
+ m_PieceMassArr.RemoveAll();
+ delete m_pTextSet;
+ m_pTextSet = nullptr;
+ delete[] m_pCharWidth;
+ m_pCharWidth = nullptr;
+ if (m_pBgnParag) {
+ m_pBgnParag->UnloadParag();
+ m_pBgnParag = nullptr;
+ }
+ if (m_pEndParag) {
+ m_pEndParag->UnloadParag();
+ m_pEndParag = nullptr;
+ }
+ m_pIter.reset();
}
const CFX_RectF& CFDE_TxtEdtPage::GetContentsBox() {
diff --git a/chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.h b/chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.h
index 13a444f0da3..81f29fed496 100644
--- a/chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.h
+++ b/chromium/third_party/pdfium/xfa/fee/fde_txtedtpage.h
@@ -7,6 +7,8 @@
#ifndef XFA_FEE_FDE_TXTEDTPAGE_H_
#define XFA_FEE_FDE_TXTEDTPAGE_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "xfa/fde/fde_visualset.h"
@@ -97,11 +99,11 @@ class CFDE_TxtEdtTextSet : public IFDE_TextSet {
class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
public:
- CFDE_TxtEdtPage(IFDE_TxtEdtEngine* pEngine, int32_t nLineIndex);
+ CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nLineIndex);
// IFDE_TxtEditPage:
void Release() override;
- IFDE_TxtEdtEngine* GetEngine() const override;
+ CFDE_TxtEdtEngine* GetEngine() const override;
int32_t GetCharRect(int32_t nIndex,
CFX_RectF& rect,
FX_BOOL bBBox = FALSE) const override;
@@ -147,7 +149,7 @@ class CFDE_TxtEdtPage : public IFDE_TxtEdtPage {
const CFX_RectF& rtF,
FX_FLOAT fTolerance) const;
- IFX_CharIter* m_pIter;
+ std::unique_ptr<IFX_CharIter> m_pIter;
CFDE_TxtEdtTextSet* m_pTextSet;
CFDE_TxtEdtEngine* m_pEditEngine;
CFDE_TXTEDTPieceMassArray m_PieceMassArr;
diff --git a/chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.cpp b/chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.cpp
index cac8c3c4559..4f5b5a15df4 100644
--- a/chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.cpp
+++ b/chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.cpp
@@ -9,7 +9,6 @@
#include "xfa/fee/fde_txtedtbuf.h"
#include "xfa/fee/fde_txtedtengine.h"
#include "xfa/fee/fx_wordbreak/fx_wordbreak.h"
-#include "xfa/fee/ifde_txtedtbuf.h"
#include "xfa/fee/ifde_txtedtengine.h"
#include "xfa/fgas/layout/fgas_textbreak.h"
@@ -19,7 +18,7 @@ CFDE_TxtEdtParag::CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine)
m_nLineCount(0),
m_lpData(NULL),
m_pEngine(pEngine) {
- FXSYS_assert(m_pEngine);
+ ASSERT(m_pEngine);
}
CFDE_TxtEdtParag::~CFDE_TxtEdtParag() {
if (m_lpData != NULL) {
@@ -31,15 +30,15 @@ void CFDE_TxtEdtParag::LoadParag() {
((int32_t*)m_lpData)[0]++;
return;
}
- IFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak();
- IFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf();
+ CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak();
+ CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf();
const FDE_TXTEDTPARAMS* pParam = m_pEngine->GetEditParams();
FX_WCHAR wcAlias = 0;
if (pParam->dwMode & FDE_TEXTEDITMODE_Password) {
wcAlias = m_pEngine->GetAliasChar();
}
- IFX_CharIter* pIter =
- new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf, wcAlias);
+ std::unique_ptr<IFX_CharIter> pIter(
+ new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pTxtBuf), wcAlias));
pIter->SetAt(m_nCharStart);
int32_t nEndIndex = m_nCharStart + m_nCharCount;
CFX_ArrayTemplate<int32_t> LineBaseArr;
@@ -72,7 +71,6 @@ void CFDE_TxtEdtParag::LoadParag() {
pIter->Next(TRUE);
}
} while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex));
- pIter->Release();
pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
pTxtBreak->ClearBreakPieces();
int32_t nLineCount = LineBaseArr.GetSize();
@@ -92,21 +90,22 @@ void CFDE_TxtEdtParag::LoadParag() {
LineBaseArr.RemoveAll();
}
void CFDE_TxtEdtParag::UnloadParag() {
- FXSYS_assert(m_lpData != NULL);
+ ASSERT(m_lpData != NULL);
((int32_t*)m_lpData)[0]--;
- FXSYS_assert(((int32_t*)m_lpData)[0] >= 0);
+ ASSERT(((int32_t*)m_lpData)[0] >= 0);
if (((int32_t*)m_lpData)[0] == 0) {
FX_Free(m_lpData);
m_lpData = NULL;
}
}
void CFDE_TxtEdtParag::CalcLines() {
- IFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak();
- IFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf();
- IFX_CharIter* pIter = new CFDE_TxtEdtBufIter((CFDE_TxtEdtBuf*)pTxtBuf);
+ CFX_TxtBreak* pTxtBreak = m_pEngine->GetTextBreak();
+ CFDE_TxtEdtBuf* pTxtBuf = m_pEngine->GetTextBuf();
int32_t nCount = 0;
uint32_t dwBreakStatus = FX_TXTBREAK_None;
int32_t nEndIndex = m_nCharStart + m_nCharCount;
+ std::unique_ptr<IFX_CharIter> pIter(
+ new CFDE_TxtEdtBufIter(static_cast<CFDE_TxtEdtBuf*>(pTxtBuf)));
pIter->SetAt(m_nCharStart);
FX_BOOL bReload = FALSE;
do {
@@ -130,7 +129,6 @@ void CFDE_TxtEdtParag::CalcLines() {
pIter->Next(TRUE);
}
} while (pIter->Next(FALSE) && (pIter->GetAt() < nEndIndex));
- pIter->Release();
pTxtBreak->EndBreak(FX_TXTBREAK_ParagraphBreak);
pTxtBreak->ClearBreakPieces();
m_nLineCount = nCount;
@@ -139,7 +137,7 @@ void CFDE_TxtEdtParag::GetLineRange(int32_t nLineIndex,
int32_t& nStart,
int32_t& nCount) const {
int32_t* pLineBaseArr = (int32_t*)m_lpData;
- FXSYS_assert(nLineIndex < m_nLineCount);
+ ASSERT(nLineIndex < m_nLineCount);
nStart = m_nCharStart;
pLineBaseArr++;
for (int32_t i = 0; i < nLineIndex; i++) {
diff --git a/chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.h b/chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.h
index 39921d5ef7e..24ecbc7bf04 100644
--- a/chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.h
+++ b/chromium/third_party/pdfium/xfa/fee/fde_txtedtparag.h
@@ -7,29 +7,35 @@
#ifndef XFA_FEE_FDE_TXTEDTPARAG_H_
#define XFA_FEE_FDE_TXTEDTPARAG_H_
-#include "xfa/fee/ifde_txtedtengine.h"
+#include <stdint.h>
class CFDE_TxtEdtEngine;
-class CFDE_TxtEdtParag : public IFDE_TxtEdtParag {
+class CFDE_TxtEdtParag {
public:
explicit CFDE_TxtEdtParag(CFDE_TxtEdtEngine* pEngine);
~CFDE_TxtEdtParag();
- virtual int32_t GetTextLength() const { return m_nCharCount; }
- virtual int32_t GetStartIndex() const { return m_nCharStart; }
- virtual int32_t CountLines() const { return m_nLineCount; }
- virtual void GetLineRange(int32_t nLineIndex,
- int32_t& nStart,
- int32_t& nCount) const;
+ int32_t GetTextLength() const { return m_nCharCount; }
+ int32_t GetStartIndex() const { return m_nCharStart; }
+ int32_t GetLineCount() const { return m_nLineCount; }
+
+ void SetTextLength(int32_t len) { m_nCharCount = len; }
+ void IncrementTextLength(int32_t len) { m_nCharCount += len; }
+ void SetStartIndex(int32_t idx) { m_nCharStart = idx; }
+ void IncrementStartIndex(int32_t val) { m_nCharStart += val; }
+ void DecrementStartIndex(int32_t val) { m_nCharStart -= val; }
+ void SetLineCount(int32_t count) { m_nLineCount = count; }
+
+ void GetLineRange(int32_t nLineIndex, int32_t& nStart, int32_t& nCount) const;
void LoadParag();
void UnloadParag();
void CalcLines();
+
+ private:
int32_t m_nCharStart;
int32_t m_nCharCount;
int32_t m_nLineCount;
-
- private:
void* m_lpData;
CFDE_TxtEdtEngine* m_pEngine;
};
diff --git a/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak.h b/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak.h
index fb352301367..e1b17875792 100644
--- a/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak.h
+++ b/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak.h
@@ -7,24 +7,51 @@
#ifndef XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_
#define XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fee/ifde_txtedtengine.h"
+
+class CFX_CharIter : public IFX_CharIter {
+ public:
+ explicit CFX_CharIter(const CFX_WideString& wsText);
+ ~CFX_CharIter() override;
+
+ FX_BOOL Next(FX_BOOL bPrev = FALSE) override;
+ FX_WCHAR GetChar() override;
+ void SetAt(int32_t nIndex) override;
+ int32_t GetAt() const override;
+ FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const override;
+ IFX_CharIter* Clone() override;
-class IFX_CharIter;
+ private:
+ const CFX_WideString& m_wsText;
+ int32_t m_nIndex;
+};
-class IFX_WordBreak {
+class CFX_WordBreak {
public:
- virtual ~IFX_WordBreak() {}
- virtual void Release() = 0;
- virtual void Attach(IFX_CharIter* pIter) = 0;
- virtual void Attach(const CFX_WideString& wsText) = 0;
- virtual FX_BOOL Next(FX_BOOL bPrev) = 0;
- virtual void SetAt(int32_t nIndex) = 0;
- virtual int32_t GetWordPos() const = 0;
- virtual int32_t GetWordLength() const = 0;
- virtual void GetWord(CFX_WideString& wsWord) const = 0;
- virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const = 0;
+ CFX_WordBreak();
+ ~CFX_WordBreak();
+
+ void Attach(IFX_CharIter* pIter);
+ void Attach(const CFX_WideString& wsText);
+ FX_BOOL Next(FX_BOOL bPrev);
+ void SetAt(int32_t nIndex);
+ int32_t GetWordPos() const;
+ int32_t GetWordLength() const;
+ void GetWord(CFX_WideString& wsWord) const;
+ FX_BOOL IsEOF(FX_BOOL bTail) const;
+
+ protected:
+ FX_BOOL FindNextBreakPos(IFX_CharIter* pIter,
+ FX_BOOL bPrev,
+ FX_BOOL bFromNext = TRUE);
+
+ private:
+ std::unique_ptr<IFX_CharIter> m_pPreIter;
+ std::unique_ptr<IFX_CharIter> m_pCurIter;
};
-IFX_WordBreak* FX_WordBreak_Create();
#endif // XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_H_
diff --git a/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp b/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp
index 3f6e2404309..eda5368afbc 100644
--- a/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp
+++ b/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp
@@ -12,14 +12,14 @@ FX_WordBreakProp FX_GetWordBreakProperty(FX_WCHAR wcCodePoint) {
return (FX_WordBreakProp)(((wcCodePoint)&1) ? (dwProperty & 0x0F)
: (dwProperty >> 4));
}
+
CFX_CharIter::CFX_CharIter(const CFX_WideString& wsText)
: m_wsText(wsText), m_nIndex(0) {
- FXSYS_assert(!wsText.IsEmpty());
+ ASSERT(!wsText.IsEmpty());
}
+
CFX_CharIter::~CFX_CharIter() {}
-void CFX_CharIter::Release() {
- delete this;
-}
+
FX_BOOL CFX_CharIter::Next(FX_BOOL bPrev) {
if (bPrev) {
if (m_nIndex <= 0) {
@@ -54,60 +54,46 @@ IFX_CharIter* CFX_CharIter::Clone() {
pIter->m_nIndex = m_nIndex;
return pIter;
}
-CFX_WordBreak::CFX_WordBreak() : m_pPreIter(NULL), m_pCurIter(NULL) {}
-CFX_WordBreak::~CFX_WordBreak() {
- if (m_pPreIter) {
- m_pPreIter->Release();
- m_pPreIter = NULL;
- }
- if (m_pCurIter) {
- m_pCurIter->Release();
- m_pCurIter = NULL;
- }
-}
-void CFX_WordBreak::Release() {
- delete this;
-}
+
+CFX_WordBreak::CFX_WordBreak() {}
+
+CFX_WordBreak::~CFX_WordBreak() {}
+
void CFX_WordBreak::Attach(IFX_CharIter* pIter) {
- FXSYS_assert(pIter);
- m_pCurIter = pIter;
+ ASSERT(pIter);
+ m_pCurIter.reset(pIter);
}
void CFX_WordBreak::Attach(const CFX_WideString& wsText) {
- m_pCurIter = new CFX_CharIter(wsText);
+ m_pCurIter.reset(new CFX_CharIter(wsText));
}
FX_BOOL CFX_WordBreak::Next(FX_BOOL bPrev) {
- IFX_CharIter* pIter = bPrev ? m_pPreIter->Clone() : m_pCurIter->Clone();
- if (pIter->IsEOF(!bPrev)) {
+ std::unique_ptr<IFX_CharIter> pIter(
+ (bPrev ? m_pPreIter : m_pCurIter)->Clone());
+ if (pIter->IsEOF(!bPrev))
return FALSE;
- }
+
pIter->Next(bPrev);
- if (!FindNextBreakPos(pIter, bPrev, TRUE)) {
- pIter->Release();
+ if (!FindNextBreakPos(pIter.get(), bPrev, TRUE))
return FALSE;
- }
+
if (bPrev) {
- m_pCurIter->Release();
- m_pCurIter = m_pPreIter;
+ m_pCurIter = std::move(m_pPreIter);
m_pCurIter->Next(TRUE);
- m_pPreIter = pIter;
+ m_pPreIter = std::move(pIter);
} else {
- m_pPreIter->Release();
- m_pPreIter = m_pCurIter;
+ m_pPreIter = std::move(m_pCurIter);
m_pPreIter->Next();
- m_pCurIter = pIter;
+ m_pCurIter = std::move(pIter);
}
return TRUE;
}
void CFX_WordBreak::SetAt(int32_t nIndex) {
- if (m_pPreIter) {
- m_pPreIter->Release();
- m_pPreIter = NULL;
- }
+ m_pPreIter.reset();
m_pCurIter->SetAt(nIndex);
- FindNextBreakPos(m_pCurIter, TRUE, FALSE);
- m_pPreIter = m_pCurIter;
- m_pCurIter = m_pPreIter->Clone();
- FindNextBreakPos(m_pCurIter, FALSE, FALSE);
+ FindNextBreakPos(m_pCurIter.get(), TRUE, FALSE);
+ m_pPreIter = std::move(m_pCurIter);
+ m_pCurIter.reset(m_pPreIter->Clone());
+ FindNextBreakPos(m_pCurIter.get(), FALSE, FALSE);
}
int32_t CFX_WordBreak::GetWordPos() const {
return m_pPreIter->GetAt();
@@ -121,16 +107,13 @@ void CFX_WordBreak::GetWord(CFX_WideString& wsWord) const {
return;
}
FX_WCHAR* lpBuf = wsWord.GetBuffer(nWordLength);
- IFX_CharIter* pTempIter = m_pPreIter->Clone();
+ std::unique_ptr<IFX_CharIter> pTempIter(m_pPreIter->Clone());
int32_t i = 0;
while (pTempIter->GetAt() <= m_pCurIter->GetAt()) {
lpBuf[i++] = pTempIter->GetChar();
- FX_BOOL bEnd = pTempIter->Next();
- if (!bEnd) {
+ if (!pTempIter->Next())
break;
- }
}
- pTempIter->Release();
wsWord.ReleaseBuffer(nWordLength);
}
FX_BOOL CFX_WordBreak::IsEOF(FX_BOOL bTail) const {
@@ -183,7 +166,7 @@ FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter,
}
}
if (nFlags > 0) {
- FXSYS_assert(nFlags <= 2);
+ ASSERT(nFlags <= 2);
if (!((nFlags == 1 && ePreType == FX_WordBreakProp_ALetter) ||
(nFlags == 2 && ePreType == FX_WordBreakProp_Numberic))) {
pIter->Next(!bPrev);
@@ -215,7 +198,7 @@ FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter,
pIter->Next(!bPrev);
return TRUE;
}
- FXSYS_assert(nFlags <= 2);
+ ASSERT(nFlags <= 2);
pIter->Next(bPrev);
wcTemp = pIter->GetChar();
eNextType = (FX_WordBreakProp)FX_GetWordBreakProperty(wcTemp);
@@ -233,6 +216,3 @@ FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter,
} while (!pIter->IsEOF(!bPrev));
return TRUE;
}
-IFX_WordBreak* FX_WordBreak_Create() {
- return new CFX_WordBreak;
-}
diff --git a/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h b/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h
index 16c429b5fe7..5cbd1856021 100644
--- a/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h
+++ b/chromium/third_party/pdfium/xfa/fee/fx_wordbreak/fx_wordbreak_impl.h
@@ -33,46 +33,5 @@ enum FX_WordBreakProp {
FX_WordBreakProp_ExtendNumLet,
};
FX_WordBreakProp FX_GetWordBreakProperty(FX_WCHAR wcCodePoint);
-class CFX_CharIter : public IFX_CharIter {
- public:
- CFX_CharIter(const CFX_WideString& wsText);
- virtual void Release();
- virtual FX_BOOL Next(FX_BOOL bPrev = FALSE);
- virtual FX_WCHAR GetChar();
- virtual void SetAt(int32_t nIndex);
- virtual int32_t GetAt() const;
- virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const;
- virtual IFX_CharIter* Clone();
-
- protected:
- ~CFX_CharIter();
-
- private:
- const CFX_WideString& m_wsText;
- int32_t m_nIndex;
-};
-class CFX_WordBreak : public IFX_WordBreak {
- public:
- CFX_WordBreak();
- virtual void Release();
- virtual void Attach(IFX_CharIter* pIter);
- virtual void Attach(const CFX_WideString& wsText);
- virtual FX_BOOL Next(FX_BOOL bPrev);
- virtual void SetAt(int32_t nIndex);
- virtual int32_t GetWordPos() const;
- virtual int32_t GetWordLength() const;
- virtual void GetWord(CFX_WideString& wsWord) const;
- virtual FX_BOOL IsEOF(FX_BOOL bTail) const;
-
- protected:
- ~CFX_WordBreak();
- FX_BOOL FindNextBreakPos(IFX_CharIter* pIter,
- FX_BOOL bPrev,
- FX_BOOL bFromNext = TRUE);
-
- private:
- IFX_CharIter* m_pPreIter;
- IFX_CharIter* m_pCurIter;
-};
#endif // XFA_FEE_FX_WORDBREAK_FX_WORDBREAK_IMPL_H_
diff --git a/chromium/third_party/pdfium/xfa/fee/ifde_txtedtbuf.h b/chromium/third_party/pdfium/xfa/fee/ifde_txtedtbuf.h
deleted file mode 100644
index db744b1b548..00000000000
--- a/chromium/third_party/pdfium/xfa/fee/ifde_txtedtbuf.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FEE_IFDE_TXTEDTBUF_H_
-#define XFA_FEE_IFDE_TXTEDTBUF_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-#define FDE_DEFCHUNKLENGTH (1024)
-
-class IFDE_TxtEdtBuf {
- public:
- virtual ~IFDE_TxtEdtBuf() {}
- virtual void Release() = 0;
-
- virtual FX_BOOL SetChunkSize(int32_t nChunkSize) = 0;
- virtual int32_t GetChunkSize() const = 0;
- virtual int32_t GetTextLength() const = 0;
- virtual void SetText(const CFX_WideString& wsText) = 0;
- virtual void GetText(CFX_WideString& wsText) const = 0;
- virtual FX_WCHAR GetCharByIndex(int32_t nIndex) const = 0;
- virtual void GetRange(CFX_WideString& wsText,
- int32_t nBegin,
- int32_t nCount = -1) const = 0;
-
- virtual void Insert(int32_t nPos,
- const FX_WCHAR* lpText,
- int32_t nLength = 1) = 0;
- virtual void Delete(int32_t nIndex, int32_t nLength = 1) = 0;
-
- virtual void Clear(FX_BOOL bRelease = TRUE) = 0;
-
- virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL) = 0;
-};
-
-#endif // XFA_FEE_IFDE_TXTEDTBUF_H_
diff --git a/chromium/third_party/pdfium/xfa/fee/ifde_txtedtengine.h b/chromium/third_party/pdfium/xfa/fee/ifde_txtedtengine.h
index 047bf50b4e9..54e96b8c8f2 100644
--- a/chromium/third_party/pdfium/xfa/fee/ifde_txtedtengine.h
+++ b/chromium/third_party/pdfium/xfa/fee/ifde_txtedtengine.h
@@ -7,21 +7,15 @@
#ifndef XFA_FEE_IFDE_TXTEDTENGINE_H_
#define XFA_FEE_IFDE_TXTEDTENGINE_H_
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fgas/font/fgas_font.h"
+class CFDE_TxtEdtEngine;
+class CFWL_EditImp;
class IFDE_TxtEdtPage;
-class IFDE_TxtEdtEngine;
-class IFDE_TxtEdtEventSink;
-class IFDE_TxtEdtParag;
typedef struct FDE_HTXTEDTFIND_ { void* pData; } * FDE_HTXTEDTFIND;
-#define FDE_TXTEDT_FIND_FLAGS_Prev (0L << 0)
-#define FDE_TXTEDT_FIND_FLAGS_Next (1L << 0)
-#define FDE_TXTEDT_FIND_FLAGS_WholeWord (1L << 1)
-#define FDE_TXTEDT_FIND_FLAGS_NoCase (1L << 2)
-
#define FDE_TEXTEDITMODE_MultiLines (1L << 0)
#define FDE_TEXTEDITMODE_AutoLineWrap (1L << 1)
#define FDE_TEXTEDITMODE_ReadOnly (1L << 2)
@@ -67,6 +61,7 @@ enum FDE_TXTEDTMOVECARET {
MC_Home,
MC_End,
};
+
enum FDE_TXTEDT_MODIFY_RET {
FDE_TXTEDT_MODIFY_RET_F_Tab = -6,
FDE_TXTEDT_MODIFY_RET_F_Locked = -5,
@@ -80,21 +75,23 @@ enum FDE_TXTEDT_MODIFY_RET {
FDE_TXTEDT_MODIFY_RET_S_Empty = 3,
FDE_TXTEDT_MODIFY_RET_T_Tab = 4,
};
+
enum FDE_TXTEDIT_LINEEND {
FDE_TXTEDIT_LINEEND_Auto,
FDE_TXTEDIT_LINEEND_CRLF,
FDE_TXTEDIT_LINEEND_CR,
FDE_TXTEDIT_LINEEND_LF,
};
-struct _FDE_TXTEDTPARAMS {
- _FDE_TXTEDTPARAMS()
+
+struct FDE_TXTEDTPARAMS {
+ FDE_TXTEDTPARAMS()
: fPlateWidth(0),
fPlateHeight(0),
nLineCount(0),
dwLayoutStyles(0),
dwAlignment(0),
dwMode(0),
- pFont(NULL),
+ pFont(nullptr),
fFontSize(10.0f),
dwFontColor(0xff000000),
fLineSpace(10.0f),
@@ -106,7 +103,8 @@ struct _FDE_TXTEDTPARAMS {
nLineEnd(0),
nHorzScale(100),
fCharSpace(0),
- pEventSink(NULL) {}
+ pEventSink(nullptr) {}
+
FX_FLOAT fPlateWidth;
FX_FLOAT fPlateHeight;
int32_t nLineCount;
@@ -125,60 +123,26 @@ struct _FDE_TXTEDTPARAMS {
int32_t nLineEnd;
int32_t nHorzScale;
FX_FLOAT fCharSpace;
- IFDE_TxtEdtEventSink* pEventSink;
+ CFWL_EditImp* pEventSink;
};
-typedef _FDE_TXTEDTPARAMS FDE_TXTEDTPARAMS;
-typedef _FDE_TXTEDTPARAMS* FDE_LPTXTEDTPARAMS;
+
enum FDE_TXTEDT_TEXTCHANGE_TYPE {
FDE_TXTEDT_TEXTCHANGE_TYPE_Insert = 0,
FDE_TXTEDT_TEXTCHANGE_TYPE_Delete,
FDE_TXTEDT_TEXTCHANGE_TYPE_Replace,
};
-struct _FDE_TXTEDT_TEXTCHANGE_INFO {
+
+struct FDE_TXTEDT_TEXTCHANGE_INFO {
int32_t nChangeType;
CFX_WideString wsInsert;
CFX_WideString wsDelete;
CFX_WideString wsPrevText;
};
-typedef _FDE_TXTEDT_TEXTCHANGE_INFO FDE_TXTEDT_TEXTCHANGE_INFO;
-typedef _FDE_TXTEDT_TEXTCHANGE_INFO* FDE_LPTXTEDT_TEXTCHANGE_INFO;
-class IFDE_TxtEdtEventSink {
- public:
- virtual ~IFDE_TxtEdtEventSink() {}
- virtual void On_CaretChanged(IFDE_TxtEdtEngine* pEdit,
- int32_t nPage,
- FX_BOOL bVisible = TRUE) = 0;
- virtual void On_TextChanged(IFDE_TxtEdtEngine* pEdit,
- FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) = 0;
- virtual void On_PageCountChanged(IFDE_TxtEdtEngine* pEdit) = 0;
- virtual void On_SelChanged(IFDE_TxtEdtEngine* pEdit) = 0;
- virtual FX_BOOL On_PageLoad(IFDE_TxtEdtEngine* pEdit,
- int32_t nPageIndex,
- int32_t nPurpose) = 0;
- virtual FX_BOOL On_PageUnload(IFDE_TxtEdtEngine* pEdit,
- int32_t nPageIndex,
- int32_t nPurpose) = 0;
- virtual FX_BOOL On_PageChange(IFDE_TxtEdtEngine* pEdit,
- int32_t nPageIndex) = 0;
- virtual void On_AddDoRecord(IFDE_TxtEdtEngine* pEdit,
- const CFX_ByteStringC& bsDoRecord) = 0;
- virtual FX_BOOL On_ValidateField(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex,
- int32_t nFieldIndex,
- const CFX_WideString& wsFieldText,
- int32_t nCharIndex) = 0;
- virtual FX_BOOL On_ValidateBlock(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex) = 0;
- virtual FX_BOOL On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex,
- CFX_WideString& wsBlockText) = 0;
- virtual FX_BOOL On_Validate(IFDE_TxtEdtEngine* pEdit,
- CFX_WideString& wsText) = 0;
-};
+
class IFX_CharIter {
public:
virtual ~IFX_CharIter() {}
- virtual void Release() = 0;
+
virtual FX_BOOL Next(FX_BOOL bPrev = FALSE) = 0;
virtual FX_WCHAR GetChar() = 0;
virtual void SetAt(int32_t nIndex) = 0;
@@ -186,73 +150,5 @@ class IFX_CharIter {
virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const = 0;
virtual IFX_CharIter* Clone() = 0;
};
-class IFDE_TxtEdtEngine {
- public:
- static IFDE_TxtEdtEngine* Create();
-
- virtual ~IFDE_TxtEdtEngine() {}
- virtual void Release() = 0;
- virtual void SetEditParams(const FDE_TXTEDTPARAMS& params) = 0;
- virtual const FDE_TXTEDTPARAMS* GetEditParams() const = 0;
-
- virtual int32_t CountPages() const = 0;
- virtual IFDE_TxtEdtPage* GetPage(int32_t nIndex) = 0;
- virtual FX_BOOL SetBufChunkSize(int32_t nChunkSize) = 0;
- virtual void SetTextByStream(IFX_Stream* pStream) = 0;
- virtual void SetText(const CFX_WideString& wsText) = 0;
- virtual int32_t GetTextLength() const = 0;
- virtual void GetText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount = -1) = 0;
- virtual void ClearText() = 0;
-
- virtual int32_t GetCaretRect(CFX_RectF& rtCaret) const = 0;
- virtual int32_t GetCaretPos() const = 0;
- virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE) = 0;
- virtual int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
- FX_BOOL bShift = FALSE,
- FX_BOOL bCtrl = FALSE) = 0;
-
- virtual void Lock() = 0;
- virtual void Unlock() = 0;
- virtual FX_BOOL IsLocked() const = 0;
-
- virtual int32_t Insert(int32_t nStart,
- const FX_WCHAR* lpText,
- int32_t nLength) = 0;
- virtual int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE) = 0;
- virtual int32_t DeleteRange(int32_t nStart, int32_t nCount = -1) = 0;
- virtual int32_t Replace(int32_t nStart,
- int32_t nLength,
- const CFX_WideString& wsReplace) = 0;
- virtual void SetLimit(int32_t nLimit) = 0;
- virtual void SetAliasChar(FX_WCHAR wAlias) = 0;
- virtual void AddSelRange(int32_t nStart, int32_t nCount = -1) = 0;
- virtual int32_t CountSelRanges() = 0;
- virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart) = 0;
- virtual void ClearSelection() = 0;
-
- virtual FX_BOOL Redo(const CFX_ByteStringC& bsRedo) = 0;
- virtual FX_BOOL Undo(const CFX_ByteStringC& bsUndo) = 0;
-
- virtual int32_t StartLayout() = 0;
- virtual int32_t DoLayout(IFX_Pause* pPause) = 0;
- virtual void EndLayout() = 0;
-
- virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL) = 0;
- virtual int32_t CountParags() const = 0;
- virtual IFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const = 0;
- virtual IFX_CharIter* CreateCharIter() = 0;
-};
-class IFDE_TxtEdtParag {
- public:
- virtual ~IFDE_TxtEdtParag() {}
- virtual int32_t GetTextLength() const = 0;
- virtual int32_t GetStartIndex() const = 0;
- virtual int32_t CountLines() const = 0;
- virtual void GetLineRange(int32_t nLineIndex,
- int32_t& nStart,
- int32_t& nCount) const = 0;
-};
#endif // XFA_FEE_IFDE_TXTEDTENGINE_H_
diff --git a/chromium/third_party/pdfium/xfa/fee/ifde_txtedtpage.h b/chromium/third_party/pdfium/xfa/fee/ifde_txtedtpage.h
index ec5912d0f16..695b442b999 100644
--- a/chromium/third_party/pdfium/xfa/fee/ifde_txtedtpage.h
+++ b/chromium/third_party/pdfium/xfa/fee/ifde_txtedtpage.h
@@ -7,18 +7,19 @@
#ifndef XFA_FEE_IFDE_TXTEDTPAGE_H_
#define XFA_FEE_IFDE_TXTEDTPAGE_H_
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "xfa/fde/fde_visualset.h"
#include "xfa/fgas/layout/fgas_textbreak.h"
-class IFDE_TxtEdtEngine;
+class CFDE_TxtEdtEngine;
+
class IFDE_TxtEdtPage : public IFDE_CanvasSet, public IFX_TxtAccess {
public:
- static IFDE_TxtEdtPage* Create(IFDE_TxtEdtEngine* pEngine, int32_t nIndex);
+ static IFDE_TxtEdtPage* Create(CFDE_TxtEdtEngine* pEngine, int32_t nIndex);
virtual void Release() = 0;
- virtual IFDE_TxtEdtEngine* GetEngine() const = 0;
+ virtual CFDE_TxtEdtEngine* GetEngine() const = 0;
virtual int32_t GetCharRect(int32_t nIndex,
CFX_RectF& rect,
FX_BOOL bBBox = FALSE) const = 0;
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.cpp b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.cpp
index ce8dda646aa..ee557b10d9e 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.cpp
@@ -55,7 +55,7 @@ static void FX_Base64EncodePiece(const FX_BASE64DATA& src,
}
}
int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst) {
- FXSYS_assert(pSrc != NULL);
+ ASSERT(pSrc != NULL);
if (iSrcLen < 1) {
return 0;
}
@@ -118,7 +118,7 @@ static void FX_Base64DecodePiece(const FX_CHAR src[4],
int32_t iChars,
FX_BASE64DATA& dst,
int32_t& iBytes) {
- FXSYS_assert(iChars > 0 && iChars < 5);
+ ASSERT(iChars > 0 && iChars < 5);
iBytes = 1;
dst.data2 = g_FXBase64DecoderMap[(uint8_t)src[0]];
if (iChars > 1) {
@@ -144,7 +144,7 @@ static void FX_Base64DecodePiece(const FX_CHAR src[4],
}
}
int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) {
- FXSYS_assert(pSrc != NULL);
+ ASSERT(pSrc != NULL);
if (iSrcLen < 1) {
return 0;
}
@@ -200,7 +200,7 @@ int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) {
return pDstEnd - pDst;
}
int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) {
- FXSYS_assert(pSrc != NULL);
+ ASSERT(pSrc != NULL);
if (iSrcLen < 1) {
return 0;
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.h b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.h
index 94a0d06f9ea..9fefb2bc403 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.h
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_algorithm.h
@@ -31,7 +31,7 @@ template <class baseType>
class CFX_DSPATemplate {
public:
int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) {
- FXSYS_assert(pArray != NULL);
+ ASSERT(pArray != NULL);
if (iCount < 1) {
return -1;
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_codepage.cpp b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_codepage.cpp
index 57d97db83c0..7362a89d303 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_codepage.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_codepage.cpp
@@ -19,7 +19,7 @@ static const FX_CHARSET_MAP g_FXCharset2CodePageTable[] = {
};
uint16_t FX_GetCodePageFromCharset(uint8_t charset) {
int32_t iEnd = sizeof(g_FXCharset2CodePageTable) / sizeof(FX_CHARSET_MAP) - 1;
- FXSYS_assert(iEnd >= 0);
+ ASSERT(iEnd >= 0);
int32_t iStart = 0, iMid;
do {
iMid = (iStart + iEnd) / 2;
@@ -45,7 +45,7 @@ static const FX_CHARSET_MAP g_FXCodepage2CharsetTable[] = {
};
uint16_t FX_GetCharsetFromCodePage(uint16_t codepage) {
int32_t iEnd = sizeof(g_FXCodepage2CharsetTable) / sizeof(FX_CHARSET_MAP) - 1;
- FXSYS_assert(iEnd >= 0);
+ ASSERT(iEnd >= 0);
int32_t iStart = 0, iMid;
do {
iMid = (iStart + iEnd) / 2;
@@ -199,7 +199,7 @@ const FX_LANG2CPMAP g_FXLang2CodepageTable[] = {
};
uint16_t FX_GetDefCodePageByLanguage(uint16_t wLanguage) {
int32_t iEnd = sizeof(g_FXLang2CodepageTable) / sizeof(FX_LANG2CPMAP) - 1;
- FXSYS_assert(iEnd >= 0);
+ ASSERT(iEnd >= 0);
int32_t iStart = 0, iMid;
do {
iMid = (iStart + iEnd) / 2;
@@ -302,19 +302,19 @@ static const FX_STR2CPHASH g_FXCPHashTable[] = {
{0xf637e157, 0x478}, {0xfc213f3a, 0x2717}, {0xff654d14, 0x3b5},
};
uint16_t FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength) {
- FXSYS_assert(pStr != NULL);
+ ASSERT(pStr != NULL);
if (iLength < 0) {
iLength = FXSYS_strlen(pStr);
}
if (iLength == 0) {
return 0xFFFF;
}
- uint32_t uHash = FX_HashCode_String_GetA(pStr, iLength, TRUE);
- int32_t iStart = 0, iMid;
+ uint32_t uHash = FX_HashCode_GetA(CFX_ByteStringC(pStr, iLength), true);
+ int32_t iStart = 0;
int32_t iEnd = sizeof(g_FXCPHashTable) / sizeof(FX_STR2CPHASH) - 1;
- FXSYS_assert(iEnd >= 0);
+ ASSERT(iEnd >= 0);
do {
- iMid = (iStart + iEnd) / 2;
+ int32_t iMid = (iStart + iEnd) / 2;
const FX_STR2CPHASH& cp = g_FXCPHashTable[iMid];
if (uHash == cp.uHash) {
return (uint16_t)cp.uCodePage;
@@ -339,5 +339,5 @@ uint16_t FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength) {
*pBuf++ = (FX_CHAR)*pStr++;
}
csStr.ReleaseBuffer(iLength);
- return FX_GetCodePageFromStringA(csStr, iLength);
+ return FX_GetCodePageFromStringA(csStr.c_str(), iLength);
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_encode.cpp b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_encode.cpp
index 84a1ef40ed1..b84406f6421 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_encode.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_encode.cpp
@@ -7,7 +7,7 @@
#include "xfa/fgas/crt/fgas_codepage.h"
void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength) {
- FXSYS_assert(pStr != NULL);
+ ASSERT(pStr != NULL);
if (iLength < 0) {
iLength = FXSYS_wcslen(pStr);
}
@@ -30,7 +30,7 @@ void FX_SwapByteOrder(FX_WCHAR* pStr, int32_t iLength) {
void FX_SwapByteOrderCopy(const FX_WCHAR* pSrc,
FX_WCHAR* pDst,
int32_t iLength) {
- FXSYS_assert(pSrc != NULL && pDst != NULL);
+ ASSERT(pSrc != NULL && pDst != NULL);
if (iLength < 0) {
iLength = FXSYS_wcslen(pSrc);
}
@@ -51,7 +51,7 @@ void FX_SwapByteOrderCopy(const FX_WCHAR* pSrc,
}
}
void FX_UTF16ToWChar(void* pBuffer, int32_t iLength) {
- FXSYS_assert(pBuffer != NULL && iLength > 0);
+ ASSERT(pBuffer != NULL && iLength > 0);
if (sizeof(FX_WCHAR) == 2) {
return;
}
@@ -64,7 +64,7 @@ void FX_UTF16ToWChar(void* pBuffer, int32_t iLength) {
void FX_UTF16ToWCharCopy(const uint16_t* pUTF16,
FX_WCHAR* pWChar,
int32_t iLength) {
- FXSYS_assert(pUTF16 != NULL && pWChar != NULL && iLength > 0);
+ ASSERT(pUTF16 != NULL && pWChar != NULL && iLength > 0);
if (sizeof(FX_WCHAR) == 2) {
FXSYS_memcpy(pWChar, pUTF16, iLength * sizeof(FX_WCHAR));
} else {
@@ -74,7 +74,7 @@ void FX_UTF16ToWCharCopy(const uint16_t* pUTF16,
}
}
void FX_WCharToUTF16(void* pBuffer, int32_t iLength) {
- FXSYS_assert(pBuffer != NULL && iLength > 0);
+ ASSERT(pBuffer != NULL && iLength > 0);
if (sizeof(FX_WCHAR) == 2) {
return;
}
@@ -87,7 +87,7 @@ void FX_WCharToUTF16(void* pBuffer, int32_t iLength) {
void FX_WCharToUTF16Copy(const FX_WCHAR* pWChar,
uint16_t* pUTF16,
int32_t iLength) {
- FXSYS_assert(pWChar != NULL && pUTF16 != NULL && iLength > 0);
+ ASSERT(pWChar != NULL && pUTF16 != NULL && iLength > 0);
if (sizeof(FX_WCHAR) == 2) {
FXSYS_memcpy(pUTF16, pWChar, iLength * sizeof(FX_WCHAR));
} else {
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.cpp b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.cpp
index 7eda5b9ba6c..9176466a615 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.cpp
@@ -6,46 +6,48 @@
#include "xfa/fgas/crt/fgas_memory.h"
+#ifndef MEMORY_TOOL_REPLACES_ALLOCATOR
+#define MEMORY_TOOL_REPLACES_ALLOCATOR // Temporary, for CF testing.
+#endif
+
#include <algorithm>
+#ifdef MEMORY_TOOL_REPLACES_ALLOCATOR
+
namespace {
-class CFX_DefStore : public IFX_MEMAllocator, public CFX_Target {
+class CFX_DefStore : public IFX_MemoryAllocator, public CFX_Target {
public:
CFX_DefStore() {}
- ~CFX_DefStore() {}
- virtual void Release() { delete this; }
- virtual void* Alloc(size_t size) { return FX_Alloc(uint8_t, size); }
- virtual void Free(void* pBlock) { FX_Free(pBlock); }
- virtual size_t GetBlockSize() const { return 0; }
- virtual size_t GetDefChunkSize() const { return 0; }
- virtual size_t SetDefChunkSize(size_t size) { return 0; }
- virtual size_t GetCurrentDataSize() const { return 0; }
+ ~CFX_DefStore() override {}
+ void* Alloc(size_t size) override { return FX_Alloc(uint8_t, size); }
+ void Free(void* pBlock) override { FX_Free(pBlock); }
};
-#if _FX_OS_ != _FX_ANDROID_
-#pragma pack(push, 1)
-#endif
+} // namespace
+
+IFX_MemoryAllocator* IFX_MemoryAllocator::Create(FX_ALLOCTYPE eType,
+ size_t chunkSize,
+ size_t blockSize) {
+ return new CFX_DefStore();
+}
+
+#else // MEMORY_TOOL_REPLACES_ALLOCATOR
+
+namespace {
+
struct FX_STATICSTORECHUNK {
FX_STATICSTORECHUNK* pNextChunk;
size_t iChunkSize;
size_t iFreeSize;
};
-#if _FX_OS_ != _FX_ANDROID_
-#pragma pack(pop)
-#endif
-class CFX_StaticStore : public IFX_MEMAllocator, public CFX_Target {
+class CFX_StaticStore : public IFX_MemoryAllocator, public CFX_Target {
public:
CFX_StaticStore(size_t iDefChunkSize = 4096);
- ~CFX_StaticStore();
- virtual void Release() { delete this; }
- virtual void* Alloc(size_t size);
- virtual void Free(void* pBlock) {}
- virtual size_t GetBlockSize() const { return 0; }
- virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; }
- virtual size_t SetDefChunkSize(size_t size);
- virtual size_t GetCurrentDataSize() const { return m_iAllocatedSize; }
+ ~CFX_StaticStore() override;
+ void* Alloc(size_t size) override;
+ void Free(void* pBlock) override {}
protected:
size_t m_iAllocatedSize;
@@ -56,9 +58,6 @@ class CFX_StaticStore : public IFX_MEMAllocator, public CFX_Target {
FX_STATICSTORECHUNK* FindChunk(size_t size);
};
-#if _FX_OS_ != _FX_ANDROID_
-#pragma pack(push, 1)
-#endif
struct FX_FIXEDSTORECHUNK {
uint8_t* FirstFlag() { return reinterpret_cast<uint8_t*>(this + 1); }
uint8_t* FirstBlock() { return FirstFlag() + iChunkSize; }
@@ -67,21 +66,13 @@ struct FX_FIXEDSTORECHUNK {
size_t iChunkSize;
size_t iFreeNum;
};
-#if _FX_OS_ != _FX_ANDROID_
-#pragma pack(pop)
-#endif
-class CFX_FixedStore : public IFX_MEMAllocator, public CFX_Target {
+class CFX_FixedStore : public IFX_MemoryAllocator, public CFX_Target {
public:
CFX_FixedStore(size_t iBlockSize, size_t iBlockNumsInChunk);
- virtual ~CFX_FixedStore();
- virtual void Release() { delete this; }
- virtual void* Alloc(size_t size);
- virtual void Free(void* pBlock);
- virtual size_t GetBlockSize() const { return m_iBlockSize; }
- virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; }
- virtual size_t SetDefChunkSize(size_t iChunkSize);
- virtual size_t GetCurrentDataSize() const { return 0; }
+ ~CFX_FixedStore() override;
+ void* Alloc(size_t size) override;
+ void Free(void* pBlock) override;
protected:
FX_FIXEDSTORECHUNK* AllocChunk();
@@ -91,75 +82,30 @@ class CFX_FixedStore : public IFX_MEMAllocator, public CFX_Target {
FX_FIXEDSTORECHUNK* m_pChunk;
};
-#if _FX_OS_ != _FX_ANDROID_
-#pragma pack(push, 1)
-#endif
-struct FX_DYNAMICSTOREBLOCK {
- uint8_t* Data() { return reinterpret_cast<uint8_t*>(this + 1); }
- FX_DYNAMICSTOREBLOCK* NextBlock() {
- return reinterpret_cast<FX_DYNAMICSTOREBLOCK*>(Data() + iBlockSize);
- }
- size_t iBlockSize;
- FX_BOOL bUsed;
-};
-
-struct FX_DYNAMICSTORECHUNK {
- FX_DYNAMICSTOREBLOCK* FirstBlock() {
- return reinterpret_cast<FX_DYNAMICSTOREBLOCK*>(this + 1);
- }
- FX_DYNAMICSTORECHUNK* pNextChunk;
- size_t iChunkSize;
- size_t iFreeSize;
-};
-#if _FX_OS_ != _FX_ANDROID_
-#pragma pack(pop)
-#endif
-
-class CFX_DynamicStore : public IFX_MEMAllocator, public CFX_Target {
- public:
- CFX_DynamicStore(size_t iDefChunkSize = 4096);
- virtual ~CFX_DynamicStore();
- virtual void Release() { delete this; }
- virtual void* Alloc(size_t size);
- virtual void Free(void* pBlock);
- virtual size_t GetBlockSize() const { return 0; }
- virtual size_t GetDefChunkSize() const { return m_iDefChunkSize; }
- virtual size_t SetDefChunkSize(size_t size);
- virtual size_t GetCurrentDataSize() const { return 0; }
-
- protected:
- FX_DYNAMICSTORECHUNK* AllocChunk(size_t size);
-
- size_t m_iDefChunkSize;
- FX_DYNAMICSTORECHUNK* m_pChunk;
-};
-
} // namespace
-#define FX_4BYTEALIGN(size) (((size) + 3) / 4 * 4)
+#define FX_4BYTEALIGN(size) (((size) + 3) & ~3)
-IFX_MEMAllocator* FX_CreateAllocator(FX_ALLOCTYPE eType,
- size_t chunkSize,
- size_t blockSize) {
+IFX_MemoryAllocator* IFX_MemoryAllocator::Create(FX_ALLOCTYPE eType,
+ size_t chunkSize,
+ size_t blockSize) {
switch (eType) {
- case FX_ALLOCTYPE_Dynamic:
- return new CFX_DynamicStore(chunkSize);
- case FX_ALLOCTYPE_Default:
- return new CFX_DefStore();
case FX_ALLOCTYPE_Static:
return new CFX_StaticStore(chunkSize);
case FX_ALLOCTYPE_Fixed:
return new CFX_FixedStore(blockSize, chunkSize);
default:
- return NULL;
+ ASSERT(0);
+ return nullptr;
}
}
+
CFX_StaticStore::CFX_StaticStore(size_t iDefChunkSize)
: m_iAllocatedSize(0),
m_iDefChunkSize(iDefChunkSize),
- m_pChunk(NULL),
- m_pLastChunk(NULL) {
- FXSYS_assert(m_iDefChunkSize != 0);
+ m_pChunk(nullptr),
+ m_pLastChunk(nullptr) {
+ ASSERT(m_iDefChunkSize != 0);
}
CFX_StaticStore::~CFX_StaticStore() {
FX_STATICSTORECHUNK* pChunk = m_pChunk;
@@ -170,13 +116,13 @@ CFX_StaticStore::~CFX_StaticStore() {
}
}
FX_STATICSTORECHUNK* CFX_StaticStore::AllocChunk(size_t size) {
- FXSYS_assert(size != 0);
+ ASSERT(size != 0);
FX_STATICSTORECHUNK* pChunk = (FX_STATICSTORECHUNK*)FX_Alloc(
uint8_t, sizeof(FX_STATICSTORECHUNK) + size);
pChunk->iChunkSize = size;
pChunk->iFreeSize = size;
- pChunk->pNextChunk = NULL;
- if (m_pLastChunk == NULL) {
+ pChunk->pNextChunk = nullptr;
+ if (!m_pLastChunk) {
m_pChunk = pChunk;
} else {
m_pLastChunk->pNextChunk = pChunk;
@@ -185,17 +131,17 @@ FX_STATICSTORECHUNK* CFX_StaticStore::AllocChunk(size_t size) {
return pChunk;
}
FX_STATICSTORECHUNK* CFX_StaticStore::FindChunk(size_t size) {
- FXSYS_assert(size != 0);
- if (m_pLastChunk == NULL || m_pLastChunk->iFreeSize < size) {
+ ASSERT(size != 0);
+ if (!m_pLastChunk || m_pLastChunk->iFreeSize < size) {
return AllocChunk(std::max(m_iDefChunkSize, size));
}
return m_pLastChunk;
}
void* CFX_StaticStore::Alloc(size_t size) {
size = FX_4BYTEALIGN(size);
- FXSYS_assert(size != 0);
+ ASSERT(size != 0);
FX_STATICSTORECHUNK* pChunk = FindChunk(size);
- FXSYS_assert(pChunk->iFreeSize >= size);
+ ASSERT(pChunk->iFreeSize >= size);
uint8_t* p = (uint8_t*)pChunk;
p += sizeof(FX_STATICSTORECHUNK) + pChunk->iChunkSize - pChunk->iFreeSize;
pChunk->iFreeSize -= size;
@@ -203,7 +149,7 @@ void* CFX_StaticStore::Alloc(size_t size) {
return p;
}
size_t CFX_StaticStore::SetDefChunkSize(size_t size) {
- FXSYS_assert(size != 0);
+ ASSERT(size != 0);
size_t v = m_iDefChunkSize;
m_iDefChunkSize = size;
return v;
@@ -211,8 +157,8 @@ size_t CFX_StaticStore::SetDefChunkSize(size_t size) {
CFX_FixedStore::CFX_FixedStore(size_t iBlockSize, size_t iBlockNumsInChunk)
: m_iBlockSize(FX_4BYTEALIGN(iBlockSize)),
m_iDefChunkSize(FX_4BYTEALIGN(iBlockNumsInChunk)),
- m_pChunk(NULL) {
- FXSYS_assert(m_iBlockSize != 0 && m_iDefChunkSize != 0);
+ m_pChunk(nullptr) {
+ ASSERT(m_iBlockSize != 0 && m_iDefChunkSize != 0);
}
CFX_FixedStore::~CFX_FixedStore() {
FX_FIXEDSTORECHUNK* pChunk = m_pChunk;
@@ -227,9 +173,9 @@ FX_FIXEDSTORECHUNK* CFX_FixedStore::AllocChunk() {
m_iBlockSize * m_iDefChunkSize;
FX_FIXEDSTORECHUNK* pChunk =
(FX_FIXEDSTORECHUNK*)FX_Alloc(uint8_t, iTotalSize);
- if (pChunk == NULL) {
- return NULL;
- }
+ if (!pChunk)
+ return nullptr;
+
FXSYS_memset(pChunk->FirstFlag(), 0, m_iDefChunkSize);
pChunk->pNextChunk = m_pChunk;
pChunk->iChunkSize = m_iDefChunkSize;
@@ -239,37 +185,35 @@ FX_FIXEDSTORECHUNK* CFX_FixedStore::AllocChunk() {
}
void* CFX_FixedStore::Alloc(size_t size) {
if (size > m_iBlockSize) {
- return NULL;
+ return nullptr;
}
FX_FIXEDSTORECHUNK* pChunk = m_pChunk;
- while (pChunk != NULL) {
+ while (pChunk) {
if (pChunk->iFreeNum > 0) {
break;
}
pChunk = pChunk->pNextChunk;
}
- if (pChunk == NULL) {
+ if (!pChunk) {
pChunk = AllocChunk();
}
- FXSYS_assert(pChunk != NULL);
uint8_t* pFlags = pChunk->FirstFlag();
size_t i = 0;
for (; i < pChunk->iChunkSize; i++)
if (pFlags[i] == 0) {
break;
}
- FXSYS_assert(i < pChunk->iChunkSize);
+ ASSERT(i < pChunk->iChunkSize);
pFlags[i] = 1;
pChunk->iFreeNum--;
return pChunk->FirstBlock() + i * m_iBlockSize;
}
void CFX_FixedStore::Free(void* pBlock) {
- FXSYS_assert(pBlock != NULL);
- FX_FIXEDSTORECHUNK* pPrior = NULL;
+ FX_FIXEDSTORECHUNK* pPrior = nullptr;
FX_FIXEDSTORECHUNK* pChunk = m_pChunk;
- uint8_t* pStart = NULL;
+ uint8_t* pStart = nullptr;
uint8_t* pEnd;
- while (pChunk != NULL) {
+ while (pChunk) {
pStart = pChunk->FirstBlock();
if (pBlock >= pStart) {
pEnd = pStart + m_iBlockSize * pChunk->iChunkSize;
@@ -279,9 +223,9 @@ void CFX_FixedStore::Free(void* pBlock) {
}
pPrior = pChunk, pChunk = pChunk->pNextChunk;
}
- FXSYS_assert(pChunk != NULL);
+ ASSERT(pChunk);
size_t iPos = ((uint8_t*)pBlock - pStart) / m_iBlockSize;
- FXSYS_assert(iPos < pChunk->iChunkSize);
+ ASSERT(iPos < pChunk->iChunkSize);
uint8_t* pFlags = pChunk->FirstFlag();
if (pFlags[iPos] == 0) {
return;
@@ -289,7 +233,7 @@ void CFX_FixedStore::Free(void* pBlock) {
pFlags[iPos] = 0;
pChunk->iFreeNum++;
if (pChunk->iFreeNum == pChunk->iChunkSize) {
- if (pPrior == NULL) {
+ if (!pPrior) {
m_pChunk = pChunk->pNextChunk;
} else {
pPrior->pNextChunk = pChunk->pNextChunk;
@@ -298,149 +242,10 @@ void CFX_FixedStore::Free(void* pBlock) {
}
}
size_t CFX_FixedStore::SetDefChunkSize(size_t iChunkSize) {
- FXSYS_assert(iChunkSize != 0);
+ ASSERT(iChunkSize != 0);
size_t v = m_iDefChunkSize;
m_iDefChunkSize = FX_4BYTEALIGN(iChunkSize);
return v;
}
-CFX_DynamicStore::CFX_DynamicStore(size_t iDefChunkSize)
- : m_iDefChunkSize(iDefChunkSize), m_pChunk(NULL) {
- FXSYS_assert(m_iDefChunkSize != 0);
-}
-CFX_DynamicStore::~CFX_DynamicStore() {
- FX_DYNAMICSTORECHUNK* pChunk = m_pChunk;
- while (pChunk) {
- FX_DYNAMICSTORECHUNK* pNext = pChunk->pNextChunk;
- FX_Free(pChunk);
- pChunk = pNext;
- }
-}
-FX_DYNAMICSTORECHUNK* CFX_DynamicStore::AllocChunk(size_t size) {
- FXSYS_assert(size != 0);
- FX_DYNAMICSTORECHUNK* pChunk = (FX_DYNAMICSTORECHUNK*)FX_Alloc(
- uint8_t,
- sizeof(FX_DYNAMICSTORECHUNK) + sizeof(FX_DYNAMICSTOREBLOCK) * 2 + size);
- if (pChunk == NULL) {
- return NULL;
- }
- pChunk->iChunkSize = size;
- pChunk->iFreeSize = size;
- FX_DYNAMICSTOREBLOCK* pBlock = pChunk->FirstBlock();
- pBlock->iBlockSize = size;
- pBlock->bUsed = FALSE;
- pBlock = pBlock->NextBlock();
- pBlock->iBlockSize = 0;
- pBlock->bUsed = TRUE;
- if (m_pChunk != NULL && size >= m_iDefChunkSize) {
- FX_DYNAMICSTORECHUNK* pLast = m_pChunk;
- while (pLast->pNextChunk != NULL) {
- pLast = pLast->pNextChunk;
- }
- pLast->pNextChunk = pChunk;
- pChunk->pNextChunk = NULL;
- } else {
- pChunk->pNextChunk = m_pChunk;
- m_pChunk = pChunk;
- }
- return pChunk;
-}
-void* CFX_DynamicStore::Alloc(size_t size) {
- size = FX_4BYTEALIGN(size);
- FXSYS_assert(size != 0);
- FX_DYNAMICSTORECHUNK* pChunk = m_pChunk;
- FX_DYNAMICSTOREBLOCK* pBlock = NULL;
- while (pChunk != NULL) {
- if (pChunk->iFreeSize >= size) {
- pBlock = pChunk->FirstBlock();
- FX_BOOL bFind = FALSE;
- while (pBlock->iBlockSize != 0) {
- if (!pBlock->bUsed && pBlock->iBlockSize >= size) {
- bFind = TRUE;
- break;
- }
- pBlock = pBlock->NextBlock();
- }
- if (bFind) {
- break;
- }
- }
- pChunk = pChunk->pNextChunk;
- }
- if (pChunk == NULL) {
- pChunk = AllocChunk(std::max(m_iDefChunkSize, size));
- pBlock = pChunk->FirstBlock();
- }
- FXSYS_assert(pChunk != NULL && pBlock != NULL);
- size_t m = size + sizeof(FX_DYNAMICSTOREBLOCK);
- pBlock->bUsed = TRUE;
- if (pBlock->iBlockSize > m) {
- size_t n = pBlock->iBlockSize;
- pBlock->iBlockSize = size;
- FX_DYNAMICSTOREBLOCK* pNextBlock = pBlock->NextBlock();
- pNextBlock->bUsed = FALSE;
- pNextBlock->iBlockSize = n - size - sizeof(FX_DYNAMICSTOREBLOCK);
- pChunk->iFreeSize -= size + sizeof(FX_DYNAMICSTOREBLOCK);
- } else {
- pChunk->iFreeSize -= pBlock->iBlockSize;
- }
- return pBlock->Data();
-}
-void CFX_DynamicStore::Free(void* pBlock) {
- FXSYS_assert(pBlock != NULL);
- FX_DYNAMICSTORECHUNK* pPriorChunk = NULL;
- FX_DYNAMICSTORECHUNK* pChunk = m_pChunk;
- while (pChunk != NULL) {
- if (pBlock > pChunk &&
- pBlock <= ((uint8_t*)pChunk + sizeof(FX_DYNAMICSTORECHUNK) +
- pChunk->iChunkSize)) {
- break;
- }
- pPriorChunk = pChunk, pChunk = pChunk->pNextChunk;
- }
- FXSYS_assert(pChunk != NULL);
- FX_DYNAMICSTOREBLOCK* pPriorBlock = NULL;
- FX_DYNAMICSTOREBLOCK* pFindBlock = pChunk->FirstBlock();
- while (pFindBlock->iBlockSize != 0) {
- if (pBlock == (void*)pFindBlock->Data()) {
- break;
- }
- pPriorBlock = pFindBlock;
- pFindBlock = pFindBlock->NextBlock();
- }
- FXSYS_assert(pFindBlock->iBlockSize != 0 && pFindBlock->bUsed &&
- pBlock == (void*)pFindBlock->Data());
- pFindBlock->bUsed = FALSE;
- pChunk->iFreeSize += pFindBlock->iBlockSize;
- if (pPriorBlock == NULL) {
- pPriorBlock = pChunk->FirstBlock();
- } else if (pPriorBlock->bUsed) {
- pPriorBlock = pFindBlock;
- }
- pFindBlock = pPriorBlock;
- size_t sizeFree = 0;
- size_t sizeBlock = 0;
- while (pFindBlock->iBlockSize != 0 && !pFindBlock->bUsed) {
- if (pFindBlock != pPriorBlock) {
- sizeFree += sizeof(FX_DYNAMICSTOREBLOCK);
- sizeBlock += sizeof(FX_DYNAMICSTOREBLOCK);
- }
- sizeBlock += pFindBlock->iBlockSize;
- pFindBlock = pFindBlock->NextBlock();
- }
- pPriorBlock->iBlockSize = sizeBlock;
- pChunk->iFreeSize += sizeFree;
- if (pChunk->iFreeSize == pChunk->iChunkSize) {
- if (pPriorChunk == NULL) {
- m_pChunk = pChunk->pNextChunk;
- } else {
- pPriorChunk->pNextChunk = pChunk->pNextChunk;
- }
- FX_Free(pChunk);
- }
-}
-size_t CFX_DynamicStore::SetDefChunkSize(size_t size) {
- FXSYS_assert(size != 0);
- size_t v = m_iDefChunkSize;
- m_iDefChunkSize = size;
- return v;
-}
+
+#endif // MEMORY_TOOL_REPLACES_ALLOCATOR
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.h b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.h
index ac27755cac0..a83933c7a5c 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.h
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_memory.h
@@ -10,39 +10,31 @@
#include "core/fxcrt/include/fx_memory.h"
#include "core/fxcrt/include/fx_system.h"
-class IFX_MEMAllocator;
-class CFX_Target;
enum FX_ALLOCTYPE {
- FX_ALLOCTYPE_Default = 0,
FX_ALLOCTYPE_Static,
FX_ALLOCTYPE_Fixed,
- FX_ALLOCTYPE_Dynamic,
};
-class IFX_MEMAllocator {
+class IFX_MemoryAllocator {
public:
- virtual ~IFX_MEMAllocator() {}
- virtual void Release() = 0;
+ virtual ~IFX_MemoryAllocator() {}
virtual void* Alloc(size_t size) = 0;
virtual void Free(void* pBlock) = 0;
- virtual size_t GetBlockSize() const = 0;
- virtual size_t GetDefChunkSize() const = 0;
- virtual size_t SetDefChunkSize(size_t size) = 0;
- virtual size_t GetCurrentDataSize() const = 0;
-};
-IFX_MEMAllocator* FX_CreateAllocator(FX_ALLOCTYPE eType,
+ static IFX_MemoryAllocator* Create(FX_ALLOCTYPE eType,
size_t chunkSize,
size_t blockSize);
+};
+
class CFX_Target {
public:
virtual ~CFX_Target() {}
void* operator new(size_t size) { return FX_Alloc(uint8_t, size); }
void operator delete(void* p) { FX_Free(p); }
- void* operator new(size_t size, IFX_MEMAllocator* pAllocator) {
+ void* operator new(size_t size, IFX_MemoryAllocator* pAllocator) {
return pAllocator->Alloc(size);
}
- void operator delete(void* p, IFX_MEMAllocator* pAllocator) {
+ void operator delete(void* p, IFX_MemoryAllocator* pAllocator) {
pAllocator->Free(p);
}
void* operator new(size_t size, void* place) { return place; }
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_stream.cpp b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_stream.cpp
index 02fa2109d16..c05e81ade32 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_stream.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_stream.cpp
@@ -384,11 +384,11 @@ CFX_FileStreamImp::~CFX_FileStreamImp() {
}
FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName,
uint32_t dwAccess) {
- FXSYS_assert(m_hFile == NULL);
- FXSYS_assert(pszSrcFileName != NULL && FXSYS_wcslen(pszSrcFileName) > 0);
+ ASSERT(m_hFile == NULL);
+ ASSERT(pszSrcFileName != NULL && FXSYS_wcslen(pszSrcFileName) > 0);
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \
_FX_OS_ == _FX_WIN64_
- CFX_WideString wsMode;
+ const FX_WCHAR* wsMode;
if (dwAccess & FX_STREAMACCESS_Write) {
if (dwAccess & FX_STREAMACCESS_Append) {
wsMode = L"a+b";
@@ -420,7 +420,7 @@ FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName,
}
}
#else
- CFX_ByteString wsMode;
+ const FX_CHAR* wsMode = "rb";
if (dwAccess & FX_STREAMACCESS_Write) {
if (dwAccess & FX_STREAMACCESS_Append) {
wsMode = "a+b";
@@ -429,18 +429,16 @@ FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName,
} else {
wsMode = "r+b";
}
- } else {
- wsMode = "rb";
}
CFX_ByteString szFileName = CFX_ByteString::FromUnicode(pszSrcFileName);
- m_hFile = FXSYS_fopen(szFileName, wsMode);
+ m_hFile = FXSYS_fopen(szFileName.c_str(), wsMode);
if (m_hFile == NULL) {
if (dwAccess & FX_STREAMACCESS_Write) {
if (dwAccess & FX_STREAMACCESS_Create) {
- m_hFile = FXSYS_fopen(szFileName, "w+b");
+ m_hFile = FXSYS_fopen(szFileName.c_str(), "w+b");
}
if (m_hFile == NULL) {
- m_hFile = FXSYS_fopen(szFileName, "r+b");
+ m_hFile = FXSYS_fopen(szFileName.c_str(), "r+b");
if (m_hFile == NULL) {
return FALSE;
}
@@ -463,32 +461,32 @@ FX_BOOL CFX_FileStreamImp::LoadFile(const FX_WCHAR* pszSrcFileName,
return TRUE;
}
int32_t CFX_FileStreamImp::GetLength() const {
- FXSYS_assert(m_hFile != NULL);
+ ASSERT(m_hFile != NULL);
return m_iLength;
}
int32_t CFX_FileStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) {
- FXSYS_assert(m_hFile != NULL);
+ ASSERT(m_hFile != NULL);
FXSYS_fseek(m_hFile, iOffset, eSeek);
return FXSYS_ftell(m_hFile);
}
int32_t CFX_FileStreamImp::GetPosition() {
- FXSYS_assert(m_hFile != NULL);
+ ASSERT(m_hFile != NULL);
return FXSYS_ftell(m_hFile);
}
FX_BOOL CFX_FileStreamImp::IsEOF() const {
- FXSYS_assert(m_hFile != NULL);
+ ASSERT(m_hFile != NULL);
return FXSYS_ftell(m_hFile) >= m_iLength;
}
int32_t CFX_FileStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) {
- FXSYS_assert(m_hFile != NULL);
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
+ ASSERT(m_hFile != NULL);
+ ASSERT(pBuffer != NULL && iBufferSize > 0);
return FXSYS_fread(pBuffer, 1, iBufferSize, m_hFile);
}
int32_t CFX_FileStreamImp::ReadString(FX_WCHAR* pStr,
int32_t iMaxLength,
FX_BOOL& bEOS) {
- FXSYS_assert(m_hFile != NULL);
- FXSYS_assert(pStr != NULL && iMaxLength > 0);
+ ASSERT(m_hFile != NULL);
+ ASSERT(pStr != NULL && iMaxLength > 0);
if (m_iLength <= 0) {
return 0;
}
@@ -511,8 +509,8 @@ int32_t CFX_FileStreamImp::ReadString(FX_WCHAR* pStr,
}
int32_t CFX_FileStreamImp::WriteData(const uint8_t* pBuffer,
int32_t iBufferSize) {
- FXSYS_assert(m_hFile != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
+ ASSERT(m_hFile != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
+ ASSERT(pBuffer != NULL && iBufferSize > 0);
int32_t iRet = FXSYS_fwrite(pBuffer, 1, iBufferSize, m_hFile);
if (iRet != 0) {
int32_t iPos = FXSYS_ftell(m_hFile);
@@ -523,8 +521,8 @@ int32_t CFX_FileStreamImp::WriteData(const uint8_t* pBuffer,
return iRet;
}
int32_t CFX_FileStreamImp::WriteString(const FX_WCHAR* pStr, int32_t iLength) {
- FXSYS_assert(m_hFile != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
- FXSYS_assert(pStr != NULL && iLength > 0);
+ ASSERT(m_hFile != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
+ ASSERT(pStr != NULL && iLength > 0);
int32_t iRet = FXSYS_fwrite(pStr, 2, iLength, m_hFile);
if (iRet != 0) {
int32_t iPos = FXSYS_ftell(m_hFile);
@@ -535,11 +533,11 @@ int32_t CFX_FileStreamImp::WriteString(const FX_WCHAR* pStr, int32_t iLength) {
return iRet;
}
void CFX_FileStreamImp::Flush() {
- FXSYS_assert(m_hFile != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
+ ASSERT(m_hFile != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
FXSYS_fflush(m_hFile);
}
FX_BOOL CFX_FileStreamImp::SetLength(int32_t iLength) {
- FXSYS_assert(m_hFile != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
+ ASSERT(m_hFile != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
FX_BOOL bRet = FX_fsetsize(m_hFile, iLength);
m_iLength = FX_filelength(m_hFile);
return bRet;
@@ -548,7 +546,7 @@ CFX_FileReadStreamImp::CFX_FileReadStreamImp()
: m_pFileRead(NULL), m_iPosition(0), m_iLength(0) {}
FX_BOOL CFX_FileReadStreamImp::LoadFileRead(IFX_FileRead* pFileRead,
uint32_t dwAccess) {
- FXSYS_assert(m_pFileRead == NULL && pFileRead != NULL);
+ ASSERT(m_pFileRead == NULL && pFileRead != NULL);
if (dwAccess & FX_STREAMACCESS_Write) {
return FALSE;
}
@@ -582,8 +580,8 @@ FX_BOOL CFX_FileReadStreamImp::IsEOF() const {
return m_iPosition >= m_iLength;
}
int32_t CFX_FileReadStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) {
- FXSYS_assert(m_pFileRead != NULL);
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
+ ASSERT(m_pFileRead != NULL);
+ ASSERT(pBuffer != NULL && iBufferSize > 0);
if (iBufferSize > m_iLength - m_iPosition) {
iBufferSize = m_iLength - m_iPosition;
}
@@ -596,8 +594,8 @@ int32_t CFX_FileReadStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) {
int32_t CFX_FileReadStreamImp::ReadString(FX_WCHAR* pStr,
int32_t iMaxLength,
FX_BOOL& bEOS) {
- FXSYS_assert(m_pFileRead != NULL);
- FXSYS_assert(pStr != NULL && iMaxLength > 0);
+ ASSERT(m_pFileRead != NULL);
+ ASSERT(pStr != NULL && iMaxLength > 0);
iMaxLength = ReadData((uint8_t*)pStr, iMaxLength * 2) / 2;
if (iMaxLength <= 0) {
return 0;
@@ -623,7 +621,7 @@ FX_BOOL CFX_BufferReadStreamImp::LoadBufferRead(IFX_BufferRead* pBufferRead,
int32_t iFileSize,
uint32_t dwAccess,
FX_BOOL bReleaseBufferRead) {
- FXSYS_assert(m_pBufferRead == NULL && pBufferRead != NULL);
+ ASSERT(m_pBufferRead == NULL && pBufferRead != NULL);
if (dwAccess & FX_STREAMACCESS_Write) {
return FALSE;
}
@@ -671,8 +669,8 @@ FX_BOOL CFX_BufferReadStreamImp::IsEOF() const {
}
int32_t CFX_BufferReadStreamImp::ReadData(uint8_t* pBuffer,
int32_t iBufferSize) {
- FXSYS_assert(m_pBufferRead != NULL);
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
+ ASSERT(m_pBufferRead != NULL);
+ ASSERT(pBuffer != NULL && iBufferSize > 0);
int32_t iLength = GetLength();
if (m_iPosition >= iLength) {
return 0;
@@ -726,8 +724,8 @@ int32_t CFX_BufferReadStreamImp::ReadData(uint8_t* pBuffer,
int32_t CFX_BufferReadStreamImp::ReadString(FX_WCHAR* pStr,
int32_t iMaxLength,
FX_BOOL& bEOS) {
- FXSYS_assert(m_pBufferRead != NULL);
- FXSYS_assert(pStr != NULL && iMaxLength > 0);
+ ASSERT(m_pBufferRead != NULL);
+ ASSERT(pStr != NULL && iMaxLength > 0);
iMaxLength = ReadData((uint8_t*)pStr, iMaxLength * 2) / 2;
if (iMaxLength <= 0) {
return 0;
@@ -743,7 +741,7 @@ CFX_FileWriteStreamImp::CFX_FileWriteStreamImp()
: m_pFileWrite(NULL), m_iPosition(0) {}
FX_BOOL CFX_FileWriteStreamImp::LoadFileWrite(IFX_FileWrite* pFileWrite,
uint32_t dwAccess) {
- FXSYS_assert(m_pFileWrite == NULL && pFileWrite != NULL);
+ ASSERT(m_pFileWrite == NULL && pFileWrite != NULL);
if (dwAccess & FX_STREAMACCESS_Read) {
return FALSE;
}
@@ -810,8 +808,8 @@ CFX_BufferStreamImp::CFX_BufferStreamImp()
FX_BOOL CFX_BufferStreamImp::LoadBuffer(uint8_t* pData,
int32_t iTotalSize,
uint32_t dwAccess) {
- FXSYS_assert(m_pData == NULL);
- FXSYS_assert(pData != NULL && iTotalSize > 0);
+ ASSERT(m_pData == NULL);
+ ASSERT(pData != NULL && iTotalSize > 0);
m_dwAccess = dwAccess;
m_pData = pData;
m_iTotalSize = iTotalSize;
@@ -820,11 +818,11 @@ FX_BOOL CFX_BufferStreamImp::LoadBuffer(uint8_t* pData,
return TRUE;
}
int32_t CFX_BufferStreamImp::GetLength() const {
- FXSYS_assert(m_pData != NULL);
+ ASSERT(m_pData != NULL);
return m_iLength;
}
int32_t CFX_BufferStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) {
- FXSYS_assert(m_pData != NULL);
+ ASSERT(m_pData != NULL);
if (eSeek == FX_STREAMSEEK_Begin) {
m_iPosition = iOffset;
} else if (eSeek == FX_STREAMSEEK_Current) {
@@ -841,16 +839,16 @@ int32_t CFX_BufferStreamImp::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) {
return m_iPosition;
}
int32_t CFX_BufferStreamImp::GetPosition() {
- FXSYS_assert(m_pData != NULL);
+ ASSERT(m_pData != NULL);
return m_iPosition;
}
FX_BOOL CFX_BufferStreamImp::IsEOF() const {
- FXSYS_assert(m_pData != NULL);
+ ASSERT(m_pData != NULL);
return m_iPosition >= m_iLength;
}
int32_t CFX_BufferStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) {
- FXSYS_assert(m_pData != NULL);
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
+ ASSERT(m_pData != NULL);
+ ASSERT(pBuffer != NULL && iBufferSize > 0);
int32_t iLen = std::min(m_iLength - m_iPosition, iBufferSize);
if (iLen <= 0) {
return 0;
@@ -862,8 +860,8 @@ int32_t CFX_BufferStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) {
int32_t CFX_BufferStreamImp::ReadString(FX_WCHAR* pStr,
int32_t iMaxLength,
FX_BOOL& bEOS) {
- FXSYS_assert(m_pData != NULL);
- FXSYS_assert(pStr != NULL && iMaxLength > 0);
+ ASSERT(m_pData != NULL);
+ ASSERT(pStr != NULL && iMaxLength > 0);
int32_t iLen = std::min((m_iLength - m_iPosition) / 2, iMaxLength);
if (iLen <= 0) {
return 0;
@@ -880,8 +878,8 @@ int32_t CFX_BufferStreamImp::ReadString(FX_WCHAR* pStr,
}
int32_t CFX_BufferStreamImp::WriteData(const uint8_t* pBuffer,
int32_t iBufferSize) {
- FXSYS_assert(m_pData != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
+ ASSERT(m_pData != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
+ ASSERT(pBuffer != NULL && iBufferSize > 0);
int32_t iLen = std::min(m_iTotalSize - m_iPosition, iBufferSize);
if (iLen <= 0) {
return 0;
@@ -895,8 +893,8 @@ int32_t CFX_BufferStreamImp::WriteData(const uint8_t* pBuffer,
}
int32_t CFX_BufferStreamImp::WriteString(const FX_WCHAR* pStr,
int32_t iLength) {
- FXSYS_assert(m_pData != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
- FXSYS_assert(pStr != NULL && iLength > 0);
+ ASSERT(m_pData != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
+ ASSERT(pStr != NULL && iLength > 0);
int32_t iLen = std::min((m_iTotalSize - m_iPosition) / 2, iLength);
if (iLen <= 0) {
return 0;
@@ -910,7 +908,7 @@ int32_t CFX_BufferStreamImp::WriteString(const FX_WCHAR* pStr,
}
IFX_Stream* IFX_Stream::CreateTextStream(IFX_Stream* pBaseStream,
FX_BOOL bDeleteOnRelease) {
- FXSYS_assert(pBaseStream != NULL);
+ ASSERT(pBaseStream != NULL);
return new CFX_TextStream(pBaseStream, bDeleteOnRelease);
}
CFX_TextStream::CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream)
@@ -922,7 +920,7 @@ CFX_TextStream::CFX_TextStream(IFX_Stream* pStream, FX_BOOL bDelStream)
m_bDelStream(bDelStream),
m_pStreamImp(pStream),
m_iRefCount(1) {
- FXSYS_assert(m_pStreamImp != NULL);
+ ASSERT(m_pStreamImp != NULL);
m_pStreamImp->Retain();
InitStream();
}
@@ -1051,7 +1049,7 @@ int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr,
int32_t iMaxLength,
FX_BOOL& bEOS,
int32_t const* pByteSize) {
- FXSYS_assert(pStr != NULL && iMaxLength > 0);
+ ASSERT(pStr != NULL && iMaxLength > 0);
if (m_pStreamImp == NULL) {
return -1;
}
@@ -1101,7 +1099,7 @@ int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr,
return iMaxLength;
}
int32_t CFX_TextStream::WriteString(const FX_WCHAR* pStr, int32_t iLength) {
- FXSYS_assert(pStr != NULL && iLength > 0);
+ ASSERT(pStr != NULL && iLength > 0);
if ((m_pStreamImp->GetAccessModes() & FX_STREAMACCESS_Write) == 0) {
return -1;
}
@@ -1304,7 +1302,7 @@ FX_BOOL CFX_Stream::IsEOF() const {
return m_iPosition >= m_iStart + m_iLength;
}
int32_t CFX_Stream::ReadData(uint8_t* pBuffer, int32_t iBufferSize) {
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
+ ASSERT(pBuffer != NULL && iBufferSize > 0);
if (m_pStreamImp == NULL) {
return -1;
}
@@ -1323,7 +1321,7 @@ int32_t CFX_Stream::ReadString(FX_WCHAR* pStr,
int32_t iMaxLength,
FX_BOOL& bEOS,
int32_t const* pByteSize) {
- FXSYS_assert(pStr != NULL && iMaxLength > 0);
+ ASSERT(pStr != NULL && iMaxLength > 0);
if (m_pStreamImp == NULL) {
return -1;
}
@@ -1348,7 +1346,7 @@ int32_t CFX_Stream::ReadString(FX_WCHAR* pStr,
}
int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) {
- FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
+ ASSERT(pBuffer != NULL && iBufferSize > 0);
if (m_pStreamImp == NULL) {
return -1;
}
@@ -1374,7 +1372,7 @@ int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) {
return iLen;
}
int32_t CFX_Stream::WriteString(const FX_WCHAR* pStr, int32_t iLength) {
- FXSYS_assert(pStr != NULL && iLength > 0);
+ ASSERT(pStr != NULL && iLength > 0);
if (m_pStreamImp == NULL) {
return -1;
}
@@ -1440,7 +1438,7 @@ uint16_t CFX_Stream::SetCodePage(uint16_t wCodePage) {
IFX_Stream* CFX_Stream::CreateSharedStream(uint32_t dwAccess,
int32_t iOffset,
int32_t iLength) {
- FXSYS_assert(iLength > 0);
+ ASSERT(iLength > 0);
if (m_pStreamImp == NULL) {
return NULL;
}
@@ -1476,12 +1474,12 @@ IFX_Stream* CFX_Stream::CreateSharedStream(uint32_t dwAccess,
}
IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream,
FX_BOOL bReleaseStream) {
- FXSYS_assert(pBaseStream != NULL);
+ ASSERT(pBaseStream != NULL);
return new CFGAS_FileRead(pBaseStream, bReleaseStream);
}
CFGAS_FileRead::CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream)
: m_bReleaseStream(bReleaseStream), m_pStream(pStream) {
- FXSYS_assert(m_pStream != NULL);
+ ASSERT(m_pStream != NULL);
}
CFGAS_FileRead::~CFGAS_FileRead() {
if (m_bReleaseStream) {
@@ -1513,7 +1511,7 @@ CFX_BufferAccImp::CFX_BufferAccImp(IFX_BufferRead* pBufferRead,
: m_pBufferRead(pBufferRead),
m_bReleaseStream(bReleaseStream),
m_iBufSize(iFileSize) {
- FXSYS_assert(m_pBufferRead);
+ ASSERT(m_pBufferRead);
}
CFX_BufferAccImp::~CFX_BufferAccImp() {
if (m_bReleaseStream && m_pBufferRead) {
@@ -1595,13 +1593,13 @@ FX_BOOL CFX_BufferAccImp::ReadBlock(void* buffer,
IFX_FileWrite* FX_CreateFileWrite(IFX_Stream* pBaseStream,
FX_BOOL bReleaseStream) {
- FXSYS_assert(pBaseStream != NULL);
+ ASSERT(pBaseStream != NULL);
return new CFGAS_FileWrite(pBaseStream, bReleaseStream);
}
CFGAS_FileWrite::CFGAS_FileWrite(IFX_Stream* pStream, FX_BOOL bReleaseStream)
: m_pStream(pStream), m_bReleaseStream(bReleaseStream) {
- FXSYS_assert(m_pStream != NULL);
+ ASSERT(m_pStream != NULL);
}
CFGAS_FileWrite::~CFGAS_FileWrite() {
if (m_bReleaseStream) {
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_system.cpp b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_system.cpp
index 7ba2d924ca6..3ab39268efd 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_system.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_system.cpp
@@ -30,7 +30,7 @@ inline int32_t FX_tolower(int32_t ch) {
} // namespace
int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) {
- FXSYS_assert(s1 != NULL && s2 != NULL && count > 0);
+ ASSERT(s1 != NULL && s2 != NULL && count > 0);
FX_WCHAR wch1 = 0;
FX_WCHAR wch2 = 0;
while (count-- > 0) {
@@ -44,7 +44,7 @@ int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) {
}
int32_t FX_filelength(FXSYS_FILE* file) {
- FXSYS_assert(file != NULL);
+ ASSERT(file != NULL);
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
return _filelength(_fileno(file));
#else
@@ -57,7 +57,7 @@ int32_t FX_filelength(FXSYS_FILE* file) {
}
FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size) {
- FXSYS_assert(file != NULL);
+ ASSERT(file != NULL);
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
return _chsize(_fileno(file), size) == 0;
#elif _FX_OS_ == _FX_WIN32_MOBILE_
@@ -73,7 +73,7 @@ FX_BOOL FX_fsetsize(FXSYS_FILE* file, int32_t size) {
}
FX_FLOAT FX_wcstof(const FX_WCHAR* pwsStr, int32_t iLength, int32_t* pUsedLen) {
- FXSYS_assert(pwsStr != NULL);
+ ASSERT(pwsStr != NULL);
if (iLength < 0) {
iLength = FXSYS_wcslen(pwsStr);
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.cpp b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.cpp
index 0d020ec38f0..4f15fc48452 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.cpp
@@ -28,7 +28,7 @@ class FX_BASEARRAYDATA : public CFX_Target {
uint8_t* pBuffer;
};
CFX_BaseArray::CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize) {
- FXSYS_assert(iGrowSize > 0 && iBlockSize > 0);
+ ASSERT(iGrowSize > 0 && iBlockSize > 0);
m_pData = new FX_BASEARRAYDATA(iGrowSize, iBlockSize);
}
CFX_BaseArray::~CFX_BaseArray() {
@@ -42,7 +42,7 @@ int32_t CFX_BaseArray::GetBlockSize() const {
return m_pData->iBlockSize;
}
uint8_t* CFX_BaseArray::AddSpaceTo(int32_t index) {
- FXSYS_assert(index > -1);
+ ASSERT(index > -1);
uint8_t*& pBuffer = m_pData->pBuffer;
int32_t& iTotalCount = m_pData->iTotalCount;
int32_t iBlockSize = m_pData->iBlockSize;
@@ -63,7 +63,7 @@ uint8_t* CFX_BaseArray::AddSpaceTo(int32_t index) {
return pBuffer + index * iBlockSize;
}
uint8_t* CFX_BaseArray::GetAt(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_pData->iBlockCount);
+ ASSERT(index > -1 && index < m_pData->iBlockCount);
return m_pData->pBuffer + index * m_pData->iBlockSize;
}
uint8_t* CFX_BaseArray::GetBuffer() const {
@@ -73,10 +73,10 @@ int32_t CFX_BaseArray::Append(const CFX_BaseArray& src,
int32_t iStart,
int32_t iCount) {
int32_t iBlockSize = m_pData->iBlockSize;
- FXSYS_assert(iBlockSize == src.m_pData->iBlockSize);
+ ASSERT(iBlockSize == src.m_pData->iBlockSize);
int32_t& iBlockCount = m_pData->iBlockCount;
int32_t iAdded = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iAdded);
+ ASSERT(iStart > -1 && iStart < iAdded);
if (iCount < 0) {
iCount = iAdded;
}
@@ -96,9 +96,9 @@ int32_t CFX_BaseArray::Copy(const CFX_BaseArray& src,
int32_t iStart,
int32_t iCount) {
int32_t iBlockSize = m_pData->iBlockSize;
- FXSYS_assert(iBlockSize == src.m_pData->iBlockSize);
+ ASSERT(iBlockSize == src.m_pData->iBlockSize);
int32_t iCopied = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iCopied);
+ ASSERT(iStart > -1 && iStart < iCopied);
if (iCount < 0) {
iCount = iCopied;
}
@@ -141,9 +141,9 @@ CFX_BaseMassArrayImp::CFX_BaseMassArrayImp(int32_t iChunkSize,
: m_iChunkSize(iChunkSize),
m_iBlockSize(iBlockSize),
m_iChunkCount(0),
- m_iBlockCount(0) {
- FXSYS_assert(m_iChunkSize > 0 && m_iBlockSize > 0);
- m_pData = new CFX_PtrArray;
+ m_iBlockCount(0),
+ m_pData(new CFX_ArrayTemplate<void*>()) {
+ ASSERT(m_iChunkSize > 0 && m_iBlockSize > 0);
m_pData->SetSize(16);
}
CFX_BaseMassArrayImp::~CFX_BaseMassArrayImp() {
@@ -151,7 +151,7 @@ CFX_BaseMassArrayImp::~CFX_BaseMassArrayImp() {
delete m_pData;
}
uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) {
- FXSYS_assert(index > -1);
+ ASSERT(index > -1);
uint8_t* pChunk;
if (index < m_iBlockCount) {
pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize);
@@ -172,22 +172,22 @@ uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) {
}
}
}
- FXSYS_assert(pChunk != NULL);
+ ASSERT(pChunk != NULL);
m_iBlockCount = index + 1;
return pChunk + (index % m_iChunkSize) * m_iBlockSize;
}
uint8_t* CFX_BaseMassArrayImp::GetAt(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_iBlockCount);
+ ASSERT(index > -1 && index < m_iBlockCount);
uint8_t* pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize);
- FXSYS_assert(pChunk != NULL);
+ ASSERT(pChunk != NULL);
return pChunk + (index % m_iChunkSize) * m_iBlockSize;
}
int32_t CFX_BaseMassArrayImp::Append(const CFX_BaseMassArrayImp& src,
int32_t iStart,
int32_t iCount) {
- FXSYS_assert(m_iBlockSize == src.m_iBlockSize);
+ ASSERT(m_iBlockSize == src.m_iBlockSize);
int32_t iAdded = src.m_iBlockCount;
- FXSYS_assert(iStart > -1 && iStart < iAdded);
+ ASSERT(iStart > -1 && iStart < iAdded);
if (iCount < 0) {
iCount = iAdded;
}
@@ -206,9 +206,9 @@ int32_t CFX_BaseMassArrayImp::Append(const CFX_BaseMassArrayImp& src,
int32_t CFX_BaseMassArrayImp::Copy(const CFX_BaseMassArrayImp& src,
int32_t iStart,
int32_t iCount) {
- FXSYS_assert(m_iBlockSize == src.m_iBlockSize);
+ ASSERT(m_iBlockSize == src.m_iBlockSize);
int32_t iCopied = src.m_iBlockCount;
- FXSYS_assert(iStart > -1);
+ ASSERT(iStart > -1);
if (iStart >= iCopied) {
return 0;
}
@@ -233,14 +233,14 @@ void CFX_BaseMassArrayImp::Append(int32_t iDstStart,
const CFX_BaseMassArrayImp& src,
int32_t iSrcStart,
int32_t iSrcCount) {
- FXSYS_assert(iDstStart > -1);
- FXSYS_assert(m_iBlockSize == src.m_iBlockSize);
- FXSYS_assert(src.m_iBlockCount > 0);
- FXSYS_assert(m_iBlockCount >= iDstStart + iSrcCount);
- FXSYS_assert(iSrcStart > -1);
- FXSYS_assert(iSrcStart < src.m_iBlockCount);
- FXSYS_assert(iSrcCount > 0);
- FXSYS_assert(iSrcStart + iSrcCount <= src.m_iBlockCount);
+ ASSERT(iDstStart > -1);
+ ASSERT(m_iBlockSize == src.m_iBlockSize);
+ ASSERT(src.m_iBlockCount > 0);
+ ASSERT(m_iBlockCount >= iDstStart + iSrcCount);
+ ASSERT(iSrcStart > -1);
+ ASSERT(iSrcStart < src.m_iBlockCount);
+ ASSERT(iSrcCount > 0);
+ ASSERT(iSrcStart + iSrcCount <= src.m_iBlockCount);
int32_t iDstChunkIndex = iDstStart / m_iChunkSize;
int32_t iSrcChunkIndex = iSrcStart / src.m_iChunkSize;
@@ -252,7 +252,7 @@ void CFX_BaseMassArrayImp::Append(int32_t iDstStart,
std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize));
int32_t iCopyBytes = iCopySize * m_iBlockSize;
while (iSrcCount > 0) {
- FXSYS_assert(pDstChunk != NULL && pSrcChunk != NULL);
+ ASSERT(pDstChunk != NULL && pSrcChunk != NULL);
FXSYS_memcpy(pDstChunk, pSrcChunk, iCopyBytes);
iSrcCount -= iCopySize;
iSrcChunkSize -= iCopySize;
@@ -335,12 +335,12 @@ struct FX_BASEDISCRETEARRAYDATA {
int32_t iBlockSize;
int32_t iChunkSize;
int32_t iChunkCount;
- CFX_PtrArray ChunkBuffer;
+ CFX_ArrayTemplate<uint8_t*> ChunkBuffer;
};
CFX_BaseDiscreteArray::CFX_BaseDiscreteArray(int32_t iChunkSize,
int32_t iBlockSize) {
- FXSYS_assert(iChunkSize > 0 && iBlockSize > 0);
+ ASSERT(iChunkSize > 0 && iBlockSize > 0);
FX_BASEDISCRETEARRAYDATA* pData = new FX_BASEDISCRETEARRAYDATA;
m_pData = pData;
pData->ChunkBuffer.SetSize(16);
@@ -353,14 +353,14 @@ CFX_BaseDiscreteArray::~CFX_BaseDiscreteArray() {
delete static_cast<FX_BASEDISCRETEARRAYDATA*>(m_pData);
}
uint8_t* CFX_BaseDiscreteArray::AddSpaceTo(int32_t index) {
- FXSYS_assert(index > -1);
+ ASSERT(index > -1);
FX_BASEDISCRETEARRAYDATA* pData = (FX_BASEDISCRETEARRAYDATA*)m_pData;
int32_t& iChunkCount = pData->iChunkCount;
int32_t iChunkSize = pData->iChunkSize;
uint8_t* pChunk = NULL;
int32_t iChunk = index / iChunkSize;
if (iChunk < iChunkCount) {
- pChunk = (uint8_t*)pData->ChunkBuffer.GetAt(iChunk);
+ pChunk = pData->ChunkBuffer.GetAt(iChunk);
}
if (!pChunk) {
pChunk = FX_Alloc2D(uint8_t, iChunkSize, pData->iBlockSize);
@@ -373,30 +373,26 @@ uint8_t* CFX_BaseDiscreteArray::AddSpaceTo(int32_t index) {
return pChunk + (index % iChunkSize) * pData->iBlockSize;
}
uint8_t* CFX_BaseDiscreteArray::GetAt(int32_t index) const {
- FXSYS_assert(index > -1);
+ ASSERT(index >= 0);
FX_BASEDISCRETEARRAYDATA* pData = (FX_BASEDISCRETEARRAYDATA*)m_pData;
int32_t iChunkSize = pData->iChunkSize;
int32_t iChunk = index / iChunkSize;
- if (iChunk >= pData->iChunkCount) {
- return NULL;
- }
- uint8_t* pChunk = (uint8_t*)pData->ChunkBuffer.GetAt(iChunk);
- if (pChunk == NULL) {
- return NULL;
- }
+ if (iChunk >= pData->iChunkCount)
+ return nullptr;
+
+ uint8_t* pChunk = pData->ChunkBuffer.GetAt(iChunk);
+ if (!pChunk)
+ return nullptr;
+
return pChunk + (index % iChunkSize) * pData->iBlockSize;
}
void CFX_BaseDiscreteArray::RemoveAll() {
FX_BASEDISCRETEARRAYDATA* pData = (FX_BASEDISCRETEARRAYDATA*)m_pData;
- CFX_PtrArray& ChunkBuffer = pData->ChunkBuffer;
+ CFX_ArrayTemplate<uint8_t*>& ChunkBuffer = pData->ChunkBuffer;
int32_t& iChunkCount = pData->iChunkCount;
- for (int32_t i = 0; i < iChunkCount; i++) {
- void* p = ChunkBuffer.GetAt(i);
- if (p == NULL) {
- continue;
- }
- FX_Free(p);
- }
+ for (int32_t i = 0; i < iChunkCount; i++)
+ FX_Free(ChunkBuffer.GetAt(i));
+
ChunkBuffer.RemoveAll();
iChunkCount = 0;
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.h b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.h
index 5ebb32ff370..24224a02f07 100644
--- a/chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.h
+++ b/chromium/third_party/pdfium/xfa/fgas/crt/fgas_utils.h
@@ -12,9 +12,6 @@
class FX_BASEARRAYDATA;
-template <class baseType>
-class CFX_CPLTree;
-
class CFX_BaseArray : public CFX_Target {
protected:
CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize);
@@ -110,12 +107,12 @@ class CFX_ObjectBaseArrayTemplate : public CFX_BaseArray {
int32_t Append(const CFX_ObjectBaseArrayTemplate& src,
int32_t iStart = 0,
int32_t iCount = -1) {
- FXSYS_assert(GetBlockSize() == src.GetBlockSize());
+ ASSERT(GetBlockSize() == src.GetBlockSize());
if (iCount == 0) {
return 0;
}
int32_t iSize = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iSize);
+ ASSERT(iStart > -1 && iStart < iSize);
if (iCount < 0) {
iCount = iSize;
}
@@ -139,12 +136,12 @@ class CFX_ObjectBaseArrayTemplate : public CFX_BaseArray {
int32_t Copy(const CFX_ObjectBaseArrayTemplate& src,
int32_t iStart = 0,
int32_t iCount = -1) {
- FXSYS_assert(GetBlockSize() == src.GetBlockSize());
+ ASSERT(GetBlockSize() == src.GetBlockSize());
if (iCount == 0) {
return 0;
}
int32_t iSize = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iSize);
+ ASSERT(iStart > -1 && iStart < iSize);
if (iCount < 0) {
iCount = iSize;
}
@@ -202,11 +199,12 @@ class CFX_BaseMassArrayImp : public CFX_Target {
int32_t iCount = -1);
int32_t RemoveLast(int32_t iCount = -1);
void RemoveAll(FX_BOOL bLeaveMemory = FALSE);
+
int32_t m_iChunkSize;
int32_t m_iBlockSize;
int32_t m_iChunkCount;
int32_t m_iBlockCount;
- CFX_PtrArray* m_pData;
+ CFX_ArrayTemplate<void*>* m_pData;
protected:
void Append(int32_t iDstStart,
@@ -312,7 +310,7 @@ class CFX_ObjectMassArrayTemplate : public CFX_BaseMassArray {
return CFX_BaseMassArray::GetSize();
}
int32_t iSize = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iSize);
+ ASSERT(iStart > -1 && iStart < iSize);
if (iCount < 0) {
iCount = iSize;
}
@@ -332,7 +330,7 @@ class CFX_ObjectMassArrayTemplate : public CFX_BaseMassArray {
return CFX_BaseMassArray::GetSize();
}
int32_t iSize = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iSize);
+ ASSERT(iStart > -1 && iStart < iSize);
if (iCount < 0) {
iCount = iSize;
}
@@ -479,7 +477,7 @@ class CFX_ObjectStackTemplate : public CFX_BaseStack {
return CFX_BaseStack::GetSize();
}
int32_t iSize = src.GetSize();
- FXSYS_assert(iStart > -1 && iStart < iSize);
+ ASSERT(iStart > -1 && iStart < iSize);
if (iCount < 0) {
iCount = iSize;
}
@@ -495,243 +493,4 @@ class CFX_ObjectStackTemplate : public CFX_BaseStack {
}
};
-template <class baseType>
-class CFX_CPLTreeNode : public CFX_Target {
- public:
- typedef CFX_CPLTreeNode<baseType> CPLTreeNode;
- CFX_CPLTreeNode()
- : m_pParentNode(NULL),
- m_pChildNode(NULL),
- m_pPrevNode(NULL),
- m_pNextNode(NULL),
- m_Data() {}
- enum TreeNode {
- Root = 0,
- Parent,
- FirstSibling,
- PreviousSibling,
- NextSibling,
- LastSibling,
- FirstNeighbor,
- PreviousNeighbor,
- NextNeighbor,
- LastNeighbor,
- FirstChild,
- LastChild
- };
- CPLTreeNode* GetNode(TreeNode eNode) const {
- switch (eNode) {
- case Root: {
- CPLTreeNode* pParent = (CPLTreeNode*)this;
- CPLTreeNode* pTemp;
- while ((pTemp = pParent->m_pParentNode) != NULL) {
- pParent = pTemp;
- }
- return pParent;
- }
- case Parent:
- return m_pParentNode;
- case FirstSibling: {
- CPLTreeNode* pNode = (CPLTreeNode*)this;
- CPLTreeNode* pTemp;
- while ((pTemp = pNode->m_pPrevNode) != NULL) {
- pNode = pTemp;
- }
- return pNode == (CPLTreeNode*)this ? NULL : pNode;
- }
- case PreviousSibling:
- return m_pPrevNode;
- case NextSibling:
- return m_pNextNode;
- case LastSibling: {
- CPLTreeNode* pNode = (CPLTreeNode*)this;
- CPLTreeNode* pTemp;
- while ((pTemp = pNode->m_pNextNode) != NULL) {
- pNode = pTemp;
- }
- return pNode == (CPLTreeNode*)this ? NULL : pNode;
- }
- case FirstNeighbor: {
- CPLTreeNode* pParent = (CPLTreeNode*)this;
- CPLTreeNode* pTemp;
- while ((pTemp = pParent->m_pParentNode) != NULL) {
- pParent = pTemp;
- }
- return pParent == (CPLTreeNode*)this ? NULL : pParent;
- }
- case PreviousNeighbor: {
- if (m_pPrevNode == NULL) {
- return m_pParentNode;
- }
- CPLTreeNode* pNode = m_pPrevNode;
- CPLTreeNode* pTemp;
- while ((pTemp = pNode->m_pChildNode) != NULL) {
- pNode = pTemp;
- while ((pTemp = pNode->m_pNextNode) != NULL) {
- pNode = pTemp;
- }
- }
- return pNode;
- }
- case NextNeighbor: {
- if (m_pChildNode != NULL) {
- return m_pChildNode;
- }
- if (m_pNextNode != NULL) {
- return m_pNextNode;
- }
- CPLTreeNode* pNode = m_pParentNode;
- while (pNode != NULL) {
- if (pNode->m_pNextNode != NULL) {
- return pNode->m_pNextNode;
- }
- pNode = pNode->m_pParentNode;
- }
- return NULL;
- }
- case LastNeighbor: {
- CPLTreeNode* pNode = (CPLTreeNode*)this;
- CPLTreeNode* pTemp;
- while ((pTemp = pNode->m_pParentNode) != NULL) {
- pNode = pTemp;
- }
- while (TRUE) {
- CPLTreeNode* pTemp;
- while ((pTemp = pNode->m_pNextNode) != NULL) {
- pNode = pTemp;
- }
- if (pNode->m_pChildNode == NULL) {
- break;
- }
- pNode = pNode->m_pChildNode;
- }
- return pNode == (CPLTreeNode*)this ? NULL : pNode;
- }
- case FirstChild:
- return m_pChildNode;
- case LastChild: {
- if (m_pChildNode == NULL) {
- return NULL;
- }
- CPLTreeNode* pChild = m_pChildNode;
- CPLTreeNode* pTemp;
- while ((pTemp = pChild->m_pNextNode) != NULL) {
- pChild = pTemp;
- }
- return pChild;
- }
- default:
- break;
- }
- return NULL;
- }
- void SetParentNode(CPLTreeNode* pNode) { m_pParentNode = pNode; }
- int32_t CountChildNodes() const {
- int32_t iCount = 0;
- CPLTreeNode* pNode = m_pChildNode;
- while (pNode) {
- iCount++;
- pNode = pNode->m_pNextNode;
- }
- return iCount;
- }
- CPLTreeNode* GetChildNode(int32_t iIndex) const {
- int32_t iCount = 0;
- CPLTreeNode* pNode = m_pChildNode;
- while (pNode) {
- if (iIndex == iCount) {
- return pNode;
- }
- iCount++;
- pNode = pNode->m_pNextNode;
- }
- return NULL;
- }
- int32_t GetNodeIndex() const {
- int32_t index = 0;
- CPLTreeNode* pNode = m_pPrevNode;
- while (pNode != NULL) {
- index++;
- pNode = pNode->m_pPrevNode;
- }
- return index;
- }
- FX_BOOL IsParentNode(const CPLTreeNode* pNode) const {
- CPLTreeNode* pParent = m_pParentNode;
- while (pParent != NULL) {
- if (pParent == pNode) {
- return TRUE;
- }
- pParent = pParent->GetTreeNode(Parent);
- }
- return FALSE;
- }
- FX_BOOL IsChildNode(const CPLTreeNode* pNode) const {
- if (pNode == NULL) {
- return FALSE;
- }
- return pNode->IsParentNode((const CPLTreeNode*)this);
- }
- void SetChildNode(CPLTreeNode* pNode) { m_pChildNode = pNode; }
- void SetPrevNode(CPLTreeNode* pNode) { m_pPrevNode = pNode; }
- void SetNextNode(CPLTreeNode* pNode) { m_pNextNode = pNode; }
- int32_t GetNodeLevel() const {
- int32_t iLevel = 0;
- CPLTreeNode* pNode = (CPLTreeNode*)this;
- while ((pNode = pNode->m_pParentNode) != NULL) {
- iLevel++;
- }
- return iLevel;
- }
- bool IsRootNode() const { return !m_pParentNode; }
- baseType GetData() const { return m_Data; }
- void SetData(baseType data) { m_Data = data; }
-
- protected:
- CPLTreeNode* m_pParentNode;
- CPLTreeNode* m_pChildNode;
- CPLTreeNode* m_pPrevNode;
- CPLTreeNode* m_pNextNode;
- baseType m_Data;
- friend class CFX_CPLTree<baseType>;
-};
-
-template <class baseType>
-class CFX_CPLTree {
- public:
- typedef CFX_CPLTreeNode<baseType> CPLTreeNode;
- CFX_CPLTree() : m_Root() {}
- ~CFX_CPLTree() {
- CPLTreeNode* pNode = m_Root.GetNode(CPLTreeNode::LastNeighbor);
- while (pNode != NULL) {
- if (pNode->IsRootNode()) {
- break;
- }
- CPLTreeNode* pTemp = pNode->GetNode(CPLTreeNode::PreviousNeighbor);
- delete pNode;
- pNode = pTemp;
- }
- }
- CPLTreeNode* GetRoot() { return &m_Root; }
- CPLTreeNode* AddChild(baseType data, CPLTreeNode* pParent = NULL) {
- if (pParent == NULL) {
- pParent = &m_Root;
- }
- CPLTreeNode* pChild = new CPLTreeNode;
- pChild->SetParentNode(pParent);
- pChild->SetData(data);
- if (pParent->m_pChildNode == NULL) {
- pParent->m_pChildNode = pChild;
- } else {
- CPLTreeNode* pLast = pParent->GetNode(CPLTreeNode::LastChild);
- pChild->SetPrevNode(pLast);
- pLast->SetNextNode(pChild);
- }
- return pChild;
- }
-
- protected:
- CPLTreeNode m_Root;
-};
-
#endif // XFA_FGAS_CRT_FGAS_UTILS_H_
diff --git a/chromium/third_party/pdfium/xfa/fgas/font/fgas_font.h b/chromium/third_party/pdfium/xfa/fgas/font/fgas_font.h
index 8b1091ff501..406c6f96a88 100644
--- a/chromium/third_party/pdfium/xfa/fgas/font/fgas_font.h
+++ b/chromium/third_party/pdfium/xfa/fgas/font/fgas_font.h
@@ -7,7 +7,7 @@
#ifndef XFA_FGAS_FONT_FGAS_FONT_H_
#define XFA_FGAS_FONT_FGAS_FONT_H_
-#include "core/include/fxge/fx_font.h"
+#include "core/fxge/include/fx_font.h"
#include "xfa/fgas/crt/fgas_stream.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -15,6 +15,8 @@
#include "xfa/fgas/crt/fgas_utils.h"
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+class CFX_FontSourceEnum_File;
+class CXFA_PDFFontMgr;
class IFX_Font;
class IFX_FontMgr;
@@ -48,15 +50,6 @@ class IFX_FontMgr;
#define FX_BOUNDINGSHAPE_Triangle 3
#define FX_BOUNDINGSHAPE_Diamond 4
-class IFX_FontProvider {
- public:
- virtual ~IFX_FontProvider() {}
- virtual FX_BOOL GetCharWidth(IFX_Font* pFont,
- FX_WCHAR wUnicode,
- int32_t& iWidth,
- FX_BOOL bCharCode = FALSE) = 0;
-};
-
class IFX_Font {
public:
static IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
@@ -96,11 +89,12 @@ class IFX_Font {
virtual void Reset() = 0;
virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const = 0;
virtual void* GetDevFont() const = 0;
- virtual void SetFontProvider(IFX_FontProvider* pProvider) = 0;
+ virtual void SetFontProvider(CXFA_PDFFontMgr* pProvider) = 0;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) = 0;
#endif
};
+
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
struct FX_FONTMATCHPARAMS {
const FX_WCHAR* pwsFamily;
@@ -130,8 +124,7 @@ struct FX_FONTDESCRIPTOR {
uint8_t uCharSet;
FX_FONTSIGNATURE FontSignature;
};
-typedef FX_FONTDESCRIPTOR* FX_LPFONTDESCRIPTOR;
-typedef FX_FONTDESCRIPTOR const* FX_LPCFONTDESCRIPTOR;
+
typedef CFX_MassArrayTemplate<FX_FONTDESCRIPTOR> CFX_FontDescriptors;
inline bool operator==(const FX_FONTDESCRIPTOR& left,
const FX_FONTDESCRIPTOR& right) {
@@ -145,19 +138,16 @@ inline bool operator==(const FX_FONTDESCRIPTOR& left,
#define FX_FONTMATCHPARA_MacthFamily 0x02
#define FX_FONTMATCHPARA_MacthUnicode 0x04
typedef void (*FX_LPEnumAllFonts)(CFX_FontDescriptors& fonts,
- void* pUserData,
const FX_WCHAR* pwsFaceName,
FX_WCHAR wUnicode);
FX_LPEnumAllFonts FX_GetDefFontEnumerator();
-typedef FX_LPCFONTDESCRIPTOR (*FX_LPMatchFont)(FX_LPFONTMATCHPARAMS pParams,
- const CFX_FontDescriptors& fonts,
- void* pUserData);
+typedef FX_FONTDESCRIPTOR const* (*FX_LPMatchFont)(
+ FX_LPFONTMATCHPARAMS pParams,
+ const CFX_FontDescriptors& fonts);
FX_LPMatchFont FX_GetDefFontMatchor();
class IFX_FontMgr {
public:
- static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator,
- FX_LPMatchFont pMatcher = NULL,
- void* pUserData = NULL);
+ static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator);
virtual ~IFX_FontMgr() {}
virtual void Release() = 0;
virtual IFX_Font* GetDefFontByCodePage(
@@ -192,44 +182,12 @@ class IFX_FontMgr {
virtual void ClearFontCache() = 0;
virtual void RemoveFont(IFX_Font* pFont) = 0;
};
-#else
-class IFX_FontMgrDelegate {
- public:
- virtual ~IFX_FontMgrDelegate() {}
- virtual IFX_Font* GetDefFontByCodePage(
- IFX_FontMgr* pFontMgr,
- uint16_t wCodePage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByCharset(
- IFX_FontMgr* pFontMgr,
- uint8_t nCharset,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByUnicode(
- IFX_FontMgr* pFontMgr,
- FX_WCHAR wUnicode,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
- virtual IFX_Font* GetDefFontByLanguage(
- IFX_FontMgr* pFontMgr,
- uint16_t wLanguage,
- uint32_t dwFontStyles,
- const FX_WCHAR* pszFontFamily = NULL) = 0;
-};
-class IFX_FontSourceEnum {
- public:
- virtual ~IFX_FontSourceEnum() {}
- virtual void Release() = 0;
- virtual FX_POSITION GetStartPosition(void* pUserData = NULL) = 0;
- virtual IFX_FileAccess* GetNext(FX_POSITION& pos, void* pUserData = NULL) = 0;
-};
-IFX_FontSourceEnum* FX_CreateDefaultFontSourceEnum();
+
+#else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
class IFX_FontMgr {
public:
- static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum,
- IFX_FontMgrDelegate* pDelegate = NULL,
- void* pUserData = NULL);
+ static IFX_FontMgr* Create(CFX_FontSourceEnum_File* pFontEnum);
virtual ~IFX_FontMgr() {}
virtual void Release() = 0;
virtual IFX_Font* GetDefFontByCodePage(
@@ -280,6 +238,6 @@ class IFX_FontMgr {
virtual void ClearFontCache() = 0;
virtual void RemoveFont(IFX_Font* pFont) = 0;
};
-#endif
+#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#endif // XFA_FGAS_FONT_FGAS_FONT_H_
diff --git a/chromium/third_party/pdfium/xfa/fgas/font/fgas_fontutils.cpp b/chromium/third_party/pdfium/xfa/fgas/font/fgas_fontutils.cpp
index 2e550f7c087..bccaf2cdb64 100644
--- a/chromium/third_party/pdfium/xfa/fgas/font/fgas_fontutils.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/font/fgas_fontutils.cpp
@@ -42,7 +42,7 @@ uint32_t FGAS_GetFontFamilyHash(const FX_WCHAR* pszFontFamily,
wsFont += L"Italic";
}
wsFont += wCodePage;
- return FX_HashCode_String_GetW((const FX_WCHAR*)wsFont, wsFont.GetLength());
+ return FX_HashCode_GetW(wsFont.AsStringC(), false);
}
static const FGAS_FONTUSB g_FXGdiFontUSBTable[] = {
{0x0000, 0x007F, 0, 1252}, {0x0080, 0x00FF, 1, 1252},
@@ -136,7 +136,7 @@ static const FGAS_FONTUSB g_FXGdiFontUSBTable[] = {
const FGAS_FONTUSB* FGAS_GetUnicodeBitField(FX_WCHAR wUnicode) {
int32_t iEnd = sizeof(g_FXGdiFontUSBTable) / sizeof(FGAS_FONTUSB) - 1;
- FXSYS_assert(iEnd >= 0);
+ ASSERT(iEnd >= 0);
int32_t iStart = 0, iMid;
do {
iMid = (iStart + iEnd) / 2;
diff --git a/chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.cpp b/chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.cpp
index 3d740ba43a0..5dfdb70018d 100644
--- a/chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.cpp
@@ -8,6 +8,7 @@
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fgas/font/fgas_fontutils.h"
+#include "xfa/fxfa/include/xfa_fontmgr.h"
IFX_Font* IFX_Font::LoadFont(const FX_WCHAR* pszFontFamily,
uint32_t dwFontStyles,
@@ -105,7 +106,6 @@ CFX_GEFont::CFX_GEFont(IFX_FontMgr* pFontMgr)
m_pBBoxMap(NULL),
m_pProvider(NULL),
m_wCharSet(0xFFFF),
- m_SubstFonts(),
m_FontMapper(16) {
}
@@ -127,11 +127,10 @@ CFX_GEFont::CFX_GEFont(const CFX_GEFont& src, uint32_t dwFontStyles)
m_pBBoxMap(NULL),
m_pProvider(NULL),
m_wCharSet(0xFFFF),
- m_SubstFonts(),
m_FontMapper(16) {
m_pFont = new CFX_Font;
- FXSYS_assert(m_pFont != NULL);
- FXSYS_assert(src.m_pFont != NULL);
+ ASSERT(m_pFont != NULL);
+ ASSERT(src.m_pFont != NULL);
m_pFont->LoadClone(src.m_pFont);
CFX_SubstFont* pSubst = m_pFont->GetSubstFont();
if (!pSubst) {
@@ -145,36 +144,27 @@ CFX_GEFont::CFX_GEFont(const CFX_GEFont& src, uint32_t dwFontStyles)
}
InitFont();
}
+
CFX_GEFont::~CFX_GEFont() {
- int32_t iCount = m_SubstFonts.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- IFX_Font* pFont = (IFX_Font*)m_SubstFonts[i];
- pFont->Release();
- }
+ for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++)
+ m_SubstFonts[i]->Release();
+
m_SubstFonts.RemoveAll();
m_FontMapper.RemoveAll();
- if (m_pFileRead != NULL) {
+ if (m_pFileRead)
m_pFileRead->Release();
- }
- if (m_pStream != NULL) {
+
+ if (m_pStream)
m_pStream->Release();
- }
- if (m_pFontEncoding != NULL) {
- delete m_pFontEncoding;
- }
- if (m_pCharWidthMap != NULL) {
- delete m_pCharWidthMap;
- }
- if (m_pRectArray != NULL) {
- delete m_pRectArray;
- }
- if (m_pBBoxMap != NULL) {
- delete m_pBBoxMap;
- }
- if (m_pFont != NULL && !m_bExtFont) {
+
+ delete m_pFontEncoding;
+ delete m_pCharWidthMap;
+ delete m_pRectArray;
+ delete m_pBBoxMap;
+ if (!m_bExtFont)
delete m_pFont;
- }
}
+
void CFX_GEFont::Release() {
if (--m_iRefCount < 1) {
if (m_pFontMgr != NULL) {
@@ -347,16 +337,17 @@ uint8_t CFX_GEFont::GetCharSet() const {
void CFX_GEFont::GetFamilyName(CFX_WideString& wsFamily) const {
if (!m_pFont->GetSubstFont() ||
m_pFont->GetSubstFont()->m_Family.GetLength() == 0) {
- wsFamily = CFX_WideString::FromLocal(m_pFont->GetFamilyName());
+ wsFamily = CFX_WideString::FromLocal(m_pFont->GetFamilyName().AsStringC());
} else {
- wsFamily = CFX_WideString::FromLocal(m_pFont->GetSubstFont()->m_Family);
+ wsFamily = CFX_WideString::FromLocal(
+ m_pFont->GetSubstFont()->m_Family.AsStringC());
}
}
void CFX_GEFont::GetPsName(CFX_WideString& wsName) const {
wsName = m_pFont->GetPsName();
}
uint32_t CFX_GEFont::GetFontStyles() const {
- FXSYS_assert(m_pFont != NULL);
+ ASSERT(m_pFont != NULL);
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
if (m_bUseLogFontStyle) {
return m_dwLogFontStyle;
@@ -389,7 +380,7 @@ FX_BOOL CFX_GEFont::GetCharWidth(FX_WCHAR wUnicode,
int32_t& iWidth,
FX_BOOL bRecursive,
FX_BOOL bCharCode) {
- FXSYS_assert(m_pCharWidthMap != NULL);
+ ASSERT(m_pCharWidthMap != NULL);
iWidth = m_pCharWidthMap->GetAt(wUnicode, 0);
if (iWidth < 1) {
if (!m_pProvider ||
@@ -425,8 +416,8 @@ FX_BOOL CFX_GEFont::GetCharBBox(FX_WCHAR wUnicode,
CFX_Rect& bbox,
FX_BOOL bRecursive,
FX_BOOL bCharCode) {
- FXSYS_assert(m_pRectArray != NULL);
- FXSYS_assert(m_pBBoxMap != NULL);
+ ASSERT(m_pRectArray != NULL);
+ ASSERT(m_pBBoxMap != NULL);
void* pRect = NULL;
if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) {
IFX_Font* pFont = NULL;
@@ -477,7 +468,7 @@ int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
FX_BOOL bRecursive,
IFX_Font** ppFont,
FX_BOOL bCharCode) {
- FXSYS_assert(m_pFontEncoding != NULL);
+ ASSERT(m_pFontEncoding != NULL);
int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode);
if (iGlyphIndex > 0) {
if (ppFont != NULL) {
@@ -513,11 +504,11 @@ int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
CFX_WideString wsFamily;
GetFamilyName(wsFamily);
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- IFX_Font* pFont = m_pFontMgr->GetDefFontByUnicode(
- wUnicode, GetFontStyles(), (const FX_WCHAR*)wsFamily);
+ IFX_Font* pFont = m_pFontMgr->GetDefFontByUnicode(wUnicode, GetFontStyles(),
+ wsFamily.c_str());
#else
IFX_Font* pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(),
- (const FX_WCHAR*)wsFamily);
+ wsFamily.c_str());
if (NULL == pFont) {
pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), NULL);
}
@@ -552,7 +543,7 @@ int32_t CFX_GEFont::GetDescent() const {
void CFX_GEFont::Reset() {
int32_t iCount = m_SubstFonts.GetSize();
for (int32_t i = 0; i < iCount; i++) {
- IFX_Font* pFont = (IFX_Font*)m_SubstFonts[i];
+ IFX_Font* pFont = m_SubstFonts[i];
((CFX_GEFont*)pFont)->Reset();
}
if (m_pCharWidthMap != NULL) {
@@ -567,6 +558,6 @@ void CFX_GEFont::Reset() {
}
IFX_Font* CFX_GEFont::GetSubstFont(int32_t iGlyphIndex) const {
iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24;
- return iGlyphIndex == 0 ? (IFX_Font*)this
- : (IFX_Font*)m_SubstFonts[iGlyphIndex - 1];
+ return iGlyphIndex == 0 ? const_cast<CFX_GEFont*>(this)
+ : m_SubstFonts[iGlyphIndex - 1];
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.h b/chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.h
index 044acdeb7fa..491f38bc893 100644
--- a/chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.h
+++ b/chromium/third_party/pdfium/xfa/fgas/font/fgas_gefont.h
@@ -12,6 +12,8 @@
#define FXFONT_SUBST_ITALIC 0x02
+class CXFA_PDFFontMgr;
+
class CFX_GEFont : public IFX_Font {
public:
CFX_GEFont(const CFX_GEFont& src, uint32_t dwFontStyles);
@@ -45,7 +47,7 @@ class CFX_GEFont : public IFX_Font {
virtual void Reset();
virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const;
virtual void* GetDevFont() const { return (void*)m_pFont; }
- virtual void SetFontProvider(IFX_FontProvider* pProvider) {
+ virtual void SetFontProvider(CXFA_PDFFontMgr* pProvider) {
m_pProvider = pProvider;
}
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
@@ -70,9 +72,9 @@ class CFX_GEFont : public IFX_Font {
CFX_WordDiscreteArray* m_pCharWidthMap;
CFX_RectMassArray* m_pRectArray;
CFX_MapPtrToPtr* m_pBBoxMap;
- IFX_FontProvider* m_pProvider;
+ CXFA_PDFFontMgr* m_pProvider;
uint16_t m_wCharSet;
- CFX_PtrArray m_SubstFonts;
+ CFX_ArrayTemplate<IFX_Font*> m_SubstFonts;
CFX_MapPtrToPtr m_FontMapper;
FX_BOOL InitFont();
FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
diff --git a/chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.cpp b/chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.cpp
index 2b403e8ee89..e840cb2bdd8 100644
--- a/chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.cpp
@@ -11,34 +11,24 @@
#include "xfa/fgas/font/fgas_fontutils.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-IFX_FontMgr* IFX_FontMgr::Create(FX_LPEnumAllFonts pEnumerator,
- FX_LPMatchFont pMatcher,
- void* pUserData) {
- return new CFX_StdFontMgrImp(pEnumerator, pMatcher, pUserData);
-}
-CFX_StdFontMgrImp::CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator,
- FX_LPMatchFont pMatcher,
- void* pUserData)
- : m_pMatcher(pMatcher),
- m_pEnumerator(pEnumerator),
+IFX_FontMgr* IFX_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) {
+ return new CFX_StdFontMgrImp(pEnumerator);
+}
+CFX_StdFontMgrImp::CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator)
+ : m_pEnumerator(pEnumerator),
m_FontFaces(),
- m_Fonts(),
m_CPFonts(8),
m_FamilyFonts(16),
m_UnicodeFonts(16),
m_BufferFonts(4),
m_FileFonts(4),
m_StreamFonts(4),
- m_DeriveFonts(4),
- m_pUserData(pUserData) {
+ m_DeriveFonts(4) {
if (m_pEnumerator != NULL) {
- m_pEnumerator(m_FontFaces, m_pUserData, NULL, 0xFEFF);
- }
- if (m_pMatcher == NULL) {
- m_pMatcher = FX_DefFontMatcher;
+ m_pEnumerator(m_FontFaces, NULL, 0xFEFF);
}
- FXSYS_assert(m_pMatcher != NULL);
}
+
CFX_StdFontMgrImp::~CFX_StdFontMgrImp() {
m_FontFaces.RemoveAll();
m_CPFonts.RemoveAll();
@@ -48,14 +38,10 @@ CFX_StdFontMgrImp::~CFX_StdFontMgrImp() {
m_FileFonts.RemoveAll();
m_StreamFonts.RemoveAll();
m_DeriveFonts.RemoveAll();
- for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--) {
- IFX_Font* pFont = (IFX_Font*)m_Fonts[i];
- if (pFont != NULL) {
- pFont->Release();
- }
- }
- m_Fonts.RemoveAll();
+ for (int32_t i = m_Fonts.GetUpperBound(); i >= 0; i--)
+ m_Fonts[i]->Release();
}
+
IFX_Font* CFX_StdFontMgrImp::GetDefFontByCodePage(
uint16_t wCodePage,
uint32_t dwFontStyles,
@@ -65,16 +51,16 @@ IFX_Font* CFX_StdFontMgrImp::GetDefFontByCodePage(
if (m_CPFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL;
}
- FX_LPCFONTDESCRIPTOR pFD;
+ FX_FONTDESCRIPTOR const* pFD;
if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) {
if ((pFD = FindFont(NULL, dwFontStyles, TRUE, wCodePage)) == NULL) {
if ((pFD = FindFont(NULL, dwFontStyles, FALSE, wCodePage)) == NULL)
return NULL;
}
}
- FXSYS_assert(pFD != NULL);
+ ASSERT(pFD != NULL);
pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
- if (pFont != NULL) {
+ if (pFont) {
m_Fonts.Add(pFont);
m_CPFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
dwHash = FGAS_GetFontFamilyHash(pFD->wsFontFace, dwFontStyles, wCodePage);
@@ -105,7 +91,7 @@ IFX_Font* CFX_StdFontMgrImp::GetDefFontByUnicode(
if (m_UnicodeFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont))
return pFont ? LoadFont(pFont, dwFontStyles, pRet->wCodePage) : nullptr;
- FX_LPCFONTDESCRIPTOR pFD =
+ FX_FONTDESCRIPTOR const* pFD =
FindFont(pszFontFamily, dwFontStyles, FALSE, pRet->wCodePage,
pRet->wBitField, wUnicode);
if (!pFD && pszFontFamily) {
@@ -146,19 +132,19 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
return pFont ? LoadFont(pFont, dwFontStyles, wCodePage) : NULL;
}
- FX_LPCFONTDESCRIPTOR pFD = NULL;
+ FX_FONTDESCRIPTOR const* pFD = NULL;
if ((pFD = FindFont(pszFontFamily, dwFontStyles, TRUE, wCodePage)) == NULL) {
if ((pFD = FindFont(pszFontFamily, dwFontStyles, FALSE, wCodePage)) ==
NULL) {
return NULL;
}
}
- FXSYS_assert(pFD != NULL);
+ ASSERT(pFD != NULL);
if (wCodePage == 0xFFFF) {
wCodePage = FX_GetCodePageFromCharset(pFD->uCharSet);
}
pFont = IFX_Font::LoadFont(pFD->wsFontFace, dwFontStyles, wCodePage, this);
- if (pFont != NULL) {
+ if (pFont) {
m_Fonts.Add(pFont);
m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
dwHash = FGAS_GetFontHashCode(wCodePage, dwFontStyles);
@@ -168,7 +154,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFontFamily,
return NULL;
}
IFX_Font* CFX_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) {
- FXSYS_assert(pBuffer != NULL && iLength > 0);
+ ASSERT(pBuffer != NULL && iLength > 0);
IFX_Font* pFont = NULL;
if (m_BufferFonts.Lookup((void*)pBuffer, (void*&)pFont)) {
if (pFont != NULL) {
@@ -176,7 +162,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) {
}
}
pFont = IFX_Font::LoadFont(pBuffer, iLength, this);
- if (pFont != NULL) {
+ if (pFont) {
m_Fonts.Add(pFont);
m_BufferFonts.SetAt((void*)pBuffer, pFont);
return pFont->Retain();
@@ -184,8 +170,8 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(const uint8_t* pBuffer, int32_t iLength) {
return NULL;
}
IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) {
- FXSYS_assert(pszFileName != NULL);
- uint32_t dwHash = FX_HashCode_String_GetW(pszFileName, -1);
+ ASSERT(pszFileName != NULL);
+ uint32_t dwHash = FX_HashCode_GetW(pszFileName, false);
IFX_Font* pFont = NULL;
if (m_FileFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
if (pFont != NULL) {
@@ -193,7 +179,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(const FX_WCHAR* pszFileName) {
}
}
pFont = IFX_Font::LoadFont(pszFileName, NULL);
- if (pFont != NULL) {
+ if (pFont) {
m_Fonts.Add(pFont);
m_FileFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
return pFont->Retain();
@@ -205,7 +191,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
uint32_t dwFontStyles,
uint16_t wCodePage,
FX_BOOL bSaveStream) {
- FXSYS_assert(pFontStream != NULL && pFontStream->GetLength() > 0);
+ ASSERT(pFontStream != NULL && pFontStream->GetLength() > 0);
IFX_Font* pFont = NULL;
if (m_StreamFonts.Lookup((void*)pFontStream, (void*&)pFont)) {
if (pFont != NULL) {
@@ -218,7 +204,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
}
}
pFont = IFX_Font::LoadFont(pFontStream, this, bSaveStream);
- if (pFont != NULL) {
+ if (pFont) {
m_Fonts.Add(pFont);
m_StreamFonts.SetAt((void*)pFontStream, (void*)pFont);
if (pszFontAlias != NULL) {
@@ -233,14 +219,14 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Stream* pFontStream,
IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont,
uint32_t dwFontStyles,
uint16_t wCodePage) {
- FXSYS_assert(pSrcFont != NULL);
+ ASSERT(pSrcFont != NULL);
if (pSrcFont->GetFontStyles() == dwFontStyles) {
return pSrcFont->Retain();
}
void* buffer[3] = {pSrcFont, (void*)(uintptr_t)dwFontStyles,
(void*)(uintptr_t)wCodePage};
- uint32_t dwHash =
- FX_HashCode_String_GetA((const FX_CHAR*)buffer, 3 * sizeof(void*));
+ uint32_t dwHash = FX_HashCode_GetA(
+ CFX_ByteStringC((uint8_t*)buffer, sizeof(buffer)), false);
IFX_Font* pFont = NULL;
if (m_DeriveFonts.GetCount() > 0) {
m_DeriveFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont);
@@ -249,7 +235,7 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont,
}
}
pFont = pSrcFont->Derive(dwFontStyles, wCodePage);
- if (pFont != NULL) {
+ if (pFont) {
m_DeriveFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
int32_t index = m_Fonts.Find(pFont);
if (index < 0) {
@@ -260,15 +246,12 @@ IFX_Font* CFX_StdFontMgrImp::LoadFont(IFX_Font* pSrcFont,
}
return NULL;
}
+
void CFX_StdFontMgrImp::ClearFontCache() {
- int32_t iCount = m_Fonts.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- IFX_Font* pFont = (IFX_Font*)m_Fonts[i];
- if (pFont != NULL) {
- pFont->Reset();
- }
- }
+ for (int32_t i = 0; i < m_Fonts.GetSize(); i++)
+ m_Fonts[i]->Reset();
}
+
void CFX_StdFontMgrImp::RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont) {
FX_POSITION pos = fontMap.GetStartPosition();
void* pKey;
@@ -296,15 +279,13 @@ void CFX_StdFontMgrImp::RemoveFont(IFX_Font* pFont) {
m_Fonts.RemoveAt(iFind, 1);
}
}
-FX_LPCFONTDESCRIPTOR CFX_StdFontMgrImp::FindFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint32_t dwMatchFlags,
- uint16_t wCodePage,
- uint32_t dwUSB,
- FX_WCHAR wUnicode) {
- if (m_pMatcher == NULL) {
- return NULL;
- }
+FX_FONTDESCRIPTOR const* CFX_StdFontMgrImp::FindFont(
+ const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint32_t dwMatchFlags,
+ uint16_t wCodePage,
+ uint32_t dwUSB,
+ FX_WCHAR wUnicode) {
FX_FONTMATCHPARAMS params;
FXSYS_memset(&params, 0, sizeof(params));
params.dwUSB = dwUSB;
@@ -313,20 +294,20 @@ FX_LPCFONTDESCRIPTOR CFX_StdFontMgrImp::FindFont(const FX_WCHAR* pszFontFamily,
params.pwsFamily = pszFontFamily;
params.dwFontStyles = dwFontStyles;
params.dwMatchFlags = dwMatchFlags;
- FX_LPCFONTDESCRIPTOR pDesc = m_pMatcher(&params, m_FontFaces, m_pUserData);
+ FX_FONTDESCRIPTOR const* pDesc = FX_DefFontMatcher(&params, m_FontFaces);
if (pDesc) {
return pDesc;
}
if (pszFontFamily && m_pEnumerator) {
CFX_FontDescriptors namedFonts;
- m_pEnumerator(namedFonts, m_pUserData, pszFontFamily, wUnicode);
+ m_pEnumerator(namedFonts, pszFontFamily, wUnicode);
params.pwsFamily = NULL;
- pDesc = m_pMatcher(&params, namedFonts, m_pUserData);
+ pDesc = FX_DefFontMatcher(&params, namedFonts);
if (pDesc == NULL) {
return NULL;
}
for (int32_t i = m_FontFaces.GetSize() - 1; i >= 0; i--) {
- FX_LPCFONTDESCRIPTOR pMatch = m_FontFaces.GetPtrAt(i);
+ FX_FONTDESCRIPTOR const* pMatch = m_FontFaces.GetPtrAt(i);
if (*pMatch == *pDesc) {
return pMatch;
}
@@ -336,16 +317,15 @@ FX_LPCFONTDESCRIPTOR CFX_StdFontMgrImp::FindFont(const FX_WCHAR* pszFontFamily,
}
return NULL;
}
-FX_LPCFONTDESCRIPTOR FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
- const CFX_FontDescriptors& fonts,
- void* pUserData) {
- FX_LPCFONTDESCRIPTOR pBestFont = NULL;
+FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
+ const CFX_FontDescriptors& fonts) {
+ FX_FONTDESCRIPTOR const* pBestFont = NULL;
int32_t iBestSimilar = 0;
FX_BOOL bMatchStyle =
(pParams->dwMatchFlags & FX_FONTMATCHPARA_MacthStyle) > 0;
int32_t iCount = fonts.GetSize();
for (int32_t i = 0; i < iCount; ++i) {
- FX_LPCFONTDESCRIPTOR pFont = fonts.GetPtrAt(i);
+ FX_FONTDESCRIPTOR const* pFont = fonts.GetPtrAt(i);
if ((pFont->dwFontStyles & FX_FONTSTYLE_BoldItalic) ==
FX_FONTSTYLE_BoldItalic) {
continue;
@@ -394,7 +374,8 @@ FX_LPCFONTDESCRIPTOR FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
}
return iBestSimilar < 1 ? NULL : pBestFont;
}
-int32_t FX_GetSimilarValue(FX_LPCFONTDESCRIPTOR pFont, uint32_t dwFontStyles) {
+int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont,
+ uint32_t dwFontStyles) {
int32_t iValue = 0;
if ((dwFontStyles & FX_FONTSTYLE_Symbolic) ==
(pFont->dwFontStyles & FX_FONTSTYLE_Symbolic)) {
@@ -445,7 +426,7 @@ static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe,
if (lf.lfFaceName[0] == L'@') {
return 1;
}
- FX_LPFONTDESCRIPTOR pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1);
+ FX_FONTDESCRIPTOR* pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1);
FXSYS_memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR));
pFont->uCharSet = lf.lfCharSet;
pFont->dwFontStyles = FX_GetGdiFontStyles(lf);
@@ -458,7 +439,6 @@ static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe,
return 1;
}
static void FX_EnumGdiFonts(CFX_FontDescriptors& fonts,
- void* pUserData,
const FX_WCHAR* pwsFaceName,
FX_WCHAR wUnicode) {
HDC hDC = ::GetDC(NULL);
@@ -503,7 +483,8 @@ Restart:
if (m_FolderPaths.GetSize() < 1) {
return "";
}
- pCurHandle = FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1]);
+ pCurHandle =
+ FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str());
FX_HandleParentPath hpp;
hpp.pFileHandle = pCurHandle;
hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1];
@@ -537,7 +518,7 @@ Restart:
hpp.bsParentPath =
m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath +
bsFolderSpearator + bsName;
- hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath);
+ hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str());
if (hpp.pFileHandle == NULL) {
continue;
}
@@ -552,59 +533,52 @@ Restart:
}
return bsName;
}
-FX_POSITION CFX_FontSourceEnum_File::GetStartPosition(void* pUserData) {
+FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() {
m_wsNext = GetNextFile().UTF8Decode();
if (0 == m_wsNext.GetLength()) {
return (FX_POSITION)0;
}
return (FX_POSITION)-1;
}
-IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos,
- void* pUserData) {
- IFX_FileAccess* pAccess =
- FX_CreateDefaultFileAccess(m_wsNext.AsWideStringC());
+
+IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) {
+ IFX_FileAccess* pAccess = FX_CreateDefaultFileAccess(m_wsNext.AsStringC());
m_wsNext = GetNextFile().UTF8Decode();
pos = 0 != m_wsNext.GetLength() ? pAccess : NULL;
return (IFX_FileAccess*)pAccess;
}
-IFX_FontSourceEnum* FX_CreateDefaultFontSourceEnum() {
- return (IFX_FontSourceEnum*)new CFX_FontSourceEnum_File;
-}
-IFX_FontMgr* IFX_FontMgr::Create(IFX_FontSourceEnum* pFontEnum,
- IFX_FontMgrDelegate* pDelegate,
- void* pUserData) {
- if (NULL == pFontEnum) {
- return NULL;
- }
- CFX_FontMgrImp* pFontMgr =
- new CFX_FontMgrImp(pFontEnum, pDelegate, pUserData);
- if (pFontMgr->EnumFonts()) {
+
+IFX_FontMgr* IFX_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) {
+ if (!pFontEnum)
+ return nullptr;
+
+ CFX_FontMgrImp* pFontMgr = new CFX_FontMgrImp(pFontEnum);
+ if (pFontMgr->EnumFonts())
return pFontMgr;
- }
+
delete pFontMgr;
- return NULL;
+ return nullptr;
}
-CFX_FontMgrImp::CFX_FontMgrImp(IFX_FontSourceEnum* pFontEnum,
- IFX_FontMgrDelegate* pDelegate,
- void* pUserData)
- : m_pFontSource(pFontEnum),
- m_pDelegate(pDelegate),
- m_pUserData(pUserData) {}
+CFX_FontMgrImp::CFX_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum)
+ : m_pFontSource(pFontEnum) {}
FX_BOOL CFX_FontMgrImp::EnumFontsFromFontMapper() {
CFX_FontMapper* pFontMapper =
CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper();
if (!pFontMapper)
return FALSE;
+
IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo();
if (!pSystemFontInfo)
return FALSE;
+
pSystemFontInfo->EnumFontList(pFontMapper);
for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) {
IFX_FileRead* pFontStream =
CreateFontStream(pFontMapper, pSystemFontInfo, i);
if (!pFontStream)
continue;
+
CFX_WideString wsFaceName =
CFX_WideString::FromLocal(pFontMapper->GetFaceName(i).c_str());
RegisterFaces(pFontStream, &wsFaceName);
@@ -612,8 +586,10 @@ FX_BOOL CFX_FontMgrImp::EnumFontsFromFontMapper() {
}
if (m_InstalledFonts.GetSize() == 0)
return FALSE;
+
return TRUE;
}
+
FX_BOOL CFX_FontMgrImp::EnumFontsFromFiles() {
CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary();
FX_POSITION pos = m_pFontSource->GetStartPosition();
@@ -648,18 +624,14 @@ void CFX_FontMgrImp::Release() {
uint32_t dwHash;
CFX_FontDescriptorInfos* pDescs;
m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs);
- if (NULL != pDescs) {
- delete pDescs;
- }
+ delete pDescs;
}
pos = m_Hash2Fonts.GetStartPosition();
while (pos) {
uint32_t dwHash;
CFX_ArrayTemplate<IFX_Font*>* pFonts;
m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts);
- if (NULL != pFonts) {
- delete pFonts;
- }
+ delete pFonts;
}
m_Hash2Fonts.RemoveAll();
pos = m_Hash2FileAccess.GetStartPosition();
@@ -692,69 +664,62 @@ void CFX_FontMgrImp::Release() {
IFX_Font* CFX_FontMgrImp::GetDefFontByCodePage(uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
- return NULL == m_pDelegate ? NULL : m_pDelegate->GetDefFontByCodePage(
- this, wCodePage, dwFontStyles,
- pszFontFamily);
+ return nullptr;
}
IFX_Font* CFX_FontMgrImp::GetDefFontByCharset(uint8_t nCharset,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
- return NULL == m_pDelegate ? NULL
- : m_pDelegate->GetDefFontByCharset(
- this, nCharset, dwFontStyles, pszFontFamily);
+ return nullptr;
}
IFX_Font* CFX_FontMgrImp::GetDefFontByUnicode(FX_WCHAR wUnicode,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
- return NULL == m_pDelegate ? NULL
- : m_pDelegate->GetDefFontByUnicode(
- this, wUnicode, dwFontStyles, pszFontFamily);
+ return nullptr;
}
IFX_Font* CFX_FontMgrImp::GetDefFontByLanguage(uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
- return NULL == m_pDelegate ? NULL : m_pDelegate->GetDefFontByLanguage(
- this, wLanguage, dwFontStyles,
- pszFontFamily);
+ return nullptr;
}
+
IFX_Font* CFX_FontMgrImp::GetFontByCodePage(uint16_t wCodePage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
CFX_ByteString bsHash;
bsHash.Format("%d, %d", wCodePage, dwFontStyles);
bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
- uint32_t dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength());
- CFX_ArrayTemplate<IFX_Font*>* pFonts = NULL;
- IFX_Font* pFont = NULL;
+ uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
+ CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr;
if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
- if (NULL == pFonts) {
- return NULL;
- }
- if (0 != pFonts->GetSize()) {
+ if (!pFonts)
+ return nullptr;
+
+ if (pFonts->GetSize() != 0)
return pFonts->GetAt(0)->Retain();
- }
}
+
if (!pFonts)
pFonts = new CFX_ArrayTemplate<IFX_Font*>;
+
m_Hash2Fonts.SetAt(dwHash, pFonts);
- CFX_FontDescriptorInfos* sortedFonts = NULL;
+ CFX_FontDescriptorInfos* sortedFonts = nullptr;
if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) {
sortedFonts = new CFX_FontDescriptorInfos;
MatchFonts(*sortedFonts, wCodePage, dwFontStyles,
CFX_WideString(pszFontFamily), 0);
m_Hash2CandidateList.SetAt(dwHash, sortedFonts);
}
- if (sortedFonts->GetSize() == 0) {
- return NULL;
- }
+ if (sortedFonts->GetSize() == 0)
+ return nullptr;
+
CFX_FontDescriptor* pDesc = sortedFonts->GetAt(0).pFont;
- if (pDesc->m_pFileAccess)
- pFont = LoadFont(pDesc->m_pFileAccess, pDesc->m_nFaceIndex, nullptr);
- else
- pFont = LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr);
- if (NULL != pFont) {
+ IFX_Font* pFont =
+ pDesc->m_pFileAccess
+ ? LoadFont(pDesc->m_pFileAccess, pDesc->m_nFaceIndex, nullptr)
+ : LoadFont(pDesc->m_wsFaceName, pDesc->m_nFaceIndex, nullptr);
+ if (pFont)
pFont->SetLogicalFontStyle(dwFontStyles);
- }
+
pFonts->Add(pFont);
return pFont;
}
@@ -779,7 +744,7 @@ IFX_Font* CFX_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode,
else
bsHash.Format("%d, %d", wCodePage, dwFontStyles);
bsHash += CFX_WideString(pszFontFamily).UTF8Encode();
- uint32_t dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength());
+ uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
CFX_ArrayTemplate<IFX_Font*>* pFonts = nullptr;
if (m_Hash2Fonts.Lookup(dwHash, pFonts)) {
if (!pFonts)
@@ -837,123 +802,121 @@ FX_BOOL CFX_FontMgrImp::VerifyUnicode(CFX_FontDescriptor* pDesc,
FXFT_Done_Face(pFace);
return !retCharmap && retIndex;
}
+
FX_BOOL CFX_FontMgrImp::VerifyUnicode(IFX_Font* pFont, FX_WCHAR wcUnicode) {
- if (NULL == pFont) {
+ if (!pFont)
return FALSE;
- }
+
FXFT_Face pFace = ((CFX_Font*)pFont->GetDevFont())->GetFace();
FXFT_CharMap charmap = FXFT_Get_Face_Charmap(pFace);
- if (0 != FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE)) {
+ if (FXFT_Select_Charmap(pFace, FXFT_ENCODING_UNICODE) != 0)
return FALSE;
- }
- if (0 == FXFT_Get_Char_Index(pFace, wcUnicode)) {
+
+ if (FXFT_Get_Char_Index(pFace, wcUnicode) == 0) {
FXFT_Set_Charmap(pFace, charmap);
return FALSE;
}
return TRUE;
}
+
IFX_Font* CFX_FontMgrImp::GetFontByLanguage(uint16_t wLanguage,
uint32_t dwFontStyles,
const FX_WCHAR* pszFontFamily) {
return GetFontByCodePage(FX_GetDefCodePageByLanguage(wLanguage), dwFontStyles,
pszFontFamily);
}
+
IFX_Font* CFX_FontMgrImp::LoadFont(const uint8_t* pBuffer,
int32_t iLength,
int32_t iFaceIndex,
int32_t* pFaceCount) {
void* Hash[2] = {(void*)(uintptr_t)pBuffer, (void*)(uintptr_t)iLength};
uint32_t dwHash =
- FX_HashCode_String_GetA((const FX_CHAR*)Hash, 2 * sizeof(void*));
- IFX_FileAccess* pFontAccess = NULL;
- if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) {
- }
- if (NULL != pFontAccess) {
- return LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE);
- } else {
- return NULL;
- }
+ FX_HashCode_GetA(CFX_ByteStringC((uint8_t*)Hash, sizeof(Hash)), false);
+ IFX_FileAccess* pFontAccess = nullptr;
+ m_Hash2FileAccess.Lookup(dwHash, pFontAccess);
+ return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE)
+ : nullptr;
}
+
IFX_Font* CFX_FontMgrImp::LoadFont(const FX_WCHAR* pszFileName,
int32_t iFaceIndex,
int32_t* pFaceCount) {
CFX_ByteString bsHash;
bsHash += CFX_WideString(pszFileName).UTF8Encode();
- uint32_t dwHash =
- FX_HashCode_String_GetA((const FX_CHAR*)bsHash, bsHash.GetLength());
- IFX_FileAccess* pFontAccess = NULL;
+
+ uint32_t dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
+ IFX_FileAccess* pFontAccess = nullptr;
if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) {
pFontAccess = FX_CreateDefaultFileAccess(pszFileName);
m_Hash2FileAccess.SetAt(dwHash, pFontAccess);
}
- if (NULL != pFontAccess) {
- return LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE);
- } else {
- return NULL;
- }
+
+ return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE)
+ : nullptr;
}
+
IFX_Font* CFX_FontMgrImp::LoadFont(IFX_Stream* pFontStream,
int32_t iFaceIndex,
int32_t* pFaceCount,
FX_BOOL bSaveStream) {
void* Hash[1] = {(void*)(uintptr_t)pFontStream};
uint32_t dwHash =
- FX_HashCode_String_GetA((const FX_CHAR*)Hash, 1 * sizeof(void*));
- IFX_FileAccess* pFontAccess = NULL;
- if (!m_Hash2FileAccess.Lookup(dwHash, pFontAccess)) {
- }
- if (NULL != pFontAccess) {
- return LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE);
- } else {
- return NULL;
- }
+ FX_HashCode_GetA(CFX_ByteStringC((uint8_t*)Hash, sizeof(Hash)), false);
+ IFX_FileAccess* pFontAccess = nullptr;
+ m_Hash2FileAccess.Lookup(dwHash, pFontAccess);
+
+ return pFontAccess ? LoadFont(pFontAccess, iFaceIndex, pFaceCount, TRUE)
+ : nullptr;
}
+
IFX_Font* CFX_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess,
int32_t iFaceIndex,
int32_t* pFaceCount,
FX_BOOL bWantCache) {
uint32_t dwHash = 0;
- IFX_Font* pFont = NULL;
+ IFX_Font* pFont = nullptr;
if (bWantCache) {
CFX_ByteString bsHash;
bsHash.Format("%d, %d", (uintptr_t)pFontAccess, iFaceIndex);
- dwHash = FX_HashCode_String_GetA(bsHash, bsHash.GetLength());
+ dwHash = FX_HashCode_GetA(bsHash.AsStringC(), false);
if (m_FileAccess2IFXFont.Lookup(dwHash, pFont)) {
- if (NULL != pFont) {
- if (NULL != pFaceCount) {
+ if (pFont) {
+ if (pFaceCount)
*pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces;
- }
return pFont->Retain();
}
}
}
+
CFX_Font* pInternalFont = new CFX_Font;
IFX_FileRead* pFontStream =
pFontAccess->CreateFileStream(FX_FILEMODE_ReadOnly);
- if (NULL == pFontStream) {
+ if (!pFontStream) {
delete pInternalFont;
- return NULL;
+ return nullptr;
}
if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) {
delete pInternalFont;
pFontStream->Release();
- return NULL;
+ return nullptr;
}
pFont = IFX_Font::LoadFont(pInternalFont, this, TRUE);
- if (NULL == pFont) {
+ if (!pFont) {
delete pInternalFont;
pFontStream->Release();
- return NULL;
+ return nullptr;
}
- if (bWantCache) {
+ if (bWantCache)
m_FileAccess2IFXFont.SetAt(dwHash, pFont);
- }
+
m_IFXFont2FileRead.SetAt(pFont, pFontStream);
- if (NULL != pFaceCount) {
+ if (pFaceCount)
*pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces;
- }
+
return pFont;
}
+
IFX_Font* CFX_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName,
int32_t iFaceIndex,
int32_t* pFaceCount) {
@@ -961,48 +924,58 @@ IFX_Font* CFX_FontMgrImp::LoadFont(const CFX_WideString& wsFaceName,
CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
if (!pFontMapper)
return nullptr;
+
IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo();
if (!pSystemFontInfo)
return nullptr;
+
IFX_FileRead* pFontStream = CreateFontStream(wsFaceName.UTF8Encode());
if (!pFontStream)
return nullptr;
+
if (!LoadFace(pFontStream, 0)) {
pFontStream->Release();
return nullptr;
}
+
CFX_Font* pInternalFont = new CFX_Font();
if (!pInternalFont->LoadFile(pFontStream, iFaceIndex)) {
pFontStream->Release();
return nullptr;
}
+
IFX_Font* pFont = IFX_Font::LoadFont(pInternalFont, this, FALSE);
if (!pFont) {
pFontStream->Release();
return nullptr;
}
+
m_IFXFont2FileRead.SetAt(pFont, pFontStream);
if (pFaceCount)
*pFaceCount = ((CFX_Font*)pFont->GetDevFont())->GetFace()->num_faces;
+
return pFont;
}
+
extern "C" {
+
unsigned long _ftStreamRead(FXFT_Stream stream,
unsigned long offset,
unsigned char* buffer,
unsigned long count) {
- if (count == 0) {
+ if (count == 0)
return 0;
- }
+
IFX_FileRead* pFile = (IFX_FileRead*)stream->descriptor.pointer;
int res = pFile->ReadBlock(buffer, offset, count);
- if (res) {
+ if (res)
return count;
- }
return 0;
}
+
void _ftStreamClose(FXFT_Stream stream) {}
-};
+
+}; // extern "C"
FXFT_Face CFX_FontMgrImp::LoadFace(IFX_FileRead* pFontStream,
int32_t iFaceIndex) {
@@ -1017,7 +990,7 @@ FXFT_Face CFX_FontMgrImp::LoadFace(IFX_FileRead* pFontStream,
FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1);
FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec));
- ftStream->base = NULL;
+ ftStream->base = nullptr;
ftStream->descriptor.pointer = pFontStream;
ftStream->pos = 0;
ftStream->size = (unsigned long)pFontStream->GetSize();
@@ -1029,7 +1002,7 @@ FXFT_Face CFX_FontMgrImp::LoadFace(IFX_FileRead* pFontStream,
ftArgs.flags |= FT_OPEN_STREAM;
ftArgs.stream = ftStream;
- FXFT_Face pFace = NULL;
+ FXFT_Face pFace = nullptr;
if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) {
FX_Free(ftStream);
return nullptr;
@@ -1044,15 +1017,19 @@ IFX_FileRead* CFX_FontMgrImp::CreateFontStream(
IFX_SystemFontInfo* pSystemFontInfo,
uint32_t index) {
int iExact = 0;
- void* hFont = pSystemFontInfo->MapFont(
- 0, 0, FXFONT_DEFAULT_CHARSET, 0, pFontMapper->GetFaceName(index), iExact);
+ void* hFont =
+ pSystemFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0,
+ pFontMapper->GetFaceName(index).c_str(), iExact);
if (!hFont)
return nullptr;
+
uint32_t dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, nullptr, 0);
if (dwFileSize == 0)
return nullptr;
+
uint8_t* pBuffer = FX_Alloc(uint8_t, dwFileSize + 1);
dwFileSize = pSystemFontInfo->GetFontData(hFont, 0, pBuffer, dwFileSize);
+
return FX_CreateMemoryStream(pBuffer, dwFileSize, TRUE);
}
@@ -1060,11 +1037,14 @@ IFX_FileRead* CFX_FontMgrImp::CreateFontStream(
const CFX_ByteString& bsFaceName) {
CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
CFX_FontMapper* pFontMapper = pFontMgr->GetBuiltinMapper();
+
if (!pFontMapper)
return nullptr;
+
IFX_SystemFontInfo* pSystemFontInfo = pFontMapper->GetSystemFontInfo();
if (!pSystemFontInfo)
return nullptr;
+
pSystemFontInfo->EnumFontList(pFontMapper);
for (int32_t i = 0; i < pFontMapper->GetFaceSize(); ++i) {
if (pFontMapper->GetFaceName(i) == bsFaceName)
@@ -1079,31 +1059,31 @@ int32_t CFX_FontMgrImp::MatchFonts(CFX_FontDescriptorInfos& MatchedFonts,
FX_WCHAR wcUnicode) {
MatchedFonts.RemoveAll();
CFX_WideString wsNormalizedFontName = FontName;
- static const int32_t nMax = 0xffff;
- CFX_FontDescriptor* pFont = NULL;
+
+ CFX_FontDescriptor* pFont = nullptr;
int32_t nCount = m_InstalledFonts.GetSize();
for (int32_t i = 0; i < nCount; i++) {
pFont = m_InstalledFonts[i];
int32_t nPenalty = CalcPenalty(pFont, wCodePage, dwFontStyles,
wsNormalizedFontName, wcUnicode);
- if (nPenalty >= 0xFFFF) {
+ if (nPenalty >= 0xffff)
continue;
- }
+
FX_FontDescriptorInfo FontInfo;
FontInfo.pFont = pFont;
FontInfo.nPenalty = nPenalty;
MatchedFonts.Add(FontInfo);
- if (MatchedFonts.GetSize() == nMax) {
+ if (MatchedFonts.GetSize() == 0xffff)
break;
- }
}
- if (MatchedFonts.GetSize() == 0) {
+ if (MatchedFonts.GetSize() == 0)
return 0;
- }
+
CFX_SSortTemplate<FX_FontDescriptorInfo> ssort;
ssort.ShellSort(MatchedFonts.GetData(), MatchedFonts.GetSize());
return MatchedFonts.GetSize();
}
+
struct FX_BitCodePage {
uint16_t wBit;
uint16_t wCodePage;
@@ -1197,7 +1177,7 @@ int32_t CFX_FontMgrImp::CalcPenalty(CFX_FontDescriptor* pInstalled,
((0 == wCodePage || 0xFFFF == wCodePage) ? (uint16_t)-1
: FX_GetCodePageBit(wCodePage));
if (wBit != (uint16_t)-1) {
- FXSYS_assert(wBit < 64);
+ ASSERT(wBit < 64);
if (0 == (pInstalled->m_dwCsb[wBit / 32] & (1 << (wBit % 32)))) {
nPenalty += 0xFFFF;
} else {
@@ -1208,7 +1188,7 @@ int32_t CFX_FontMgrImp::CalcPenalty(CFX_FontDescriptor* pInstalled,
((0 == wcUnicode || 0xFFFE == wcUnicode) ? (uint16_t)999
: FX_GetUnicodeBit(wcUnicode));
if (wBit != (uint16_t)999) {
- FXSYS_assert(wBit < 128);
+ ASSERT(wBit < 128);
if (0 == (pInstalled->m_dwUsb[wBit / 32] & (1 << (wBit % 32)))) {
nPenalty += 0xFFFF;
} else {
@@ -1223,9 +1203,7 @@ void CFX_FontMgrImp::ClearFontCache() {
uint32_t dwHash;
CFX_FontDescriptorInfos* pDescs;
m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs);
- if (NULL != pDescs) {
- delete pDescs;
- }
+ delete pDescs;
}
pos = m_FileAccess2IFXFont.GetStartPosition();
while (pos) {
@@ -1280,51 +1258,51 @@ void CFX_FontMgrImp::RemoveFont(IFX_Font* pEFont) {
}
}
}
+
void CFX_FontMgrImp::RegisterFace(FXFT_Face pFace,
CFX_FontDescriptors& Fonts,
const CFX_WideString* pFaceName,
IFX_FileAccess* pFontAccess) {
- if (0 == (pFace->face_flags & FT_FACE_FLAG_SCALABLE)) {
+ if ((pFace->face_flags & FT_FACE_FLAG_SCALABLE) == 0)
return;
- }
+
CFX_FontDescriptor* pFont = new CFX_FontDescriptor;
pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FX_FONTSTYLE_Bold : 0;
pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FX_FONTSTYLE_Italic : 0;
pFont->m_dwFontStyles |= GetFlags(pFace);
+
CFX_ArrayTemplate<uint16_t> Charsets;
GetCharsets(pFace, Charsets);
GetUSBCSB(pFace, pFont->m_dwUsb, pFont->m_dwCsb);
- unsigned long nLength = 0;
+
FT_ULong dwTag;
- uint8_t* pTable = NULL;
+ uint8_t* pTable = nullptr;
FT_ENC_TAG(dwTag, 'n', 'a', 'm', 'e');
- unsigned int error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, NULL, &nLength);
- if (0 == error && 0 != nLength) {
+
+ unsigned long nLength = 0;
+ unsigned int error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, nullptr, &nLength);
+ if (error == 0 && nLength != 0) {
pTable = FX_Alloc(uint8_t, nLength);
- error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, pTable, NULL);
+ error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, pTable, nullptr);
if (0 != error) {
FX_Free(pTable);
- pTable = NULL;
+ pTable = nullptr;
}
}
GetNames(pTable, pFont->m_wsFamilyNames);
- if (NULL != pTable) {
+ if (pTable)
FX_Free(pTable);
- }
+
pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode());
- if (pFaceName) {
- pFont->m_wsFaceName = *pFaceName;
- } else {
- pFont->m_wsFaceName =
- CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace));
- }
+ pFont->m_wsFaceName =
+ pFaceName ? *pFaceName
+ : CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace));
pFont->m_nFaceIndex = pFace->face_index;
- if (pFontAccess)
- pFont->m_pFileAccess = pFontAccess->Retain();
- else
- pFont->m_pFileAccess = nullptr;
+ pFont->m_pFileAccess = pFontAccess ? pFontAccess->Retain() : nullptr;
+
Fonts.Add(pFont);
}
+
void CFX_FontMgrImp::RegisterFaces(IFX_FileRead* pFontStream,
const CFX_WideString* pFaceName) {
int32_t index = 0;
@@ -1334,7 +1312,7 @@ void CFX_FontMgrImp::RegisterFaces(IFX_FileRead* pFontStream,
if (!pFace)
continue;
// All faces keep number of faces. It can be retrieved from any one face.
- if (!num_faces)
+ if (num_faces == 0)
num_faces = pFace->num_faces;
RegisterFace(pFace, m_InstalledFonts, pFaceName, nullptr);
if (FXFT_Get_Face_External_Stream(pFace))
@@ -1385,7 +1363,7 @@ void CFX_FontMgrImp::GetNames(const uint8_t* name_table,
uint16_t nPlatformID = GetUInt16(lpNameRecord + j * 12 + 0);
uint16_t nNameLength = GetUInt16(lpNameRecord + j * 12 + 8);
uint16_t nNameOffset = GetUInt16(lpNameRecord + j * 12 + 10);
- wsFamily.Empty();
+ wsFamily.clear();
if (nPlatformID != 1) {
for (uint16_t k = 0; k < nNameLength / 2; k++) {
FX_WCHAR wcTemp = GetUInt16(lpStr + nNameOffset + k * 2);
@@ -1509,7 +1487,7 @@ void CFX_FontMgrImp::GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB) {
}
int32_t CFX_FontMgrImp::IsPartName(const CFX_WideString& Name1,
const CFX_WideString& Name2) {
- if (Name1.Find((const FX_WCHAR*)Name2) != -1) {
+ if (Name1.Find(Name2.c_str()) != -1) {
return 1;
}
return 0;
diff --git a/chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.h b/chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.h
index 433f2df2761..e66dd3131a0 100644
--- a/chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.h
+++ b/chromium/third_party/pdfium/xfa/fgas/font/fgas_stdfontmgr.h
@@ -8,22 +8,20 @@
#define XFA_FGAS_FONT_FGAS_STDFONTMGR_H_
#include "core/fxcrt/include/fx_ext.h"
-#include "core/include/fxge/fx_freetype.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_freetype.h"
+#include "core/fxge/include/fx_ge.h"
#include "third_party/freetype/include/freetype/fttypes.h"
#include "xfa/fgas/font/fgas_font.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-int32_t FX_GetSimilarValue(FX_LPCFONTDESCRIPTOR pFont, uint32_t dwFontStyles);
-FX_LPCFONTDESCRIPTOR FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
- const CFX_FontDescriptors& fonts,
- void* pUserData);
+int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont,
+ uint32_t dwFontStyles);
+FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams,
+ const CFX_FontDescriptors& fonts);
class CFX_StdFontMgrImp : public IFX_FontMgr {
public:
- CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator,
- FX_LPMatchFont pMatcher,
- void* pUserData);
+ CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator);
~CFX_StdFontMgrImp();
virtual void Release() { delete this; }
virtual IFX_Font* GetDefFontByCodePage(uint16_t wCodePage,
@@ -55,10 +53,18 @@ class CFX_StdFontMgrImp : public IFX_FontMgr {
virtual void RemoveFont(IFX_Font* pFont);
protected:
- FX_LPMatchFont m_pMatcher;
+ void RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont);
+ FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily,
+ uint32_t dwFontStyles,
+ uint32_t dwMatchFlags,
+ uint16_t wCodePage,
+ uint32_t dwUSB = 999,
+ FX_WCHAR wUnicode = 0);
+ IFX_Font* GetFont(FX_FONTDESCRIPTOR const* pFD, uint32_t dwFontStyles);
+
FX_LPEnumAllFonts m_pEnumerator;
CFX_FontDescriptors m_FontFaces;
- CFX_PtrArray m_Fonts;
+ CFX_ArrayTemplate<IFX_Font*> m_Fonts;
CFX_MapPtrToPtr m_CPFonts;
CFX_MapPtrToPtr m_FamilyFonts;
CFX_MapPtrToPtr m_UnicodeFonts;
@@ -66,15 +72,6 @@ class CFX_StdFontMgrImp : public IFX_FontMgr {
CFX_MapPtrToPtr m_FileFonts;
CFX_MapPtrToPtr m_StreamFonts;
CFX_MapPtrToPtr m_DeriveFonts;
- void* m_pUserData;
- void RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont);
- FX_LPCFONTDESCRIPTOR FindFont(const FX_WCHAR* pszFontFamily,
- uint32_t dwFontStyles,
- uint32_t dwMatchFlags,
- uint16_t wCodePage,
- uint32_t dwUSB = 999,
- FX_WCHAR wUnicode = 0);
- IFX_Font* GetFont(FX_LPCFONTDESCRIPTOR pFD, uint32_t dwFontStyles);
};
uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf);
@@ -129,19 +126,22 @@ struct FX_HandleParentPath {
CFX_ByteString bsParentPath;
};
-class CFX_FontSourceEnum_File : public IFX_FontSourceEnum {
+class CFX_FontSourceEnum_File {
public:
CFX_FontSourceEnum_File();
- virtual void Release() { delete this; }
- virtual FX_POSITION GetStartPosition(void* pUserData = NULL);
- virtual IFX_FileAccess* GetNext(FX_POSITION& pos, void* pUserData = NULL);
+
+ void Release() { delete this; }
+ FX_POSITION GetStartPosition();
+ IFX_FileAccess* GetNext(FX_POSITION& pos);
private:
CFX_ByteString GetNextFile();
+
CFX_WideString m_wsNext;
CFX_ObjectArray<FX_HandleParentPath> m_FolderQueue;
CFX_ByteStringArray m_FolderPaths;
};
+
typedef CFX_MapPtrTemplate<uint32_t, IFX_FileAccess*> CFX_HashFileMap;
typedef CFX_MapPtrTemplate<uint32_t, IFX_Font*> CFX_HashFontMap;
typedef CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*>
@@ -155,9 +155,8 @@ typedef CFX_MapPtrTemplate<IFX_Font*, IFX_FileRead*> CFX_FonStreamtMap;
class CFX_FontMgrImp : public IFX_FontMgr {
public:
- CFX_FontMgrImp(IFX_FontSourceEnum* pFontEnum,
- IFX_FontMgrDelegate* pDelegate = NULL,
- void* pUserData = NULL);
+ CFX_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum);
+
virtual void Release();
virtual IFX_Font* GetDefFontByCodePage(uint16_t wCodePage,
uint32_t dwFontStyles,
@@ -237,15 +236,14 @@ class CFX_FontMgrImp : public IFX_FontMgr {
IFX_SystemFontInfo* pSystemFontInfo,
uint32_t index);
IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName);
+
CFX_HashFontDescsMap m_Hash2CandidateList;
CFX_HashFontsMap m_Hash2Fonts;
CFX_HashFileMap m_Hash2FileAccess;
CFX_HashFontMap m_FileAccess2IFXFont;
CFX_FonStreamtMap m_IFXFont2FileRead;
CFX_UnicodeFontMap m_FailedUnicodes2NULL;
- IFX_FontSourceEnum* m_pFontSource;
- IFX_FontMgrDelegate* m_pDelegate;
- void* m_pUserData;
+ CFX_FontSourceEnum_File* m_pFontSource;
};
#endif
diff --git a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.cpp b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.cpp
index 38a2d212af7..aaef7aec615 100644
--- a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -8,182 +8,13 @@
#include <algorithm>
+#include "core/fxcrt/include/fx_arabic.h"
#include "core/fxcrt/include/fx_arb.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-namespace {
-
-class CFX_RTFLine {
- public:
- CFX_RTFLine()
- : m_LinePieces(16),
- m_iStart(0),
- m_iWidth(0),
- m_iArabicChars(0),
- m_iMBCSChars(0) {}
- ~CFX_RTFLine() { RemoveAll(); }
- int32_t CountChars() const { return m_LineChars.GetSize(); }
- CFX_RTFChar& GetChar(int32_t index) {
- FXSYS_assert(index > -1 && index < m_LineChars.GetSize());
- return *m_LineChars.GetDataPtr(index);
- }
- CFX_RTFChar* GetCharPtr(int32_t index) {
- FXSYS_assert(index > -1 && index < m_LineChars.GetSize());
- return m_LineChars.GetDataPtr(index);
- }
- int32_t CountPieces() const { return m_LinePieces.GetSize(); }
- CFX_RTFPiece& GetPiece(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_LinePieces.GetSize());
- return m_LinePieces.GetAt(index);
- }
- CFX_RTFPiece* GetPiecePtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_LinePieces.GetSize());
- return m_LinePieces.GetPtrAt(index);
- }
- int32_t GetLineEnd() const { return m_iStart + m_iWidth; }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- CFX_RTFChar* pChar;
- IFX_Unknown* pUnknown;
- int32_t iCount = m_LineChars.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- pChar = m_LineChars.GetDataPtr(i);
- if ((pUnknown = pChar->m_pUserData) != NULL) {
- pUnknown->Release();
- }
- }
- m_LineChars.RemoveAll();
- m_LinePieces.RemoveAll(bLeaveMemory);
- m_iWidth = 0;
- m_iArabicChars = 0;
- m_iMBCSChars = 0;
- }
- CFX_RTFCharArray m_LineChars;
- CFX_RTFPieceArray m_LinePieces;
- int32_t m_iStart;
- int32_t m_iWidth;
- int32_t m_iArabicChars;
- int32_t m_iMBCSChars;
-};
-
-class CFX_RTFBreak : public IFX_RTFBreak {
- public:
- CFX_RTFBreak(uint32_t dwPolicies);
- ~CFX_RTFBreak();
- void Release() override { delete this; }
- void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) override;
- void SetLineStartPos(FX_FLOAT fLinePos) override;
- uint32_t GetLayoutStyles() const override { return m_dwLayoutStyles; }
- void SetLayoutStyles(uint32_t dwLayoutStyles) override;
- void SetFont(IFX_Font* pFont) override;
- void SetFontSize(FX_FLOAT fFontSize) override;
- void SetTabWidth(FX_FLOAT fTabWidth) override;
- void AddPositionedTab(FX_FLOAT fTabPos) override;
- void SetPositionedTabs(const CFX_FloatArray& tabs) override;
- void ClearPositionedTabs() override;
- void SetDefaultChar(FX_WCHAR wch) override;
- void SetLineBreakChar(FX_WCHAR wch) override;
- void SetLineBreakTolerance(FX_FLOAT fTolerance) override;
- void SetHorizontalScale(int32_t iScale) override;
- void SetVerticalScale(int32_t iScale) override;
- void SetCharRotation(int32_t iCharRotation) override;
- void SetCharSpace(FX_FLOAT fCharSpace) override;
- void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) override;
- void SetReadingOrder(FX_BOOL bRTL = FALSE) override;
- void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left) override;
- void SetUserData(IFX_Unknown* pUserData) override;
- uint32_t AppendChar(FX_WCHAR wch) override;
- uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak) override;
- int32_t CountBreakPieces() const override;
- const CFX_RTFPiece* GetBreakPiece(int32_t index) const override;
- void GetLineRect(CFX_RectF& rect) const override;
- void ClearBreakPieces() override;
- void Reset() override;
- int32_t GetDisplayPos(
- const FX_RTFTEXTOBJ* pText,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const override;
- int32_t GetCharRects(const FX_RTFTEXTOBJ* pText,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const override;
- uint32_t AppendChar_CharCode(FX_WCHAR wch);
- uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation);
-
- protected:
- uint32_t m_dwPolicies;
- IFX_ArabicChar* m_pArabicChar;
- int32_t m_iBoundaryStart;
- int32_t m_iBoundaryEnd;
- uint32_t m_dwLayoutStyles;
- FX_BOOL m_bPagination;
- FX_BOOL m_bVertical;
- FX_BOOL m_bSingleLine;
- FX_BOOL m_bCharCode;
- IFX_Font* m_pFont;
- int32_t m_iFontHeight;
- int32_t m_iFontSize;
- int32_t m_iTabWidth;
- CFX_Int32Array m_PositionedTabs;
- FX_BOOL m_bOrphanLine;
- FX_WCHAR m_wDefChar;
- int32_t m_iDefChar;
- FX_WCHAR m_wLineBreakChar;
- int32_t m_iHorizontalScale;
- int32_t m_iVerticalScale;
- int32_t m_iLineRotation;
- int32_t m_iCharRotation;
- int32_t m_iRotation;
- int32_t m_iCharSpace;
- FX_BOOL m_bWordSpace;
- int32_t m_iWordSpace;
- FX_BOOL m_bRTL;
- int32_t m_iAlignment;
- IFX_Unknown* m_pUserData;
- uint32_t m_dwCharType;
- uint32_t m_dwIdentity;
- CFX_RTFLine m_RTFLine1;
- CFX_RTFLine m_RTFLine2;
- CFX_RTFLine* m_pCurLine;
- int32_t m_iReady;
- int32_t m_iTolerance;
- int32_t GetLineRotation(uint32_t dwStyles) const;
- void SetBreakStatus();
- CFX_RTFChar* GetLastChar(int32_t index) const;
- CFX_RTFLine* GetRTFLine(FX_BOOL bReady) const;
- CFX_RTFPieceArray* GetRTFPieces(FX_BOOL bReady) const;
- uint32_t GetUnifiedCharType(uint32_t dwType) const;
- int32_t GetLastPositionedTab() const;
- FX_BOOL GetPositionedTab(int32_t& iTabPos) const;
- int32_t GetBreakPos(CFX_RTFCharArray& tca,
- int32_t& iEndPos,
- FX_BOOL bAllChars = FALSE,
- FX_BOOL bOnlyBrk = FALSE);
- void SplitTextLine(CFX_RTFLine* pCurLine,
- CFX_RTFLine* pNextLine,
- FX_BOOL bAllChars = FALSE);
- FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine,
- FX_BOOL bAllChars,
- uint32_t dwStatus);
- void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus);
- void EndBreak_Alignment(CFX_TPOArray& tpos,
- FX_BOOL bAllChars,
- uint32_t dwStatus);
-};
-
-} // namespace
-
-IFX_RTFBreak* IFX_RTFBreak::Create(uint32_t dwPolicies) {
- return new CFX_RTFBreak(dwPolicies);
-}
CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies)
: m_dwPolicies(dwPolicies),
- m_pArabicChar(NULL),
m_iBoundaryStart(0),
m_iBoundaryEnd(2000000),
m_dwLayoutStyles(0),
@@ -218,13 +49,11 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies)
m_pCurLine(NULL),
m_iReady(0),
m_iTolerance(0) {
- m_pArabicChar = IFX_ArabicChar::Create();
m_pCurLine = &m_RTFLine1;
}
CFX_RTFBreak::~CFX_RTFBreak() {
Reset();
m_PositionedTabs.RemoveAll();
- m_pArabicChar->Release();
if (m_pUserData != NULL) {
m_pUserData->Release();
}
@@ -406,8 +235,8 @@ void CFX_RTFBreak::SetReadingOrder(FX_BOOL bRTL) {
m_bRTL = bRTL;
}
void CFX_RTFBreak::SetAlignment(int32_t iAlignment) {
- FXSYS_assert(iAlignment >= FX_RTFLINEALIGNMENT_Left &&
- iAlignment <= FX_RTFLINEALIGNMENT_Distributed);
+ ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left &&
+ iAlignment <= FX_RTFLINEALIGNMENT_Distributed);
m_iAlignment = iAlignment;
}
void CFX_RTFBreak::SetUserData(IFX_Unknown* pUserData) {
@@ -467,7 +296,7 @@ CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const {
return NULL;
}
}
- FXSYS_assert(m_pCurLine != NULL);
+ ASSERT(m_pCurLine != NULL);
return m_pCurLine;
}
CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const {
@@ -511,7 +340,7 @@ static const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = {
&CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others,
};
uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
- FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL && m_pArabicChar != NULL);
+ ASSERT(m_pFont && m_pCurLine);
if (m_bCharCode) {
return AppendChar_CharCode(wch);
}
@@ -560,8 +389,8 @@ uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
return std::max(dwRet1, dwRet2);
}
uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) {
- FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL);
- FXSYS_assert(m_bCharCode);
+ ASSERT(m_pFont != NULL && m_pCurLine != NULL);
+ ASSERT(m_bCharCode);
m_pCurLine->m_iMBCSChars++;
CFX_RTFCharArray& tca = m_pCurLine->m_LineChars;
CFX_RTFChar* pCurChar = tca.AddSpace();
@@ -688,7 +517,7 @@ uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar,
if (pLastChar != NULL) {
iLineWidth -= pLastChar->m_iCharWidth;
CFX_RTFChar* pPrevChar = GetLastChar(2);
- wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar);
+ wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
bAlef = (wForm == 0xFEFF &&
pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation;
@@ -712,8 +541,8 @@ uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar,
iCharWidth = 0;
}
}
- wForm =
- m_pArabicChar->GetFormChar(pCurChar, (bAlef ? NULL : pLastChar), NULL);
+ wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? nullptr : pLastChar,
+ nullptr);
if (m_bVertical != FX_IsOdd(iRotation)) {
iCharWidth = 1000;
} else if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode) &&
@@ -774,8 +603,8 @@ uint32_t CFX_RTFBreak::AppendChar_Others(CFX_RTFChar* pCurChar,
return FX_RTFBREAK_None;
}
uint32_t CFX_RTFBreak::EndBreak(uint32_t dwStatus) {
- FXSYS_assert(dwStatus >= FX_RTFBREAK_PieceBreak &&
- dwStatus <= FX_RTFBREAK_PageBreak);
+ ASSERT(dwStatus >= FX_RTFBREAK_PieceBreak &&
+ dwStatus <= FX_RTFBREAK_PageBreak);
m_dwIdentity++;
CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces;
int32_t iCount = pCurPieces->GetSize();
@@ -1235,7 +1064,7 @@ int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca,
void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine,
CFX_RTFLine* pNextLine,
FX_BOOL bAllChars) {
- FXSYS_assert(pCurLine != NULL && pNextLine != NULL);
+ ASSERT(pCurLine != NULL && pNextLine != NULL);
int32_t iCount = pCurLine->CountChars();
if (iCount < 2) {
return;
@@ -1349,8 +1178,8 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText,
if (pText == NULL || pText->iLength < 1) {
return 0;
}
- FXSYS_assert(pText->pStr != NULL && pText->pWidths != NULL &&
- pText->pFont != NULL && pText->pRect != NULL);
+ ASSERT(pText->pStr != NULL && pText->pWidths != NULL &&
+ pText->pFont != NULL && pText->pRect != NULL);
const FX_WCHAR* pStr = pText->pStr;
int32_t* pWidths = pText->pWidths;
int32_t iLength = pText->iLength - 1;
@@ -1436,7 +1265,7 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText,
} else {
wNext = 0xFEFF;
}
- wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext);
+ wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext);
} else if (bRTLPiece || bVerticalChar) {
wForm = FX_GetMirrorChar(wch, dwProps, bRTLPiece, bVerticalChar);
} else if (dwCharType == FX_CHARTYPE_Numeric && bArabicNumber) {
@@ -1590,8 +1419,8 @@ int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText,
if (pText == NULL || pText->iLength < 1) {
return 0;
}
- FXSYS_assert(pText->pStr != NULL && pText->pWidths != NULL &&
- pText->pFont != NULL && pText->pRect != NULL);
+ ASSERT(pText->pStr != NULL && pText->pWidths != NULL &&
+ pText->pFont != NULL && pText->pRect != NULL);
const FX_WCHAR* pStr = pText->pStr;
int32_t* pWidths = pText->pWidths;
int32_t iLength = pText->iLength;
diff --git a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.h b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.h
index dd791c24df6..d595ad38d10 100644
--- a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_rtfbreak.h
@@ -8,7 +8,7 @@
#define XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_
#include "core/fxcrt/include/fx_ucd.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/layout/fgas_textbreak.h"
@@ -114,7 +114,7 @@ class CFX_RTFPiece : public CFX_Target {
m_pUserData(NULL) {}
~CFX_RTFPiece() { Reset(); }
void AppendChar(const CFX_RTFChar& tc) {
- FXSYS_assert(m_pChars != NULL);
+ ASSERT(m_pChars != NULL);
m_pChars->Add(tc);
if (m_iWidth < 0) {
m_iWidth = tc.m_iCharWidth;
@@ -129,15 +129,15 @@ class CFX_RTFPiece : public CFX_Target {
int32_t GetLength() const { return m_iChars; }
int32_t GetEndChar() const { return m_iStartChar + m_iChars; }
CFX_RTFChar& GetChar(int32_t index) {
- FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
+ ASSERT(index > -1 && index < m_iChars && m_pChars != NULL);
return *m_pChars->GetDataPtr(m_iStartChar + index);
}
CFX_RTFChar* GetCharPtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
+ ASSERT(index > -1 && index < m_iChars && m_pChars != NULL);
return m_pChars->GetDataPtr(m_iStartChar + index);
}
void GetString(FX_WCHAR* pText) const {
- FXSYS_assert(pText != NULL);
+ ASSERT(pText != NULL);
int32_t iEndChar = m_iStartChar + m_iChars;
CFX_RTFChar* pChar;
for (int32_t i = m_iStartChar; i < iEndChar; i++) {
@@ -151,7 +151,7 @@ class CFX_RTFPiece : public CFX_Target {
wsText.ReleaseBuffer(m_iChars);
}
void GetWidths(int32_t* pWidths) const {
- FXSYS_assert(pWidths != NULL);
+ ASSERT(pWidths != NULL);
int32_t iEndChar = m_iStartChar + m_iChars;
CFX_RTFChar* pChar;
for (int32_t i = m_iStartChar; i < iEndChar; i++) {
@@ -190,48 +190,164 @@ class CFX_RTFPiece : public CFX_Target {
};
typedef CFX_BaseArrayTemplate<CFX_RTFPiece> CFX_RTFPieceArray;
-class IFX_RTFBreak {
+class CFX_RTFLine {
public:
- static IFX_RTFBreak* Create(uint32_t dwPolicies);
- virtual ~IFX_RTFBreak() {}
- virtual void Release() = 0;
- virtual void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) = 0;
- virtual void SetLineStartPos(FX_FLOAT fLinePos) = 0;
- virtual uint32_t GetLayoutStyles() const = 0;
- virtual void SetLayoutStyles(uint32_t dwLayoutStyles) = 0;
- virtual void SetFont(IFX_Font* pFont) = 0;
- virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
- virtual void SetTabWidth(FX_FLOAT fTabWidth) = 0;
- virtual void AddPositionedTab(FX_FLOAT fTabPos) = 0;
- virtual void SetPositionedTabs(const CFX_FloatArray& tabs) = 0;
- virtual void ClearPositionedTabs() = 0;
- virtual void SetDefaultChar(FX_WCHAR wch) = 0;
- virtual void SetLineBreakChar(FX_WCHAR wch) = 0;
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
- virtual void SetHorizontalScale(int32_t iScale) = 0;
- virtual void SetVerticalScale(int32_t iScale) = 0;
- virtual void SetCharRotation(int32_t iCharRotation) = 0;
- virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0;
- virtual void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) = 0;
- virtual void SetReadingOrder(FX_BOOL bRTL = FALSE) = 0;
- virtual void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left) = 0;
- virtual void SetUserData(IFX_Unknown* pUserData) = 0;
- virtual uint32_t AppendChar(FX_WCHAR wch) = 0;
- virtual uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak) = 0;
- virtual int32_t CountBreakPieces() const = 0;
- virtual const CFX_RTFPiece* GetBreakPiece(int32_t index) const = 0;
- virtual void GetLineRect(CFX_RectF& rect) const = 0;
- virtual void ClearBreakPieces() = 0;
- virtual void Reset() = 0;
- virtual int32_t GetDisplayPos(
- const FX_RTFTEXTOBJ* pText,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
- virtual int32_t GetCharRects(const FX_RTFTEXTOBJ* pText,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const = 0;
+ CFX_RTFLine()
+ : m_LinePieces(16),
+ m_iStart(0),
+ m_iWidth(0),
+ m_iArabicChars(0),
+ m_iMBCSChars(0) {}
+ ~CFX_RTFLine() { RemoveAll(); }
+ int32_t CountChars() const { return m_LineChars.GetSize(); }
+ CFX_RTFChar& GetChar(int32_t index) {
+ ASSERT(index > -1 && index < m_LineChars.GetSize());
+ return *m_LineChars.GetDataPtr(index);
+ }
+ CFX_RTFChar* GetCharPtr(int32_t index) {
+ ASSERT(index > -1 && index < m_LineChars.GetSize());
+ return m_LineChars.GetDataPtr(index);
+ }
+ int32_t CountPieces() const { return m_LinePieces.GetSize(); }
+ CFX_RTFPiece& GetPiece(int32_t index) const {
+ ASSERT(index > -1 && index < m_LinePieces.GetSize());
+ return m_LinePieces.GetAt(index);
+ }
+ CFX_RTFPiece* GetPiecePtr(int32_t index) const {
+ ASSERT(index > -1 && index < m_LinePieces.GetSize());
+ return m_LinePieces.GetPtrAt(index);
+ }
+ int32_t GetLineEnd() const { return m_iStart + m_iWidth; }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
+ CFX_RTFChar* pChar;
+ IFX_Unknown* pUnknown;
+ int32_t iCount = m_LineChars.GetSize();
+ for (int32_t i = 0; i < iCount; i++) {
+ pChar = m_LineChars.GetDataPtr(i);
+ if ((pUnknown = pChar->m_pUserData) != NULL) {
+ pUnknown->Release();
+ }
+ }
+ m_LineChars.RemoveAll();
+ m_LinePieces.RemoveAll(bLeaveMemory);
+ m_iWidth = 0;
+ m_iArabicChars = 0;
+ m_iMBCSChars = 0;
+ }
+ CFX_RTFCharArray m_LineChars;
+ CFX_RTFPieceArray m_LinePieces;
+ int32_t m_iStart;
+ int32_t m_iWidth;
+ int32_t m_iArabicChars;
+ int32_t m_iMBCSChars;
+};
+
+class CFX_RTFBreak {
+ public:
+ CFX_RTFBreak(uint32_t dwPolicies);
+ ~CFX_RTFBreak();
+ void Release() { delete this; }
+ void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd);
+ void SetLineStartPos(FX_FLOAT fLinePos);
+ uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
+ void SetLayoutStyles(uint32_t dwLayoutStyles);
+ void SetFont(IFX_Font* pFont);
+ void SetFontSize(FX_FLOAT fFontSize);
+ void SetTabWidth(FX_FLOAT fTabWidth);
+ void AddPositionedTab(FX_FLOAT fTabPos);
+ void SetPositionedTabs(const CFX_FloatArray& tabs);
+ void ClearPositionedTabs();
+ void SetDefaultChar(FX_WCHAR wch);
+ void SetLineBreakChar(FX_WCHAR wch);
+ void SetLineBreakTolerance(FX_FLOAT fTolerance);
+ void SetHorizontalScale(int32_t iScale);
+ void SetVerticalScale(int32_t iScale);
+ void SetCharRotation(int32_t iCharRotation);
+ void SetCharSpace(FX_FLOAT fCharSpace);
+ void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace);
+ void SetReadingOrder(FX_BOOL bRTL = FALSE);
+ void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left);
+ void SetUserData(IFX_Unknown* pUserData);
+ uint32_t AppendChar(FX_WCHAR wch);
+ uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak);
+ int32_t CountBreakPieces() const;
+ const CFX_RTFPiece* GetBreakPiece(int32_t index) const;
+ void GetLineRect(CFX_RectF& rect) const;
+ void ClearBreakPieces();
+ void Reset();
+ int32_t GetDisplayPos(const FX_RTFTEXTOBJ* pText,
+ FXTEXT_CHARPOS* pCharPos,
+ FX_BOOL bCharCode = FALSE,
+ CFX_WideString* pWSForms = NULL,
+ FX_AdjustCharDisplayPos pAdjustPos = NULL) const;
+ int32_t GetCharRects(const FX_RTFTEXTOBJ* pText,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bCharBBox = FALSE) const;
+ uint32_t AppendChar_CharCode(FX_WCHAR wch);
+ uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation);
+
+ protected:
+ uint32_t m_dwPolicies;
+ int32_t m_iBoundaryStart;
+ int32_t m_iBoundaryEnd;
+ uint32_t m_dwLayoutStyles;
+ FX_BOOL m_bPagination;
+ FX_BOOL m_bVertical;
+ FX_BOOL m_bSingleLine;
+ FX_BOOL m_bCharCode;
+ IFX_Font* m_pFont;
+ int32_t m_iFontHeight;
+ int32_t m_iFontSize;
+ int32_t m_iTabWidth;
+ CFX_Int32Array m_PositionedTabs;
+ FX_BOOL m_bOrphanLine;
+ FX_WCHAR m_wDefChar;
+ int32_t m_iDefChar;
+ FX_WCHAR m_wLineBreakChar;
+ int32_t m_iHorizontalScale;
+ int32_t m_iVerticalScale;
+ int32_t m_iLineRotation;
+ int32_t m_iCharRotation;
+ int32_t m_iRotation;
+ int32_t m_iCharSpace;
+ FX_BOOL m_bWordSpace;
+ int32_t m_iWordSpace;
+ FX_BOOL m_bRTL;
+ int32_t m_iAlignment;
+ IFX_Unknown* m_pUserData;
+ uint32_t m_dwCharType;
+ uint32_t m_dwIdentity;
+ CFX_RTFLine m_RTFLine1;
+ CFX_RTFLine m_RTFLine2;
+ CFX_RTFLine* m_pCurLine;
+ int32_t m_iReady;
+ int32_t m_iTolerance;
+ int32_t GetLineRotation(uint32_t dwStyles) const;
+ void SetBreakStatus();
+ CFX_RTFChar* GetLastChar(int32_t index) const;
+ CFX_RTFLine* GetRTFLine(FX_BOOL bReady) const;
+ CFX_RTFPieceArray* GetRTFPieces(FX_BOOL bReady) const;
+ uint32_t GetUnifiedCharType(uint32_t dwType) const;
+ int32_t GetLastPositionedTab() const;
+ FX_BOOL GetPositionedTab(int32_t& iTabPos) const;
+ int32_t GetBreakPos(CFX_RTFCharArray& tca,
+ int32_t& iEndPos,
+ FX_BOOL bAllChars = FALSE,
+ FX_BOOL bOnlyBrk = FALSE);
+ void SplitTextLine(CFX_RTFLine* pCurLine,
+ CFX_RTFLine* pNextLine,
+ FX_BOOL bAllChars = FALSE);
+ FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine,
+ FX_BOOL bAllChars,
+ uint32_t dwStatus);
+ void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus);
+ void EndBreak_Alignment(CFX_TPOArray& tpos,
+ FX_BOOL bAllChars,
+ uint32_t dwStatus);
};
#endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_
diff --git a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.cpp b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.cpp
index d33d02c6f2b..4b4ef1fa7bd 100644
--- a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.cpp
@@ -8,180 +8,14 @@
#include <algorithm>
+#include "core/fxcrt/include/fx_arabic.h"
#include "core/fxcrt/include/fx_arb.h"
#include "core/fxcrt/include/fx_memory.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-namespace {
-
-class CFX_TxtLine {
- public:
- CFX_TxtLine(int32_t iBlockSize)
- : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {
- m_pLineChars = new CFX_TxtCharArray;
- m_pLinePieces = new CFX_TxtPieceArray(16);
- }
- ~CFX_TxtLine() {
- RemoveAll();
- delete m_pLineChars;
- delete m_pLinePieces;
- }
- int32_t CountChars() const { return m_pLineChars->GetSize(); }
- CFX_TxtChar* GetCharPtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_pLineChars->GetSize());
- return m_pLineChars->GetDataPtr(index);
- }
- int32_t CountPieces() const { return m_pLinePieces->GetSize(); }
- CFX_TxtPiece* GetPiecePtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_pLinePieces->GetSize());
- return m_pLinePieces->GetPtrAt(index);
- }
- void GetString(CFX_WideString& wsStr) const {
- int32_t iCount = m_pLineChars->GetSize();
- FX_WCHAR* pBuf = wsStr.GetBuffer(iCount);
- CFX_Char* pChar;
- for (int32_t i = 0; i < iCount; i++) {
- pChar = m_pLineChars->GetDataPtr(i);
- *pBuf++ = (FX_WCHAR)pChar->m_wCharCode;
- }
- wsStr.ReleaseBuffer(iCount);
- }
- void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
- m_pLineChars->RemoveAll();
- m_pLinePieces->RemoveAll(bLeaveMemory);
- m_iWidth = 0;
- m_iArabicChars = 0;
- }
- CFX_TxtCharArray* m_pLineChars;
- CFX_TxtPieceArray* m_pLinePieces;
- int32_t m_iStart;
- int32_t m_iWidth;
- int32_t m_iArabicChars;
-};
-
-class CFX_TxtBreak : public IFX_TxtBreak {
- public:
- CFX_TxtBreak(uint32_t dwPolicies);
- ~CFX_TxtBreak();
- virtual void Release() { delete this; }
- virtual void SetLineWidth(FX_FLOAT fLineWidth);
- virtual void SetLinePos(FX_FLOAT fLinePos);
- virtual uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
- virtual void SetLayoutStyles(uint32_t dwLayoutStyles);
- virtual void SetFont(IFX_Font* pFont);
- virtual void SetFontSize(FX_FLOAT fFontSize);
- virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
- virtual void SetDefaultChar(FX_WCHAR wch);
- virtual void SetParagraphBreakChar(FX_WCHAR wch);
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance);
- virtual void SetHorizontalScale(int32_t iScale);
- virtual void SetVerticalScale(int32_t iScale);
- virtual void SetCharRotation(int32_t iCharRotation);
- virtual void SetCharSpace(FX_FLOAT fCharSpace);
- virtual void SetAlignment(int32_t iAlignment);
- virtual uint32_t GetContextCharStyles() const;
- virtual void SetContextCharStyles(uint32_t dwCharStyles);
- virtual void SetCombWidth(FX_FLOAT fCombWidth);
- virtual void SetUserData(void* pUserData);
- virtual uint32_t AppendChar(FX_WCHAR wch);
- virtual uint32_t EndBreak(uint32_t dwStatus = FX_TXTBREAK_PieceBreak);
- virtual int32_t CountBreakChars() const;
- virtual int32_t CountBreakPieces() const;
- virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const;
- virtual void ClearBreakPieces();
- virtual void Reset();
- virtual int32_t GetDisplayPos(
- const FX_TXTRUN* pTxtRun,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const;
- virtual int32_t GetCharRects(const FX_TXTRUN* pTxtRun,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const;
- void AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps);
- uint32_t AppendChar_Combination(CFX_Char* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Control(CFX_Char* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Arabic(CFX_Char* pCurChar, int32_t iRotation);
- uint32_t AppendChar_Others(CFX_Char* pCurChar, int32_t iRotation);
-
- protected:
- uint32_t m_dwPolicies;
- FX_BOOL m_bPagination;
- IFX_ArabicChar* m_pArabicChar;
- int32_t m_iLineWidth;
- uint32_t m_dwLayoutStyles;
- FX_BOOL m_bVertical;
- FX_BOOL m_bArabicContext;
- FX_BOOL m_bArabicShapes;
- FX_BOOL m_bRTL;
- FX_BOOL m_bSingleLine;
- FX_BOOL m_bCombText;
- int32_t m_iArabicContext;
- int32_t m_iCurArabicContext;
- IFX_Font* m_pFont;
- int32_t m_iFontSize;
- FX_BOOL m_bEquidistant;
- int32_t m_iTabWidth;
- FX_WCHAR m_wDefChar;
- FX_WCHAR m_wParagBreakChar;
- int32_t m_iDefChar;
- int32_t m_iLineRotation;
- int32_t m_iCharRotation;
- int32_t m_iRotation;
- int32_t m_iAlignment;
- uint32_t m_dwContextCharStyles;
- int32_t m_iCombWidth;
- void* m_pUserData;
- uint32_t m_dwCharType;
- FX_BOOL m_bCurRTL;
- int32_t m_iCurAlignment;
- FX_BOOL m_bArabicNumber;
- FX_BOOL m_bArabicComma;
- CFX_TxtLine* m_pTxtLine1;
- CFX_TxtLine* m_pTxtLine2;
- CFX_TxtLine* m_pCurLine;
- int32_t m_iReady;
- int32_t m_iTolerance;
- int32_t m_iHorScale;
- int32_t m_iVerScale;
- int32_t m_iCharSpace;
- void SetBreakStatus();
- int32_t GetLineRotation(uint32_t dwStyles) const;
- CFX_TxtChar* GetLastChar(int32_t index, FX_BOOL bOmitChar = TRUE) const;
- CFX_TxtLine* GetTxtLine(FX_BOOL bReady) const;
- CFX_TxtPieceArray* GetTxtPieces(FX_BOOL bReady) const;
- uint32_t GetUnifiedCharType(uint32_t dwType) const;
- void ResetArabicContext();
- void ResetContextCharStyles();
- void EndBreak_UpdateArabicShapes();
- FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine,
- FX_BOOL bAllChars,
- uint32_t dwStatus);
- void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus);
- void EndBreak_Alignment(CFX_TPOArray& tpos,
- FX_BOOL bAllChars,
- uint32_t dwStatus);
- int32_t GetBreakPos(CFX_TxtCharArray& ca,
- int32_t& iEndPos,
- FX_BOOL bAllChars = FALSE,
- FX_BOOL bOnlyBrk = FALSE);
- void SplitTextLine(CFX_TxtLine* pCurLine,
- CFX_TxtLine* pNextLine,
- FX_BOOL bAllChars = FALSE);
-};
-
-} // namespace
-
-extern const FX_LINEBREAKTYPE gs_FX_LineBreak_PairTable[64][32];
-IFX_TxtBreak* IFX_TxtBreak::Create(uint32_t dwPolicies) {
- return new CFX_TxtBreak(dwPolicies);
-}
CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
: m_dwPolicies(dwPolicies),
- m_pArabicChar(NULL),
m_iLineWidth(2000000),
m_dwLayoutStyles(0),
m_bVertical(FALSE),
@@ -216,7 +50,6 @@ CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
m_iVerScale(100),
m_iCharSpace(0) {
m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0;
- m_pArabicChar = IFX_ArabicChar::Create();
if (m_bPagination) {
m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char));
m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char));
@@ -231,11 +64,10 @@ CFX_TxtBreak::~CFX_TxtBreak() {
Reset();
delete m_pTxtLine1;
delete m_pTxtLine2;
- m_pArabicChar->Release();
}
void CFX_TxtBreak::SetLineWidth(FX_FLOAT fLineWidth) {
m_iLineWidth = FXSYS_round(fLineWidth * 20000.0f);
- FXSYS_assert(m_iLineWidth >= 20000);
+ ASSERT(m_iLineWidth >= 20000);
}
void CFX_TxtBreak::SetLinePos(FX_FLOAT fLinePos) {
int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f);
@@ -332,8 +164,8 @@ void CFX_TxtBreak::SetCharRotation(int32_t iCharRotation) {
m_iRotation %= 4;
}
void CFX_TxtBreak::SetAlignment(int32_t iAlignment) {
- FXSYS_assert(iAlignment >= FX_TXTLINEALIGNMENT_Left &&
- iAlignment <= FX_TXTLINEALIGNMENT_Distributed);
+ ASSERT(iAlignment >= FX_TXTLINEALIGNMENT_Left &&
+ iAlignment <= FX_TXTLINEALIGNMENT_Distributed);
m_iAlignment = iAlignment;
ResetArabicContext();
}
@@ -507,7 +339,7 @@ void CFX_TxtBreak::AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps) {
}
uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar,
int32_t iRotation) {
- FXSYS_assert(pCurChar != NULL);
+ ASSERT(pCurChar != NULL);
FX_WCHAR wch = pCurChar->m_wCharCode;
FX_WCHAR wForm;
int32_t iCharWidth = 0;
@@ -630,7 +462,7 @@ uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar,
iLineWidth -= iCharWidth;
}
CFX_Char* pPrevChar = GetLastChar(2);
- wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar);
+ wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
bAlef = (wForm == 0xFEFF &&
pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation;
@@ -653,7 +485,7 @@ uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar,
}
}
m_dwCharType = dwType;
- wForm = m_pArabicChar->GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL);
+ wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL);
if (m_bCombText) {
iCharWidth = m_iCombWidth;
} else {
@@ -773,7 +605,7 @@ uint32_t CFX_TxtBreak::AppendChar(FX_WCHAR wch) {
return std::max(dwRet1, dwRet2);
}
void CFX_TxtBreak::EndBreak_UpdateArabicShapes() {
- FXSYS_assert(m_bArabicShapes);
+ ASSERT(m_bArabicShapes);
int32_t iCount = m_pCurLine->CountChars();
if (iCount < 2) {
return;
@@ -1072,8 +904,8 @@ void CFX_TxtBreak::EndBreak_Alignment(CFX_TPOArray& tpos,
}
}
uint32_t CFX_TxtBreak::EndBreak(uint32_t dwStatus) {
- FXSYS_assert(dwStatus >= FX_TXTBREAK_PieceBreak &&
- dwStatus <= FX_TXTBREAK_PageBreak);
+ ASSERT(dwStatus >= FX_TXTBREAK_PieceBreak &&
+ dwStatus <= FX_TXTBREAK_PageBreak);
CFX_TxtPieceArray* pCurPieces = m_pCurLine->m_pLinePieces;
int32_t iCount = pCurPieces->GetSize();
if (iCount > 0) {
@@ -1239,7 +1071,7 @@ int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca,
void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
CFX_TxtLine* pNextLine,
FX_BOOL bAllChars) {
- FXSYS_assert(pCurLine != NULL && pNextLine != NULL);
+ ASSERT(pCurLine != NULL && pNextLine != NULL);
int32_t iCount = pCurLine->CountChars();
if (iCount < 2) {
return;
@@ -1339,7 +1171,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
}
IFX_TxtAccess* pAccess = pTxtRun->pAccess;
void* pIdentity = pTxtRun->pIdentity;
- const FX_WCHAR* pStr = pTxtRun->pStr;
+ const FX_WCHAR* pStr = pTxtRun->wsStr.c_str();
int32_t* pWidths = pTxtRun->pWidths;
int32_t iLength = pTxtRun->iLength - 1;
IFX_Font* pFont = pTxtRun->pFont;
@@ -1433,7 +1265,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun,
} else {
wNext = 0xFEFF;
}
- wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext);
+ wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext);
bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647);
} else if (dwCharType == FX_CHARTYPE_Combination) {
wForm = wch;
@@ -1719,7 +1551,7 @@ int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun,
}
IFX_TxtAccess* pAccess = pTxtRun->pAccess;
void* pIdentity = pTxtRun->pIdentity;
- const FX_WCHAR* pStr = pTxtRun->pStr;
+ const FX_WCHAR* pStr = pTxtRun->wsStr.c_str();
int32_t* pWidths = pTxtRun->pWidths;
int32_t iLength = pTxtRun->iLength;
CFX_RectF rect(*pTxtRun->pRect);
diff --git a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.h b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.h
index add156e971a..6d961f218a3 100644
--- a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.h
+++ b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_textbreak.h
@@ -8,16 +8,15 @@
#define XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
#include "core/fxcrt/include/fx_ucd.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/layout/fgas_unicode.h"
-class IFX_Font;
class CFX_Char;
-class IFX_TxtAccess;
class CFX_TxtChar;
class CFX_TxtPiece;
-class IFX_TxtBreak;
+class IFX_Font;
+class IFX_TxtAccess;
#define FX_TXTBREAKPOLICY_None 0x00
#define FX_TXTBREAKPOLICY_Pagination 0x01
@@ -79,27 +78,25 @@ class IFX_TxtAccess {
};
struct FX_TXTRUN {
- FX_TXTRUN() {
- pAccess = NULL;
- pIdentity = NULL;
- pStr = NULL;
- pWidths = NULL;
- iLength = 0;
- pFont = NULL;
- fFontSize = 12;
- dwStyles = 0;
- iHorizontalScale = 100;
- iVerticalScale = 100;
- iCharRotation = 0;
- dwCharStyles = 0;
- pRect = NULL;
- wLineBreakChar = L'\n';
- bSkipSpace = TRUE;
- }
+ FX_TXTRUN()
+ : pAccess(nullptr),
+ pIdentity(nullptr),
+ pWidths(nullptr),
+ iLength(0),
+ pFont(nullptr),
+ fFontSize(12),
+ dwStyles(0),
+ iHorizontalScale(100),
+ iVerticalScale(100),
+ iCharRotation(0),
+ dwCharStyles(0),
+ pRect(nullptr),
+ wLineBreakChar(L'\n'),
+ bSkipSpace(TRUE) {}
IFX_TxtAccess* pAccess;
void* pIdentity;
- const FX_WCHAR* pStr;
+ CFX_WideString wsStr;
int32_t* pWidths;
int32_t iLength;
IFX_Font* pFont;
@@ -135,11 +132,11 @@ class CFX_TxtPiece : public CFX_Target {
int32_t GetLength() const { return m_iChars; }
int32_t GetEndChar() const { return m_iStartChar + m_iChars; }
CFX_TxtChar* GetCharPtr(int32_t index) const {
- FXSYS_assert(index > -1 && index < m_iChars && m_pChars != NULL);
+ ASSERT(index > -1 && index < m_iChars && m_pChars != NULL);
return m_pChars->GetDataPtr(m_iStartChar + index);
}
void GetString(FX_WCHAR* pText) const {
- FXSYS_assert(pText != NULL);
+ ASSERT(pText != NULL);
int32_t iEndChar = m_iStartChar + m_iChars;
CFX_Char* pChar;
for (int32_t i = m_iStartChar; i < iEndChar; i++) {
@@ -154,7 +151,7 @@ class CFX_TxtPiece : public CFX_Target {
wsText.ReleaseBuffer(m_iChars);
}
void GetWidths(int32_t* pWidths) const {
- FXSYS_assert(pWidths != NULL);
+ ASSERT(pWidths != NULL);
int32_t iEndChar = m_iStartChar + m_iChars;
CFX_Char* pChar;
for (int32_t i = m_iStartChar; i < iEndChar; i++) {
@@ -177,46 +174,161 @@ class CFX_TxtPiece : public CFX_Target {
};
typedef CFX_BaseArrayTemplate<CFX_TxtPiece> CFX_TxtPieceArray;
-class IFX_TxtBreak {
+class CFX_TxtLine {
public:
- static IFX_TxtBreak* Create(uint32_t dwPolicies);
- virtual ~IFX_TxtBreak() {}
- virtual void Release() = 0;
- virtual void SetLineWidth(FX_FLOAT fLineWidth) = 0;
- virtual void SetLinePos(FX_FLOAT fLinePos) = 0;
- virtual uint32_t GetLayoutStyles() const = 0;
- virtual void SetLayoutStyles(uint32_t dwLayoutStyles) = 0;
- virtual void SetFont(IFX_Font* pFont) = 0;
- virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
- virtual void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) = 0;
- virtual void SetDefaultChar(FX_WCHAR wch) = 0;
- virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0;
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
- virtual void SetHorizontalScale(int32_t iScale) = 0;
- virtual void SetVerticalScale(int32_t iScale) = 0;
- virtual void SetCharRotation(int32_t iCharRotation) = 0;
- virtual void SetCharSpace(FX_FLOAT fCharSpace) = 0;
- virtual void SetAlignment(int32_t iAlignment) = 0;
- virtual uint32_t GetContextCharStyles() const = 0;
- virtual void SetContextCharStyles(uint32_t dwCharStyles) = 0;
- virtual void SetCombWidth(FX_FLOAT fCombWidth) = 0;
- virtual void SetUserData(void* pUserData) = 0;
- virtual uint32_t AppendChar(FX_WCHAR wch) = 0;
- virtual uint32_t EndBreak(uint32_t dwStatus = FX_TXTBREAK_PieceBreak) = 0;
- virtual int32_t CountBreakChars() const = 0;
- virtual int32_t CountBreakPieces() const = 0;
- virtual const CFX_TxtPiece* GetBreakPiece(int32_t index) const = 0;
- virtual void ClearBreakPieces() = 0;
- virtual void Reset() = 0;
- virtual int32_t GetDisplayPos(
- const FX_TXTRUN* pTxtRun,
- FXTEXT_CHARPOS* pCharPos,
- FX_BOOL bCharCode = FALSE,
- CFX_WideString* pWSForms = NULL,
- FX_AdjustCharDisplayPos pAdjustPos = NULL) const = 0;
- virtual int32_t GetCharRects(const FX_TXTRUN* pTxtRun,
- CFX_RectFArray& rtArray,
- FX_BOOL bCharBBox = FALSE) const = 0;
+ CFX_TxtLine(int32_t iBlockSize)
+ : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {
+ m_pLineChars = new CFX_TxtCharArray;
+ m_pLinePieces = new CFX_TxtPieceArray(16);
+ }
+ ~CFX_TxtLine() {
+ RemoveAll();
+ delete m_pLineChars;
+ delete m_pLinePieces;
+ }
+ int32_t CountChars() const { return m_pLineChars->GetSize(); }
+ CFX_TxtChar* GetCharPtr(int32_t index) const {
+ ASSERT(index > -1 && index < m_pLineChars->GetSize());
+ return m_pLineChars->GetDataPtr(index);
+ }
+ int32_t CountPieces() const { return m_pLinePieces->GetSize(); }
+ CFX_TxtPiece* GetPiecePtr(int32_t index) const {
+ ASSERT(index > -1 && index < m_pLinePieces->GetSize());
+ return m_pLinePieces->GetPtrAt(index);
+ }
+ void GetString(CFX_WideString& wsStr) const {
+ int32_t iCount = m_pLineChars->GetSize();
+ FX_WCHAR* pBuf = wsStr.GetBuffer(iCount);
+ CFX_Char* pChar;
+ for (int32_t i = 0; i < iCount; i++) {
+ pChar = m_pLineChars->GetDataPtr(i);
+ *pBuf++ = (FX_WCHAR)pChar->m_wCharCode;
+ }
+ wsStr.ReleaseBuffer(iCount);
+ }
+ void RemoveAll(FX_BOOL bLeaveMemory = FALSE) {
+ m_pLineChars->RemoveAll();
+ m_pLinePieces->RemoveAll(bLeaveMemory);
+ m_iWidth = 0;
+ m_iArabicChars = 0;
+ }
+ CFX_TxtCharArray* m_pLineChars;
+ CFX_TxtPieceArray* m_pLinePieces;
+ int32_t m_iStart;
+ int32_t m_iWidth;
+ int32_t m_iArabicChars;
+};
+
+class CFX_TxtBreak {
+ public:
+ CFX_TxtBreak(uint32_t dwPolicies);
+ ~CFX_TxtBreak();
+
+ void Release() { delete this; }
+ void SetLineWidth(FX_FLOAT fLineWidth);
+ void SetLinePos(FX_FLOAT fLinePos);
+ uint32_t GetLayoutStyles() const { return m_dwLayoutStyles; }
+ void SetLayoutStyles(uint32_t dwLayoutStyles);
+ void SetFont(IFX_Font* pFont);
+ void SetFontSize(FX_FLOAT fFontSize);
+ void SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
+ void SetDefaultChar(FX_WCHAR wch);
+ void SetParagraphBreakChar(FX_WCHAR wch);
+ void SetLineBreakTolerance(FX_FLOAT fTolerance);
+ void SetHorizontalScale(int32_t iScale);
+ void SetVerticalScale(int32_t iScale);
+ void SetCharRotation(int32_t iCharRotation);
+ void SetCharSpace(FX_FLOAT fCharSpace);
+ void SetAlignment(int32_t iAlignment);
+ uint32_t GetContextCharStyles() const;
+ void SetContextCharStyles(uint32_t dwCharStyles);
+ void SetCombWidth(FX_FLOAT fCombWidth);
+ void SetUserData(void* pUserData);
+ uint32_t AppendChar(FX_WCHAR wch);
+ uint32_t EndBreak(uint32_t dwStatus = FX_TXTBREAK_PieceBreak);
+ int32_t CountBreakChars() const;
+ int32_t CountBreakPieces() const;
+ const CFX_TxtPiece* GetBreakPiece(int32_t index) const;
+ void ClearBreakPieces();
+ void Reset();
+ int32_t GetDisplayPos(const FX_TXTRUN* pTxtRun,
+ FXTEXT_CHARPOS* pCharPos,
+ FX_BOOL bCharCode = FALSE,
+ CFX_WideString* pWSForms = NULL,
+ FX_AdjustCharDisplayPos pAdjustPos = NULL) const;
+ int32_t GetCharRects(const FX_TXTRUN* pTxtRun,
+ CFX_RectFArray& rtArray,
+ FX_BOOL bCharBBox = FALSE) const;
+ void AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps);
+ uint32_t AppendChar_Combination(CFX_Char* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Tab(CFX_Char* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Control(CFX_Char* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Arabic(CFX_Char* pCurChar, int32_t iRotation);
+ uint32_t AppendChar_Others(CFX_Char* pCurChar, int32_t iRotation);
+
+ protected:
+ uint32_t m_dwPolicies;
+ FX_BOOL m_bPagination;
+ int32_t m_iLineWidth;
+ uint32_t m_dwLayoutStyles;
+ FX_BOOL m_bVertical;
+ FX_BOOL m_bArabicContext;
+ FX_BOOL m_bArabicShapes;
+ FX_BOOL m_bRTL;
+ FX_BOOL m_bSingleLine;
+ FX_BOOL m_bCombText;
+ int32_t m_iArabicContext;
+ int32_t m_iCurArabicContext;
+ IFX_Font* m_pFont;
+ int32_t m_iFontSize;
+ FX_BOOL m_bEquidistant;
+ int32_t m_iTabWidth;
+ FX_WCHAR m_wDefChar;
+ FX_WCHAR m_wParagBreakChar;
+ int32_t m_iDefChar;
+ int32_t m_iLineRotation;
+ int32_t m_iCharRotation;
+ int32_t m_iRotation;
+ int32_t m_iAlignment;
+ uint32_t m_dwContextCharStyles;
+ int32_t m_iCombWidth;
+ void* m_pUserData;
+ uint32_t m_dwCharType;
+ FX_BOOL m_bCurRTL;
+ int32_t m_iCurAlignment;
+ FX_BOOL m_bArabicNumber;
+ FX_BOOL m_bArabicComma;
+ CFX_TxtLine* m_pTxtLine1;
+ CFX_TxtLine* m_pTxtLine2;
+ CFX_TxtLine* m_pCurLine;
+ int32_t m_iReady;
+ int32_t m_iTolerance;
+ int32_t m_iHorScale;
+ int32_t m_iVerScale;
+ int32_t m_iCharSpace;
+ void SetBreakStatus();
+ int32_t GetLineRotation(uint32_t dwStyles) const;
+ CFX_TxtChar* GetLastChar(int32_t index, FX_BOOL bOmitChar = TRUE) const;
+ CFX_TxtLine* GetTxtLine(FX_BOOL bReady) const;
+ CFX_TxtPieceArray* GetTxtPieces(FX_BOOL bReady) const;
+ uint32_t GetUnifiedCharType(uint32_t dwType) const;
+ void ResetArabicContext();
+ void ResetContextCharStyles();
+ void EndBreak_UpdateArabicShapes();
+ FX_BOOL EndBreak_SplitLine(CFX_TxtLine* pNextLine,
+ FX_BOOL bAllChars,
+ uint32_t dwStatus);
+ void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus);
+ void EndBreak_Alignment(CFX_TPOArray& tpos,
+ FX_BOOL bAllChars,
+ uint32_t dwStatus);
+ int32_t GetBreakPos(CFX_TxtCharArray& ca,
+ int32_t& iEndPos,
+ FX_BOOL bAllChars = FALSE,
+ FX_BOOL bOnlyBrk = FALSE);
+ void SplitTextLine(CFX_TxtLine* pCurLine,
+ CFX_TxtLine* pNextLine,
+ FX_BOOL bAllChars = FALSE);
};
#endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_
diff --git a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_unicode.cpp b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_unicode.cpp
index a4cbee03b7e..94f06253ac6 100644
--- a/chromium/third_party/pdfium/xfa/fgas/layout/fgas_unicode.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/layout/fgas_unicode.cpp
@@ -7,8 +7,8 @@
#include "xfa/fgas/layout/fgas_unicode.h"
void FX_TEXTLAYOUT_PieceSort(CFX_TPOArray& tpos, int32_t iStart, int32_t iEnd) {
- FXSYS_assert(iStart > -1 && iStart < tpos.GetSize());
- FXSYS_assert(iEnd > -1 && iEnd < tpos.GetSize());
+ ASSERT(iStart > -1 && iStart < tpos.GetSize());
+ ASSERT(iEnd > -1 && iEnd < tpos.GetSize());
if (iStart >= iEnd) {
return;
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.cpp b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.cpp
index 456e476dee6..f3c560b823d 100644
--- a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.cpp
@@ -31,23 +31,23 @@ const int64_t g_FXMillisecondsPerMinute = 60000;
const int64_t g_FXMillisecondsPerHour = 3600000;
const int64_t g_FXMillisecondsPerDay = 86400000;
FX_BOOL FX_IsLeapYear(int32_t iYear) {
- FXSYS_assert(iYear != 0);
+ ASSERT(iYear != 0);
return ((iYear % 4) == 0 && (iYear % 100) != 0) || (iYear % 400) == 0;
}
int32_t FX_DaysInYear(int32_t iYear) {
- FXSYS_assert(iYear != 0);
+ ASSERT(iYear != 0);
return FX_IsLeapYear(iYear) ? g_FXDaysPerLeapYear : g_FXDaysPerYear;
}
uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth) {
- FXSYS_assert(iYear != 0);
- FXSYS_assert(iMonth >= 1 && iMonth <= 12);
+ ASSERT(iYear != 0);
+ ASSERT(iMonth >= 1 && iMonth <= 12);
const uint8_t* p =
FX_IsLeapYear(iYear) ? g_FXDaysPerLeapMonth : g_FXDaysPerMonth;
return p[iMonth - 1];
}
static int32_t FX_DaysBeforeMonthInYear(int32_t iYear, uint8_t iMonth) {
- FXSYS_assert(iYear != 0);
- FXSYS_assert(iMonth >= 1 && iMonth <= 12);
+ ASSERT(iYear != 0);
+ ASSERT(iMonth >= 1 && iMonth <= 12);
const int32_t* p =
FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth;
return p[iMonth - 1];
@@ -56,9 +56,9 @@ static int64_t FX_DateToDays(int32_t iYear,
uint8_t iMonth,
uint8_t iDay,
FX_BOOL bIncludeThisDay = FALSE) {
- FXSYS_assert(iYear != 0);
- FXSYS_assert(iMonth >= 1 && iMonth <= 12);
- FXSYS_assert(iDay >= 1 && iDay <= FX_DaysInMonth(iYear, iMonth));
+ ASSERT(iYear != 0);
+ ASSERT(iMonth >= 1 && iMonth <= 12);
+ ASSERT(iDay >= 1 && iDay <= FX_DaysInMonth(iYear, iMonth));
int64_t iDays = FX_DaysBeforeMonthInYear(iYear, iMonth);
iDays += iDay;
if (!bIncludeThisDay) {
@@ -197,10 +197,10 @@ void CFX_Unitime::Set(int32_t year,
uint8_t minute,
uint8_t second,
uint16_t millisecond) {
- FXSYS_assert(hour <= 23);
- FXSYS_assert(minute <= 59);
- FXSYS_assert(second <= 59);
- FXSYS_assert(millisecond <= 999);
+ ASSERT(hour <= 23);
+ ASSERT(minute <= 59);
+ ASSERT(second <= 59);
+ ASSERT(millisecond <= 999);
m_iUnitime = (int64_t)hour * g_FXMillisecondsPerHour +
(int64_t)minute * g_FXMillisecondsPerMinute +
(int64_t)second * g_FXMillisecondsPerSecond + millisecond;
diff --git a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.h b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.h
index df2989fc583..7c8f111bfc9 100644
--- a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.h
+++ b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_datetime.h
@@ -205,37 +205,6 @@ struct FX_DATETIME {
} Time;
};
-struct FX_DATETIMEZONE {
- union {
- struct {
- union {
- struct {
- int32_t year;
- uint8_t month;
- uint8_t day;
- };
- FX_DATE date;
- };
- union {
- struct {
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- uint16_t millisecond;
- };
- FX_TIME time;
- };
- };
- FX_DATETIME dt;
- };
- union {
- struct {
- int8_t tzHour;
- uint8_t tzMinute;
- };
- FX_TIMEZONE tz;
- };
-};
#if _FX_OS_ != _FX_ANDROID_
#pragma pack(pop)
#endif
diff --git a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.cpp b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.cpp
index 878cbf6aeb8..bb4fe93ba3f 100644
--- a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.cpp
@@ -60,21 +60,11 @@ static const FX_WCHAR gs_wsTimeSymbols[] = L"hHkKMSFAzZ";
static const FX_WCHAR gs_wsDateSymbols[] = L"DJMEeGgYwW";
static const FX_WCHAR gs_wsConstChars[] = L",-:/. ";
-static FX_STRSIZE FX_Local_Find(const CFX_WideStringC& wsSymbols,
- FX_WCHAR ch,
- FX_STRSIZE nStart = 0) {
- FX_STRSIZE nLength = wsSymbols.GetLength();
- if (nLength < 1 || nStart > nLength) {
- return -1;
- }
- const FX_WCHAR* lpsz =
- (const FX_WCHAR*)FXSYS_wcschr(wsSymbols.raw_str() + nStart, ch);
- return (lpsz == NULL) ? -1 : (FX_STRSIZE)(lpsz - wsSymbols.raw_str());
-}
static const FX_WCHAR* const gs_LocalNumberSymbols[] = {
L"decimal", L"grouping", L"percent", L"minus",
L"zero", L"currencySymbol", L"currencyName",
};
+
IFX_Locale* IFX_Locale::Create(CXML_Element* pLocaleData) {
return new CFX_Locale(pLocaleData);
}
@@ -111,12 +101,12 @@ void CFX_Locale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
CFX_ByteString bsSpace;
CFX_WideString wsName = gs_LocalNumberSymbols[eType];
CXML_Element* pNumberSymbols =
- m_pElement->GetElement(bsSpace.AsByteStringC(), "numberSymbols");
+ m_pElement->GetElement(bsSpace.AsStringC(), "numberSymbols");
if (!pNumberSymbols) {
return;
}
- wsNumSymbol = FX_GetXMLContent(bsSpace.AsByteStringC(), pNumberSymbols,
- "numberSymbol", wsName.AsWideStringC());
+ wsNumSymbol = FX_GetXMLContent(bsSpace.AsStringC(), pNumberSymbols,
+ "numberSymbol", wsName.AsStringC());
}
void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const {
if (!m_pElement) {
@@ -124,7 +114,7 @@ void CFX_Locale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const {
}
CFX_ByteString bsSpace;
CXML_Element* pNumberSymbols =
- m_pElement->GetElement(bsSpace.AsByteStringC(), "dateTimeSymbols");
+ m_pElement->GetElement(bsSpace.AsStringC(), "dateTimeSymbols");
if (!pNumberSymbols) {
return;
}
@@ -138,22 +128,22 @@ static void FX_GetCalendarSymbol(CXML_Element* pXmlElement,
CFX_ByteString bsSpace;
CFX_ByteString pstrSymbolNames = symbol_type + "Names";
CXML_Element* pChild =
- pXmlElement->GetElement(bsSpace.AsByteStringC(), "calendarSymbols");
+ pXmlElement->GetElement(bsSpace.AsStringC(), "calendarSymbols");
if (!pChild) {
return;
}
- CXML_Element* pSymbolNames = pChild->GetElement(
- bsSpace.AsByteStringC(), pstrSymbolNames.AsByteStringC());
+ CXML_Element* pSymbolNames =
+ pChild->GetElement(bsSpace.AsStringC(), pstrSymbolNames.AsStringC());
if (!pSymbolNames) {
return;
}
if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) {
- pSymbolNames = pChild->GetElement(bsSpace.AsByteStringC(),
- pstrSymbolNames.AsByteStringC(), 1);
+ pSymbolNames =
+ pChild->GetElement(bsSpace.AsStringC(), pstrSymbolNames.AsStringC(), 1);
}
if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) {
CXML_Element* pSymbolName = pSymbolNames->GetElement(
- bsSpace.AsByteStringC(), symbol_type.AsByteStringC(), index);
+ bsSpace.AsStringC(), symbol_type.AsStringC(), index);
if (pSymbolName) {
wsName = pSymbolName->GetContent(0);
}
@@ -217,7 +207,7 @@ void CFX_Locale::GetTimeZone(FX_TIMEZONE& tz) const {
CXML_Element* pxmlTimeZone = m_pElement->GetElement("", "timeZone");
if (pxmlTimeZone) {
CFX_WideString wsTimeZone = pxmlTimeZone->GetContent(0);
- FX_ParseTimeZone(wsTimeZone, wsTimeZone.GetLength(), tz);
+ FX_ParseTimeZone(wsTimeZone.c_str(), wsTimeZone.GetLength(), tz);
}
}
void CFX_Locale::GetEraName(CFX_WideString& wsEraName, FX_BOOL bAD) const {
@@ -232,13 +222,13 @@ static void FX_GetPattern(CXML_Element* pXmlElement,
CFX_WideString& wsPattern) {
CFX_ByteString bsSpace;
CXML_Element* pDatePatterns = pXmlElement->GetElement(
- bsSpace.AsByteStringC(), (bsCategory + "s").AsByteStringC());
+ bsSpace.AsStringC(), (bsCategory + "s").AsStringC());
if (!pDatePatterns) {
return;
}
- wsPattern = FX_GetXMLContent(bsSpace.AsByteStringC(), pDatePatterns,
- bsCategory.AsByteStringC(),
- wsSubCategory.AsWideStringC());
+ wsPattern =
+ FX_GetXMLContent(bsSpace.AsStringC(), pDatePatterns,
+ bsCategory.AsStringC(), wsSubCategory.AsStringC());
}
static void FX_GetDateTimePattern(CXML_Element* pXmlElement,
const CFX_ByteString& bsCategory,
@@ -315,7 +305,7 @@ static FX_BOOL FX_WStringToNumeric(const CFX_WideString& wsValue,
int32_t cc = 0;
bool bNegative = false;
bool bExpSign = false;
- const FX_WCHAR* str = (const FX_WCHAR*)wsValue;
+ const FX_WCHAR* str = wsValue.c_str();
int32_t len = wsValue.GetLength();
while (cc < len && FX_IsSpace(str[cc]))
cc++;
@@ -456,20 +446,13 @@ CFX_WideString CFX_LCNumeric::ToString(int32_t nTreading,
return wsResult;
}
-IFX_FormatString* IFX_FormatString::Create(IFX_LocaleMgr* pLocaleMgr,
- FX_BOOL bUseLCID) {
- if (!pLocaleMgr) {
- return NULL;
- }
- return new CFX_FormatString(pLocaleMgr, bUseLCID);
-}
CFX_FormatString::CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID)
: m_pLocaleMgr(pLocaleMgr), m_bUseLCID(bUseLCID) {}
CFX_FormatString::~CFX_FormatString() {}
void CFX_FormatString::SplitFormatString(const CFX_WideString& wsFormatString,
CFX_WideStringArray& wsPatterns) {
int32_t iStrLen = wsFormatString.GetLength();
- const FX_WCHAR* pStr = (const FX_WCHAR*)wsFormatString;
+ const FX_WCHAR* pStr = wsFormatString.c_str();
const FX_WCHAR* pToken = pStr;
const FX_WCHAR* pEnd = pStr + iStrLen;
FX_BOOL iQuote = FALSE;
@@ -580,12 +563,13 @@ FX_LOCALECATEGORY CFX_FormatString::GetCategory(
FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown;
int32_t ccf = 0;
int32_t iLenf = wsPattern.GetLength();
- const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern;
+ const FX_WCHAR* pStr = wsPattern.c_str();
FX_BOOL bBraceOpen = FALSE;
+ CFX_WideStringC wsConstChars(gs_wsConstChars);
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
FX_GetLiteralText(pStr, ccf, iLenf);
- } else if (!bBraceOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) {
+ } else if (!bBraceOpen && wsConstChars.Find(pStr[ccf]) == -1) {
CFX_WideString wsCategory(pStr[ccf]);
ccf++;
while (TRUE) {
@@ -602,8 +586,7 @@ FX_LOCALECATEGORY CFX_FormatString::GetCategory(
wsCategory += pStr[ccf];
ccf++;
}
- uint32_t dwHash =
- FX_HashCode_String_GetW(wsCategory, wsCategory.GetLength());
+ uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringC(), false);
if (dwHash == FX_LOCALECATEGORY_DateHash) {
if (eCategory == FX_LOCALECATEGORY_Time) {
return FX_LOCALECATEGORY_DateTime;
@@ -640,13 +623,13 @@ static uint16_t FX_WStringToLCID(const FX_WCHAR* pstrLCID) {
return (uint16_t)wcstol((wchar_t*)pstrLCID, &pEnd, 16);
}
uint16_t CFX_FormatString::GetLCID(const CFX_WideString& wsPattern) {
- return FX_WStringToLCID(GetLocaleName(wsPattern));
+ return FX_WStringToLCID(GetLocaleName(wsPattern).c_str());
}
CFX_WideString CFX_FormatString::GetLocaleName(
const CFX_WideString& wsPattern) {
int32_t ccf = 0;
int32_t iLenf = wsPattern.GetLength();
- const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern;
+ const FX_WCHAR* pStr = wsPattern.c_str();
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
FX_GetLiteralText(pStr, ccf, iLenf);
@@ -668,14 +651,15 @@ IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern,
IFX_Locale* pLocale = NULL;
int32_t ccf = 0;
int32_t iLenf = wsPattern.GetLength();
- const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern;
+ const FX_WCHAR* pStr = wsPattern.c_str();
FX_BOOL bBrackOpen = FALSE;
+ CFX_WideStringC wsConstChars(gs_wsConstChars);
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
int32_t iCurChar = ccf;
FX_GetLiteralText(pStr, ccf, iLenf);
wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
- } else if (!bBrackOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) {
+ } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == -1) {
CFX_WideString wsSearchCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
@@ -693,7 +677,7 @@ IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern,
while (ccf < iLenf && pStr[ccf] != ')') {
wsLCID += pStr[ccf++];
}
- pLocale = GetPatternLocale(wsLCID.AsWideStringC());
+ pLocale = GetPatternLocale(wsLCID);
} else if (pStr[ccf] == '{') {
bBrackOpen = TRUE;
break;
@@ -724,15 +708,16 @@ IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern,
IFX_Locale* pLocale = NULL;
int32_t ccf = 0;
int32_t iLenf = wsPattern.GetLength();
- const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern;
+ const FX_WCHAR* pStr = wsPattern.c_str();
FX_BOOL bFindDot = FALSE;
FX_BOOL bBrackOpen = FALSE;
+ CFX_WideStringC wsConstChars(gs_wsConstChars);
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
int32_t iCurChar = ccf;
FX_GetLiteralText(pStr, ccf, iLenf);
wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
- } else if (!bBrackOpen && FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) {
+ } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == -1) {
CFX_WideString wsCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
@@ -752,7 +737,7 @@ IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern,
while (ccf < iLenf && pStr[ccf] != ')') {
wsLCID += pStr[ccf++];
}
- pLocale = GetPatternLocale(wsLCID.AsWideStringC());
+ pLocale = GetPatternLocale(wsLCID);
} else if (pStr[ccf] == '{') {
bBrackOpen = TRUE;
break;
@@ -763,7 +748,7 @@ IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern,
wsSubCategory += pStr[ccf++];
}
uint32_t dwSubHash =
- FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength());
+ FX_HashCode_GetW(wsSubCategory.AsStringC(), false);
FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal;
for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) {
if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) {
@@ -772,11 +757,11 @@ IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern,
break;
}
}
- wsSubCategory.Empty();
+ wsSubCategory.clear();
if (!pLocale) {
pLocale = m_pLocaleMgr->GetDefLocale();
}
- FXSYS_assert(pLocale != NULL);
+ ASSERT(pLocale != NULL);
pLocale->GetNumPattern(eSubCategory, wsSubCategory);
iDotIndex = wsSubCategory.Find('.');
if (iDotIndex > 0) {
@@ -823,14 +808,13 @@ static FX_BOOL FX_GetNumericDotIndex(const CFX_WideString& wsNum,
int32_t& iDotIndex) {
int32_t ccf = 0;
int32_t iLenf = wsNum.GetLength();
- const FX_WCHAR* pStr = (const FX_WCHAR*)wsNum;
+ const FX_WCHAR* pStr = wsNum.c_str();
int32_t iLenDot = wsDotSymbol.GetLength();
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
FX_GetLiteralText(pStr, ccf, iLenf);
} else if (ccf + iLenDot <= iLenf &&
- !FXSYS_wcsncmp(pStr + ccf, (const FX_WCHAR*)wsDotSymbol,
- iLenDot)) {
+ !FXSYS_wcsncmp(pStr + ccf, wsDotSymbol.c_str(), iLenDot)) {
iDotIndex = ccf;
return TRUE;
}
@@ -846,7 +830,7 @@ static FX_BOOL FX_GetNumericDotIndex(const CFX_WideString& wsNum,
FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText,
const CFX_WideString& wsPattern,
CFX_WideString& wsValue) {
- wsValue.Empty();
+ wsValue.clear();
if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) {
return FALSE;
}
@@ -856,9 +840,9 @@ FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText,
return FALSE;
}
int32_t iText = 0, iPattern = 0;
- const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText;
+ const FX_WCHAR* pStrText = wsSrcText.c_str();
int32_t iLenText = wsSrcText.GetLength();
- const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat;
+ const FX_WCHAR* pStrPattern = wsTextFormat.c_str();
int32_t iLenPattern = wsTextFormat.GetLength();
while (iPattern < iLenPattern && iText < iLenText) {
switch (pStrPattern[iPattern]) {
@@ -867,8 +851,7 @@ FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText,
FX_GetLiteralText(pStrPattern, iPattern, iLenPattern);
int32_t iLiteralLen = wsLiteral.GetLength();
if (iText + iLiteralLen > iLenText ||
- FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral,
- iLiteralLen)) {
+ FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) {
wsValue = wsSrcText;
return FALSE;
}
@@ -940,9 +923,9 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus);
int32_t iMinusLen = wsMinus.GetLength();
int cc = 0, ccf = 0;
- const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum;
+ const FX_WCHAR* str = wsSrcNum.c_str();
int len = wsSrcNum.GetLength();
- const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat;
+ const FX_WCHAR* strf = wsNumFormat.c_str();
int lenf = wsNumFormat.GetLength();
double dbRetValue = 0;
double coeff = 1;
@@ -964,8 +947,8 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf);
int32_t iLiteralLen = wsLiteral.GetLength();
cc -= iLiteralLen - 1;
- if (cc < 0 || FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral,
- iLiteralLen)) {
+ if (cc < 0 ||
+ FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
cc--;
@@ -1002,8 +985,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc--;
} else {
cc -= iMinusLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
cc--;
@@ -1016,8 +998,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc--;
} else {
cc -= iMinusLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
cc--;
@@ -1043,7 +1024,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
continue;
} else if (cc - iMinusLen + 1 > 0 &&
!FXSYS_wcsncmp(str + (cc - iMinusLen + 1),
- (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ wsMinus.c_str(), iMinusLen)) {
bExpSign = TRUE;
cc -= iMinusLen;
} else {
@@ -1060,8 +1041,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
wsSymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
cc -= iSymbolLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) {
return FALSE;
}
cc--;
@@ -1125,7 +1105,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
int32_t iSysmbolLen = wsSymbol.GetLength();
cc -= iSysmbolLen - 1;
if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSysmbolLen)) {
+ FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) {
return FALSE;
}
cc--;
@@ -1146,8 +1126,8 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
if (cc >= 0) {
cc -= iGroupLen - 1;
if (cc >= 0 &&
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol,
- iGroupLen) == 0) {
+ FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) ==
+ 0) {
cc--;
} else {
cc += iGroupLen - 1;
@@ -1192,8 +1172,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf);
int32_t iLiteralLen = wsLiteral.GetLength();
cc -= iLiteralLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, iLiteralLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
cc--;
@@ -1234,8 +1213,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc--;
} else {
cc -= iMinusLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
cc--;
@@ -1248,8 +1226,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc--;
} else {
cc -= iMinusLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
cc--;
@@ -1274,8 +1251,8 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc--;
continue;
} else if (cc - iMinusLen + 1 > 0 &&
- !FXSYS_wcsncmp(str + (cc - iMinusLen + 1),
- (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), wsMinus.c_str(),
+ iMinusLen)) {
bExpSign = TRUE;
cc -= iMinusLen;
} else {
@@ -1291,8 +1268,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
cc -= iSymbolLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) {
return FALSE;
}
cc--;
@@ -1355,8 +1331,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol);
int32_t iSysmbolLen = wsSymbol.GetLength();
cc -= iSysmbolLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSysmbolLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) {
return FALSE;
}
cc--;
@@ -1369,8 +1344,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
if (cc >= 0) {
cc -= iGroupLen - 1;
if (cc >= 0 &&
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol,
- iGroupLen) == 0) {
+ FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) {
cc--;
} else {
cc += iGroupLen - 1;
@@ -1417,8 +1391,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf);
int32_t iLiteralLen = wsLiteral.GetLength();
if (cc + iLiteralLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral,
- iLiteralLen)) {
+ FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
cc += iLiteralLen;
@@ -1461,7 +1434,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc++;
} else {
if (cc + iMinusLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
bNeg = TRUE;
@@ -1474,7 +1447,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc++;
} else {
if (cc + iMinusLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
bNeg = TRUE;
@@ -1512,7 +1485,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
wsSymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
if (cc + iSymbolLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) {
+ FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) {
return FALSE;
}
cc += iSymbolLen;
@@ -1567,8 +1540,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol);
int32_t iSysmbolLen = wsSymbol.GetLength();
if (cc + iSysmbolLen <= len &&
- !FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol,
- iSysmbolLen)) {
+ !FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) {
cc += iSysmbolLen;
}
ccf++;
@@ -1586,8 +1558,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
} break;
case ',': {
if (cc + iGroupLen <= len &&
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol,
- iGroupLen) == 0) {
+ FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) {
cc += iGroupLen;
}
ccf++;
@@ -1636,7 +1607,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
}
void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult) {
int32_t iCount = wsNum.GetLength();
- const FX_WCHAR* pStr = (const FX_WCHAR*)wsNum;
+ const FX_WCHAR* pStr = wsNum.c_str();
FX_WCHAR* pDst = wsResult.GetBuffer(iCount);
int32_t nIndex = 0;
FX_BOOL bMinus = FALSE;
@@ -1684,7 +1655,7 @@ void FX_ParseNumString(const CFX_WideString& wsNum, CFX_WideString& wsResult) {
FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
const CFX_WideString& wsPattern,
CFX_WideString& wsValue) {
- wsValue.Empty();
+ wsValue.clear();
if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) {
return FALSE;
}
@@ -1706,9 +1677,9 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus);
int32_t iMinusLen = wsMinus.GetLength();
int cc = 0, ccf = 0;
- const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum;
+ const FX_WCHAR* str = wsSrcNum.c_str();
int len = wsSrcNum.GetLength();
- const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat;
+ const FX_WCHAR* strf = wsNumFormat.c_str();
int lenf = wsNumFormat.GetLength();
FX_BOOL bHavePercentSymbol = FALSE;
FX_BOOL bNeg = FALSE;
@@ -1727,8 +1698,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf);
int32_t iLiteralLen = wsLiteral.GetLength();
cc -= iLiteralLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, iLiteralLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
cc--;
@@ -1766,8 +1736,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc--;
} else {
cc -= iMinusLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
cc--;
@@ -1780,8 +1749,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc--;
} else {
cc -= iMinusLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
cc--;
@@ -1806,8 +1774,8 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc--;
continue;
} else if (cc - iMinusLen + 1 > 0 &&
- !FXSYS_wcsncmp(str + (cc - iMinusLen + 1),
- (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), wsMinus.c_str(),
+ iMinusLen)) {
bExpSign = TRUE;
cc -= iMinusLen;
} else {
@@ -1823,8 +1791,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
cc -= iSymbolLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) {
return FALSE;
}
cc--;
@@ -1887,8 +1854,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol);
int32_t iSysmbolLen = wsSymbol.GetLength();
cc -= iSysmbolLen - 1;
- if (cc < 0 ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSysmbolLen)) {
+ if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) {
return FALSE;
}
cc--;
@@ -1901,8 +1867,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
if (cc >= 0) {
cc -= iGroupLen - 1;
if (cc >= 0 &&
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol,
- iGroupLen) == 0) {
+ FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) {
cc--;
} else {
cc += iGroupLen - 1;
@@ -1957,8 +1922,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf);
int32_t iLiteralLen = wsLiteral.GetLength();
if (cc + iLiteralLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral,
- iLiteralLen)) {
+ FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
cc += iLiteralLen;
@@ -1996,7 +1960,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc++;
} else {
if (cc + iMinusLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
bNeg = TRUE;
@@ -2009,7 +1973,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
cc++;
} else {
if (cc + iMinusLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsMinus, iMinusLen)) {
+ FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) {
return FALSE;
}
bNeg = TRUE;
@@ -2047,7 +2011,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
wsSymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
if (cc + iSymbolLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol, iSymbolLen)) {
+ FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) {
return FALSE;
}
cc += iSymbolLen;
@@ -2102,8 +2066,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol);
int32_t iSysmbolLen = wsSymbol.GetLength();
if (cc + iSysmbolLen <= len &&
- !FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsSymbol,
- iSysmbolLen)) {
+ !FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) {
cc += iSysmbolLen;
}
ccf++;
@@ -2120,8 +2083,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
} break;
case ',': {
if (cc + iGroupLen <= len &&
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsGroupSymbol,
- iGroupLen) == 0) {
+ FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) {
cc += iGroupLen;
}
ccf++;
@@ -2157,7 +2119,7 @@ FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
}
}
if (iExponent || bHavePercentSymbol) {
- CFX_Decimal decimal = CFX_Decimal(wsValue.AsWideStringC());
+ CFX_Decimal decimal = CFX_Decimal(wsValue.AsStringC());
if (iExponent) {
decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent));
}
@@ -2181,16 +2143,17 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat(
FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown;
int32_t ccf = 0;
int32_t iLenf = wsPattern.GetLength();
- const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern;
+ const FX_WCHAR* pStr = wsPattern.c_str();
int32_t iFindCategory = 0;
FX_BOOL bBraceOpen = FALSE;
+ CFX_WideStringC wsConstChars(gs_wsConstChars);
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
int32_t iCurChar = ccf;
FX_GetLiteralText(pStr, ccf, iLenf);
wsTempPattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
} else if (!bBraceOpen && iFindCategory != 3 &&
- FX_Local_Find(gs_wsConstChars, pStr[ccf]) < 0) {
+ wsConstChars.Find(pStr[ccf]) == -1) {
CFX_WideString wsCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
@@ -2229,7 +2192,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat(
while (ccf < iLenf && pStr[ccf] != ')') {
wsLCID += pStr[ccf++];
}
- pLocale = GetPatternLocale(wsLCID.AsWideStringC());
+ pLocale = GetPatternLocale(wsLCID);
} else if (pStr[ccf] == '{') {
bBraceOpen = TRUE;
break;
@@ -2240,7 +2203,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat(
wsSubCategory += pStr[ccf++];
}
uint32_t dwSubHash =
- FX_HashCode_String_GetW(wsSubCategory, wsSubCategory.GetLength());
+ FX_HashCode_GetW(wsSubCategory.AsStringC(), false);
FX_LOCALEDATETIMESUBCATEGORY eSubCategory =
FX_LOCALEDATETIMESUBCATEGORY_Medium;
for (int32_t i = 0; i < g_iFXLocaleDateTimeSubCatCount; i++) {
@@ -2254,7 +2217,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat(
if (!pLocale) {
pLocale = m_pLocaleMgr->GetDefLocale();
}
- FXSYS_assert(pLocale != NULL);
+ ASSERT(pLocale != NULL);
switch (eCategory) {
case FX_LOCALECATEGORY_Date:
pLocale->GetDatePattern(eSubCategory, wsDatePattern);
@@ -2272,7 +2235,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat(
default:
break;
}
- wsTempPattern.Empty();
+ wsTempPattern.clear();
continue;
}
ccf++;
@@ -2285,7 +2248,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat(
} else if (eCategory == FX_LOCALECATEGORY_Date) {
wsDatePattern = wsTempPattern;
}
- wsTempPattern.Empty();
+ wsTempPattern.clear();
}
} else {
wsTempPattern += pStr[ccf];
@@ -2303,7 +2266,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat(
pLocale = m_pLocaleMgr->GetDefLocale();
}
if (!iFindCategory) {
- wsTimePattern.Empty();
+ wsTimePattern.clear();
wsDatePattern = wsPattern;
}
return (FX_DATETIMETYPE)iFindCategory;
@@ -2317,36 +2280,36 @@ static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate,
int32_t month = 1;
int32_t day = 1;
int32_t ccf = 0;
- const FX_WCHAR* str = (const FX_WCHAR*)wsDate;
+ const FX_WCHAR* str = wsDate.c_str();
int32_t len = wsDate.GetLength();
- const FX_WCHAR* strf = (const FX_WCHAR*)wsDatePattern;
+ const FX_WCHAR* strf = wsDatePattern.c_str();
int32_t lenf = wsDatePattern.GetLength();
+ CFX_WideStringC wsDateSymbols(gs_wsDateSymbols);
while (cc < len && ccf < lenf) {
if (strf[ccf] == '\'') {
CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf);
int32_t iLiteralLen = wsLiteral.GetLength();
if (cc + iLiteralLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, iLiteralLen)) {
+ FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
cc += iLiteralLen;
ccf++;
continue;
- } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) {
- if (strf[ccf] != str[cc]) {
+ } else if (wsDateSymbols.Find(strf[ccf]) == -1) {
+ if (strf[ccf] != str[cc])
return FALSE;
- }
cc++;
ccf++;
continue;
}
uint32_t dwSymbolNum = 1;
- uint32_t dwSymbol = strf[ccf++];
- while (ccf < lenf && strf[ccf] == dwSymbol) {
+ FX_WCHAR dwCharSymbol = strf[ccf++];
+ while (ccf < lenf && strf[ccf] == dwCharSymbol) {
ccf++;
dwSymbolNum++;
}
- dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0');
+ uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) {
if (!FX_IsDigit(str[cc])) {
return FALSE;
@@ -2395,7 +2358,7 @@ static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate,
if (wsMonthNameAbbr.IsEmpty()) {
continue;
}
- if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthNameAbbr, str + cc,
+ if (!FXSYS_wcsncmp(wsMonthNameAbbr.c_str(), str + cc,
wsMonthNameAbbr.GetLength())) {
break;
}
@@ -2412,7 +2375,7 @@ static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate,
if (wsMonthName.IsEmpty()) {
continue;
}
- if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthName, str + cc,
+ if (!FXSYS_wcsncmp(wsMonthName.c_str(), str + cc,
wsMonthName.GetLength())) {
break;
}
@@ -2431,7 +2394,7 @@ static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate,
if (wsDayNameAbbr.IsEmpty()) {
continue;
}
- if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayNameAbbr, str + cc,
+ if (!FXSYS_wcsncmp(wsDayNameAbbr.c_str(), str + cc,
wsDayNameAbbr.GetLength())) {
break;
}
@@ -2447,7 +2410,7 @@ static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate,
if (wsDayName == L"") {
continue;
}
- if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayName, str + cc,
+ if (!FXSYS_wcsncmp(wsDayName.c_str(), str + cc,
wsDayName.GetLength())) {
break;
}
@@ -2534,38 +2497,38 @@ static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime,
uint8_t second = 0;
uint16_t millisecond = 0;
int32_t ccf = 0;
- const FX_WCHAR* str = (const FX_WCHAR*)wsTime;
+ const FX_WCHAR* str = wsTime.c_str();
int len = wsTime.GetLength();
- const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern;
+ const FX_WCHAR* strf = wsTimePattern.c_str();
int lenf = wsTimePattern.GetLength();
FX_BOOL bHasA = FALSE;
FX_BOOL bPM = FALSE;
+ CFX_WideStringC wsTimeSymbols(gs_wsTimeSymbols);
while (cc < len && ccf < lenf) {
if (strf[ccf] == '\'') {
CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf);
int32_t iLiteralLen = wsLiteral.GetLength();
if (cc + iLiteralLen > len ||
- FXSYS_wcsncmp(str + cc, (const FX_WCHAR*)wsLiteral, iLiteralLen)) {
+ FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
cc += iLiteralLen;
ccf++;
continue;
- } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) == -1) {
- if (strf[ccf] != str[cc]) {
+ } else if (wsTimeSymbols.Find(strf[ccf]) == -1) {
+ if (strf[ccf] != str[cc])
return FALSE;
- }
cc++;
ccf++;
continue;
}
uint32_t dwSymbolNum = 1;
- uint32_t dwSymbol = strf[ccf++];
- while (ccf < lenf && strf[ccf] == dwSymbol) {
+ FX_WCHAR dwCharSymbol = strf[ccf++];
+ while (ccf < lenf && strf[ccf] == dwCharSymbol) {
ccf++;
dwSymbolNum++;
}
- dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0');
+ uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'k', '1') ||
dwSymbol == FXBSTR_ID(0, 0, 'H', '1') ||
dwSymbol == FXBSTR_ID(0, 0, 'h', '1') ||
@@ -2771,9 +2734,9 @@ FX_BOOL CFX_FormatString::ParseZero(const CFX_WideString& wsSrcText,
CFX_WideString wsTextFormat;
GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat);
int32_t iText = 0, iPattern = 0;
- const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText;
+ const FX_WCHAR* pStrText = wsSrcText.c_str();
int32_t iLenText = wsSrcText.GetLength();
- const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat;
+ const FX_WCHAR* pStrPattern = wsTextFormat.c_str();
int32_t iLenPattern = wsTextFormat.GetLength();
while (iPattern < iLenPattern && iText < iLenText) {
if (pStrPattern[iPattern] == '\'') {
@@ -2781,8 +2744,7 @@ FX_BOOL CFX_FormatString::ParseZero(const CFX_WideString& wsSrcText,
FX_GetLiteralText(pStrPattern, iPattern, iLenPattern);
int32_t iLiteralLen = wsLiteral.GetLength();
if (iText + iLiteralLen > iLenText ||
- FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral,
- iLiteralLen)) {
+ FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
iText += iLiteralLen;
@@ -2802,9 +2764,9 @@ FX_BOOL CFX_FormatString::ParseNull(const CFX_WideString& wsSrcText,
CFX_WideString wsTextFormat;
GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat);
int32_t iText = 0, iPattern = 0;
- const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText;
+ const FX_WCHAR* pStrText = wsSrcText.c_str();
int32_t iLenText = wsSrcText.GetLength();
- const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat;
+ const FX_WCHAR* pStrPattern = wsTextFormat.c_str();
int32_t iLenPattern = wsTextFormat.GetLength();
while (iPattern < iLenPattern && iText < iLenText) {
if (pStrPattern[iPattern] == '\'') {
@@ -2812,8 +2774,7 @@ FX_BOOL CFX_FormatString::ParseNull(const CFX_WideString& wsSrcText,
FX_GetLiteralText(pStrPattern, iPattern, iLenPattern);
int32_t iLiteralLen = wsLiteral.GetLength();
if (iText + iLiteralLen > iLenText ||
- FXSYS_wcsncmp(pStrText + iText, (const FX_WCHAR*)wsLiteral,
- iLiteralLen)) {
+ FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) {
return FALSE;
}
iText += iLiteralLen;
@@ -2841,8 +2802,8 @@ FX_BOOL CFX_FormatString::FormatText(const CFX_WideString& wsSrcText,
CFX_WideString wsTextFormat;
GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat);
int32_t iText = 0, iPattern = 0;
- const FX_WCHAR* pStrText = (const FX_WCHAR*)wsSrcText;
- const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat;
+ const FX_WCHAR* pStrText = wsSrcText.c_str();
+ const FX_WCHAR* pStrPattern = wsTextFormat.c_str();
int32_t iLenPattern = wsTextFormat.GetLength();
while (iPattern < iLenPattern) {
switch (pStrPattern[iPattern]) {
@@ -2920,14 +2881,14 @@ FX_BOOL CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
return FALSE;
}
int32_t cc = 0, ccf = 0;
- const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat;
+ const FX_WCHAR* strf = wsNumFormat.c_str();
int lenf = wsNumFormat.GetLength();
- CFX_WideString wsSrcNum = wsInputNum;
+ CFX_WideString wsSrcNum(wsInputNum);
wsSrcNum.TrimLeft('0');
if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') {
wsSrcNum.Insert(0, '0');
}
- CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsWideStringC());
+ CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC());
if (dwNumStyle & FX_NUMSTYLE_Percent) {
decimal = decimal * CFX_Decimal(100);
wsSrcNum = decimal;
@@ -2990,7 +2951,7 @@ FX_BOOL CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
wsSrcNum.Delete(0, 1);
}
FX_BOOL bAddNeg = FALSE;
- const FX_WCHAR* str = (const FX_WCHAR*)wsSrcNum;
+ const FX_WCHAR* str = wsSrcNum.c_str();
int len = wsSrcNum.GetLength();
int dot_index = wsSrcNum.Find('.');
if (dot_index == -1) {
@@ -3155,7 +3116,7 @@ FX_BOOL CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
}
if (cc >= 0) {
int nPos = dot_index % 3;
- wsOutput.Empty();
+ wsOutput.clear();
for (int32_t i = 0; i < dot_index; i++) {
if (i % 3 == nPos && i != 0) {
wsOutput += wsGroupSymbol;
@@ -3353,7 +3314,7 @@ FX_BOOL CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum,
return FALSE;
}
int32_t cc = 0, ccf = 0;
- const FX_WCHAR* strf = (const FX_WCHAR*)wsNumFormat;
+ const FX_WCHAR* strf = wsNumFormat.c_str();
int lenf = wsNumFormat.GetLength();
double dbOrgRaw = lcNum.GetDouble();
double dbRetValue = dbOrgRaw;
@@ -3416,7 +3377,7 @@ FX_BOOL CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum,
wsNumeric.Delete(0, 1);
}
FX_BOOL bAddNeg = FALSE;
- const FX_WCHAR* str = (const FX_WCHAR*)wsNumeric;
+ const FX_WCHAR* str = wsNumeric.c_str();
int len = wsNumeric.GetLength();
int dot_index = wsNumeric.Find('.');
if (dot_index == -1) {
@@ -3572,7 +3533,7 @@ FX_BOOL CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum,
}
if (cc >= 0) {
int nPos = dot_index % 3;
- wsOutput.Empty();
+ wsOutput.clear();
for (int32_t i = 0; i < dot_index; i++) {
if (i % 3 == nPos && i != 0) {
wsOutput += wsGroupSymbol;
@@ -3755,7 +3716,7 @@ FX_BOOL CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum,
if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) {
return FALSE;
}
- return FormatStrNum(wsSrcNum.AsWideStringC(), wsPattern, wsOutput);
+ return FormatStrNum(wsSrcNum.AsStringC(), wsPattern, wsOutput);
}
FX_BOOL CFX_FormatString::FormatNum(FX_FLOAT fNum,
const CFX_WideString& wsPattern,
@@ -3773,7 +3734,7 @@ FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate,
int32_t day = 1;
uint16_t wYear = 0;
int cc_start = 0, cc = 0;
- const FX_WCHAR* str = (const FX_WCHAR*)wsDate;
+ const FX_WCHAR* str = wsDate.c_str();
int len = wsDate.GetLength();
if (len > 10) {
return FALSE;
@@ -3856,7 +3817,7 @@ FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
uint8_t second = 0;
uint16_t millisecond = 0;
int cc_start = 0, cc = cc_start;
- const FX_WCHAR* str = (const FX_WCHAR*)wsTime.raw_str();
+ const FX_WCHAR* str = wsTime.c_str();
int len = wsTime.GetLength();
while (cc < len && cc < 2) {
if (!FX_IsDigit(str[cc])) {
@@ -3978,24 +3939,25 @@ static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern,
uint8_t month = datetime.GetMonth();
uint8_t day = datetime.GetDay();
int32_t ccf = 0;
- const FX_WCHAR* strf = (const FX_WCHAR*)wsDatePattern;
+ const FX_WCHAR* strf = wsDatePattern.c_str();
int32_t lenf = wsDatePattern.GetLength();
+ CFX_WideStringC wsDateSymbols(gs_wsDateSymbols);
while (ccf < lenf) {
if (strf[ccf] == '\'') {
wsResult += FX_GetLiteralText(strf, ccf, lenf);
ccf++;
continue;
- } else if (FX_Local_Find(gs_wsDateSymbols, strf[ccf]) < 0) {
+ } else if (wsDateSymbols.Find(strf[ccf]) == -1) {
wsResult += strf[ccf++];
continue;
}
uint32_t dwSymbolNum = 1;
- uint32_t dwSymbol = strf[ccf++];
- while (ccf < lenf && strf[ccf] == dwSymbol) {
+ FX_WCHAR dwCharSymbol = strf[ccf++];
+ while (ccf < lenf && strf[ccf] == dwCharSymbol) {
ccf++;
dwSymbolNum++;
}
- dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0');
+ uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) {
CFX_WideString wsDay;
wsDay.Format(L"%d", day);
@@ -4097,7 +4059,7 @@ static FX_BOOL FX_TimeFormat(const CFX_WideString& wsTimePattern,
uint8_t second = datetime.GetSecond();
uint16_t millisecond = datetime.GetMillisecond();
int32_t ccf = 0;
- const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern;
+ const FX_WCHAR* strf = wsTimePattern.c_str();
int32_t lenf = wsTimePattern.GetLength();
uint16_t wHour = hour;
FX_BOOL bPM = FALSE;
@@ -4106,22 +4068,23 @@ static FX_BOOL FX_TimeFormat(const CFX_WideString& wsTimePattern,
bPM = TRUE;
}
}
+ CFX_WideStringC wsTimeSymbols(gs_wsTimeSymbols);
while (ccf < lenf) {
if (strf[ccf] == '\'') {
wsResult += FX_GetLiteralText(strf, ccf, lenf);
ccf++;
continue;
- } else if (FX_Local_Find(gs_wsTimeSymbols, strf[ccf]) < 0) {
+ } else if (wsTimeSymbols.Find(strf[ccf]) == -1) {
wsResult += strf[ccf++];
continue;
}
uint32_t dwSymbolNum = 1;
- uint32_t dwSymbol = strf[ccf++];
- while (ccf < lenf && strf[ccf] == dwSymbol) {
+ FX_WCHAR dwCharSymbol = strf[ccf++];
+ while (ccf < lenf && strf[ccf] == dwCharSymbol) {
ccf++;
dwSymbolNum++;
}
- dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0');
+ uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0');
if (dwSymbol == FXBSTR_ID(0, 0, 'h', '1')) {
if (wHour > 12) {
wHour -= 12;
@@ -4257,13 +4220,13 @@ FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime,
if (eCategory == FX_DATETIMETYPE_Date) {
FX_DateFromCanonical(wsSrcDateTime, dt);
} else if (eCategory == FX_DATETIMETYPE_Time) {
- FX_TimeFromCanonical(wsSrcDateTime.AsWideStringC(), dt, pLocale);
+ FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale);
}
} else {
FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt);
FX_TimeFromCanonical(
- wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1).AsWideStringC(),
- dt, pLocale);
+ wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1).AsStringC(), dt,
+ pLocale);
}
return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern,
eCategory != FX_DATETIMETYPE_TimeDate, pLocale,
@@ -4286,7 +4249,7 @@ FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime,
if (eCategory == FX_DATETIMETYPE_Unknown) {
if (eDateTimeType == FX_DATETIMETYPE_Time) {
wsTimePattern = wsDatePattern;
- wsDatePattern.Empty();
+ wsDatePattern.clear();
}
eCategory = eDateTimeType;
}
@@ -4301,14 +4264,13 @@ FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime,
return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale,
wsOutput);
} else if (eCategory == FX_DATETIMETYPE_Time &&
- FX_TimeFromCanonical(wsSrcDateTime.AsWideStringC(), dt,
- pLocale)) {
+ FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale)) {
return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale,
wsOutput);
}
} else {
- CFX_WideStringC wsSrcDate((const FX_WCHAR*)wsSrcDateTime, iT);
- CFX_WideStringC wsSrcTime((const FX_WCHAR*)wsSrcDateTime + iT + 1,
+ CFX_WideString wsSrcDate(wsSrcDateTime.c_str(), iT);
+ CFX_WideStringC wsSrcTime(wsSrcDateTime.c_str() + iT + 1,
wsSrcDateTime.GetLength() - iT - 1);
if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) {
return FALSE;
@@ -4347,7 +4309,7 @@ FX_BOOL CFX_FormatString::FormatZero(const CFX_WideString& wsPattern,
CFX_WideString wsTextFormat;
GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat);
int32_t iPattern = 0;
- const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat;
+ const FX_WCHAR* pStrPattern = wsTextFormat.c_str();
int32_t iLenPattern = wsTextFormat.GetLength();
while (iPattern < iLenPattern) {
if (pStrPattern[iPattern] == '\'') {
@@ -4369,7 +4331,7 @@ FX_BOOL CFX_FormatString::FormatNull(const CFX_WideString& wsPattern,
CFX_WideString wsTextFormat;
GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat);
int32_t iPattern = 0;
- const FX_WCHAR* pStrPattern = (const FX_WCHAR*)wsTextFormat;
+ const FX_WCHAR* pStrPattern = wsTextFormat.c_str();
int32_t iLenPattern = wsTextFormat.GetLength();
while (iPattern < iLenPattern) {
if (pStrPattern[iPattern] == '\'') {
@@ -4383,10 +4345,7 @@ FX_BOOL CFX_FormatString::FormatNull(const CFX_WideString& wsPattern,
}
return TRUE;
}
-IFX_Locale* CFX_FormatString::GetPatternLocale(
- const CFX_WideStringC& wsLocale) {
- if (m_bUseLCID) {
- }
+IFX_Locale* CFX_FormatString::GetPatternLocale(const CFX_WideString& wsLocale) {
return m_pLocaleMgr->GetLocaleByName(wsLocale);
}
#define FXMATH_DECIMAL_SCALELIMIT 0x1c
@@ -4521,7 +4480,7 @@ static inline void fxmath_decimal_helper_raw_mul(uint64_t a[],
uint8_t bl,
uint64_t c[],
uint8_t cl) {
- assert(al + bl <= cl);
+ ASSERT(al + bl <= cl);
{
for (int i = 0; i < cl; i++) {
c[i] = 0;
@@ -4702,7 +4661,7 @@ CFX_Decimal::CFX_Decimal(FX_FLOAT val, uint8_t scale) {
m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(val < 0 && IsNotZero(), scale);
}
CFX_Decimal::CFX_Decimal(const CFX_WideStringC& strObj) {
- const FX_WCHAR* str = strObj.raw_str();
+ const FX_WCHAR* str = strObj.c_str();
const FX_WCHAR* strBound = str + strObj.GetLength();
FX_BOOL pointmet = 0;
FX_BOOL negmet = 0;
@@ -4739,7 +4698,7 @@ CFX_Decimal::CFX_Decimal(const CFX_WideStringC& strObj) {
}
CFX_Decimal::CFX_Decimal(const CFX_ByteStringC& strObj) {
- *this = CFX_Decimal(CFX_WideString::FromLocal(strObj).AsWideStringC());
+ *this = CFX_Decimal(CFX_WideString::FromLocal(strObj).AsStringC());
}
CFX_Decimal::operator CFX_WideString() const {
diff --git a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.h b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.h
index 20b6c1232e5..d1d862b0b5e 100644
--- a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.h
+++ b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_locale.h
@@ -90,7 +90,7 @@ class IFX_LocaleMgr {
virtual uint16_t GetDefLocaleID() = 0;
virtual IFX_Locale* GetDefLocale() = 0;
virtual IFX_Locale* GetLocale(uint16_t lcid) = 0;
- virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName) = 0;
+ virtual IFX_Locale* GetLocaleByName(const CFX_WideString& wsLocaleName) = 0;
};
IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
uint16_t wDefaultLCID);
@@ -100,58 +100,6 @@ FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate,
FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
CFX_Unitime& datetime,
IFX_Locale* pLocale);
-class IFX_FormatString {
- public:
- static IFX_FormatString* Create(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID);
-
- virtual ~IFX_FormatString() {}
- virtual void Release() = 0;
- virtual void SplitFormatString(const CFX_WideString& wsFormatString,
- CFX_WideStringArray& wsPatterns) = 0;
- virtual FX_LOCALECATEGORY GetCategory(const CFX_WideString& wsPattern) = 0;
- virtual uint16_t GetLCID(const CFX_WideString& wsPattern) = 0;
- virtual CFX_WideString GetLocaleName(const CFX_WideString& wsPattern) = 0;
- virtual FX_BOOL ParseText(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsValue) = 0;
- virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum,
- const CFX_WideString& wsPattern,
- FX_FLOAT& fValue) = 0;
- virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsValue) = 0;
- virtual FX_BOOL ParseDateTime(const CFX_WideString& wsSrcDateTime,
- const CFX_WideString& wsPattern,
- FX_DATETIMETYPE eDateTimeType,
- CFX_Unitime& dtValue) = 0;
- virtual FX_BOOL ParseZero(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern) = 0;
- virtual FX_BOOL ParseNull(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern) = 0;
- virtual FX_BOOL FormatText(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput) = 0;
- virtual FX_BOOL FormatNum(const CFX_WideString& wsSrcNum,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput) = 0;
- virtual FX_BOOL FormatNum(FX_FLOAT fNum,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput) = 0;
- virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput) = 0;
- virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput,
- FX_DATETIMETYPE eDateTimeType) = 0;
- virtual FX_BOOL FormatDateTime(const CFX_Unitime& dt,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput) = 0;
- virtual FX_BOOL FormatZero(const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput) = 0;
- virtual FX_BOOL FormatNull(const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput) = 0;
-};
class CFX_Decimal {
public:
CFX_Decimal();
diff --git a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localeimp.h b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localeimp.h
index c45ed950b98..bbbdcb17e1f 100644
--- a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localeimp.h
+++ b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localeimp.h
@@ -44,59 +44,59 @@ class CFX_Locale : public IFX_Locale {
CXML_Element* m_pElement;
};
-class CFX_FormatString : public IFX_FormatString {
+class CFX_FormatString {
public:
CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID);
- virtual void Release() { delete this; }
- virtual void SplitFormatString(const CFX_WideString& wsFormatString,
- CFX_WideStringArray& wsPatterns);
- virtual FX_LOCALECATEGORY GetCategory(const CFX_WideString& wsPattern);
- virtual uint16_t GetLCID(const CFX_WideString& wsPattern);
- virtual CFX_WideString GetLocaleName(const CFX_WideString& wsPattern);
- virtual FX_BOOL ParseText(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsValue);
- virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum,
- const CFX_WideString& wsPattern,
- FX_FLOAT& fValue);
- virtual FX_BOOL ParseNum(const CFX_WideString& wsSrcNum,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsValue);
- virtual FX_BOOL ParseDateTime(const CFX_WideString& wsSrcDateTime,
- const CFX_WideString& wsPattern,
- FX_DATETIMETYPE eDateTimeType,
- CFX_Unitime& dtValue);
- virtual FX_BOOL ParseZero(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern);
- virtual FX_BOOL ParseNull(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern);
- virtual FX_BOOL FormatText(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput);
- virtual FX_BOOL FormatNum(const CFX_WideString& wsSrcNum,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput);
- virtual FX_BOOL FormatNum(FX_FLOAT fNum,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput);
- virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput);
- virtual FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput,
- FX_DATETIMETYPE eDateTimeType);
- virtual FX_BOOL FormatDateTime(const CFX_Unitime& dt,
- const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput);
- virtual FX_BOOL FormatZero(const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput);
- virtual FX_BOOL FormatNull(const CFX_WideString& wsPattern,
- CFX_WideString& wsOutput);
+ void Release() { delete this; }
+
+ void SplitFormatString(const CFX_WideString& wsFormatString,
+ CFX_WideStringArray& wsPatterns);
+ FX_LOCALECATEGORY GetCategory(const CFX_WideString& wsPattern);
+ uint16_t GetLCID(const CFX_WideString& wsPattern);
+ CFX_WideString GetLocaleName(const CFX_WideString& wsPattern);
+ FX_BOOL ParseText(const CFX_WideString& wsSrcText,
+ const CFX_WideString& wsPattern,
+ CFX_WideString& wsValue);
+ FX_BOOL ParseNum(const CFX_WideString& wsSrcNum,
+ const CFX_WideString& wsPattern,
+ FX_FLOAT& fValue);
+ FX_BOOL ParseNum(const CFX_WideString& wsSrcNum,
+ const CFX_WideString& wsPattern,
+ CFX_WideString& wsValue);
+ FX_BOOL ParseDateTime(const CFX_WideString& wsSrcDateTime,
+ const CFX_WideString& wsPattern,
+ FX_DATETIMETYPE eDateTimeType,
+ CFX_Unitime& dtValue);
+ FX_BOOL ParseZero(const CFX_WideString& wsSrcText,
+ const CFX_WideString& wsPattern);
+ FX_BOOL ParseNull(const CFX_WideString& wsSrcText,
+ const CFX_WideString& wsPattern);
+ FX_BOOL FormatText(const CFX_WideString& wsSrcText,
+ const CFX_WideString& wsPattern,
+ CFX_WideString& wsOutput);
+ FX_BOOL FormatNum(const CFX_WideString& wsSrcNum,
+ const CFX_WideString& wsPattern,
+ CFX_WideString& wsOutput);
+ FX_BOOL FormatNum(FX_FLOAT fNum,
+ const CFX_WideString& wsPattern,
+ CFX_WideString& wsOutput);
+ FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime,
+ const CFX_WideString& wsPattern,
+ CFX_WideString& wsOutput);
+ FX_BOOL FormatDateTime(const CFX_WideString& wsSrcDateTime,
+ const CFX_WideString& wsPattern,
+ CFX_WideString& wsOutput,
+ FX_DATETIMETYPE eDateTimeType);
+ FX_BOOL FormatDateTime(const CFX_Unitime& dt,
+ const CFX_WideString& wsPattern,
+ CFX_WideString& wsOutput);
+ FX_BOOL FormatZero(const CFX_WideString& wsPattern, CFX_WideString& wsOutput);
+ FX_BOOL FormatNull(const CFX_WideString& wsPattern, CFX_WideString& wsOutput);
protected:
- virtual ~CFX_FormatString();
+ ~CFX_FormatString();
+
IFX_Locale* GetTextFormat(const CFX_WideString& wsPattern,
const CFX_WideStringC& wsCategory,
CFX_WideString& wsPurgePattern);
@@ -114,7 +114,8 @@ class CFX_FormatString : public IFX_FormatString {
IFX_Locale*& pLocale,
CFX_WideString& wsDatePattern,
CFX_WideString& wsTimePattern);
- IFX_Locale* GetPatternLocale(const CFX_WideStringC& wsLocale);
+ IFX_Locale* GetPatternLocale(const CFX_WideString& wsLocale);
+
IFX_LocaleMgr* m_pLocaleMgr;
FX_BOOL m_bUseLCID;
};
diff --git a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.cpp b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.cpp
index 69b86389034..e0ce8d91272 100644
--- a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.cpp
@@ -29,7 +29,7 @@ IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
}
CFX_WideString wsFullPath(pszLocalPath);
wsFullPath += L"\\" + wsFileName;
- IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath);
+ IFX_FileRead* pRead = FX_CreateFileRead(wsFullPath.c_str());
if (!pRead) {
continue;
}
@@ -39,7 +39,7 @@ IFX_LocaleMgr* FX_LocaleMgr_Create(const FX_WCHAR* pszLocalPath,
if (bssp == "http://www.foxitsoftware.com/localization") {
CFX_WideString wsLCID = pXmlLocale->GetAttrValue("", "lcid");
wchar_t* pEnd = NULL;
- uint32_t dwLCID = wcstol(wsLCID, &pEnd, 16);
+ uint32_t dwLCID = wcstol(wsLCID.c_str(), &pEnd, 16);
if (pLocaleMgr->m_lcid2xml.GetValueAt((void*)(uintptr_t)dwLCID)) {
delete pXmlLocale;
} else {
@@ -91,7 +91,6 @@ IFX_Locale* CFX_LocaleMgr::GetLocale(uint16_t lcid) {
}
return pLocale;
}
-IFX_Locale* CFX_LocaleMgr::GetLocaleByName(
- const CFX_WideStringC& wsLocaleName) {
- return NULL;
+IFX_Locale* CFX_LocaleMgr::GetLocaleByName(const CFX_WideString& wsLocaleName) {
+ return nullptr;
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.h b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.h
index 5f2647071b8..d0ba90c9a8d 100644
--- a/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.h
+++ b/chromium/third_party/pdfium/xfa/fgas/localization/fgas_localemgr.h
@@ -12,15 +12,17 @@
class CFX_LocaleMgr : public IFX_LocaleMgr {
public:
CFX_LocaleMgr(uint16_t wDefLCID);
- virtual void Release() { delete this; }
- virtual uint16_t GetDefLocaleID();
- virtual IFX_Locale* GetDefLocale();
- virtual IFX_Locale* GetLocale(uint16_t lcid);
- virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName);
+
+ void Release() override { delete this; }
+ uint16_t GetDefLocaleID() override;
+ IFX_Locale* GetDefLocale() override;
+ IFX_Locale* GetLocale(uint16_t lcid) override;
+ IFX_Locale* GetLocaleByName(const CFX_WideString& wsLocaleName) override;
+
CFX_MapPtrToPtr m_lcid2xml;
protected:
- ~CFX_LocaleMgr();
+ ~CFX_LocaleMgr() override;
CFX_MapPtrToPtr m_lcid2locale;
uint16_t m_wDefLCID;
};
diff --git a/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax_imp.cpp b/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax.cpp
index ea3dafff59b..1128e1184f9 100644
--- a/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax.cpp
@@ -4,19 +4,18 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fgas/xml/fgas_sax_imp.h"
+#include "xfa/fgas/xml/fgas_sax.h"
#include <algorithm>
+#include "xfa/fxfa/include/xfa_checksum.h"
+
namespace {
const uint32_t kSaxFileBufSize = 32768;
} // namespace
-IFX_SAXReader* FX_SAXReader_Create() {
- return new CFX_SAXReader;
-}
CFX_SAXFile::CFX_SAXFile()
: m_pFile(NULL),
m_dwStart(0),
@@ -28,12 +27,12 @@ CFX_SAXFile::CFX_SAXFile()
FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile,
uint32_t dwStart,
uint32_t dwLen) {
- FXSYS_assert(m_pFile == NULL && pFile != NULL);
+ ASSERT(m_pFile == NULL && pFile != NULL);
uint32_t dwSize = pFile->GetSize();
if (dwStart >= dwSize) {
return FALSE;
}
- if (dwLen == -1 || dwStart + dwLen > dwSize) {
+ if (dwLen == static_cast<uint32_t>(-1) || dwStart + dwLen > dwSize) {
dwLen = dwSize - dwStart;
}
if (dwLen == 0) {
@@ -52,7 +51,7 @@ FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile,
return TRUE;
}
FX_BOOL CFX_SAXFile::ReadNextBlock() {
- FXSYS_assert(m_pFile != NULL);
+ ASSERT(m_pFile != NULL);
uint32_t dwSize = m_dwEnd - m_dwCur;
if (dwSize == 0) {
return FALSE;
@@ -558,7 +557,7 @@ void CFX_SAXReader::SkipNode() {
return;
}
iLen--;
- FXSYS_assert(iLen > -1);
+ ASSERT(iLen > -1);
m_SkipStack.RemoveAt(iLen, 1);
m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0;
return;
@@ -618,16 +617,16 @@ void CFX_SAXReader::SkipNode() {
ParseChar(m_CurByte);
}
}
+
void CFX_SAXReader::NotifyData() {
- FXSYS_assert(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Tag)
m_pHandler->OnTagData(m_pCurItem->m_pNode,
m_bCharData ? FX_SAXNODE_CharData : FX_SAXNODE_Text,
CFX_ByteStringC(m_pszData, m_iDataLength),
m_File.m_dwCur + m_dwDataOffset);
}
+
void CFX_SAXReader::NotifyEnter() {
- FXSYS_assert(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Tag ||
m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
m_pCurItem->m_pNode =
@@ -635,8 +634,8 @@ void CFX_SAXReader::NotifyEnter() {
m_pCurItem->m_eNode, m_dwNodePos);
}
}
+
void CFX_SAXReader::NotifyAttribute() {
- FXSYS_assert(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Tag ||
m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
m_pHandler->OnTagAttribute(m_pCurItem->m_pNode,
@@ -644,29 +643,28 @@ void CFX_SAXReader::NotifyAttribute() {
CFX_ByteStringC(m_pszData, m_iDataLength));
}
}
+
void CFX_SAXReader::NotifyBreak() {
- FXSYS_assert(m_pHandler != NULL);
- if (m_pCurItem->m_eNode == FX_SAXNODE_Tag) {
+ if (m_pCurItem->m_eNode == FX_SAXNODE_Tag)
m_pHandler->OnTagBreak(m_pCurItem->m_pNode);
- }
}
+
void CFX_SAXReader::NotifyClose() {
- FXSYS_assert(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Tag ||
m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
m_pHandler->OnTagClose(m_pCurItem->m_pNode, m_dwNodePos);
}
}
+
void CFX_SAXReader::NotifyEnd() {
- FXSYS_assert(m_pHandler != NULL);
- if (m_pCurItem->m_eNode == FX_SAXNODE_Tag) {
- m_pHandler->OnTagEnd(m_pCurItem->m_pNode,
- CFX_ByteStringC(m_pszData, m_iDataLength),
- m_dwNodePos);
- }
+ if (m_pCurItem->m_eNode != FX_SAXNODE_Tag)
+ return;
+
+ m_pHandler->OnTagEnd(m_pCurItem->m_pNode,
+ CFX_ByteStringC(m_pszData, m_iDataLength), m_dwNodePos);
}
+
void CFX_SAXReader::NotifyTargetData() {
- FXSYS_assert(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
m_pHandler->OnTargetData(m_pCurItem->m_pNode, m_pCurItem->m_eNode,
CFX_ByteStringC(m_pszName, m_iNameLength),
@@ -677,12 +675,14 @@ void CFX_SAXReader::NotifyTargetData() {
m_dwNodePos);
}
}
+
void CFX_SAXReader::SkipCurrentNode() {
- if (!m_pCurItem) {
+ if (!m_pCurItem)
return;
- }
+
m_pCurItem->m_bSkip = TRUE;
}
-void CFX_SAXReader::SetHandler(IFX_SAXReaderHandler* pHandler) {
+
+void CFX_SAXReader::SetHandler(CXFA_SAXReaderHandler* pHandler) {
m_pHandler = pHandler;
}
diff --git a/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax.h b/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax.h
index 501c358e0f5..57ff6b2470a 100644
--- a/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax.h
+++ b/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax.h
@@ -27,42 +27,137 @@ enum FX_SAXNODE {
FX_SAXNODE_CharData,
};
-class IFX_SAXReaderHandler {
+enum FX_SAXMODE {
+ FX_SAXMODE_Text = 0,
+ FX_SAXMODE_NodeStart,
+ FX_SAXMODE_DeclOrComment,
+ FX_SAXMODE_DeclNode,
+ FX_SAXMODE_Comment,
+ FX_SAXMODE_CommentContent,
+ FX_SAXMODE_TagName,
+ FX_SAXMODE_TagAttributeName,
+ FX_SAXMODE_TagAttributeEqual,
+ FX_SAXMODE_TagAttributeValue,
+ FX_SAXMODE_TagMaybeClose,
+ FX_SAXMODE_TagClose,
+ FX_SAXMODE_TagEnd,
+ FX_SAXMODE_TargetData,
+ FX_SAXMODE_MAX,
+};
+
+class CXFA_SAXReaderHandler;
+
+class CFX_SAXFile {
+ public:
+ CFX_SAXFile();
+ FX_BOOL StartFile(IFX_FileRead* pFile, uint32_t dwStart, uint32_t dwLen);
+ FX_BOOL ReadNextBlock();
+ void Reset();
+ IFX_FileRead* m_pFile;
+ uint32_t m_dwStart;
+ uint32_t m_dwEnd;
+ uint32_t m_dwCur;
+ uint8_t* m_pBuf;
+ uint32_t m_dwBufSize;
+ uint32_t m_dwBufIndex;
+};
+
+class CFX_SAXItem {
public:
- virtual ~IFX_SAXReaderHandler() {}
- virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName,
- FX_SAXNODE eType,
- uint32_t dwStartPos) = 0;
- virtual void OnTagAttribute(void* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue) = 0;
- virtual void OnTagBreak(void* pTag) = 0;
- virtual void OnTagData(void* pTag,
- FX_SAXNODE eType,
- const CFX_ByteStringC& bsData,
- uint32_t dwStartPos) = 0;
- virtual void OnTagClose(void* pTag, uint32_t dwEndPos) = 0;
- virtual void OnTagEnd(void* pTag,
- const CFX_ByteStringC& bsTagName,
- uint32_t dwEndPos) = 0;
- virtual void OnTargetData(void* pTag,
- FX_SAXNODE eType,
- const CFX_ByteStringC& bsData,
- uint32_t dwStartPos) = 0;
+ CFX_SAXItem()
+ : m_pNode(NULL),
+ m_eNode(FX_SAXNODE_Unknown),
+ m_dwID(0),
+ m_bSkip(FALSE),
+ m_pPrev(NULL),
+ m_pNext(NULL) {}
+ void* m_pNode;
+ FX_SAXNODE m_eNode;
+ uint32_t m_dwID;
+ FX_BOOL m_bSkip;
+ CFX_SAXItem* m_pPrev;
+ CFX_SAXItem* m_pNext;
};
-class IFX_SAXReader {
+class CFX_SAXCommentContext {
public:
- virtual ~IFX_SAXReader() {}
- virtual void Release() = 0;
- virtual int32_t StartParse(IFX_FileRead* pFile,
- uint32_t dwStart = 0,
- uint32_t dwLen = -1,
- uint32_t dwParseMode = 0) = 0;
- virtual int32_t ContinueParse(IFX_Pause* pPause = NULL) = 0;
- virtual void SkipCurrentNode() = 0;
- virtual void SetHandler(IFX_SAXReaderHandler* pHandler) = 0;
+ CFX_SAXCommentContext() : m_iHeaderCount(0), m_iTailCount(0) {}
+ int32_t m_iHeaderCount;
+ int32_t m_iTailCount;
+};
+
+class CFX_SAXReader {
+ public:
+ CFX_SAXReader();
+ ~CFX_SAXReader();
+
+ void Release() { delete this; }
+ int32_t StartParse(IFX_FileRead* pFile,
+ uint32_t dwStart = 0,
+ uint32_t dwLen = -1,
+ uint32_t dwParseMode = 0);
+ int32_t ContinueParse(IFX_Pause* pPause = NULL);
+ void SkipCurrentNode();
+ void SetHandler(CXFA_SAXReaderHandler* pHandler);
+ void AppendData(uint8_t ch);
+ void AppendName(uint8_t ch);
+ void ParseText();
+ void ParseNodeStart();
+ void ParseInstruction();
+ void ParseDeclOrComment();
+ void ParseDeclNode();
+ void ParseComment();
+ void ParseCommentContent();
+ void ParseTagName();
+ void ParseTagAttributeName();
+ void ParseTagAttributeEqual();
+ void ParseTagAttributeValue();
+ void ParseMaybeClose();
+ void ParseTagClose();
+ void ParseTagEnd();
+ void ParseTargetData();
+
+ protected:
+ void Reset();
+ void Push();
+ void Pop();
+ FX_BOOL SkipSpace(uint8_t ch);
+ void SkipNode();
+ void NotifyData();
+ void NotifyEnter();
+ void NotifyAttribute();
+ void NotifyBreak();
+ void NotifyClose();
+ void NotifyEnd();
+ void NotifyTargetData();
+ void ReallocDataBuffer();
+ void ReallocNameBuffer();
+ void ParseChar(uint8_t ch);
+
+ CFX_SAXFile m_File;
+ CXFA_SAXReaderHandler* m_pHandler;
+ int32_t m_iState;
+ CFX_SAXItem* m_pRoot;
+ CFX_SAXItem* m_pCurItem;
+ uint32_t m_dwItemID;
+ FX_SAXMODE m_eMode;
+ FX_SAXMODE m_ePrevMode;
+ FX_BOOL m_bCharData;
+ uint8_t m_CurByte;
+ uint32_t m_dwDataOffset;
+ CFX_ByteArray m_SkipStack;
+ uint8_t m_SkipChar;
+ uint32_t m_dwNodePos;
+ uint8_t* m_pszData;
+ int32_t m_iDataSize;
+ int32_t m_iDataLength;
+ int32_t m_iEntityStart;
+ int32_t m_iDataPos;
+ uint8_t* m_pszName;
+ int32_t m_iNameSize;
+ int32_t m_iNameLength;
+ uint32_t m_dwParseMode;
+ CFX_SAXCommentContext* m_pCommentContext;
};
-IFX_SAXReader* FX_SAXReader_Create();
#endif // XFA_FGAS_XML_FGAS_SAX_H_
diff --git a/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax_imp.h b/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax_imp.h
deleted file mode 100644
index a52d8356ee2..00000000000
--- a/chromium/third_party/pdfium/xfa/fgas/xml/fgas_sax_imp.h
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FGAS_XML_FGAS_SAX_IMP_H_
-#define XFA_FGAS_XML_FGAS_SAX_IMP_H_
-
-#include "xfa/fgas/xml/fgas_sax.h"
-
-class CFX_SAXFile {
- public:
- CFX_SAXFile();
- FX_BOOL StartFile(IFX_FileRead* pFile, uint32_t dwStart, uint32_t dwLen);
- FX_BOOL ReadNextBlock();
- void Reset();
- IFX_FileRead* m_pFile;
- uint32_t m_dwStart;
- uint32_t m_dwEnd;
- uint32_t m_dwCur;
- uint8_t* m_pBuf;
- uint32_t m_dwBufSize;
- uint32_t m_dwBufIndex;
-};
-
-enum FX_SAXMODE {
- FX_SAXMODE_Text = 0,
- FX_SAXMODE_NodeStart,
- FX_SAXMODE_DeclOrComment,
- FX_SAXMODE_DeclNode,
- FX_SAXMODE_Comment,
- FX_SAXMODE_CommentContent,
- FX_SAXMODE_TagName,
- FX_SAXMODE_TagAttributeName,
- FX_SAXMODE_TagAttributeEqual,
- FX_SAXMODE_TagAttributeValue,
- FX_SAXMODE_TagMaybeClose,
- FX_SAXMODE_TagClose,
- FX_SAXMODE_TagEnd,
- FX_SAXMODE_TargetData,
- FX_SAXMODE_MAX,
-};
-
-class CFX_SAXItem {
- public:
- CFX_SAXItem()
- : m_pNode(NULL),
- m_eNode(FX_SAXNODE_Unknown),
- m_dwID(0),
- m_bSkip(FALSE),
- m_pPrev(NULL),
- m_pNext(NULL) {}
- void* m_pNode;
- FX_SAXNODE m_eNode;
- uint32_t m_dwID;
- FX_BOOL m_bSkip;
- CFX_SAXItem* m_pPrev;
- CFX_SAXItem* m_pNext;
-};
-
-class CFX_SAXCommentContext {
- public:
- CFX_SAXCommentContext() : m_iHeaderCount(0), m_iTailCount(0) {}
- int32_t m_iHeaderCount;
- int32_t m_iTailCount;
-};
-
-class CFX_SAXReader : public IFX_SAXReader {
- public:
- CFX_SAXReader();
- ~CFX_SAXReader();
- virtual void Release() { delete this; }
- virtual int32_t StartParse(IFX_FileRead* pFile,
- uint32_t dwStart = 0,
- uint32_t dwLen = -1,
- uint32_t dwParseMode = 0);
- virtual int32_t ContinueParse(IFX_Pause* pPause = NULL);
- virtual void SkipCurrentNode();
- virtual void SetHandler(IFX_SAXReaderHandler* pHandler);
- void AppendData(uint8_t ch);
- void AppendName(uint8_t ch);
- void ParseText();
- void ParseNodeStart();
- void ParseInstruction();
- void ParseDeclOrComment();
- void ParseDeclNode();
- void ParseComment();
- void ParseCommentContent();
- void ParseTagName();
- void ParseTagAttributeName();
- void ParseTagAttributeEqual();
- void ParseTagAttributeValue();
- void ParseMaybeClose();
- void ParseTagClose();
- void ParseTagEnd();
- void ParseTargetData();
-
- protected:
- CFX_SAXFile m_File;
- IFX_SAXReaderHandler* m_pHandler;
- int32_t m_iState;
- CFX_SAXItem* m_pRoot;
- CFX_SAXItem* m_pCurItem;
- uint32_t m_dwItemID;
- FX_SAXMODE m_eMode;
- FX_SAXMODE m_ePrevMode;
- FX_BOOL m_bCharData;
- uint8_t m_CurByte;
- uint32_t m_dwDataOffset;
- CFX_ByteArray m_SkipStack;
- uint8_t m_SkipChar;
- uint32_t m_dwNodePos;
- uint8_t* m_pszData;
- int32_t m_iDataSize;
- int32_t m_iDataLength;
- int32_t m_iEntityStart;
- int32_t m_iDataPos;
- uint8_t* m_pszName;
- int32_t m_iNameSize;
- int32_t m_iNameLength;
- uint32_t m_dwParseMode;
- CFX_SAXCommentContext* m_pCommentContext;
- void Reset();
- void Push();
- void Pop();
- FX_BOOL SkipSpace(uint8_t ch);
- void SkipNode();
- void NotifyData();
- void NotifyEnter();
- void NotifyAttribute();
- void NotifyBreak();
- void NotifyClose();
- void NotifyEnd();
- void NotifyTargetData();
- void ReallocDataBuffer();
- void ReallocNameBuffer();
- void ParseChar(uint8_t ch);
-};
-
-#endif // XFA_FGAS_XML_FGAS_SAX_IMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.cpp
index 610233e84ee..57a3c93e9ee 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.cpp
@@ -7,9 +7,9 @@
#include "xfa/fwl/basewidget/fwl_barcodeimp.h"
#include "xfa/fwl/basewidget/fwl_editimp.h"
+#include "xfa/fwl/basewidget/fxmath_barcodeimp.h"
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
@@ -38,45 +38,48 @@ CFWL_BarcodeImp::CFWL_BarcodeImp(const CFWL_WidgetImpProperties& properties,
CFWL_BarcodeImp::~CFWL_BarcodeImp() {
ReleaseBarcodeEngine();
}
-FWL_ERR CFWL_BarcodeImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_BarcodeImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_Barcode;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_BarcodeImp::GetClassID() const {
- return FWL_CLASSHASH_Barcode;
+
+FWL_Type CFWL_BarcodeImp::GetClassID() const {
+ return FWL_Type::Barcode;
}
-FWL_ERR CFWL_BarcodeImp::Initialize() {
+
+FWL_Error CFWL_BarcodeImp::Initialize() {
if (!m_pDelegate) {
m_pDelegate = new CFWL_BarcodeImpDelegate(this);
}
- if (CFWL_EditImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
- return FWL_ERR_Succeeded;
+ if (CFWL_EditImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_BarcodeImp::Finalize() {
+FWL_Error CFWL_BarcodeImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
ReleaseBarcodeEngine();
return CFWL_EditImp::Finalize();
}
-FWL_ERR CFWL_BarcodeImp::Update() {
+FWL_Error CFWL_BarcodeImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
- FWL_ERR ret = CFWL_EditImp::Update();
+ FWL_Error ret = CFWL_EditImp::Update();
GenerateBarcodeImageCache();
return ret;
}
-FWL_ERR CFWL_BarcodeImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_BarcodeImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
GenerateBarcodeImageCache();
if (!m_pBarcodeEngine || (m_dwStatus & XFA_BCS_EncodeSuccess) == 0) {
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFX_Matrix mt;
mt.e = m_rtClient.left;
@@ -87,9 +90,9 @@ FWL_ERR CFWL_BarcodeImp::DrawWidget(CFX_Graphics* pGraphics,
int32_t errorCode = 0;
if (!m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix,
errorCode)) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
return CFWL_EditImp::DrawWidget(pGraphics, pMatrix);
}
@@ -105,25 +108,25 @@ void CFWL_BarcodeImp::GenerateBarcodeImageCache() {
if (!m_pBarcodeEngine)
return;
CFX_WideString wsText;
- if (GetText(wsText) != FWL_ERR_Succeeded)
+ if (GetText(wsText) != FWL_Error::Succeeded)
return;
CFWL_ThemePart part;
part.m_pWidget = m_pInterface;
IFWL_ThemeProvider* pTheme = GetAvailableTheme();
- IFX_Font* pFont =
- static_cast<IFX_Font*>(pTheme->GetCapacity(&part, FWL_WGTCAPACITY_Font));
+ IFX_Font* pFont = static_cast<IFX_Font*>(
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Font));
CFX_Font* pCXFont =
pFont ? static_cast<CFX_Font*>(pFont->GetDevFont()) : nullptr;
if (pCXFont) {
m_pBarcodeEngine->SetFont(pCXFont);
}
FX_FLOAT* pFontSize = static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FontSize));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::FontSize));
if (pFontSize) {
m_pBarcodeEngine->SetFontSize(*pFontSize);
}
FX_ARGB* pFontColor = static_cast<FX_ARGB*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_TextColor));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TextColor));
if (pFontColor) {
m_pBarcodeEngine->SetFontColor(*pFontColor);
}
@@ -170,15 +173,22 @@ void CFWL_BarcodeImp::GenerateBarcodeImageCache() {
m_pBarcodeEngine->SetTruncated(pData->GetTruncated());
}
int32_t errorCode = 0;
- m_dwStatus = m_pBarcodeEngine->Encode(wsText.AsWideStringC(), TRUE, errorCode)
+ m_dwStatus = m_pBarcodeEngine->Encode(wsText.AsStringC(), TRUE, errorCode)
? XFA_BCS_EncodeSuccess
: 0;
}
+
void CFWL_BarcodeImp::CreateBarcodeEngine() {
- if ((m_pBarcodeEngine == NULL) && (m_type != BC_UNKNOWN)) {
- m_pBarcodeEngine = FX_Barcode_Create(m_type);
+ if (m_pBarcodeEngine || m_type == BC_UNKNOWN)
+ return;
+
+ m_pBarcodeEngine = new CFX_Barcode;
+ if (!m_pBarcodeEngine->Create(m_type)) {
+ m_pBarcodeEngine->Release();
+ m_pBarcodeEngine = nullptr;
}
}
+
void CFWL_BarcodeImp::ReleaseBarcodeEngine() {
if (m_pBarcodeEngine) {
m_pBarcodeEngine->Release();
@@ -193,7 +203,7 @@ void CFWL_BarcodeImp::SetType(BC_TYPE type) {
m_type = type;
m_dwStatus = XFA_BCS_NeedUpdate;
}
-FWL_ERR CFWL_BarcodeImp::SetText(const CFX_WideString& wsText) {
+FWL_Error CFWL_BarcodeImp::SetText(const CFX_WideString& wsText) {
ReleaseBarcodeEngine();
m_dwStatus = XFA_BCS_NeedUpdate;
return CFWL_EditImp::SetText(wsText);
@@ -209,14 +219,15 @@ FX_BOOL CFWL_BarcodeImp::IsProtectedType() {
}
return FALSE;
}
+
CFWL_BarcodeImpDelegate::CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner)
: CFWL_EditImpDelegate(pOwner) {}
-FWL_ERR CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- uint32_t dwFlag = pEvent->GetClassID();
- if (dwFlag == FWL_EVTHASH_EDT_TextChanged) {
+
+void CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ if (pEvent->GetClassID() == CFWL_EventType::TextChanged) {
CFWL_BarcodeImp* pOwner = static_cast<CFWL_BarcodeImp*>(m_pOwner);
pOwner->ReleaseBarcodeEngine();
pOwner->m_dwStatus = XFA_BCS_NeedUpdate;
}
- return CFWL_EditImpDelegate::OnProcessEvent(pEvent);
+ CFWL_EditImpDelegate::OnProcessEvent(pEvent);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.h
index 77b3552a632..705329572ad 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_barcodeimp.h
@@ -10,10 +10,10 @@
#include "xfa/fwl/basewidget/fwl_editimp.h"
#include "xfa/fwl/basewidget/ifwl_barcode.h"
#include "xfa/fwl/basewidget/ifwl_scrollbar.h"
-#include "xfa/fwl/basewidget/ifx_barcode.h"
class CFWL_WidgetImpProperties;
class CFWL_BarcodeImpDelegate;
+class CFX_Barcode;
class IFWL_Widget;
#define XFA_BCS_NeedUpdate 0x0001
@@ -23,32 +23,37 @@ class CFWL_BarcodeImp : public CFWL_EditImp {
public:
CFWL_BarcodeImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual ~CFWL_BarcodeImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FWL_ERR SetText(const CFX_WideString& wsText);
- virtual void SetType(BC_TYPE type);
+ ~CFWL_BarcodeImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error Update() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+ FWL_Error SetText(const CFX_WideString& wsText) override;
+
+ void SetType(BC_TYPE type);
FX_BOOL IsProtectedType();
protected:
+ friend class CFWL_BarcodeImpDelegate;
+
void GenerateBarcodeImageCache();
void CreateBarcodeEngine();
void ReleaseBarcodeEngine();
- IFX_Barcode* m_pBarcodeEngine;
+
+ CFX_Barcode* m_pBarcodeEngine;
uint32_t m_dwStatus;
BC_TYPE m_type;
- friend class CFWL_BarcodeImpDelegate;
};
class CFWL_BarcodeImpDelegate : public CFWL_EditImpDelegate {
public:
CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner);
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
};
#endif // XFA_FWL_BASEWIDGET_FWL_BARCODEIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.cpp
index e7ce56777e7..c67c0c4291e 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.cpp
@@ -9,7 +9,6 @@
#include "xfa/fwl/basewidget/ifwl_caret.h"
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
@@ -23,16 +22,16 @@ IFWL_Caret* IFWL_Caret::Create(const CFWL_WidgetImpProperties& properties,
return pCaret;
}
IFWL_Caret::IFWL_Caret() {}
-FWL_ERR IFWL_Caret::ShowCaret(FX_BOOL bFlag) {
- return static_cast<CFWL_CaretImp*>(GetImpl())->ShowCaret(bFlag);
+void IFWL_Caret::ShowCaret(FX_BOOL bFlag) {
+ static_cast<CFWL_CaretImp*>(GetImpl())->ShowCaret(bFlag);
}
-FWL_ERR IFWL_Caret::GetFrequency(uint32_t& elapse) {
+FWL_Error IFWL_Caret::GetFrequency(uint32_t& elapse) {
return static_cast<CFWL_CaretImp*>(GetImpl())->GetFrequency(elapse);
}
-FWL_ERR IFWL_Caret::SetFrequency(uint32_t elapse) {
+FWL_Error IFWL_Caret::SetFrequency(uint32_t elapse) {
return static_cast<CFWL_CaretImp*>(GetImpl())->SetFrequency(elapse);
}
-FWL_ERR IFWL_Caret::SetColor(CFX_Color crFill) {
+FWL_Error IFWL_Caret::SetColor(CFX_Color crFill) {
return static_cast<CFWL_CaretImp*>(GetImpl())->SetColor(crFill);
}
@@ -45,26 +44,29 @@ CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties,
m_pTimer = new CFWL_CaretTimer(this);
SetStates(FWL_STATE_CAT_HightLight);
}
+
CFWL_CaretImp::~CFWL_CaretImp() {
- if (m_pTimer) {
- delete m_pTimer;
- m_pTimer = NULL;
- }
+ delete m_pTimer;
}
-FWL_ERR CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_Caret;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_CaretImp::GetClassID() const {
- return FWL_CLASSHASH_Caret;
+
+FWL_Type CFWL_CaretImp::GetClassID() const {
+ return FWL_Type::Caret;
}
-FWL_ERR CFWL_CaretImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_CaretImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_CaretImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CaretImp::Finalize() {
+
+FWL_Error CFWL_CaretImp::Finalize() {
if (m_hTimer) {
FWL_StopTimer(m_hTimer);
m_hTimer = NULL;
@@ -73,43 +75,46 @@ FWL_ERR CFWL_CaretImp::Finalize() {
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_CaretImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_CaretImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
m_pProperties->m_pThemeProvider = GetAvailableTheme();
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) {
+
+void CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) {
if (m_hTimer) {
FWL_StopTimer(m_hTimer);
- m_hTimer = NULL;
+ m_hTimer = nullptr;
}
- if (bFlag) {
+ if (bFlag)
m_hTimer = FWL_StartTimer(m_pTimer, m_dwElapse);
- }
- return SetStates(FWL_WGTSTATE_Invisible, !bFlag);
+
+ SetStates(FWL_WGTSTATE_Invisible, !bFlag);
}
-FWL_ERR CFWL_CaretImp::GetFrequency(uint32_t& elapse) {
+FWL_Error CFWL_CaretImp::GetFrequency(uint32_t& elapse) {
elapse = m_dwElapse;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CaretImp::SetFrequency(uint32_t elapse) {
+FWL_Error CFWL_CaretImp::SetFrequency(uint32_t elapse) {
m_dwElapse = elapse;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CaretImp::SetColor(CFX_Color crFill) {
+FWL_Error CFWL_CaretImp::SetColor(CFX_Color crFill) {
m_bSetColor = TRUE;
m_crFill = crFill;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_BOOL CFWL_CaretImp::DrawCaretBK(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix) {
+
+void CFWL_CaretImp::DrawCaretBK(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
CFX_RectF rect;
GetWidgetRect(rect);
rect.Set(0, 0, rect.width, rect.height);
@@ -117,19 +122,17 @@ FX_BOOL CFWL_CaretImp::DrawCaretBK(CFX_Graphics* pGraphics,
param.m_pWidget = m_pInterface;
param.m_pGraphics = pGraphics;
param.m_rtPart = rect;
- if (m_bSetColor) {
+ if (m_bSetColor)
param.m_pData = &m_crFill;
- }
- if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) {
- return FWL_ERR_Succeeded;
- }
- param.m_iPart = FWL_PART_CAT_Background;
- param.m_dwStates = FWL_PARTSTATE_CAT_HightLight;
- if (pMatrix) {
+ if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight))
+ return;
+
+ param.m_iPart = CFWL_Part::Background;
+ param.m_dwStates = CFWL_PartState_HightLight;
+ if (pMatrix)
param.m_matrix.Concat(*pMatrix);
- }
+
pTheme->DrawBackground(&param);
- return FWL_ERR_Succeeded;
}
CFWL_CaretImp::CFWL_CaretTimer::CFWL_CaretTimer(CFWL_CaretImp* pCaret)
@@ -147,12 +150,13 @@ int32_t CFWL_CaretImp::CFWL_CaretTimer::Run(FWL_HTIMER hTimer) {
m_pCaret->Repaint(&rt);
return 1;
}
+
CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- return 1;
-}
-FWL_ERR CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {}
+
+void CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.h
index 47c3a1a7f57..b1ebcfa1847 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_caretimp.h
@@ -9,6 +9,7 @@
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_timer.h"
+#include "xfa/fwl/core/ifwl_widget.h"
#include "xfa/fxgraphics/cfx_color.h"
class CFWL_WidgetImpProperties;
@@ -19,26 +20,25 @@ class CFWL_CaretImp : public CFWL_WidgetImp {
public:
CFWL_CaretImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual ~CFWL_CaretImp();
+ ~CFWL_CaretImp() override;
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
-
- virtual FWL_ERR ShowCaret(FX_BOOL bFlag = TRUE);
- virtual FWL_ERR GetFrequency(uint32_t& elapse);
- virtual FWL_ERR SetFrequency(uint32_t elapse);
- virtual FWL_ERR SetColor(CFX_Color crFill);
+ void ShowCaret(FX_BOOL bFlag = TRUE);
+ FWL_Error GetFrequency(uint32_t& elapse);
+ FWL_Error SetFrequency(uint32_t elapse);
+ FWL_Error SetColor(CFX_Color crFill);
protected:
- FX_BOOL DrawCaretBK(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix);
+ friend class CFWL_CaretImpDelegate;
+ friend class CFWL_CaretTimer;
+
class CFWL_CaretTimer : public IFWL_Timer {
public:
explicit CFWL_CaretTimer(CFWL_CaretImp* pCaret);
@@ -46,20 +46,24 @@ class CFWL_CaretImp : public CFWL_WidgetImp {
int32_t Run(FWL_HTIMER hTimer) override;
CFWL_CaretImp* const m_pCaret;
};
+
+ void DrawCaretBK(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+
CFWL_CaretTimer* m_pTimer;
FWL_HTIMER m_hTimer;
uint32_t m_dwElapse;
CFX_Color m_crFill;
FX_BOOL m_bSetColor;
- friend class CFWL_CaretImpDelegate;
- friend class CFWL_CaretTimer;
};
+
class CFWL_CaretImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
CFWL_CaretImp* m_pOwner;
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.cpp
index d2d149ffd41..574da160ee3 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.cpp
@@ -14,12 +14,15 @@
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
-#define FWL_CKB_CaptionMargin 5
+namespace {
+
+const int kCaptionMargin = 5;
+
+} // namespace
// static
IFWL_CheckBox* IFWL_CheckBox::Create(const CFWL_WidgetImpProperties& properties,
@@ -34,7 +37,7 @@ IFWL_CheckBox::IFWL_CheckBox() {}
int32_t IFWL_CheckBox::GetCheckState() {
return static_cast<CFWL_CheckBoxImp*>(GetImpl())->GetCheckState();
}
-FWL_ERR IFWL_CheckBox::SetCheckState(int32_t iCheck) {
+FWL_Error IFWL_CheckBox::SetCheckState(int32_t iCheck) {
return static_cast<CFWL_CheckBoxImp*>(GetImpl())->SetCheckState(iCheck);
}
@@ -49,34 +52,40 @@ CFWL_CheckBoxImp::CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties,
m_rtCaption.Reset();
m_rtFocus.Reset();
}
+
CFWL_CheckBoxImp::~CFWL_CheckBoxImp() {}
-FWL_ERR CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_CheckBoxImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_CheckBox;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_CheckBoxImp::GetClassID() const {
- return FWL_CLASSHASH_CheckBox;
+
+FWL_Type CFWL_CheckBoxImp::GetClassID() const {
+ return FWL_Type::CheckBox;
}
-FWL_ERR CFWL_CheckBoxImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_CheckBoxImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_CheckBoxImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CheckBoxImp::Finalize() {
+
+FWL_Error CFWL_CheckBoxImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
if (!m_pProperties->m_pThemeProvider)
m_pProperties->m_pThemeProvider = GetAvailableTheme();
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pDataProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
CFX_WideString wsCaption;
m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
if (wsCaption.GetLength() > 0) {
@@ -85,7 +94,7 @@ FWL_ERR CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine);
rect.Set(0, 0, sz.x, sz.y);
}
- rect.Inflate(FWL_CKB_CaptionMargin, FWL_CKB_CaptionMargin);
+ rect.Inflate(kCaptionMargin, kCaptionMargin);
IFWL_CheckBoxDP* pData =
static_cast<IFWL_CheckBoxDP*>(m_pProperties->m_pDataProvider);
FX_FLOAT fCheckBox = pData->GetBoxSize(m_pInterface);
@@ -97,38 +106,38 @@ FWL_ERR CFWL_CheckBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CheckBoxImp::Update() {
+FWL_Error CFWL_CheckBoxImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
}
UpdateTextOutStyles();
Layout();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_CKB_Border, m_pProperties->m_pThemeProvider,
+ DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider,
pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_CKB_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
int32_t dwStates = GetPartStates();
{
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CKB_Background;
+ param.m_iPart = CFWL_Part::Background;
param.m_dwStates = dwStates;
param.m_pGraphics = pGraphics;
if (pMatrix) {
@@ -139,21 +148,21 @@ FWL_ERR CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
param.m_pData = &m_rtFocus;
}
pTheme->DrawBackground(&param);
- param.m_iPart = FWL_PART_CKB_CheckBox;
+ param.m_iPart = CFWL_Part::CheckBox;
param.m_rtPart = m_rtBox;
pTheme->DrawBackground(&param);
}
if (!m_pProperties->m_pDataProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
{
CFX_WideString wsCaption;
m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption);
int32_t iLen = wsCaption.GetLength();
if (iLen <= 0)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
CFWL_ThemeText textParam;
textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_CKB_Caption;
+ textParam.m_iPart = CFWL_Part::Caption;
textParam.m_dwStates = dwStates;
textParam.m_pGraphics = pGraphics;
if (pMatrix) {
@@ -165,7 +174,7 @@ FWL_ERR CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics,
textParam.m_iTTOAlign = m_iTTOAlign;
pTheme->DrawText(&textParam);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_CheckBoxImp::GetCheckState() {
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_3State) &&
@@ -179,7 +188,7 @@ int32_t CFWL_CheckBoxImp::GetCheckState() {
}
return 0;
}
-FWL_ERR CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) {
+FWL_Error CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) {
m_pProperties->m_dwStates &= ~FWL_STATE_CKB_CheckMask;
switch (iCheck) {
case 0: {
@@ -198,7 +207,7 @@ FWL_ERR CFWL_CheckBoxImp::SetCheckState(int32_t iCheck) {
default: {}
}
Repaint(&m_rtClient);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_CheckBoxImp::Layout() {
int32_t width = int32_t(m_pProperties->m_rtWidget.width + 0.5f);
@@ -242,7 +251,7 @@ void CFWL_CheckBoxImp::Layout() {
m_rtBox.Set(fBoxLeft, fBoxTop, fCheckBox, fCheckBox);
m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft,
m_rtClient.height);
- m_rtCaption.Inflate(-FWL_CKB_CaptionMargin, -FWL_CKB_CaptionMargin);
+ m_rtCaption.Inflate(-kCaptionMargin, -kCaptionMargin);
CFX_RectF rtFocus;
rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width,
m_rtCaption.height);
@@ -280,25 +289,25 @@ void CFWL_CheckBoxImp::Layout() {
}
}
uint32_t CFWL_CheckBoxImp::GetPartStates() {
- int32_t dwStates = FWL_PARTSTATE_CKB_UnChecked;
+ int32_t dwStates = CFWL_PartState_Normal;
if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
FWL_STATE_CKB_Neutral) {
- dwStates = FWL_PARTSTATE_CKB_Neutral;
+ dwStates = CFWL_PartState_Neutral;
} else if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
FWL_STATE_CKB_Checked) {
- dwStates = FWL_PARTSTATE_CKB_Checked;
+ dwStates = CFWL_PartState_Checked;
}
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- dwStates |= FWL_PARTSTATE_CKB_Disabled;
+ dwStates |= CFWL_PartState_Disabled;
} else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) {
- dwStates |= FWL_PARTSTATE_CKB_Hovered;
+ dwStates |= CFWL_PartState_Hovered;
} else if (m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) {
- dwStates |= FWL_PARTSTATE_CKB_Pressed;
+ dwStates |= CFWL_PartState_Pressed;
} else {
- dwStates |= FWL_PARTSTATE_CKB_Normal;
+ dwStates |= CFWL_PartState_Normal;
}
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- dwStates |= FWL_PARTSTATE_CKB_Focused;
+ dwStates |= CFWL_PartState_Focused;
}
return dwStates;
}
@@ -362,7 +371,7 @@ void CFWL_CheckBoxImp::NextStates() {
CFWL_WidgetMgr* pWidgetMgr =
static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
if (!pWidgetMgr->IsFormDisabled()) {
- CFX_PtrArray radioarr;
+ CFX_ArrayTemplate<IFWL_Widget*> radioarr;
pWidgetMgr->GetSameGroupRadioButton(m_pInterface, radioarr);
IFWL_CheckBox* pCheckBox = NULL;
int32_t iCount = radioarr.GetSize();
@@ -409,61 +418,67 @@ void CFWL_CheckBoxImp::NextStates() {
}
CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
+ return;
+
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::Activate: {
OnActivate(pMessage);
break;
}
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ case CFWL_MessageType::SetFocus: {
+ OnFocusChanged(pMessage, TRUE);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(pMessage, FALSE);
+ break;
+ }
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseLeave: {
+ case FWL_MouseCommand::Leave: {
OnMouseLeave(pMsg);
break;
}
- default: {}
+ default:
+ break;
}
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
OnKeyDown(pKey);
- }
break;
}
- default: { iRet = 0; }
+ default: {
+ break;
+ }
}
+
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
}
-FWL_ERR CFWL_CheckBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_CheckBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_CheckBoxImpDelegate::OnActivate(CFWL_Message* pMsg) {
m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
m_pOwner->Repaint(&(m_pOwner->m_rtClient));
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.h
index fe0ebb05cbb..89f680c9852 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_checkboximp.h
@@ -8,6 +8,7 @@
#define XFA_FWL_BASEWIDGET_FWL_CHECKBOXIMP_H_
#include "xfa/fwl/core/fwl_widgetimp.h"
+#include "xfa/fwl/core/ifwl_widget.h"
class CFWL_CheckBoxImpDelegate;
class CFWL_MsgMouse;
@@ -18,23 +19,28 @@ class CFWL_CheckBoxImp : public CFWL_WidgetImp {
public:
CFWL_CheckBoxImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- ~CFWL_CheckBoxImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual int32_t GetCheckState();
- virtual FWL_ERR SetCheckState(int32_t iCheck);
+ ~CFWL_CheckBoxImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error Update() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+ int32_t GetCheckState();
+ FWL_Error SetCheckState(int32_t iCheck);
protected:
+ friend class CFWL_CheckBoxImpDelegate;
+
void Layout();
uint32_t GetPartStates();
void UpdateTextOutStyles();
void NextStates();
+
CFX_RectF m_rtClient;
CFX_RectF m_rtBox;
CFX_RectF m_rtCaption;
@@ -42,14 +48,15 @@ class CFWL_CheckBoxImp : public CFWL_WidgetImp {
uint32_t m_dwTTOStyles;
int32_t m_iTTOAlign;
FX_BOOL m_bBtnDown;
- friend class CFWL_CheckBoxImpDelegate;
};
+
class CFWL_CheckBoxImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnActivate(CFWL_Message* pMsg);
@@ -59,6 +66,7 @@ class CFWL_CheckBoxImpDelegate : public CFWL_WidgetImpDelegate {
void OnMouseMove(CFWL_MsgMouse* pMsg);
void OnMouseLeave(CFWL_MsgMouse* pMsg);
void OnKeyDown(CFWL_MsgKey* pMsg);
+
CFWL_CheckBoxImp* m_pOwner;
};
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.cpp
index 66d749a382c..81c2fa75d3b 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.cpp
@@ -7,6 +7,7 @@
#include "xfa/fwl/basewidget/fwl_comboboximp.h"
#include "xfa/fde/tto/fde_textout.h"
+#include "xfa/fee/fde_txtedtengine.h"
#include "xfa/fwl/basewidget/fwl_editimp.h"
#include "xfa/fwl/basewidget/fwl_formproxyimp.h"
#include "xfa/fwl/basewidget/fwl_listboximp.h"
@@ -18,12 +19,9 @@
#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_formimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_panelimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_notethread.h"
+#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
// static
@@ -39,22 +37,22 @@ IFWL_ComboBox::IFWL_ComboBox() {}
int32_t IFWL_ComboBox::GetCurSel() {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetCurSel();
}
-FWL_ERR IFWL_ComboBox::SetCurSel(int32_t iSel) {
+FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetCurSel(iSel);
}
-FWL_ERR IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
+FWL_Error IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetEditText(wsText);
}
int32_t IFWL_ComboBox::GetEditTextLength() const {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetEditTextLength();
}
-FWL_ERR IFWL_ComboBox::GetEditText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+FWL_Error IFWL_ComboBox::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())
->GetEditText(wsText, nStart, nCount);
}
-FWL_ERR IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
+FWL_Error IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())
->SetEditSelRange(nStart, nCount);
}
@@ -65,10 +63,10 @@ int32_t IFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
int32_t IFWL_ComboBox::GetEditLimit() {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetEditLimit();
}
-FWL_ERR IFWL_ComboBox::SetEditLimit(int32_t nLimit) {
+FWL_Error IFWL_ComboBox::SetEditLimit(int32_t nLimit) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetEditLimit(nLimit);
}
-FWL_ERR IFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
+FWL_Error IFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDoClipboard(iCmd);
}
FX_BOOL IFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) {
@@ -83,7 +81,7 @@ IFWL_ListBox* IFWL_ComboBox::GetListBoxt() {
FX_BOOL IFWL_ComboBox::AfterFocusShowDropList() {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->AfterFocusShowDropList();
}
-FX_ERR IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
+FWL_Error IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->OpenDropDownList(bActivate);
}
FX_BOOL IFWL_ComboBox::EditCanUndo() {
@@ -125,11 +123,11 @@ FX_BOOL IFWL_ComboBox::EditDelete() {
FX_BOOL IFWL_ComboBox::EditDeSelect() {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDeSelect();
}
-FWL_ERR IFWL_ComboBox::GetBBox(CFX_RectF& rect) {
+FWL_Error IFWL_ComboBox::GetBBox(CFX_RectF& rect) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetBBox(rect);
}
-FWL_ERR IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
return static_cast<CFWL_ComboBoxImp*>(GetImpl())
->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
@@ -142,38 +140,39 @@ CFWL_ComboEditImp::CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties,
CFWL_ComboEditImpDelegate::CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner)
: CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {}
-int32_t CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
+ return;
+
FX_BOOL backDefault = TRUE;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- if (dwMsgCode == FWL_MSGHASH_SetFocus) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- }
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::SetFocus: {
+ m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ backDefault = FALSE;
+ break;
+ }
+ case CFWL_MessageType::KillFocus: {
+ m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
backDefault = FALSE;
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- if ((pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) &&
+ if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) &&
((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) {
m_pOwner->SetSelected();
m_pOwner->SetComboBoxFocus(TRUE);
}
break;
}
- default: {}
- }
- if (!backDefault) {
- return 1;
+ default:
+ break;
}
- return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+ if (backDefault)
+ CFWL_EditImpDelegate::OnProcessMessage(pMessage);
}
+
void CFWL_ComboEditImp::ClearSelected() {
ClearSelections();
Repaint(&m_rtClient);
@@ -200,16 +199,16 @@ void CFWL_ComboEditImp::SetComboBoxFocus(FX_BOOL bSet) {
CFWL_ComboListImp::CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_ListBoxImp(properties, pOuter), m_bNotifyOwner(TRUE) {
- FXSYS_assert(pOuter != NULL);
+ ASSERT(pOuter != NULL);
}
-FWL_ERR CFWL_ComboListImp::Initialize() {
- if (CFWL_ListBoxImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+FWL_Error CFWL_ComboListImp::Initialize() {
+ if (CFWL_ListBoxImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
delete m_pDelegate;
m_pDelegate = new CFWL_ComboListImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboListImp::Finalize() {
+FWL_Error CFWL_ComboListImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_ListBoxImp::Finalize();
@@ -282,17 +281,20 @@ void CFWL_ComboListImp::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
void CFWL_ComboListImp::SetFocus(FX_BOOL bSet) {
CFWL_WidgetImp::SetFocus(bSet);
}
+
CFWL_ComboListImpDelegate::CFWL_ComboListImpDelegate(CFWL_ComboListImp* pOwner)
: CFWL_ListBoxImpDelegate(pOwner), m_pOwner(pOwner) {}
-int32_t CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwHashCode = pMessage->GetClassID();
+ return;
+
+ CFWL_MessageType dwHashCode = pMessage->GetClassID();
FX_BOOL backDefault = TRUE;
- if (dwHashCode == FWL_MSGHASH_SetFocus ||
- dwHashCode == FWL_MSGHASH_KillFocus) {
- OnDropListFocusChanged(pMessage, dwHashCode == FWL_MSGHASH_SetFocus);
- } else if (dwHashCode == FWL_MSGHASH_Mouse) {
+ if (dwHashCode == CFWL_MessageType::SetFocus ||
+ dwHashCode == CFWL_MessageType::KillFocus) {
+ OnDropListFocusChanged(pMessage, dwHashCode == CFWL_MessageType::SetFocus);
+ } else if (dwHashCode == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
CFX_RectF rect;
@@ -302,36 +304,36 @@ int32_t CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
pMsg->m_fy -= rect.top;
IFWL_WidgetDelegate* pDelegate =
m_pOwner->m_pVertScrollBar->SetDelegate(NULL);
- return pDelegate->OnProcessMessage(pMsg);
+ pDelegate->OnProcessMessage(pMsg);
+ return;
}
}
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_MouseMove: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::Move: {
backDefault = FALSE;
OnDropListMouseMove(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown: {
backDefault = FALSE;
OnDropListLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
backDefault = FALSE;
OnDropListLButtonUp(pMsg);
break;
}
- default: {}
+ default:
+ break;
}
- } else if (dwHashCode == FWL_MSGHASH_Key) {
+ } else if (dwHashCode == CFWL_MessageType::Key) {
backDefault = !OnDropListKey(static_cast<CFWL_MsgKey*>(pMessage));
}
- if (!backDefault) {
- return 1;
- }
- return CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage);
+ if (backDefault)
+ CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage);
}
+
void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg,
FX_BOOL bSet) {
if (!bSet) {
@@ -412,7 +414,7 @@ int32_t CFWL_ComboListImpDelegate::OnDropListKey(CFWL_MsgKey* pKey) {
CFWL_ComboBoxImp* pOuter =
static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl());
FX_BOOL bPropagate = FALSE;
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) {
uint32_t dwKeyCode = pKey->m_dwKeyCode;
switch (dwKeyCode) {
case FWL_VKEY_Return:
@@ -429,7 +431,7 @@ int32_t CFWL_ComboListImpDelegate::OnDropListKey(CFWL_MsgKey* pKey) {
}
default: { bPropagate = TRUE; }
}
- } else if (pKey->m_dwCmd == FWL_MSGKEYCMD_Char) {
+ } else if (pKey->m_dwCmd == FWL_KeyCommand::Char) {
bPropagate = TRUE;
}
if (bPropagate) {
@@ -473,34 +475,39 @@ CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties,
m_pForm(NULL),
m_bLButtonDown(FALSE),
m_iCurSel(-1),
- m_iBtnState(FWL_PARTSTATE_CMB_Normal),
+ m_iBtnState(CFWL_PartState_Normal),
m_fComboFormHandler(0),
m_bNeedShowList(FALSE) {
m_rtClient.Reset();
m_rtBtn.Reset();
m_rtHandler.Reset();
}
+
CFWL_ComboBoxImp::~CFWL_ComboBoxImp() {}
-FWL_ERR CFWL_ComboBoxImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_ComboBoxImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_ComboBox;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_ComboBoxImp::GetClassID() const {
- return FWL_CLASSHASH_ComboBox;
+
+FWL_Type CFWL_ComboBoxImp::GetClassID() const {
+ return FWL_Type::ComboBox;
}
-FWL_ERR CFWL_ComboBoxImp::Initialize() {
- if (m_pWidgetMgr->IsFormDisabled()) {
+
+FWL_Error CFWL_ComboBoxImp::Initialize() {
+ if (m_pWidgetMgr->IsFormDisabled())
return DisForm_Initialize();
- }
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_WGTSTATE_Invisible; // Probably a bug; not a FWL_ERR_ value.
+
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
CFWL_WidgetImpProperties prop;
prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText)
prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
- }
+
prop.m_pDataProvider = m_pProperties->m_pDataProvider;
m_pListBox.reset(IFWL_ListBox::CreateComboList(prop, m_pInterface));
m_pListBox->Initialize();
@@ -510,13 +517,14 @@ FWL_ERR CFWL_ComboBoxImp::Initialize() {
m_pEdit->Initialize();
static_cast<CFWL_EditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface);
}
- if (m_pEdit) {
+ if (m_pEdit)
m_pEdit->SetParent(m_pInterface);
- }
+
SetStates(m_pProperties->m_dwStates);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBoxImp::Finalize() {
+
+FWL_Error CFWL_ComboBoxImp::Finalize() {
if (m_pEdit) {
m_pEdit->Finalize();
}
@@ -525,7 +533,7 @@ FWL_ERR CFWL_ComboBoxImp::Finalize() {
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Reset();
FX_BOOL bIsDropDown = IsDropDownStyle();
@@ -539,23 +547,23 @@ FWL_ERR CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
ReSetTheme();
}
FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
- GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pFWidth)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
rect.Inflate(0, 0, *pFWidth, 0);
CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error CFWL_ComboBoxImp::ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
- FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown;
- FX_BOOL bRemoveDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown;
+ bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
+ bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
if (bAddDropDown && !m_pEdit) {
CFWL_WidgetImpProperties prop;
m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop, nullptr));
@@ -567,12 +575,12 @@ FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(uint32_t dwStylesExAdded,
}
return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
-FWL_ERR CFWL_ComboBoxImp::Update() {
+FWL_Error CFWL_ComboBoxImp::Update() {
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_Update();
}
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
ReSetTheme();
FX_BOOL bDropDown = IsDropDownStyle();
@@ -587,38 +595,38 @@ FWL_ERR CFWL_ComboBoxImp::Update() {
part.m_pWidget = m_pInterface;
m_fComboFormHandler =
*static_cast<FX_FLOAT*>(m_pProperties->m_pThemeProvider->GetCapacity(
- &part, FWL_WGTCAPACITY_CMB_ComboFormHandler));
- return FWL_ERR_Succeeded;
+ &part, CFWL_WidgetCapacity::ComboFormHandler));
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_ComboBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CFWL_ComboBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_HitTest(fx, fy);
}
return CFWL_WidgetImp::HitTest(fx, fy);
}
-FWL_ERR CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_DrawWidget(pGraphics, pMatrix);
}
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
FX_BOOL bIsDropDown = IsDropDownStyle();
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_CMB_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_CMB_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
if (!bIsDropDown) {
CFX_RectF rtTextBk(m_rtClient);
rtTextBk.width -= m_rtBtn.width;
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CMB_Background;
+ param.m_iPart = CFWL_Part::Background;
param.m_pGraphics = pGraphics;
if (pMatrix) {
param.m_matrix.Concat(*pMatrix);
@@ -635,17 +643,17 @@ FWL_ERR CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics,
}
}
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- param.m_dwStates = FWL_PARTSTATE_CMB_Disabled;
+ param.m_dwStates = CFWL_PartState_Disabled;
} else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) &&
(m_iCurSel >= 0)) {
- param.m_dwStates = FWL_PARTSTATE_CMB_Selected;
+ param.m_dwStates = CFWL_PartState_Selected;
} else {
- param.m_dwStates = FWL_PARTSTATE_CMB_Normal;
+ param.m_dwStates = CFWL_PartState_Normal;
}
pTheme->DrawBackground(&param);
if (m_iCurSel >= 0) {
if (!m_pListBox)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
CFX_WideString wsText;
IFWL_ComboBoxDP* pData =
static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
@@ -654,14 +662,14 @@ FWL_ERR CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics,
->GetItemText(hItem, wsText);
CFWL_ThemeText param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CMB_Caption;
+ param.m_iPart = CFWL_Part::Caption;
param.m_dwStates = m_iBtnState;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
param.m_rtPart = rtTextBk;
param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
- ? FWL_PARTSTATE_CMB_Selected
- : FWL_PARTSTATE_CMB_Normal;
+ ? CFWL_PartState_Selected
+ : CFWL_PartState_Normal;
param.m_wsText = wsText;
param.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
param.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
@@ -671,20 +679,21 @@ FWL_ERR CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics,
{
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CMB_DropDownButton;
+ param.m_iPart = CFWL_Part::DropDownButton;
param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_CMB_Disabled
+ ? CFWL_PartState_Disabled
: m_iBtnState;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
param.m_rtPart = m_rtBtn;
pTheme->DrawBackground(&param);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+FWL_Error CFWL_ComboBoxImp::SetThemeProvider(
+ IFWL_ThemeProvider* pThemeProvider) {
if (!pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
m_pProperties->m_pThemeProvider = pThemeProvider;
if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox.get())) {
m_pListBox->SetThemeProvider(pThemeProvider);
@@ -692,12 +701,12 @@ FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit.get())) {
m_pEdit->SetThemeProvider(pThemeProvider);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_ComboBoxImp::GetCurSel() {
return m_iCurSel;
}
-FWL_ERR CFWL_ComboBoxImp::SetCurSel(int32_t iSel) {
+FWL_Error CFWL_ComboBoxImp::SetCurSel(int32_t iSel) {
int32_t iCount =
static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->CountItems();
FX_BOOL bClearSel = iSel < 0 || iSel >= iCount;
@@ -717,21 +726,21 @@ FWL_ERR CFWL_ComboBoxImp::SetCurSel(int32_t iSel) {
m_pEdit->Update();
}
m_iCurSel = bClearSel ? -1 : iSel;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBoxImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
+
+void CFWL_ComboBoxImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
FX_BOOL bIsDropDown = IsDropDownStyle();
- if (bIsDropDown && m_pEdit) {
+ if (bIsDropDown && m_pEdit)
m_pEdit->SetStates(dwStates, bSet);
- }
- if (m_pListBox) {
+ if (m_pListBox)
m_pListBox->SetStates(dwStates, bSet);
- }
- return CFWL_WidgetImp::SetStates(dwStates, bSet);
+ CFWL_WidgetImp::SetStates(dwStates, bSet);
}
-FWL_ERR CFWL_ComboBoxImp::SetEditText(const CFX_WideString& wsText) {
+
+FWL_Error CFWL_ComboBoxImp::SetEditText(const CFX_WideString& wsText) {
if (!m_pEdit)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
m_pEdit->SetText(wsText);
return m_pEdit->Update();
}
@@ -740,9 +749,9 @@ int32_t CFWL_ComboBoxImp::GetEditTextLength() const {
return -1;
return m_pEdit->GetTextLength();
}
-FWL_ERR CFWL_ComboBoxImp::GetEditText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+FWL_Error CFWL_ComboBoxImp::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
if (m_pEdit) {
return m_pEdit->GetText(wsText, nStart, nCount);
} else if (m_pListBox) {
@@ -751,14 +760,14 @@ FWL_ERR CFWL_ComboBoxImp::GetEditText(CFX_WideString& wsText,
FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel);
return m_pListBox->GetItemText(hItem, wsText);
}
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
-FWL_ERR CFWL_ComboBoxImp::SetEditSelRange(int32_t nStart, int32_t nCount) {
+FWL_Error CFWL_ComboBoxImp::SetEditSelRange(int32_t nStart, int32_t nCount) {
if (!m_pEdit)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->ClearSelected();
m_pEdit->AddSelRange(nStart, nCount);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_ComboBoxImp::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
if (!m_pEdit)
@@ -770,14 +779,14 @@ int32_t CFWL_ComboBoxImp::GetEditLimit() {
return -1;
return m_pEdit->GetLimit();
}
-FWL_ERR CFWL_ComboBoxImp::SetEditLimit(int32_t nLimit) {
+FWL_Error CFWL_ComboBoxImp::SetEditLimit(int32_t nLimit) {
if (!m_pEdit)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pEdit->SetLimit(nLimit);
}
-FWL_ERR CFWL_ComboBoxImp::EditDoClipboard(int32_t iCmd) {
+FWL_Error CFWL_ComboBoxImp::EditDoClipboard(int32_t iCmd) {
if (!m_pEdit)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pEdit->DoClipboard(iCmd);
}
FX_BOOL CFWL_ComboBoxImp::EditRedo(const CFX_ByteStringC& bsRecord) {
@@ -804,9 +813,9 @@ FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList() {
m_bNeedShowList = FALSE;
return TRUE;
}
-FX_ERR CFWL_ComboBoxImp::OpenDropDownList(FX_BOOL bActivate) {
+FWL_Error CFWL_ComboBoxImp::OpenDropDownList(FX_BOOL bActivate) {
ShowDropList(bActivate);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_ComboBoxImp::EditCanUndo() {
return m_pEdit->CanUndo();
@@ -842,15 +851,15 @@ FX_BOOL CFWL_ComboBoxImp::EditPaste(const CFX_WideString& wsPaste) {
return m_pEdit->Paste(wsPaste);
}
FX_BOOL CFWL_ComboBoxImp::EditSelectAll() {
- return m_pEdit->AddSelRange(0) == FWL_ERR_Succeeded;
+ return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded;
}
FX_BOOL CFWL_ComboBoxImp::EditDelete() {
- return m_pEdit->ClearText() == FWL_ERR_Succeeded;
+ return m_pEdit->ClearText() == FWL_Error::Succeeded;
}
FX_BOOL CFWL_ComboBoxImp::EditDeSelect() {
- return m_pEdit->ClearSelections() == FWL_ERR_Succeeded;
+ return m_pEdit->ClearSelections() == FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBoxImp::GetBBox(CFX_RectF& rect) {
+FWL_Error CFWL_ComboBoxImp::GetBBox(CFX_RectF& rect) {
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_GetBBox(rect);
}
@@ -861,14 +870,14 @@ FWL_ERR CFWL_ComboBoxImp::GetBBox(CFX_RectF& rect) {
rtList.Offset(rect.left, rect.top);
rect.Union(rtList);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBoxImp::EditModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error CFWL_ComboBoxImp::EditModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
if (m_pEdit != NULL) {
return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
} else {
- return FWL_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
}
}
FX_FLOAT CFWL_ComboBoxImp::GetListHeight() {
@@ -879,8 +888,8 @@ void CFWL_ComboBoxImp::DrawStretchHandler(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground param;
param.m_pGraphics = pGraphics;
- param.m_iPart = FWL_PART_CMB_StretcgHandler;
- param.m_dwStates = FWL_PARTSTATE_CMB_Normal;
+ param.m_iPart = CFWL_Part::StretchHandler;
+ param.m_dwStates = CFWL_PartState_Normal;
param.m_pWidget = m_pInterface;
if (pMatrix) {
param.m_matrix.Concat(*pMatrix);
@@ -1001,8 +1010,8 @@ void CFWL_ComboBoxImp::Layout() {
return DisForm_Layout();
}
GetClientRect(m_rtClient);
- FX_FLOAT* pFWidth =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pFWidth)
return;
FX_FLOAT fBtn = *pFWidth;
@@ -1126,11 +1135,13 @@ void CFWL_ComboBoxImp::ProcessSelChanged(FX_BOOL bLButtonUp) {
Repaint(&m_rtClient);
}
}
+
void CFWL_ComboBoxImp::InitProxyForm() {
if (m_pForm)
return;
if (!m_pListBox)
return;
+
CFWL_WidgetImpProperties propForm;
propForm.m_pOwner = m_pInterface;
propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
@@ -1143,18 +1154,21 @@ void CFWL_ComboBoxImp::InitProxyForm() {
m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this);
m_pProxy->SetDelegate(m_pListProxyDelegate);
}
-FWL_ERR CFWL_ComboBoxImp::DisForm_Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_WGTSTATE_Invisible; // Ditto.
+
+FWL_Error CFWL_ComboBoxImp::DisForm_Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
DisForm_InitComboList();
DisForm_InitComboEdit();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
+
void CFWL_ComboBoxImp::DisForm_InitComboList() {
- if (m_pListBox) {
+ if (m_pListBox)
return;
- }
+
CFWL_WidgetImpProperties prop;
prop.m_pParent = m_pInterface;
prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
@@ -1224,13 +1238,13 @@ void CFWL_ComboBoxImp::DisForm_ShowDropList(FX_BOOL bActivate) {
FX_BOOL CFWL_ComboBoxImp::DisForm_IsDropListShowed() {
return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible);
}
-FWL_ERR CFWL_ComboBoxImp::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error CFWL_ComboBoxImp::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
if (!m_pEdit) {
DisForm_InitComboEdit();
}
- FX_BOOL bAddDropDown = dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown;
- FX_BOOL bDelDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown;
+ bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
+ bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown;
m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown;
if (bAddDropDown) {
@@ -1240,37 +1254,34 @@ FWL_ERR CFWL_ComboBoxImp::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
}
return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
-FWL_ERR CFWL_ComboBoxImp::DisForm_Update() {
+FWL_Error CFWL_ComboBoxImp::DisForm_Update() {
if (m_iLock) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (m_pEdit) {
ReSetEditAlignment();
}
ReSetTheme();
Layout();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_ComboBoxImp::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CFWL_ComboBoxImp::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
CFX_RectF rect;
rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width,
m_pProperties->m_rtWidget.height);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edit;
- }
- if (m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::Edit;
+ if (m_rtBtn.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
if (DisForm_IsDropListShowed()) {
m_pListBox->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
}
- return FWL_WGTHITTEST_Unknown;
+ return FWL_WidgetHit::Unknown;
}
-FWL_ERR CFWL_ComboBoxImp::DisForm_DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_ComboBoxImp::DisForm_DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
CFX_Matrix mtOrg;
mtOrg.Set(1, 0, 0, 1, 0, 0);
@@ -1283,7 +1294,7 @@ FWL_ERR CFWL_ComboBoxImp::DisForm_DrawWidget(CFX_Graphics* pGraphics,
if (!m_rtBtn.IsEmpty(0.1f)) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_CMB_DropDownButton;
+ param.m_iPart = CFWL_Part::DropDownButton;
param.m_dwStates = m_iBtnState;
param.m_pGraphics = pGraphics;
param.m_rtPart = m_rtBtn;
@@ -1306,9 +1317,9 @@ FWL_ERR CFWL_ComboBoxImp::DisForm_DrawWidget(CFX_Graphics* pGraphics,
mt.Concat(mtOrg);
m_pListBox->DrawWidget(pGraphics, &mt);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBoxImp::DisForm_GetBBox(CFX_RectF& rect) {
+FWL_Error CFWL_ComboBoxImp::DisForm_GetBBox(CFX_RectF& rect) {
rect = m_pProperties->m_rtWidget;
if (m_pListBox && DisForm_IsDropListShowed()) {
CFX_RectF rtList;
@@ -1316,24 +1327,23 @@ FWL_ERR CFWL_ComboBoxImp::DisForm_GetBBox(CFX_RectF& rect) {
rtList.Offset(rect.left, rect.top);
rect.Union(rtList);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_ComboBoxImp::DisForm_Layout() {
GetClientRect(m_rtClient);
m_rtContent = m_rtClient;
- FX_FLOAT* pFWidth =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pFWidth)
return;
- FX_FLOAT borderWidth = 0;
- { borderWidth = FWL_PART_CMB_Border; }
+ FX_FLOAT borderWidth = 1;
FX_FLOAT fBtn = *pFWidth;
if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) {
m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth,
fBtn - borderWidth, m_rtClient.height - 2 * borderWidth);
}
CFX_RectF* pUIMargin =
- static_cast<CFX_RectF*>(GetThemeCapacity(FWL_WGTCAPACITY_UIMargin));
+ static_cast<CFX_RectF*>(GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
if (pUIMargin) {
m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
pUIMargin->height);
@@ -1358,58 +1368,66 @@ void CFWL_ComboBoxImp::DisForm_Layout() {
m_pEdit->Update();
}
}
+
CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_OnProcessMessage(pMessage);
+ DisForm_OnProcessMessage(pMessage);
+ return;
}
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
- FX_BOOL iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ return;
+
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::SetFocus: {
+ OnFocusChanged(pMessage, TRUE);
+ break;
+ }
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(pMessage, FALSE);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseLeave: {
+ case FWL_MouseCommand::Leave: {
OnMouseLeave(pMsg);
break;
}
- default: {}
+ default:
+ break;
}
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
OnKey(static_cast<CFWL_MsgKey*>(pMessage));
break;
}
- default: { iRet = 0; }
+ default: {
+ break;
+ }
}
+
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
}
-FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- uint32_t dwFlag = pEvent->GetClassID();
- if (dwFlag == FWL_EVTHASH_LTB_DrawItem) {
+
+void CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+ CFWL_EventType dwFlag = pEvent->GetClassID();
+ if (dwFlag == CFWL_EventType::DrawItem) {
CFWL_EvtLtbDrawItem* pDrawItemEvent =
static_cast<CFWL_EvtLtbDrawItem*>(pEvent);
CFWL_EvtCmbDrawItem pTemp;
@@ -1418,14 +1436,14 @@ FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
pTemp.m_index = pDrawItemEvent->m_index;
pTemp.m_rtItem = pDrawItemEvent->m_rect;
m_pOwner->DispatchEvent(&pTemp);
- } else if (dwFlag == FWL_EVTHASH_Scroll) {
+ } else if (dwFlag == CFWL_EventType::Scroll) {
CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent);
CFWL_EvtScroll pScrollEv;
pScrollEv.m_pSrcTarget = m_pOwner->m_pInterface;
pScrollEv.m_iScrollCode = pScrollEvent->m_iScrollCode;
pScrollEv.m_fPos = pScrollEvent->m_fPos;
m_pOwner->DispatchEvent(&pScrollEv);
- } else if (dwFlag == FWL_EVTHASH_EDT_TextChanged) {
+ } else if (dwFlag == CFWL_EventType::TextChanged) {
CFWL_EvtEdtTextChanged* pTextChangedEvent =
static_cast<CFWL_EvtEdtTextChanged*>(pEvent);
CFWL_EvtCmbEditChanged pTemp;
@@ -1435,16 +1453,17 @@ FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
pTemp.nChangeType = pTextChangedEvent->nChangeType;
m_pOwner->DispatchEvent(&pTemp);
}
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_ComboBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_ComboBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
FX_BOOL bSet) {
- IFWL_Target* pDstTarget = pMsg->m_pDstTarget;
- IFWL_Target* pSrcTarget = pMsg->m_pSrcTarget;
+ IFWL_Widget* pDstTarget = pMsg->m_pDstTarget;
+ IFWL_Widget* pSrcTarget = pMsg->m_pSrcTarget;
FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
if (bSet) {
m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
@@ -1482,30 +1501,29 @@ void CFWL_ComboBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
m_pOwner->MatchEditText();
}
m_pOwner->m_bLButtonDown = TRUE;
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Pressed;
+ m_pOwner->m_iBtnState = CFWL_PartState_Pressed;
m_pOwner->Repaint(&m_pOwner->m_rtClient);
m_pOwner->ShowDropList(TRUE);
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
+ m_pOwner->m_iBtnState = CFWL_PartState_Normal;
m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
}
void CFWL_ComboBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
m_pOwner->m_bLButtonDown = FALSE;
if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Hovered;
+ m_pOwner->m_iBtnState = CFWL_PartState_Hovered;
} else {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
+ m_pOwner->m_iBtnState = CFWL_PartState_Normal;
}
m_pOwner->Repaint(&m_pOwner->m_rtBtn);
}
void CFWL_ComboBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
int32_t iOldState = m_pOwner->m_iBtnState;
if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = m_pOwner->m_bLButtonDown
- ? FWL_PARTSTATE_CMB_Pressed
- : FWL_PARTSTATE_CMB_Hovered;
+ m_pOwner->m_iBtnState = m_pOwner->m_bLButtonDown ? CFWL_PartState_Pressed
+ : CFWL_PartState_Hovered;
} else {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
+ m_pOwner->m_iBtnState = CFWL_PartState_Normal;
}
if ((iOldState != m_pOwner->m_iBtnState) &&
!((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
@@ -1517,7 +1535,7 @@ void CFWL_ComboBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
if (!m_pOwner->IsDropListShowed() &&
!((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
FWL_WGTSTATE_Disabled)) {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_CMB_Normal;
+ m_pOwner->m_iBtnState = CFWL_PartState_Normal;
m_pOwner->Repaint(&m_pOwner->m_rtBtn);
}
}
@@ -1585,48 +1603,51 @@ void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
pDelegate->OnProcessMessage(pMsg);
}
}
-int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
+void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
+ return;
+
FX_BOOL backDefault = TRUE;
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::SetFocus: {
backDefault = FALSE;
- DisForm_OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ DisForm_OnFocusChanged(pMessage, TRUE);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::KillFocus: {
+ backDefault = FALSE;
+ DisForm_OnFocusChanged(pMessage, FALSE);
+ break;
+ }
+ case CFWL_MessageType::Mouse: {
backDefault = FALSE;
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
DisForm_OnLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg);
break;
}
- default: {}
+ default:
+ break;
}
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
backDefault = FALSE;
CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyUp) {
+ if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp)
break;
- }
if (m_pOwner->DisForm_IsDropListShowed() &&
- pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
- uint32_t dwKeyCode = pKey->m_dwKeyCode;
- FX_BOOL bListKey =
- dwKeyCode == FWL_VKEY_Up || dwKeyCode == FWL_VKEY_Down ||
- dwKeyCode == FWL_VKEY_Return || dwKeyCode == FWL_VKEY_Escape;
+ pKey->m_dwCmd == FWL_KeyCommand::KeyDown) {
+ FX_BOOL bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up ||
+ pKey->m_dwKeyCode == FWL_VKEY_Down ||
+ pKey->m_dwKeyCode == FWL_VKEY_Return ||
+ pKey->m_dwKeyCode == FWL_VKEY_Escape;
if (bListKey) {
IFWL_WidgetDelegate* pDelegate =
m_pOwner->m_pListBox->SetDelegate(NULL);
@@ -1637,13 +1658,13 @@ int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
DisForm_OnKey(pKey);
break;
}
- default: {}
- }
- if (!backDefault) {
- return 1;
+ default:
+ break;
}
- return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ if (backDefault)
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
}
+
void CFWL_ComboBoxImpDelegate::DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg) {
FX_BOOL bDropDown = m_pOwner->DisForm_IsDropListShowed();
CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient;
@@ -1727,6 +1748,7 @@ void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) {
pDelegate->OnProcessMessage(pMsg);
}
}
+
CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(
IFWL_Form* pForm,
CFWL_ComboBoxImp* pComboBox)
@@ -1735,49 +1757,62 @@ CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(
m_fStartPos(0),
m_pForm(pForm),
m_pComboBox(pComboBox) {}
-int32_t CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
- if (dwMsgCode == FWL_MSGHASH_Mouse) {
- CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
+ return;
+
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::Mouse: {
+ CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
+ OnLButtonDown(pMsg);
+ break;
+ }
+ case FWL_MouseCommand::LeftButtonUp: {
+ OnLButtonUp(pMsg);
+ break;
+ }
+ case FWL_MouseCommand::Move: {
+ OnMouseMove(pMsg);
+ break;
+ }
+ default:
+ break;
}
- default: {}
+ break;
}
+ case CFWL_MessageType::Deactivate: {
+ OnDeactive(static_cast<CFWL_MsgDeactivate*>(pMessage));
+ break;
+ }
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), FALSE);
+ break;
+ }
+ case CFWL_MessageType::SetFocus: {
+ OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), TRUE);
+ break;
+ }
+ default:
+ break;
}
- if (dwMsgCode == FWL_MSGHASH_Deactivate) {
- OnDeactive(static_cast<CFWL_MsgDeactivate*>(pMessage));
- }
- if (dwMsgCode == FWL_MSGHASH_KillFocus || dwMsgCode == FWL_MSGHASH_SetFocus) {
- OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage),
- dwMsgCode == FWL_MSGHASH_SetFocus);
- }
- return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
}
-FWL_ERR CFWL_ComboProxyImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+
+void CFWL_ComboProxyImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
m_pComboBox->DrawStretchHandler(pGraphics, pMatrix);
- return FWL_ERR_Succeeded;
}
+
void CFWL_ComboProxyImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- IFWL_NoteThread* pThread = m_pForm->GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = m_pForm->GetOwnerApp();
+ if (!pApp)
return;
+
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
CFX_RectF rtWidget;
m_pForm->GetWidgetRect(rtWidget);
rtWidget.left = rtWidget.top = 0;
@@ -1792,11 +1827,12 @@ void CFWL_ComboProxyImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
}
void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
m_bLButtonDown = FALSE;
- IFWL_NoteThread* pThread = m_pForm->GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = m_pForm->GetOwnerApp();
+ if (!pApp)
return;
+
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
pDriver->SetGrab(m_pForm, FALSE);
if (m_bLButtonUpSelf) {
CFX_RectF rect;
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.h
index 262db35082f..45cb47d3219 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_comboboximp.h
@@ -44,7 +44,7 @@ class CFWL_ComboEditImp : public CFWL_EditImp {
class CFWL_ComboEditImpDelegate : public CFWL_EditImpDelegate {
public:
CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
protected:
CFWL_ComboEditImp* m_pOwner;
@@ -53,22 +53,27 @@ class CFWL_ComboListImp : public CFWL_ListBoxImp {
public:
CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+
+ // CFWL_WidgetImp
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+
int32_t MatchItem(const CFX_WideString& wsMatch);
void ChangeSelected(int32_t iSel);
int32_t CountItems();
void GetItemRect(int32_t nIndex, CFX_RectF& rtItem);
void ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy);
void SetFocus(FX_BOOL bSet);
+
FX_BOOL m_bNotifyOwner;
+
friend class CFWL_ComboListImpDelegate;
friend class CFWL_ComboBoxImp;
};
class CFWL_ComboListImpDelegate : public CFWL_ListBoxImpDelegate {
public:
CFWL_ComboListImpDelegate(CFWL_ComboListImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
protected:
void OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
@@ -83,55 +88,65 @@ class CFWL_ComboBoxImp : public CFWL_WidgetImp {
public:
CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual ~CFWL_ComboBoxImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
- virtual FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_ERR Update();
- virtual uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- virtual int32_t GetCurSel();
- virtual FWL_ERR SetCurSel(int32_t iSel);
- virtual FWL_ERR SetEditText(const CFX_WideString& wsText);
- virtual int32_t GetEditTextLength() const;
- virtual FWL_ERR GetEditText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
- virtual FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1);
- virtual int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
- virtual int32_t GetEditLimit();
- virtual FWL_ERR SetEditLimit(int32_t nLimit);
- virtual FWL_ERR EditDoClipboard(int32_t iCmd);
- virtual FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
- virtual FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
- virtual IFWL_ListBox* GetListBoxt();
- virtual FX_BOOL AfterFocusShowDropList();
- virtual FX_ERR OpenDropDownList(FX_BOOL bActivate);
- virtual FX_BOOL EditCanUndo();
- virtual FX_BOOL EditCanRedo();
- virtual FX_BOOL EditUndo();
- virtual FX_BOOL EditRedo();
- virtual FX_BOOL EditCanCopy();
- virtual FX_BOOL EditCanCut();
- virtual FX_BOOL EditCanSelectAll();
- virtual FX_BOOL EditCopy(CFX_WideString& wsCopy);
- virtual FX_BOOL EditCut(CFX_WideString& wsCut);
- virtual FX_BOOL EditPaste(const CFX_WideString& wsPaste);
- virtual FX_BOOL EditSelectAll();
- virtual FX_BOOL EditDelete();
- virtual FX_BOOL EditDeSelect();
- virtual FWL_ERR GetBBox(CFX_RectF& rect);
- virtual FWL_ERR EditModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
+ ~CFWL_ComboBoxImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) override;
+ void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override;
+ FWL_Error Update() override;
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+ FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
+
+ int32_t GetCurSel();
+ FWL_Error SetCurSel(int32_t iSel);
+ FWL_Error SetEditText(const CFX_WideString& wsText);
+ int32_t GetEditTextLength() const;
+ FWL_Error GetEditText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ FWL_Error SetEditSelRange(int32_t nStart, int32_t nCount = -1);
+ int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
+ int32_t GetEditLimit();
+ FWL_Error SetEditLimit(int32_t nLimit);
+ FWL_Error EditDoClipboard(int32_t iCmd);
+ FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
+ FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
+ IFWL_ListBox* GetListBoxt();
+ FX_BOOL AfterFocusShowDropList();
+ FWL_Error OpenDropDownList(FX_BOOL bActivate);
+ FX_BOOL EditCanUndo();
+ FX_BOOL EditCanRedo();
+ FX_BOOL EditUndo();
+ FX_BOOL EditRedo();
+ FX_BOOL EditCanCopy();
+ FX_BOOL EditCanCut();
+ FX_BOOL EditCanSelectAll();
+ FX_BOOL EditCopy(CFX_WideString& wsCopy);
+ FX_BOOL EditCut(CFX_WideString& wsCut);
+ FX_BOOL EditPaste(const CFX_WideString& wsPaste);
+ FX_BOOL EditSelectAll();
+ FX_BOOL EditDelete();
+ FX_BOOL EditDeSelect();
+ FWL_Error GetBBox(CFX_RectF& rect);
+ FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
protected:
+ friend class CFWL_ComboListImp;
+ friend class CFWL_ComboEditImp;
+ friend class CFWL_ComboEditImpDelegate;
+ friend class CFWL_ComboListImpDelegate;
+ friend class CFWL_ComboBoxImpDelegate;
+ friend class CFWL_ComboProxyImpDelegate;
+
void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix);
FX_FLOAT GetListHeight();
void ShowDropList(FX_BOOL bActivate);
@@ -145,18 +160,18 @@ class CFWL_ComboBoxImp : public CFWL_WidgetImp {
void ReSetListItemAlignment();
void ProcessSelChanged(FX_BOOL bLButtonUp);
void InitProxyForm();
- FWL_ERR DisForm_Initialize();
+ FWL_Error DisForm_Initialize();
void DisForm_InitComboList();
void DisForm_InitComboEdit();
void DisForm_ShowDropList(FX_BOOL bActivate);
FX_BOOL DisForm_IsDropListShowed();
- FWL_ERR DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
- FWL_ERR DisForm_Update();
- uint32_t DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
- FWL_ERR DisForm_DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- FWL_ERR DisForm_GetBBox(CFX_RectF& rect);
+ FWL_Error DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
+ FWL_Error DisForm_Update();
+ FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ FWL_Error DisForm_DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
+ FWL_Error DisForm_GetBBox(CFX_RectF& rect);
void DisForm_Layout();
CFX_RectF m_rtClient;
@@ -177,21 +192,14 @@ class CFWL_ComboBoxImp : public CFWL_WidgetImp {
FX_BOOL m_bNeedShowList;
CFWL_FormProxyImp* m_pProxy;
CFWL_ComboProxyImpDelegate* m_pListProxyDelegate;
-
- friend class CFWL_ComboListImp;
- friend class CFWL_ComboEditImp;
- friend class CFWL_ComboEditImpDelegate;
- friend class CFWL_ComboListImpDelegate;
- friend class CFWL_ComboBoxImpDelegate;
- friend class CFWL_ComboProxyImpDelegate;
};
class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
@@ -203,7 +211,7 @@ class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate {
void DoSubCtrlKey(CFWL_MsgKey* pMsg);
protected:
- int32_t DisForm_OnProcessMessage(CFWL_Message* pMessage);
+ void DisForm_OnProcessMessage(CFWL_Message* pMessage);
void DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg);
void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
void DisForm_OnKey(CFWL_MsgKey* pMsg);
@@ -216,9 +224,9 @@ class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate {
class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, CFWL_ComboBoxImp* pComboBox);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
void Reset() { m_bLButtonUpSelf = FALSE; }
protected:
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp
index 978fb619e2c..a0af1a0d715 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp
@@ -14,14 +14,16 @@
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/fwl_formimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_panelimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
-#define FWL_DTP_WIDTH 100
-#define FWL_DTP_HEIGHT 20
+namespace {
+
+const int kDateTimePickerWidth = 100;
+const int kDateTimePickerHeight = 20;
+
+} // namespace
// static
IFWL_DateTimePicker* IFWL_DateTimePicker::Create(
@@ -81,24 +83,24 @@ int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
->GetDataTimeEdit()
->GetSelRange(nIndex, nStart);
}
-FWL_ERR IFWL_DateTimePicker::GetCurSel(int32_t& iYear,
- int32_t& iMonth,
- int32_t& iDay) {
+FWL_Error IFWL_DateTimePicker::GetCurSel(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
->GetCurSel(iYear, iMonth, iDay);
}
-FWL_ERR IFWL_DateTimePicker::SetCurSel(int32_t iYear,
- int32_t iMonth,
- int32_t iDay) {
+FWL_Error IFWL_DateTimePicker::SetCurSel(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
->SetCurSel(iYear, iMonth, iDay);
}
-FWL_ERR IFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
+FWL_Error IFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditText(wsText);
}
-FWL_ERR IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+FWL_Error IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
->GetEditText(wsText, nStart, nCount);
}
@@ -141,55 +143,59 @@ FX_BOOL IFWL_DateTimePicker::Delete() {
FX_BOOL IFWL_DateTimePicker::DeSelect() {
return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->DeSelect();
}
-FWL_ERR IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
+FWL_Error IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->GetBBox(rect);
}
-FWL_ERR IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
+FWL_Error IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditLimit(nLimit);
}
-FWL_ERR IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
return static_cast<CFWL_DateTimePickerImp*>(GetImpl())
->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
CFWL_DateTimeEdit::CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_EditImp(properties, pOuter) {}
-FWL_ERR CFWL_DateTimeEdit::Initialize() {
+FWL_Error CFWL_DateTimeEdit::Initialize() {
m_pDelegate = new CFWL_DateTimeEditImpDelegate(this);
- if (CFWL_EditImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
- return FWL_ERR_Succeeded;
+ if (CFWL_EditImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimeEdit::Finalize() {
+FWL_Error CFWL_DateTimeEdit::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_EditImp::Finalize();
}
+
CFWL_DateTimeEditImpDelegate::CFWL_DateTimeEditImpDelegate(
CFWL_DateTimeEdit* pOwner)
: CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {}
-int32_t CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- return DisForm_OnProcessMessage(pMessage);
+ DisForm_OnProcessMessage(pMessage);
+ return;
}
- uint32_t dwHashCode = pMessage->GetClassID();
- if (dwHashCode == FWL_MSGHASH_SetFocus ||
- dwHashCode == FWL_MSGHASH_KillFocus) {
+
+ CFWL_MessageType dwHashCode = pMessage->GetClassID();
+ if (dwHashCode == CFWL_MessageType::SetFocus ||
+ dwHashCode == CFWL_MessageType::KillFocus) {
IFWL_Widget* pOuter = m_pOwner->GetOuter();
IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL);
pDelegate->OnProcessMessage(pMessage);
}
- return 1;
}
-int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage(
+
+void CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage(
CFWL_Message* pMessage) {
- uint32_t dwHashCode = pMessage->GetClassID();
+ CFWL_MessageType dwHashCode = pMessage->GetClassID();
if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- if (dwHashCode == FWL_MSGHASH_Mouse) {
+ if (dwHashCode == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
- if (pMouse->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown ||
- pMouse->m_dwCmd == FWL_MSGMOUSECMD_RButtonDown) {
+ if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown ||
+ pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) {
if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
}
@@ -203,59 +209,62 @@ int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage(
pDateTime->Repaint(&rtInvalidate);
}
}
- } else if (dwHashCode == FWL_MSGHASH_Key) {
- return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
}
}
- return CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+ CFWL_EditImpDelegate::OnProcessMessage(pMessage);
}
+
CFWL_DateTimeCalendar::CFWL_DateTimeCalendar(
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_MonthCalendarImp(properties, pOuter) {}
-FWL_ERR CFWL_DateTimeCalendar::Initialize() {
- if (CFWL_MonthCalendarImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+FWL_Error CFWL_DateTimeCalendar::Initialize() {
+ if (CFWL_MonthCalendarImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
delete m_pDelegate;
m_pDelegate = new CFWL_DateTimeCalendarImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimeCalendar::Finalize() {
+FWL_Error CFWL_DateTimeCalendar::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_MonthCalendarImp::Finalize();
}
+
CFWL_DateTimeCalendarImpDelegate::CFWL_DateTimeCalendarImpDelegate(
CFWL_DateTimeCalendar* pOwner)
: CFWL_MonthCalendarImpDelegate(pOwner), m_pOwner(pOwner) {
m_bFlag = FALSE;
}
-int32_t CFWL_DateTimeCalendarImpDelegate::OnProcessMessage(
+
+void CFWL_DateTimeCalendarImpDelegate::OnProcessMessage(
CFWL_Message* pMessage) {
- uint32_t dwCode = pMessage->GetClassID();
- if (dwCode == FWL_MSGHASH_SetFocus || dwCode == FWL_MSGHASH_KillFocus) {
+ CFWL_MessageType dwCode = pMessage->GetClassID();
+ if (dwCode == CFWL_MessageType::SetFocus ||
+ dwCode == CFWL_MessageType::KillFocus) {
IFWL_Widget* pOuter = m_pOwner->GetOuter();
IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL);
- return pDelegate->OnProcessMessage(pMessage);
- } else if (dwCode == FWL_MSGHASH_Mouse) {
+ pDelegate->OnProcessMessage(pMessage);
+ return;
+ }
+ if (dwCode == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) {
+ if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown)
OnLButtonDownEx(pMsg);
- return 1;
- } else if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) {
+ else if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp)
OnLButtonUpEx(pMsg);
- return 1;
- }
+ return;
}
- return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
+ CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
}
+
void CFWL_DateTimeCalendarImpDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) {
if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = FWL_PARTSTATE_MCD_Pressed;
+ m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed;
m_pOwner->PrevMonth();
m_pOwner->Repaint(&m_pOwner->m_rtClient);
} else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates |= FWL_PARTSTATE_MCD_Pressed;
+ m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed;
m_pOwner->NextMonth();
m_pOwner->Repaint(&m_pOwner->m_rtClient);
} else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
@@ -304,11 +313,10 @@ void CFWL_DateTimeCalendarImpDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
pPicker->m_pForm->GetWidgetRect(rt);
rt.Set(0, 0, rt.width, rt.height);
if (iCurSel > 0) {
- FWL_DATEINFO* lpDatesInfo =
- (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iCurSel - 1);
+ FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1);
CFX_RectF rtInvalidate(lpDatesInfo->rect);
if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
- lpDatesInfo = (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iOldSel - 1);
+ lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1);
rtInvalidate.Union(lpDatesInfo->rect);
}
m_pOwner->AddSelDay(iCurSel);
@@ -365,17 +373,19 @@ void CFWL_DateTimeCalendarImpDelegate::OnMouseMoveEx(CFWL_MsgMouse* pMsg) {
m_pOwner->Repaint(&rtInvalidate);
}
}
-int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage(
+
+void CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage(
CFWL_Message* pMessage) {
- if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) {
+ if (pMessage->GetClassID() == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) {
+ if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) {
DisForm_OnLButtonUpEx(pMsg);
- return 1;
+ return;
}
}
- return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
+ CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
}
+
void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx(
CFWL_MsgMouse* pMsg) {
if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
@@ -397,11 +407,10 @@ void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx(
}
int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
if (iCurSel > 0) {
- FWL_DATEINFO* lpDatesInfo =
- (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iCurSel - 1);
+ FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1);
CFX_RectF rtInvalidate(lpDatesInfo->rect);
if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
- lpDatesInfo = (FWL_DATEINFO*)m_pOwner->m_arrDates.GetAt(iOldSel - 1);
+ lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1);
rtInvalidate.Union(lpDatesInfo->rect);
}
m_pOwner->AddSelDay(iCurSel);
@@ -412,6 +421,7 @@ void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx(
pDateTime->ShowMonthCalendar(FALSE);
}
}
+
CFWL_DateTimePickerImp::CFWL_DateTimePickerImp(
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
@@ -426,17 +436,22 @@ CFWL_DateTimePickerImp::CFWL_DateTimePickerImp(
m_pForm(nullptr) {
m_rtBtn.Set(0, 0, 0, 0);
}
+
CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp() {}
-FWL_ERR CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_DateTimePicker;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_DateTimePickerImp::GetClassID() const {
- return FWL_CLASSHASH_DateTimePicker;
+
+FWL_Type CFWL_DateTimePickerImp::GetClassID() const {
+ return FWL_Type::DateTimePicker;
}
-FWL_ERR CFWL_DateTimePickerImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_DateTimePickerImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_DateTimePickerImpDelegate(this);
m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
CFWL_WidgetImpProperties propMonth;
@@ -458,9 +473,10 @@ FWL_ERR CFWL_DateTimePickerImp::Initialize() {
m_pEdit->Initialize();
RegisterEventTarget(m_pMonthCal.get());
RegisterEventTarget(m_pEdit.get());
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::Finalize() {
+
+FWL_Error CFWL_DateTimePickerImp::Finalize() {
if (m_pEdit) {
m_pEdit->Finalize();
}
@@ -475,35 +491,35 @@ FWL_ERR CFWL_DateTimePickerImp::Finalize() {
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect,
- FX_BOOL bAutoSize) {
+FWL_Error CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_GetWidgetRect(rect, bAutoSize);
}
if (bAutoSize) {
- rect.Set(0, 0, FWL_DTP_WIDTH, FWL_DTP_HEIGHT);
+ rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight);
CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::Update() {
+FWL_Error CFWL_DateTimePickerImp::Update() {
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_Update();
}
if (m_iLock) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
}
m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
GetClientRect(m_rtClient);
- FX_FLOAT* pFWidth =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pFWidth)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
FX_FLOAT fBtn = *pFWidth;
m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1,
m_rtClient.height - 1);
@@ -525,40 +541,37 @@ FWL_ERR CFWL_DateTimePickerImp::Update() {
CFX_RectF rtMonthCal;
m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
CFX_RectF rtPopUp;
- rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT,
+ rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
rtMonthCal.width, rtMonthCal.height);
m_pMonthCal->SetWidgetRect(rtPopUp);
m_pMonthCal->Update();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
- if (m_pWidgetMgr->IsFormDisabled()) {
+FWL_WidgetHit CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ if (m_pWidgetMgr->IsFormDisabled())
return DisForm_HitTest(fx, fy);
- }
- if (m_rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
+ if (m_rtClient.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
if (IsMonthCalendarShowed()) {
CFX_RectF rect;
m_pMonthCal->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
}
- return FWL_WGTHITTEST_Unknown;
+ return FWL_WidgetHit::Unknown;
}
-FWL_ERR CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_DTP_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_DTP_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
if (!m_rtBtn.IsEmpty()) {
DrawDropDownButton(pGraphics, pTheme, pMatrix);
@@ -566,53 +579,56 @@ FWL_ERR CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics,
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_DrawWidget(pGraphics, pMatrix);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider* pTP) {
+FWL_Error CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider* pTP) {
m_pProperties->m_pThemeProvider = pTP;
m_pMonthCal->SetThemeProvider(pTP);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::GetCurSel(int32_t& iYear,
- int32_t& iMonth,
- int32_t& iDay) {
+FWL_Error CFWL_DateTimePickerImp::GetCurSel(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
iYear = m_iYear;
iMonth = m_iMonth;
iDay = m_iDay;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::SetCurSel(int32_t iYear,
- int32_t iMonth,
- int32_t iDay) {
+FWL_Error CFWL_DateTimePickerImp::SetCurSel(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
if (iYear <= 0 || iYear >= 3000)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (iMonth <= 0 || iMonth >= 13)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (iDay <= 0 || iDay >= 32)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
m_iYear = iYear;
m_iMonth = iMonth;
m_iDay = iDay;
m_pMonthCal->SetSelect(iYear, iMonth, iDay);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::SetEditText(const CFX_WideString& wsText) {
+
+FWL_Error CFWL_DateTimePickerImp::SetEditText(const CFX_WideString& wsText) {
if (!m_pEdit)
- return FWL_ERR_Indefinite;
- int32_t iRet = m_pEdit->SetText(wsText);
+ return FWL_Error::Indefinite;
+
+ FWL_Error iRet = m_pEdit->SetText(wsText);
Repaint(&m_rtClient);
CFWL_Event_DtpEditChanged ev;
ev.m_wsText = wsText;
DispatchEvent(&ev);
return iRet;
}
-FWL_ERR CFWL_DateTimePickerImp::GetEditText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+
+FWL_Error CFWL_DateTimePickerImp::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
if (m_pEdit) {
return m_pEdit->GetText(wsText, nStart, nCount);
}
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
FX_BOOL CFWL_DateTimePickerImp::CanUndo() {
return m_pEdit->CanUndo();
@@ -650,15 +666,15 @@ FX_BOOL CFWL_DateTimePickerImp::Paste(const CFX_WideString& wsPaste) {
return m_pEdit->Paste(wsPaste);
}
FX_BOOL CFWL_DateTimePickerImp::SelectAll() {
- return m_pEdit->AddSelRange(0) == FWL_ERR_Succeeded;
+ return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded;
}
FX_BOOL CFWL_DateTimePickerImp::Delete() {
- return m_pEdit->ClearText() == FWL_ERR_Succeeded;
+ return m_pEdit->ClearText() == FWL_Error::Succeeded;
}
FX_BOOL CFWL_DateTimePickerImp::DeSelect() {
- return m_pEdit->ClearSelections() == FWL_ERR_Succeeded;
+ return m_pEdit->ClearSelections() == FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) {
+FWL_Error CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) {
if (m_pWidgetMgr->IsFormDisabled()) {
return DisForm_GetBBox(rect);
}
@@ -670,13 +686,14 @@ FWL_ERR CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) {
m_pProperties->m_rtWidget.top);
rect.Union(rtMonth);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit) {
+FWL_Error CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit) {
return m_pEdit->SetLimit(nLimit);
}
-FWL_ERR CFWL_DateTimePickerImp::ModifyEditStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error CFWL_DateTimePickerImp::ModifyEditStylesEx(
+ uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics,
@@ -693,7 +710,7 @@ void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics,
} else {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_DTP_DropDownButton;
+ param.m_iPart = CFWL_Part::DropDownButton;
param.m_dwStates = m_iBtnState;
param.m_pGraphics = pGraphics;
param.m_rtPart = m_rtBtn;
@@ -823,13 +840,13 @@ void CFWL_DateTimePickerImp::InitProxyForm() {
IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit() {
return m_pEdit.get();
}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_Initialize() {
+FWL_Error CFWL_DateTimePickerImp::DisForm_Initialize() {
m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
DisForm_InitDateTimeCalendar();
DisForm_InitDateTimeEdit();
RegisterEventTarget(m_pMonthCal.get());
RegisterEventTarget(m_pEdit.get());
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() {
if (m_pMonthCal) {
@@ -901,26 +918,23 @@ void CFWL_DateTimePickerImp::DisForm_ShowMonthCalendar(FX_BOOL bActivate) {
rtInvalidate.Inflate(2, 2);
Repaint(&rtInvalidate);
}
-uint32_t CFWL_DateTimePickerImp::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CFWL_DateTimePickerImp::DisForm_HitTest(FX_FLOAT fx,
+ FX_FLOAT fy) {
CFX_RectF rect;
rect.Set(0, 0, m_pProperties->m_rtWidget.width,
m_pProperties->m_rtWidget.height);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edit;
- }
- if (DisForm_IsNeedShowButton()) {
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::Edit;
+ if (DisForm_IsNeedShowButton())
rect.width += m_fBtn;
- }
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
if (IsMonthCalendarShowed()) {
m_pMonthCal->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
}
- return FWL_WGTHITTEST_Unknown;
+ return FWL_WidgetHit::Unknown;
}
FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton() {
FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused ||
@@ -928,50 +942,52 @@ FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton() {
m_pEdit->GetStates() & FWL_WGTSTATE_Focused;
return bFocus;
}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_Update() {
- if (m_iLock) {
- return FWL_ERR_Indefinite;
- }
- if (!m_pProperties->m_pThemeProvider) {
+
+FWL_Error CFWL_DateTimePickerImp::DisForm_Update() {
+ if (m_iLock)
+ return FWL_Error::Indefinite;
+ if (!m_pProperties->m_pThemeProvider)
m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
+
m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider);
GetClientRect(m_rtClient);
m_pEdit->SetWidgetRect(m_rtClient);
ReSetEditAlignment();
m_pEdit->Update();
- if (m_pMonthCal->GetThemeProvider() == NULL) {
+ if (!m_pMonthCal->GetThemeProvider())
m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider);
- }
+
if (m_pProperties->m_pDataProvider) {
IFWL_DateTimePickerDP* pData =
static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider);
pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear,
m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay);
}
- FX_FLOAT* pWidth =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ FX_FLOAT* pWidth = static_cast<FX_FLOAT*>(
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pWidth)
- return 0;
+ return FWL_Error::Succeeded;
+
m_fBtn = *pWidth;
CFX_RectF rtMonthCal;
m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
CFX_RectF rtPopUp;
- rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + FWL_DTP_HEIGHT,
+ rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight,
rtMonthCal.width, rtMonthCal.height);
m_pMonthCal->SetWidgetRect(rtPopUp);
m_pMonthCal->Update();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect,
- FX_BOOL bAutoSize) {
+
+FWL_Error CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
rect = m_pProperties->m_rtWidget;
if (DisForm_IsNeedShowButton()) {
rect.width += m_fBtn;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) {
+FWL_Error CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) {
rect = m_pProperties->m_rtWidget;
if (DisForm_IsNeedShowButton()) {
rect.width += m_fBtn;
@@ -983,12 +999,13 @@ FWL_ERR CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) {
m_pProperties->m_rtWidget.top);
rect.Union(rtMonth);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePickerImp::DisForm_DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_DateTimePickerImp::DisForm_DrawWidget(
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (m_pEdit) {
CFX_RectF rtEdit;
m_pEdit->GetWidgetRect(rtEdit);
@@ -1009,61 +1026,70 @@ FWL_ERR CFWL_DateTimePickerImp::DisForm_DrawWidget(CFX_Graphics* pGraphics,
}
m_pMonthCal->DrawWidget(pGraphics, &mt);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
+
CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate(
CFWL_DateTimePickerImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage(
- CFWL_Message* pMessage) {
+
+void CFWL_DateTimePickerImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
- switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ return;
+
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::SetFocus: {
+ OnFocusChanged(pMessage, TRUE);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(pMessage, FALSE);
+ break;
+ }
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMouse->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMouse->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMouse);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMouse);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMouse);
break;
}
- case FWL_MSGMOUSECMD_MouseLeave: {
+ case FWL_MouseCommand::Leave: {
OnMouseLeave(pMouse);
break;
}
- default: {}
+ default:
+ break;
+ }
+ break;
+ }
+ case CFWL_MessageType::Key: {
+ if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
+ IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
+ pDelegate->OnProcessMessage(pMessage);
+ return;
}
break;
}
default:
break;
}
- if (dwMsgCode == FWL_MSGHASH_Key &&
- m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
- IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL);
- return pDelegate->OnProcessMessage(pMessage);
- }
- return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
}
-FWL_ERR CFWL_DateTimePickerImpDelegate::OnDrawWidget(
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_DateTimePickerImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
FX_BOOL bSet) {
if (!pMsg)
@@ -1113,23 +1139,23 @@ void CFWL_DateTimePickerImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
return;
m_pOwner->m_bLBtnDown = FALSE;
if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Hovered;
+ m_pOwner->m_iBtnState = CFWL_PartState_Hovered;
} else {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Normal;
+ m_pOwner->m_iBtnState = CFWL_PartState_Normal;
}
m_pOwner->Repaint(&m_pOwner->m_rtBtn);
}
void CFWL_DateTimePickerImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
} else {
- m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Normal;
+ m_pOwner->m_iBtnState = CFWL_PartState_Normal;
}
m_pOwner->Repaint(&m_pOwner->m_rtBtn);
}
void CFWL_DateTimePickerImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
if (!pMsg)
return;
- m_pOwner->m_iBtnState = FWL_PARTSTATE_DTP_Normal;
+ m_pOwner->m_iBtnState = CFWL_PartState_Normal;
m_pOwner->Repaint(&m_pOwner->m_rtBtn);
}
void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg,
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.h
index 68e85050e4c..8490324d9dd 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_datetimepickerimp.h
@@ -58,8 +58,8 @@ class CFWL_DateTimeEdit : public CFWL_EditImp {
public:
CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ virtual FWL_Error Initialize();
+ virtual FWL_Error Finalize();
protected:
friend class CFWL_DateTimeEditImpDelegate;
@@ -67,10 +67,10 @@ class CFWL_DateTimeEdit : public CFWL_EditImp {
class CFWL_DateTimeEditImpDelegate : public CFWL_EditImpDelegate {
public:
CFWL_DateTimeEditImpDelegate(CFWL_DateTimeEdit* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
private:
- int32_t DisForm_OnProcessMessage(CFWL_Message* pMessage);
+ void DisForm_OnProcessMessage(CFWL_Message* pMessage);
protected:
CFWL_DateTimeEdit* m_pOwner;
@@ -79,8 +79,8 @@ class CFWL_DateTimeCalendar : public CFWL_MonthCalendarImp {
public:
CFWL_DateTimeCalendar(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ virtual FWL_Error Initialize();
+ virtual FWL_Error Finalize();
protected:
friend class CFWL_DateTimeCalendarImpDelegate;
@@ -88,14 +88,14 @@ class CFWL_DateTimeCalendar : public CFWL_MonthCalendarImp {
class CFWL_DateTimeCalendarImpDelegate : public CFWL_MonthCalendarImpDelegate {
public:
CFWL_DateTimeCalendarImpDelegate(CFWL_DateTimeCalendar* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
void OnLButtonDownEx(CFWL_MsgMouse* pMsg);
void OnLButtonUpEx(CFWL_MsgMouse* pMsg);
void OnMouseMoveEx(CFWL_MsgMouse* pMsg);
private:
- int32_t DisForm_OnProcessMessage(CFWL_Message* pMessage);
+ void DisForm_OnProcessMessage(CFWL_Message* pMessage);
void DisForm_OnLButtonUpEx(CFWL_MsgMouse* pMsg);
protected:
@@ -106,42 +106,45 @@ class CFWL_DateTimePickerImp : public CFWL_WidgetImp {
public:
CFWL_DateTimePickerImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual ~CFWL_DateTimePickerImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pTP);
- virtual FWL_ERR GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
- virtual FWL_ERR SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
- virtual FWL_ERR SetEditText(const CFX_WideString& wsText);
- virtual FWL_ERR GetEditText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
+ ~CFWL_DateTimePickerImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error Update() override;
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+ FWL_Error SetThemeProvider(IFWL_ThemeProvider* pTP) override;
+
+ FWL_Error GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
+ FWL_Error SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
+ FWL_Error SetEditText(const CFX_WideString& wsText);
+ FWL_Error GetEditText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
public:
- virtual FX_BOOL CanUndo();
- virtual FX_BOOL CanRedo();
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual FX_BOOL CanCopy();
- virtual FX_BOOL CanCut();
- virtual FX_BOOL CanSelectAll();
- virtual FX_BOOL Copy(CFX_WideString& wsCopy);
- virtual FX_BOOL Cut(CFX_WideString& wsCut);
- virtual FX_BOOL Paste(const CFX_WideString& wsPaste);
- virtual FX_BOOL SelectAll();
- virtual FX_BOOL Delete();
- virtual FX_BOOL DeSelect();
- virtual FWL_ERR GetBBox(CFX_RectF& rect);
- virtual FWL_ERR SetEditLimit(int32_t nLimit);
- virtual FWL_ERR ModifyEditStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
+ FX_BOOL CanUndo();
+ FX_BOOL CanRedo();
+ FX_BOOL Undo();
+ FX_BOOL Redo();
+ FX_BOOL CanCopy();
+ FX_BOOL CanCut();
+ FX_BOOL CanSelectAll();
+ FX_BOOL Copy(CFX_WideString& wsCopy);
+ FX_BOOL Cut(CFX_WideString& wsCut);
+ FX_BOOL Paste(const CFX_WideString& wsPaste);
+ FX_BOOL SelectAll();
+ FX_BOOL Delete();
+ FX_BOOL DeSelect();
+ FWL_Error GetBBox(CFX_RectF& rect);
+ FWL_Error SetEditLimit(int32_t nLimit);
+ FWL_Error ModifyEditStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
public:
IFWL_DateTimeEdit* GetDataTimeEdit();
@@ -161,18 +164,18 @@ class CFWL_DateTimePickerImp : public CFWL_WidgetImp {
void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay);
private:
- FWL_ERR DisForm_Initialize();
+ FWL_Error DisForm_Initialize();
void DisForm_InitDateTimeCalendar();
void DisForm_InitDateTimeEdit();
FX_BOOL DisForm_IsMonthCalendarShowed();
void DisForm_ShowMonthCalendar(FX_BOOL bActivate);
- uint32_t DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy);
FX_BOOL DisForm_IsNeedShowButton();
- FWL_ERR DisForm_Update();
- FWL_ERR DisForm_GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- FWL_ERR DisForm_GetBBox(CFX_RectF& rect);
- FWL_ERR DisForm_DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ FWL_Error DisForm_Update();
+ FWL_Error DisForm_GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ FWL_Error DisForm_GetBBox(CFX_RectF& rect);
+ FWL_Error DisForm_DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
protected:
CFX_RectF m_rtBtn;
@@ -193,9 +196,9 @@ class CFWL_DateTimePickerImp : public CFWL_WidgetImp {
m_iCurMonth = 3;
m_iCurDay = 29;
}
- virtual FWL_ERR GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) {
- return FWL_ERR_Succeeded;
+ virtual FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_Error::Succeeded;
}
virtual int32_t GetCurDay(IFWL_Widget* pWidget) { return m_iCurDay; }
virtual int32_t GetCurMonth(IFWL_Widget* pWidget) { return m_iCurMonth; }
@@ -214,9 +217,9 @@ class CFWL_DateTimePickerImp : public CFWL_WidgetImp {
class CFWL_DateTimePickerImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_DateTimePickerImpDelegate(CFWL_DateTimePickerImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.cpp
index fb25c1e0fcc..1e0fede4be6 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -7,10 +7,12 @@
#include "xfa/fwl/basewidget/fwl_editimp.h"
#include <algorithm>
+#include <memory>
#include <vector>
+#include "xfa/fde/fde_gedevice.h"
#include "xfa/fde/fde_render.h"
-#include "xfa/fde/fde_renderdevice.h"
+#include "xfa/fee/fde_txtedtengine.h"
#include "xfa/fee/ifde_txtedtpage.h"
#include "xfa/fwl/basewidget/fwl_caretimp.h"
#include "xfa/fwl/basewidget/fwl_comboboximp.h"
@@ -22,14 +24,36 @@
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_path.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+
+namespace {
+
+const int kEditMargin = 3;
+
+bool FX_EDIT_ISLATINWORD(FX_WCHAR c) {
+ return c == 0x2D || (c <= 0x005A && c >= 0x0041) ||
+ (c <= 0x007A && c >= 0x0061) || (c <= 0x02AF && c >= 0x00C0) ||
+ c == 0x0027;
+}
+
+void AddSquigglyPath(CFX_Path* pPathData,
+ FX_FLOAT fStartX,
+ FX_FLOAT fEndX,
+ FX_FLOAT fY,
+ FX_FLOAT fStep) {
+ pPathData->MoveTo(fStartX, fY);
+ int i = 1;
+ for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) {
+ pPathData->LineTo(fx, fY + (i & 1) * fStep);
+ }
+}
+
+} // namespace
// static
IFWL_Edit* IFWL_Edit::Create(const CFWL_WidgetImpProperties& properties,
@@ -51,18 +75,18 @@ IFWL_Edit* IFWL_Edit::CreateComboEdit(
return pEdit;
}
IFWL_Edit::IFWL_Edit() {}
-FWL_ERR IFWL_Edit::SetText(const CFX_WideString& wsText) {
+FWL_Error IFWL_Edit::SetText(const CFX_WideString& wsText) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetText(wsText);
}
int32_t IFWL_Edit::GetTextLength() const {
return static_cast<CFWL_EditImp*>(GetImpl())->GetTextLength();
}
-FWL_ERR IFWL_Edit::GetText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+FWL_Error IFWL_Edit::GetText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
return static_cast<CFWL_EditImp*>(GetImpl())->GetText(wsText, nStart, nCount);
}
-FWL_ERR IFWL_Edit::ClearText() {
+FWL_Error IFWL_Edit::ClearText() {
return static_cast<CFWL_EditImp*>(GetImpl())->ClearText();
}
int32_t IFWL_Edit::GetCaretPos() const {
@@ -71,7 +95,7 @@ int32_t IFWL_Edit::GetCaretPos() const {
int32_t IFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetCaretPos(nIndex, bBefore);
}
-FWL_ERR IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
+FWL_Error IFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
return static_cast<CFWL_EditImp*>(GetImpl())->AddSelRange(nStart, nCount);
}
int32_t IFWL_Edit::CountSelRanges() {
@@ -80,39 +104,36 @@ int32_t IFWL_Edit::CountSelRanges() {
int32_t IFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) {
return static_cast<CFWL_EditImp*>(GetImpl())->GetSelRange(nIndex, nStart);
}
-FWL_ERR IFWL_Edit::ClearSelections() {
+FWL_Error IFWL_Edit::ClearSelections() {
return static_cast<CFWL_EditImp*>(GetImpl())->ClearSelections();
}
int32_t IFWL_Edit::GetLimit() {
return static_cast<CFWL_EditImp*>(GetImpl())->GetLimit();
}
-FWL_ERR IFWL_Edit::SetLimit(int32_t nLimit) {
+FWL_Error IFWL_Edit::SetLimit(int32_t nLimit) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetLimit(nLimit);
}
-FWL_ERR IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
+FWL_Error IFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetAliasChar(wAlias);
}
-FWL_ERR IFWL_Edit::Insert(int32_t nStart,
- const FX_WCHAR* lpText,
- int32_t nLen) {
+FWL_Error IFWL_Edit::Insert(int32_t nStart,
+ const FX_WCHAR* lpText,
+ int32_t nLen) {
return static_cast<CFWL_EditImp*>(GetImpl())->Insert(nStart, lpText, nLen);
}
-FWL_ERR IFWL_Edit::DeleteSelections() {
+FWL_Error IFWL_Edit::DeleteSelections() {
return static_cast<CFWL_EditImp*>(GetImpl())->DeleteSelections();
}
-FWL_ERR IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
+FWL_Error IFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
return static_cast<CFWL_EditImp*>(GetImpl())->DeleteRange(nStart, nCount);
}
-FWL_ERR IFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) {
- return static_cast<CFWL_EditImp*>(GetImpl())->ReplaceSelections(wsReplace);
-}
-FWL_ERR IFWL_Edit::Replace(int32_t nStart,
- int32_t nLen,
- const CFX_WideStringC& wsReplace) {
+FWL_Error IFWL_Edit::Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace) {
return static_cast<CFWL_EditImp*>(GetImpl())
->Replace(nStart, nLen, wsReplace);
}
-FWL_ERR IFWL_Edit::DoClipboard(int32_t iCmd) {
+FWL_Error IFWL_Edit::DoClipboard(int32_t iCmd) {
return static_cast<CFWL_EditImp*>(GetImpl())->DoClipboard(iCmd);
}
FX_BOOL IFWL_Edit::Copy(CFX_WideString& wsCopy) {
@@ -145,20 +166,20 @@ FX_BOOL IFWL_Edit::CanUndo() {
FX_BOOL IFWL_Edit::CanRedo() {
return static_cast<CFWL_EditImp*>(GetImpl())->CanRedo();
}
-FWL_ERR IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
+FWL_Error IFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
return static_cast<CFWL_EditImp*>(GetImpl())
->SetTabWidth(fTabWidth, bEquidistant);
}
-FWL_ERR IFWL_Edit::SetOuter(IFWL_Widget* pOuter) {
+FWL_Error IFWL_Edit::SetOuter(IFWL_Widget* pOuter) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetOuter(pOuter);
}
-FWL_ERR IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
+FWL_Error IFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetNumberRange(iMin, iMax);
}
-FWL_ERR IFWL_Edit::SetBackColor(uint32_t dwColor) {
+FWL_Error IFWL_Edit::SetBackColor(uint32_t dwColor) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetBackgroundColor(dwColor);
}
-FWL_ERR IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
+FWL_Error IFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetFont(wsFont, fSize);
}
void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
@@ -174,7 +195,7 @@ FX_BOOL IFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf,
return static_cast<CFWL_EditImp*>(GetImpl())
->ReplaceSpellCheckWord(pointf, bsReplace);
}
-#define FWL_EDIT_Margin 3
+
CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_WidgetImp(properties, pOuter),
@@ -199,6 +220,7 @@ CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
m_rtEngine.Reset();
m_rtStatic.Reset();
}
+
CFWL_EditImp::~CFWL_EditImp() {
if (m_pEdtEngine) {
m_pEdtEngine->Release();
@@ -206,26 +228,30 @@ CFWL_EditImp::~CFWL_EditImp() {
}
ClearRecord();
}
-FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_Edit;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_EditImp::GetClassID() const {
- return FWL_CLASSHASH_Edit;
+
+FWL_Type CFWL_EditImp::GetClassID() const {
+ return FWL_Type::Edit;
}
-FWL_ERR CFWL_EditImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
- if (!m_pDelegate) {
+
+FWL_Error CFWL_EditImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+ if (!m_pDelegate)
m_pDelegate = new CFWL_EditImpDelegate(this);
- }
+
InitCaret();
- if (!m_pEdtEngine) {
+ if (!m_pEdtEngine)
InitEngine();
- }
- return FWL_ERR_Succeeded;
+
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::Finalize() {
+
+FWL_Error CFWL_EditImp::Finalize() {
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
ShowCaret(FALSE);
}
@@ -239,7 +265,7 @@ FWL_ERR CFWL_EditImp::Finalize() {
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
if (m_pEdtEngine) {
@@ -259,85 +285,70 @@ FWL_ERR CFWL_EditImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
if (IsShowScrollBar(TRUE)) {
FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>(
- GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
rect.width += *pfWidth;
- rect.width += FWL_EDIT_Margin;
+ rect.width += kEditMargin;
}
if (IsShowScrollBar(FALSE)) {
FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>(
- GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
rect.height += *pfWidth;
- rect.height += FWL_EDIT_Margin;
+ rect.height += kEditMargin;
}
}
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
+
+void CFWL_EditImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) ||
(m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
ShowCaret(FALSE);
}
- return CFWL_WidgetImp::SetStates(dwStates, bSet);
+ CFWL_WidgetImp::SetStates(dwStates, bSet);
}
-FWL_ERR CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) {
+
+FWL_Error CFWL_EditImp::SetWidgetRect(const CFX_RectF& rect) {
return CFWL_WidgetImp::SetWidgetRect(rect);
}
-FWL_ERR CFWL_EditImp::Update() {
+FWL_Error CFWL_EditImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
}
Layout();
if (m_rtClient.IsEmpty()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
UpdateEditEngine();
UpdateVAlignment();
UpdateScroll();
InitCaret();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+
+FWL_WidgetHit CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
if (IsShowScrollBar(TRUE)) {
CFX_RectF rect;
m_pVertScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_VScrollBar;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::VScrollBar;
}
if (IsShowScrollBar(FALSE)) {
CFX_RectF rect;
m_pHorzScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_HScrollBar;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::HScrollBar;
}
}
- if (m_rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edit;
- }
- return FWL_WGTHITTEST_Unknown;
-}
-#define FX_EDIT_ISLATINWORD(u) \
- (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \
- (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0) || \
- u == 0x0027)
-static void AddSquigglyPath(CFX_Path& PathData,
- FX_FLOAT fStartX,
- FX_FLOAT fEndX,
- FX_FLOAT fY,
- FX_FLOAT fStep) {
- PathData.MoveTo(fStartX, fY);
- FX_FLOAT fx;
- int32_t i;
- for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
- PathData.LineTo(fx, fY + (i & 1) * fStep);
- }
+ if (m_rtClient.Contains(fx, fy))
+ return FWL_WidgetHit::Edit;
+ return FWL_WidgetHit::Unknown;
}
+
void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData,
int32_t nStart,
int32_t nCount,
@@ -360,7 +371,7 @@ void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData,
fStep = txtEdtParams->fFontSize / 16.0f;
fStartX = rectText.left + fOffSetX;
fEndX = fStartX + rectText.Width();
- AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
+ AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep);
}
}
int32_t CFWL_EditImp::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) {
@@ -423,7 +434,7 @@ FX_BOOL CFWL_EditImp::ReplaceSpellCheckWord(CFX_PointF pointf,
pBuffer[i] = bsReplace[i];
}
wsDest.ReleaseBuffer(nDestLen);
- Replace(nWordStart, nWordCount, wsDest.AsWideStringC());
+ Replace(nWordStart, nWordCount, wsDest.AsStringC());
return TRUE;
}
void CFWL_EditImp::DrawSpellCheck(CFX_Graphics* pGraphics,
@@ -459,7 +470,7 @@ void CFWL_EditImp::DrawSpellCheck(CFX_Graphics* pGraphics,
AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX,
fOffSetY);
}
- sLatinWord.Empty();
+ sLatinWord.clear();
}
}
checkWordEvent.bsWord = sLatinWord;
@@ -484,14 +495,14 @@ void CFWL_EditImp::DrawSpellCheck(CFX_Graphics* pGraphics,
}
pGraphics->RestoreGraphState();
}
-FWL_ERR CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (m_rtClient.IsEmpty()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
if (!m_pWidgetMgr->IsFormDisabled()) {
@@ -505,16 +516,16 @@ FWL_ERR CFWL_EditImp::DrawWidget(CFX_Graphics* pGraphics,
DrawSpellCheck(pGraphics, pMatrix);
}
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_EDT_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_EDT_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+FWL_Error CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
if (!pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (m_pHorzScrollBar) {
m_pHorzScrollBar->SetThemeProvider(pThemeProvider);
}
@@ -525,175 +536,197 @@ FWL_ERR CFWL_EditImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
m_pCaret->SetThemeProvider(pThemeProvider);
}
m_pProperties->m_pThemeProvider = pThemeProvider;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::SetText(const CFX_WideString& wsText) {
+
+FWL_Error CFWL_EditImp::SetText(const CFX_WideString& wsText) {
m_pEdtEngine->SetText(wsText);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
+
int32_t CFWL_EditImp::GetTextLength() const {
if (!m_pEdtEngine)
return -1;
return m_pEdtEngine->GetTextLength();
}
-FWL_ERR CFWL_EditImp::GetText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+
+FWL_Error CFWL_EditImp::GetText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
m_pEdtEngine->GetText(wsText, nStart, nCount);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::ClearText() {
+
+FWL_Error CFWL_EditImp::ClearText() {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
m_pEdtEngine->ClearText();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
+
int32_t CFWL_EditImp::GetCaretPos() const {
if (!m_pEdtEngine)
return -1;
return m_pEdtEngine->GetCaretPos();
}
+
int32_t CFWL_EditImp::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
if (!m_pEdtEngine)
return -1;
return m_pEdtEngine->SetCaretPos(nIndex, bBefore);
}
-FWL_ERR CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount) {
+
+FWL_Error CFWL_EditImp::AddSelRange(int32_t nStart, int32_t nCount) {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
m_pEdtEngine->AddSelRange(nStart, nCount);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
+
int32_t CFWL_EditImp::CountSelRanges() {
if (!m_pEdtEngine)
return 0;
return m_pEdtEngine->CountSelRanges();
- return FWL_ERR_Succeeded;
}
+
int32_t CFWL_EditImp::GetSelRange(int32_t nIndex, int32_t& nStart) {
if (!m_pEdtEngine)
return -1;
return m_pEdtEngine->GetSelRange(nIndex, nStart);
}
-FWL_ERR CFWL_EditImp::ClearSelections() {
+
+FWL_Error CFWL_EditImp::ClearSelections() {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
m_pEdtEngine->ClearSelection();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
+
int32_t CFWL_EditImp::GetLimit() {
return m_nLimit;
}
-FWL_ERR CFWL_EditImp::SetLimit(int32_t nLimit) {
+
+FWL_Error CFWL_EditImp::SetLimit(int32_t nLimit) {
m_nLimit = nLimit;
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
m_pEdtEngine->SetLimit(nLimit);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) {
+
+FWL_Error CFWL_EditImp::SetAliasChar(FX_WCHAR wAlias) {
if (!m_pEdtEngine)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
m_pEdtEngine->SetAliasChar(wAlias);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::Insert(int32_t nStart,
- const FX_WCHAR* lpText,
- int32_t nLen) {
+
+FWL_Error CFWL_EditImp::Insert(int32_t nStart,
+ const FX_WCHAR* lpText,
+ int32_t nLen) {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
(m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
m_pEdtEngine->Insert(nStart, lpText, nLen);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::DeleteSelections() {
+
+FWL_Error CFWL_EditImp::DeleteSelections() {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
int32_t iCount = m_pEdtEngine->CountSelRanges();
- if (iCount > 0) {
+ if (iCount > 0)
m_pEdtEngine->Delete(-1);
- }
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) {
+
+FWL_Error CFWL_EditImp::DeleteRange(int32_t nStart, int32_t nCount) {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
m_pEdtEngine->DeleteRange(nStart, nCount);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_EditImp::ReplaceSelections(const CFX_WideStringC& wsReplace) {
- if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
- int32_t iCount = m_pEdtEngine->CountSelRanges();
- for (int i = 0; i < iCount; i++) {
- int32_t nStart;
- int32_t nCount = m_pEdtEngine->GetSelRange(i, nStart);
- m_pEdtEngine->Replace(nStart, nCount, wsReplace);
- }
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::Replace(int32_t nStart,
- int32_t nLen,
- const CFX_WideStringC& wsReplace) {
+
+FWL_Error CFWL_EditImp::Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace) {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
- m_pEdtEngine->Replace(nStart, nLen, wsReplace);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
+ m_pEdtEngine->Replace(nStart, nLen, CFX_WideString(wsReplace));
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::DoClipboard(int32_t iCmd) {
+
+FWL_Error CFWL_EditImp::DoClipboard(int32_t iCmd) {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
(m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
+
FX_BOOL CFWL_EditImp::Copy(CFX_WideString& wsCopy) {
if (!m_pEdtEngine)
return FALSE;
+
int32_t nCount = m_pEdtEngine->CountSelRanges();
- if (nCount == 0) {
+ if (nCount == 0)
return FALSE;
- }
- wsCopy.Empty();
+
+ wsCopy.clear();
CFX_WideString wsTemp;
int32_t nStart, nLength;
for (int32_t i = 0; i < nCount; i++) {
nLength = m_pEdtEngine->GetSelRange(i, nStart);
m_pEdtEngine->GetText(wsTemp, nStart, nLength);
wsCopy += wsTemp;
- wsTemp.Empty();
+ wsTemp.clear();
}
return TRUE;
}
+
FX_BOOL CFWL_EditImp::Cut(CFX_WideString& wsCut) {
if (!m_pEdtEngine)
return FALSE;
+
int32_t nCount = m_pEdtEngine->CountSelRanges();
- if (nCount == 0) {
+ if (nCount == 0)
return FALSE;
- }
- wsCut.Empty();
+
+ wsCut.clear();
CFX_WideString wsTemp;
int32_t nStart, nLength;
for (int32_t i = 0; i < nCount; i++) {
nLength = m_pEdtEngine->GetSelRange(i, nStart);
m_pEdtEngine->GetText(wsTemp, nStart, nLength);
wsCut += wsTemp;
- wsTemp.Empty();
+ wsTemp.clear();
}
m_pEdtEngine->Delete(0);
return TRUE;
}
+
FX_BOOL CFWL_EditImp::Paste(const CFX_WideString& wsPaste) {
if (!m_pEdtEngine)
return FALSE;
+
int32_t nCaret = m_pEdtEngine->GetCaretPos();
int32_t iError =
m_pEdtEngine->Insert(nCaret, wsPaste.c_str(), wsPaste.GetLength());
@@ -703,80 +736,89 @@ FX_BOOL CFWL_EditImp::Paste(const CFX_WideString& wsPaste) {
}
return TRUE;
}
+
FX_BOOL CFWL_EditImp::Delete() {
if (!m_pEdtEngine)
return FALSE;
+
int32_t nCount = m_pEdtEngine->CountSelRanges();
- if (nCount < 1) {
+ if (nCount < 1)
return FALSE;
- }
+
m_pEdtEngine->Delete(0);
return TRUE;
}
+
FX_BOOL CFWL_EditImp::Redo(const CFX_ByteStringC& bsRecord) {
if (!m_pEdtEngine)
return FALSE;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo)
return TRUE;
- }
return m_pEdtEngine->Redo(bsRecord);
}
+
FX_BOOL CFWL_EditImp::Undo(const CFX_ByteStringC& bsRecord) {
if (!m_pEdtEngine)
return FALSE;
- if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoRedoUndo)
return TRUE;
- }
return m_pEdtEngine->Undo(bsRecord);
}
+
FX_BOOL CFWL_EditImp::Undo() {
- if (!CanUndo()) {
+ if (!CanUndo())
return FALSE;
- }
+
CFX_ByteString bsRecord = m_RecordArr[m_iCurRecord--];
- return Undo(bsRecord.AsByteStringC());
+ return Undo(bsRecord.AsStringC());
}
+
FX_BOOL CFWL_EditImp::Redo() {
- if (!CanRedo()) {
+ if (!CanRedo())
return FALSE;
- }
+
CFX_ByteString bsRecord = m_RecordArr[++m_iCurRecord];
- return Redo(bsRecord.AsByteStringC());
+ return Redo(bsRecord.AsStringC());
}
+
FX_BOOL CFWL_EditImp::CanUndo() {
return m_iCurRecord >= 0;
}
+
FX_BOOL CFWL_EditImp::CanRedo() {
return m_iCurRecord < m_RecordArr.GetSize() - 1;
}
-FWL_ERR CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
+
+FWL_Error CFWL_EditImp::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
if (!m_pEdtEngine)
- return FWL_ERR_Succeeded;
- FDE_LPTXTEDTPARAMS pParams =
- (FDE_LPTXTEDTPARAMS)m_pEdtEngine->GetEditParams();
+ return FWL_Error::Indefinite;
+
+ FDE_TXTEDTPARAMS* pParams = m_pEdtEngine->GetEditParams();
pParams->fTabWidth = fTabWidth;
pParams->bTabEquidistant = bEquidistant;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) {
+
+FWL_Error CFWL_EditImp::SetOuter(IFWL_Widget* pOuter) {
m_pOuter = pOuter;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) {
+
+FWL_Error CFWL_EditImp::SetNumberRange(int32_t iMin, int32_t iMax) {
m_iMin = iMin;
m_iMax = iMax;
m_bSetRange = TRUE;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine* pEdit,
+
+void CFWL_EditImp::On_CaretChanged(CFDE_TxtEdtEngine* pEdit,
int32_t nPage,
FX_BOOL bVisible) {
- if (m_rtEngine.IsEmpty()) {
+ if (m_rtEngine.IsEmpty())
return;
- }
- if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
return;
- }
+
FX_BOOL bRepaintContent = UpdateOffset();
UpdateCaret();
CFX_RectF rtInvalid;
@@ -796,12 +838,13 @@ void CFWL_EditImp::On_CaretChanged(IFDE_TxtEdtEngine* pEdit,
Repaint(&rtInvalid);
}
}
-void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit,
+
+void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit,
FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
uint32_t dwStyleEx = m_pProperties->m_dwStyleExes;
- if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask) {
+ if (dwStyleEx & FWL_STYLEEXT_EDT_VAlignMask)
UpdateVAlignment();
- }
+
IFDE_TxtEdtPage* page = m_pEdtEngine->GetPage(0);
FX_FLOAT fContentWidth = page->GetContentsBox().width;
FX_FLOAT fContentHeight = page->GetContentsBox().height;
@@ -861,25 +904,25 @@ void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit,
LayoutScrollBar();
Repaint(&rtTemp);
}
-void CFWL_EditImp::On_SelChanged(IFDE_TxtEdtEngine* pEdit) {
+void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) {
CFX_RectF rtTemp;
GetClientRect(rtTemp);
Repaint(&rtTemp);
}
-FX_BOOL CFWL_EditImp::On_PageLoad(IFDE_TxtEdtEngine* pEdit,
+FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
int32_t nPurpose) {
- IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
+ CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
if (!pPage)
return FALSE;
pPage->LoadPage(nullptr, nullptr);
return TRUE;
}
-FX_BOOL CFWL_EditImp::On_PageUnload(IFDE_TxtEdtEngine* pEdit,
+FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
int32_t nPurpose) {
- IFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
+ CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
if (!pPage)
return FALSE;
@@ -887,28 +930,12 @@ FX_BOOL CFWL_EditImp::On_PageUnload(IFDE_TxtEdtEngine* pEdit,
return TRUE;
}
-void CFWL_EditImp::On_AddDoRecord(IFDE_TxtEdtEngine* pEdit,
+void CFWL_EditImp::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit,
const CFX_ByteStringC& bsDoRecord) {
AddDoRecord(bsDoRecord);
}
-FX_BOOL CFWL_EditImp::On_ValidateField(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex,
- int32_t nFieldIndex,
- const CFX_WideString& wsFieldText,
- int32_t nCharIndex) {
- return TRUE;
-}
-FX_BOOL CFWL_EditImp::On_ValidateBlock(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex) {
- return TRUE;
-}
-FX_BOOL CFWL_EditImp::On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex,
- CFX_WideString& wsBlockText) {
- return FALSE;
-}
-FX_BOOL CFWL_EditImp::On_Validate(IFDE_TxtEdtEngine* pEdit,
+FX_BOOL CFWL_EditImp::On_Validate(CFDE_TxtEdtEngine* pEdit,
CFX_WideString& wsText) {
IFWL_Widget* pDst = GetOuter();
if (!pDst) {
@@ -922,15 +949,15 @@ FX_BOOL CFWL_EditImp::On_Validate(IFDE_TxtEdtEngine* pEdit,
DispatchEvent(&event);
return event.bValidate;
}
-FWL_ERR CFWL_EditImp::SetBackgroundColor(uint32_t color) {
+FWL_Error CFWL_EditImp::SetBackgroundColor(uint32_t color) {
m_backColor = color;
m_updateBackColor = TRUE;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
+FWL_Error CFWL_EditImp::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
m_wsFont = wsFont;
m_fFontSize = fSize;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_EditImp::SetScrollOffset(FX_FLOAT fScrollOffset) {
m_fScrollOffsetY = fScrollOffset;
@@ -940,14 +967,14 @@ void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_EDT_Background;
- param.m_dwData = FWL_PARTDATA_EDT_Background;
+ param.m_iPart = CFWL_Part::Background;
+ param.m_bStaticBackground = false;
param.m_dwStates = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly
- ? FWL_PARTSTATE_EDT_ReadOnly
- : FWL_PARTSTATE_EDT_Normal;
+ ? CFWL_PartState_ReadOnly
+ : CFWL_PartState_Normal;
uint32_t dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled);
if (dwStates) {
- param.m_dwStates = FWL_PARTSTATE_EDT_Disable;
+ param.m_dwStates = CFWL_PartState_Disabled;
}
param.m_pGraphics = pGraphics;
param.m_matrix = *pMatrix;
@@ -962,7 +989,8 @@ void CFWL_EditImp::DrawTextBk(CFX_Graphics* pGraphics,
rtStatic.Set(m_rtClient.right() - rtScorll.height,
m_rtClient.bottom() - rtScorll.height, rtScorll.height,
rtScorll.height);
- param.m_dwData = FWL_PARTDATA_EDT_StaticBackground;
+ param.m_bStaticBackground = true;
+ param.m_bMaximize = true;
param.m_rtPart = rtStatic;
pTheme->DrawBackground(&param);
}
@@ -1032,24 +1060,20 @@ void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics,
param.m_pGraphics = pGraphics;
param.m_matrix = *pMatrix;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_EDT_Background;
+ param.m_iPart = CFWL_Part::Background;
param.m_pPath = &path;
pTheme->DrawBackground(&param);
}
CFX_RenderDevice* pRenderDev = pGraphics->GetRenderDevice();
if (!pRenderDev)
return;
- IFDE_RenderDevice* pRenderDevice = IFDE_RenderDevice::Create(pRenderDev);
- if (!pRenderDevice)
- return;
- IFDE_RenderContext* pRenderContext = IFDE_RenderContext::Create();
- if (!pRenderContext)
- return;
+
+ std::unique_ptr<CFDE_RenderDevice> pRenderDevice(
+ new CFDE_RenderDevice(pRenderDev, FALSE));
+ std::unique_ptr<CFDE_RenderContext> pRenderContext(new CFDE_RenderContext);
pRenderDevice->SetClipRect(rtClip);
- pRenderContext->StartRender(pRenderDevice, pPage, mt);
- pRenderContext->DoRender(NULL);
- pRenderContext->Release();
- pRenderDevice->Release();
+ pRenderContext->StartRender(pRenderDevice.get(), pPage, mt);
+ pRenderContext->DoRender(nullptr);
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) {
pGraphics->RestoreGraphState();
CFX_Path path;
@@ -1065,12 +1089,13 @@ void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics,
param.m_pGraphics = pGraphics;
param.m_matrix = *pMatrix;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_EDT_CombTextLine;
+ param.m_iPart = CFWL_Part::CombTextLine;
param.m_pPath = &path;
pTheme->DrawBackground(&param);
}
pGraphics->RestoreGraphState();
}
+
void CFWL_EditImp::UpdateEditEngine() {
UpdateEditParams();
UpdateEditLayout();
@@ -1162,22 +1187,22 @@ void CFWL_EditImp::UpdateEditParams() {
params.dwMode |= FDE_TEXTEDITMODE_ReadOnly;
}
FX_FLOAT* pFontSize =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FontSize));
+ static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize));
if (!pFontSize)
return;
m_fFontSize = *pFontSize;
uint32_t* pFontColor =
- static_cast<uint32_t*>(GetThemeCapacity(FWL_WGTCAPACITY_TextColor));
+ static_cast<uint32_t*>(GetThemeCapacity(CFWL_WidgetCapacity::TextColor));
if (!pFontColor)
return;
params.dwFontColor = *pFontColor;
FX_FLOAT* pLineHeight =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_LineHeight));
+ static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::LineHeight));
if (!pLineHeight)
return;
params.fLineSpace = *pLineHeight;
IFX_Font* pFont =
- static_cast<IFX_Font*>(GetThemeCapacity(FWL_WGTCAPACITY_Font));
+ static_cast<IFX_Font*>(GetThemeCapacity(CFWL_WidgetCapacity::Font));
if (!pFont)
return;
params.pFont = pFont;
@@ -1221,57 +1246,48 @@ FX_BOOL CFWL_EditImp::UpdateOffset() {
IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
if (!pPage)
return FALSE;
+
CFX_RectF rtFDE = pPage->GetContentsBox();
rtFDE.Offset(fOffSetX, fOffSetY);
if (rtFDE.right() < rtEidt.right() && m_fScrollOffsetX > 0) {
m_fScrollOffsetX += rtFDE.right() - rtEidt.right();
- if (m_fScrollOffsetX < 0) {
- m_fScrollOffsetX = 0;
- }
+ m_fScrollOffsetX = std::max(m_fScrollOffsetX, 0.0f);
}
if (rtFDE.bottom() < rtEidt.bottom() && m_fScrollOffsetY > 0) {
m_fScrollOffsetY += rtFDE.bottom() - rtEidt.bottom();
- if (m_fScrollOffsetY < 0) {
- m_fScrollOffsetY = 0;
- }
+ m_fScrollOffsetY = std::max(m_fScrollOffsetY, 0.0f);
}
return FALSE;
- } else {
- FX_FLOAT offsetX = 0.0;
- FX_FLOAT offsetY = 0.0;
- if (rtCaret.left < rtEidt.left) {
- offsetX = rtCaret.left - rtEidt.left;
- }
- if (rtCaret.right() > rtEidt.right()) {
- offsetX = rtCaret.right() - rtEidt.right();
- }
- if (rtCaret.top < rtEidt.top) {
- offsetY = rtCaret.top - rtEidt.top;
- }
- if (rtCaret.bottom() > rtEidt.bottom()) {
- offsetY = rtCaret.bottom() - rtEidt.bottom();
- }
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption)) {
- m_fScrollOffsetX += offsetX;
- }
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption)) {
- m_fScrollOffsetY += offsetY;
- }
- if (m_fFontSize > m_rtEngine.height) {
- m_fScrollOffsetY = 0;
- }
- return TRUE;
}
+
+ FX_FLOAT offsetX = 0.0;
+ FX_FLOAT offsetY = 0.0;
+ if (rtCaret.left < rtEidt.left)
+ offsetX = rtCaret.left - rtEidt.left;
+ if (rtCaret.right() > rtEidt.right())
+ offsetX = rtCaret.right() - rtEidt.right();
+ if (rtCaret.top < rtEidt.top)
+ offsetY = rtCaret.top - rtEidt.top;
+ if (rtCaret.bottom() > rtEidt.bottom())
+ offsetY = rtCaret.bottom() - rtEidt.bottom();
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption))
+ m_fScrollOffsetX += offsetX;
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption))
+ m_fScrollOffsetY += offsetY;
+ if (m_fFontSize > m_rtEngine.height)
+ m_fScrollOffsetY = 0;
+ return TRUE;
}
+
FX_BOOL CFWL_EditImp::UpdateOffset(IFWL_ScrollBar* pScrollBar,
FX_FLOAT fPosChanged) {
- if (pScrollBar == m_pHorzScrollBar.get()) {
+ if (pScrollBar == m_pHorzScrollBar.get())
m_fScrollOffsetX += fPosChanged;
- } else {
+ else
m_fScrollOffsetY += fPosChanged;
- }
return TRUE;
}
+
void CFWL_EditImp::UpdateVAlignment() {
IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
if (!pPage)
@@ -1281,7 +1297,7 @@ void CFWL_EditImp::UpdateVAlignment() {
FX_FLOAT fSpaceAbove = 0.0f;
FX_FLOAT fSpaceBelow = 0.0f;
CFX_SizeF* pSpace = static_cast<CFX_SizeF*>(
- GetThemeCapacity(FWL_WGTCAPACITY_SpaceAboveBelow));
+ GetThemeCapacity(CFWL_WidgetCapacity::SpaceAboveBelow));
if (pSpace) {
fSpaceAbove = pSpace->x;
fSpaceBelow = pSpace->y;
@@ -1464,30 +1480,30 @@ int32_t CFWL_EditImp::AddDoRecord(const CFX_ByteStringC& bsDoRecord) {
m_RecordArr.RemoveAt(i);
}
}
- m_RecordArr.Add(bsDoRecord);
+ m_RecordArr.Add(CFX_ByteString(bsDoRecord));
return m_iCurRecord = m_RecordArr.GetSize() - 1;
}
void CFWL_EditImp::Layout() {
GetClientRect(m_rtClient);
m_rtEngine = m_rtClient;
- FX_FLOAT* pfWidth =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>(
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pfWidth)
return;
FX_FLOAT fWidth = *pfWidth;
if (!m_pOuter) {
- CFX_RectF* pUIMargin =
- static_cast<CFX_RectF*>(GetThemeCapacity(FWL_WGTCAPACITY_UIMargin));
+ CFX_RectF* pUIMargin = static_cast<CFX_RectF*>(
+ GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
if (pUIMargin) {
m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
pUIMargin->height);
}
- } else if (m_pOuter->GetClassID() == FWL_CLASSHASH_DateTimePicker) {
+ } else if (m_pOuter->GetClassID() == FWL_Type::DateTimePicker) {
CFWL_ThemePart part;
part.m_pWidget = m_pOuter;
CFX_RectF* pUIMargin =
static_cast<CFX_RectF*>(m_pOuter->GetThemeProvider()->GetCapacity(
- &part, FWL_WGTCAPACITY_UIMargin));
+ &part, CFWL_WidgetCapacity::UIMargin));
if (pUIMargin) {
m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
pUIMargin->height);
@@ -1499,8 +1515,8 @@ void CFWL_EditImp::Layout() {
InitScrollBar();
CFX_RectF rtVertScr;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- rtVertScr.Set(m_rtClient.right() + FWL_EDIT_Margin, m_rtClient.top,
- fWidth, m_rtClient.height);
+ rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth,
+ m_rtClient.height);
} else {
rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth,
m_rtClient.height);
@@ -1519,7 +1535,7 @@ void CFWL_EditImp::Layout() {
InitScrollBar(FALSE);
CFX_RectF rtHoriScr;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + FWL_EDIT_Margin,
+ rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin,
m_rtClient.width, fWidth);
} else {
rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth,
@@ -1547,13 +1563,13 @@ void CFWL_EditImp::LayoutScrollBar() {
if (bShowVertScrollbar) {
if (!m_pVertScrollBar) {
pfWidth = static_cast<FX_FLOAT*>(
- GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
InitScrollBar();
CFX_RectF rtVertScr;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- rtVertScr.Set(m_rtClient.right() + FWL_EDIT_Margin, m_rtClient.top,
- fWidth, m_rtClient.height);
+ rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth,
+ m_rtClient.height);
} else {
rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth,
m_rtClient.height);
@@ -1572,13 +1588,13 @@ void CFWL_EditImp::LayoutScrollBar() {
if (!m_pHorzScrollBar) {
if (!pfWidth) {
pfWidth = static_cast<FX_FLOAT*>(
- GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
}
FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
InitScrollBar(FALSE);
CFX_RectF rtHoriScr;
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
- rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + FWL_EDIT_Margin,
+ rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin,
m_rtClient.width, fWidth);
} else {
rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth,
@@ -1598,10 +1614,12 @@ void CFWL_EditImp::LayoutScrollBar() {
UpdateScroll();
}
}
+
void CFWL_EditImp::DeviceToEngine(CFX_PointF& pt) {
- pt.x += -m_rtEngine.left + m_fScrollOffsetX;
- pt.y += -m_rtEngine.top - m_fVAlignOffset + m_fScrollOffsetY;
+ pt.x += m_fScrollOffsetX - m_rtEngine.left;
+ pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset;
}
+
void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) {
if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
return;
@@ -1615,24 +1633,24 @@ void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) {
pScrollBar->Initialize();
(bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
}
+
void CFWL_EditImp::InitEngine() {
- if (m_pEdtEngine) {
- return;
- }
- m_pEdtEngine = IFDE_TxtEdtEngine::Create();
+ if (!m_pEdtEngine)
+ m_pEdtEngine = new CFDE_TxtEdtEngine;
}
FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget,
FX_BOOL bVisible,
const CFX_RectF* pRtAnchor) {
- CXFA_FFWidget* pXFAWidget = (CXFA_FFWidget*)pWidget->GetPrivateData(pWidget);
- if (!pXFAWidget) {
+ CXFA_FFWidget* pXFAWidget =
+ static_cast<CXFA_FFWidget*>(pWidget->GetPrivateData(pWidget));
+ if (!pXFAWidget)
return FALSE;
- }
+
IXFA_DocProvider* pDocProvider = pXFAWidget->GetDoc()->GetDocProvider();
- if (!pDocProvider) {
+ if (!pDocProvider)
return FALSE;
- }
+
if (bVisible) {
CFX_Matrix mt;
pXFAWidget->GetRotateMatrix(mt);
@@ -1733,77 +1751,78 @@ void CFWL_EditImp::ProcessInsertError(int32_t iError) {
default: {}
}
}
+
CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
+ return;
+
+ CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
+ case CFWL_MessageType::Activate: {
DoActivate(static_cast<CFWL_MsgActivate*>(pMessage));
break;
}
- case FWL_MSGHASH_Deactivate: {
+ case CFWL_MessageType::Deactivate: {
DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage));
break;
}
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ case CFWL_MessageType::SetFocus:
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(pMessage, dwMsgCode == CFWL_MessageType::SetFocus);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonDblClk: {
+ case FWL_MouseCommand::LeftButtonDblClk: {
OnButtonDblClk(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMsg);
break;
}
- case FWL_MSGMOUSECMD_RButtonDown: {
+ case FWL_MouseCommand::RightButtonDown: {
DoButtonDown(pMsg);
break;
}
- default: {}
+ default:
+ break;
}
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
- uint32_t dwCmd = pKey->m_dwCmd;
- if (dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
OnKeyDown(pKey);
- } else if (dwCmd == FWL_MSGKEYCMD_Char) {
+ else if (pKey->m_dwCmd == FWL_KeyCommand::Char)
OnChar(pKey);
- }
break;
}
- default: { iRet = 0; }
+ default: {
+ break;
+ }
}
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
}
-FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+
+void CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
if (!pEvent)
- return FWL_ERR_Indefinite;
- uint32_t dwHashCode = pEvent->GetClassID();
- if (dwHashCode != FWL_EVTHASH_Scroll) {
- return FWL_ERR_Succeeded;
- }
+ return;
+ if (pEvent->GetClassID() != CFWL_EventType::Scroll)
+ return;
+
IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() &&
m_pOwner->m_pVertScrollBar) ||
@@ -1813,12 +1832,13 @@ FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget),
pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos);
}
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_EditImpDelegate::DoActivate(CFWL_MsgActivate* pMsg) {
m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated;
m_pOwner->Repaint(&m_pOwner->m_rtClient);
@@ -1848,7 +1868,7 @@ void CFWL_EditImpDelegate::DoButtonDown(CFWL_MsgMouse* pMsg) {
}
void CFWL_EditImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
uint32_t dwStyleEx = m_pOwner->GetStylesEx();
- FX_BOOL bRepaint = dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret;
+ bool bRepaint = !!(dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret);
if (bSet) {
m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
if (!m_pOwner->m_pEdtEngine) {
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.h
index f8fb1aa37dd..9c0853b4fdd 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_editimp.h
@@ -24,48 +24,49 @@ class IFWL_Caret;
class CFWL_EditImp;
class CFWL_EditImpDelegate;
-class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink {
+class CFWL_EditImp : public CFWL_WidgetImp {
public:
CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
~CFWL_EditImp() override;
// CFWL_WidgetImp:
- FWL_ERR GetClassName(CFX_WideString& wsClass) const override;
- uint32_t GetClassID() const override;
- FWL_ERR Initialize() override;
- FWL_ERR Finalize() override;
- FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
- FWL_ERR SetWidgetRect(const CFX_RectF& rect) override;
- FWL_ERR Update() override;
- uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
- FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override;
- FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
- FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error SetWidgetRect(const CFX_RectF& rect) override;
+ FWL_Error Update() override;
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
+ void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
+ FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
- virtual FWL_ERR SetText(const CFX_WideString& wsText);
+ virtual FWL_Error SetText(const CFX_WideString& wsText);
virtual int32_t GetTextLength() const;
- virtual FWL_ERR GetText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
- virtual FWL_ERR ClearText();
+ virtual FWL_Error GetText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ virtual FWL_Error ClearText();
virtual int32_t GetCaretPos() const;
virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE);
- virtual FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1);
+ virtual FWL_Error AddSelRange(int32_t nStart, int32_t nCount = -1);
virtual int32_t CountSelRanges();
virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
- virtual FWL_ERR ClearSelections();
+ virtual FWL_Error ClearSelections();
virtual int32_t GetLimit();
- virtual FWL_ERR SetLimit(int32_t nLimit);
- virtual FWL_ERR SetAliasChar(FX_WCHAR wAlias);
- virtual FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
- virtual FWL_ERR DeleteSelections();
- virtual FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1);
- virtual FWL_ERR ReplaceSelections(const CFX_WideStringC& wsReplace);
- virtual FWL_ERR Replace(int32_t nStart,
- int32_t nLen,
- const CFX_WideStringC& wsReplace);
- virtual FWL_ERR DoClipboard(int32_t iCmd);
+ virtual FWL_Error SetLimit(int32_t nLimit);
+ virtual FWL_Error SetAliasChar(FX_WCHAR wAlias);
+ virtual FWL_Error Insert(int32_t nStart,
+ const FX_WCHAR* lpText,
+ int32_t nLen);
+ virtual FWL_Error DeleteSelections();
+ virtual FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1);
+ virtual FWL_Error Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace);
+ virtual FWL_Error DoClipboard(int32_t iCmd);
virtual FX_BOOL Copy(CFX_WideString& wsCopy);
virtual FX_BOOL Cut(CFX_WideString& wsCut);
virtual FX_BOOL Paste(const CFX_WideString& wsPaste);
@@ -76,41 +77,27 @@ class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink {
virtual FX_BOOL Redo();
virtual FX_BOOL CanUndo();
virtual FX_BOOL CanRedo();
- virtual FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
- virtual FWL_ERR SetOuter(IFWL_Widget* pOuter);
- virtual FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax);
- void On_CaretChanged(IFDE_TxtEdtEngine* pEdit,
+ virtual FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
+ virtual FWL_Error SetOuter(IFWL_Widget* pOuter);
+ virtual FWL_Error SetNumberRange(int32_t iMin, int32_t iMax);
+ virtual FWL_Error SetBackgroundColor(uint32_t color);
+ virtual FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
+
+ void On_CaretChanged(CFDE_TxtEdtEngine* pEdit,
int32_t nPage,
- FX_BOOL bVisible = true) override;
- void On_TextChanged(IFDE_TxtEdtEngine* pEdit,
- FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) override;
- void On_PageCountChanged(IFDE_TxtEdtEngine* pEdit) override {}
- void On_SelChanged(IFDE_TxtEdtEngine* pEdit) override;
- FX_BOOL On_PageLoad(IFDE_TxtEdtEngine* pEdit,
+ FX_BOOL bVisible = true);
+ void On_TextChanged(CFDE_TxtEdtEngine* pEdit,
+ FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo);
+ void On_SelChanged(CFDE_TxtEdtEngine* pEdit);
+ FX_BOOL On_PageLoad(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
- int32_t nPurpose) override;
- FX_BOOL On_PageUnload(IFDE_TxtEdtEngine* pEdit,
+ int32_t nPurpose);
+ FX_BOOL On_PageUnload(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
- int32_t nPurpose) override;
- FX_BOOL On_PageChange(IFDE_TxtEdtEngine* pEdit, int32_t nPageIndex) override {
- return TRUE;
- }
- void On_AddDoRecord(IFDE_TxtEdtEngine* pEdit,
- const CFX_ByteStringC& bsDoRecord) override;
- FX_BOOL On_ValidateField(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex,
- int32_t nFieldIndex,
- const CFX_WideString& wsFieldText,
- int32_t nCharIndex) override;
- FX_BOOL On_ValidateBlock(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex) override;
- FX_BOOL On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit,
- int32_t nBlockIndex,
- CFX_WideString& wsBlockText) override;
- FX_BOOL On_Validate(IFDE_TxtEdtEngine* pEdit,
- CFX_WideString& wsText) override;
- virtual FWL_ERR SetBackgroundColor(uint32_t color);
- virtual FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
+ int32_t nPurpose);
+ void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit,
+ const CFX_ByteStringC& bsDoRecord);
+ FX_BOOL On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText);
void SetScrollOffset(FX_FLOAT fScrollOffset);
FX_BOOL GetSuggestWords(CFX_PointF pointf,
std::vector<CFX_ByteString>& sSuggest);
@@ -160,7 +147,7 @@ class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink {
FX_FLOAT m_fVAlignOffset;
FX_FLOAT m_fScrollOffsetX;
FX_FLOAT m_fScrollOffsetY;
- IFDE_TxtEdtEngine* m_pEdtEngine;
+ CFDE_TxtEdtEngine* m_pEdtEngine;
FX_BOOL m_bLButtonDown;
int32_t m_nSelStart;
int32_t m_nLimit;
@@ -188,10 +175,10 @@ class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink {
class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_EditImpDelegate(CFWL_EditImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void DoActivate(CFWL_MsgActivate* pMsg);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.cpp
index 27a608795bb..2b76078e0c3 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.cpp
@@ -8,48 +8,52 @@
#include "xfa/fwl/core/fwl_formimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_panelimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
CFWL_FormProxyImp::CFWL_FormProxyImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_FormImp(properties, pOuter) {}
+
CFWL_FormProxyImp::~CFWL_FormProxyImp() {}
-FWL_ERR CFWL_FormProxyImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_FormProxyImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_FormProxy;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_FormProxyImp::GetClassID() const {
- return FWL_CLASSHASH_FormProxy;
+
+FWL_Type CFWL_FormProxyImp::GetClassID() const {
+ return FWL_Type::FormProxy;
}
+
FX_BOOL CFWL_FormProxyImp::IsInstance(const CFX_WideStringC& wsClass) const {
if (wsClass == CFX_WideStringC(FWL_CLASS_FormProxy)) {
return TRUE;
}
return CFWL_FormImp::IsInstance(wsClass);
}
-FWL_ERR CFWL_FormProxyImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+FWL_Error CFWL_FormProxyImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
m_pDelegate = new CFWL_FormProxyImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_FormProxyImp::Finalize() {
+FWL_Error CFWL_FormProxyImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_FormProxyImp::Update() {
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_FormProxyImp::Update() {
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_FormProxyImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_FormProxyImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return FWL_Error::Succeeded;
}
+
CFWL_FormProxyImpDelegate::CFWL_FormProxyImpDelegate(CFWL_FormProxyImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_FormProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_FormProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pOuter->SetDelegate(NULL);
- return pDelegate->OnProcessMessage(pMessage);
+ pDelegate->OnProcessMessage(pMessage);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.h
index 4e5e8075078..56c868e5135 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_formproxyimp.h
@@ -17,23 +17,26 @@ class CFWL_FormProxyImp : public CFWL_FormImp {
public:
CFWL_FormProxyImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- ~CFWL_FormProxyImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ ~CFWL_FormProxyImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error Update() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
protected:
friend class CFWL_FormProxyImpDelegate;
};
+
class CFWL_FormProxyImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_FormProxyImpDelegate(CFWL_FormProxyImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
protected:
CFWL_FormProxyImp* m_pOwner;
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.cpp
index 24b29d6ac0a..9b05a7fee4a 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.cpp
@@ -14,11 +14,14 @@
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
-#define FWL_LISTBOX_ItemTextMargin 2
+namespace {
+
+const int kItemTextMargin = 2;
+
+} // namespace
// static
IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties,
@@ -49,18 +52,16 @@ FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) {
int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) {
return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelIndex(nIndex);
}
-FWL_ERR IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
+FWL_Error IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(hItem, bSelect);
}
-FWL_ERR IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) {
+FWL_Error IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(hItem, wsText);
}
-FWL_ERR IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
+FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert);
}
-FWL_ERR* IFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) {
- return static_cast<CFWL_ListBoxImp*>(GetImpl())->Sort(pCom);
-}
CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
@@ -75,21 +76,27 @@ CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties,
m_rtConent.Reset();
m_rtStatic.Reset();
}
+
CFWL_ListBoxImp::~CFWL_ListBoxImp() {}
-FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_ListBox;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_ListBoxImp::GetClassID() const {
- return FWL_CLASSHASH_ListBox;
+
+FWL_Type CFWL_ListBoxImp::GetClassID() const {
+ return FWL_Type::ListBox;
}
-FWL_ERR CFWL_ListBoxImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_ListBoxImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_ListBoxImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBoxImp::Finalize() {
+
+FWL_Error CFWL_ListBoxImp::Finalize() {
if (m_pVertScrollBar) {
m_pVertScrollBar->Finalize();
}
@@ -100,7 +107,7 @@ FWL_ERR CFWL_ListBoxImp::Finalize() {
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
if (!m_pProperties->m_pThemeProvider) {
@@ -112,11 +119,11 @@ FWL_ERR CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBoxImp::Update() {
+FWL_Error CFWL_ListBoxImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
@@ -139,43 +146,39 @@ FWL_ERR CFWL_ListBoxImp::Update() {
}
m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
m_fScorllBarWidth = GetScrollWidth();
- SortItem();
CalcSize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
if (IsShowScrollBar(FALSE)) {
CFX_RectF rect;
m_pHorzScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_HScrollBar;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::HScrollBar;
}
if (IsShowScrollBar(TRUE)) {
CFX_RectF rect;
m_pVertScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
- return FWL_WGTHITTEST_VScrollBar;
- }
+ if (rect.Contains(fx, fy))
+ return FWL_WidgetHit::VScrollBar;
}
- if (m_rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
- return FWL_WGTHITTEST_Unknown;
+ if (m_rtClient.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
+ return FWL_WidgetHit::Unknown;
}
-FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
pGraphics->SaveGraphState();
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_LTB_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_LTB_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
CFX_RectF rtClip(m_rtConent);
if (IsShowScrollBar(FALSE)) {
@@ -193,17 +196,18 @@ FWL_ERR CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics,
}
DrawItems(pGraphics, pTheme, pMatrix);
pGraphics->RestoreGraphState();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+FWL_Error CFWL_ListBoxImp::SetThemeProvider(
+ IFWL_ThemeProvider* pThemeProvider) {
if (!pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!pThemeProvider->IsValidWidget(m_pInterface)) {
m_pScrollBarTP = pThemeProvider;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
m_pProperties->m_pThemeProvider = pThemeProvider;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_ListBoxImp::CountSelItems() {
if (!m_pProperties->m_pDataProvider)
@@ -270,9 +274,9 @@ int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) {
}
return -1;
}
-FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
+FWL_Error CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
if (!m_pProperties->m_pDataProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!hItem) {
if (bSelect) {
SelectAll();
@@ -280,52 +284,37 @@ FWL_ERR CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
ClearSelection();
SetFocusItem(NULL);
}
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
SetSelectionDirect(hItem, bSelect);
} else {
SetSelection(hItem, hItem, bSelect);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem,
- CFX_WideString& wsText) {
+FWL_Error CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
if (!m_pProperties->m_pDataProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
pData->GetItemText(m_pInterface, hItem, wsText);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
+
+FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) {
IFWL_ScrollBar* pScrollBar =
bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
fPos = pScrollBar->GetPos();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FWL_ERR_Indefinite;
-}
-FWL_ERR* CFWL_ListBoxImp::Sort(IFWL_ListBoxCompare* pCom) {
- FWL_HLISTITEM hTemp;
- IFWL_ListBoxDP* pData =
- static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t sz = pData->CountItems(m_pInterface);
- for (int32_t i = 0; i < sz - 1; i++) {
- for (int32_t j = i + 1; j < sz; j++) {
- if (pCom->Compare(pData->GetItem(m_pInterface, i),
- pData->GetItem(m_pInterface, j)) > 0) {
- hTemp = pData->GetItem(m_pInterface, i);
- pData->SetItemIndex(m_pInterface, pData->GetItem(m_pInterface, j), i);
- pData->SetItemIndex(m_pInterface, hTemp, j);
- }
- }
- }
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
}
+
FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem,
uint32_t dwKeyCode) {
FWL_HLISTITEM hRet = NULL;
@@ -403,14 +392,11 @@ void CFWL_ListBoxImp::ClearSelection() {
for (int32_t i = 0; i < iCount; i++) {
FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
uint32_t dwState = pData->GetItemStyles(m_pInterface, hItem);
- FX_BOOL bFindSel = dwState & FWL_ITEMSTATE_LTB_Selected;
- if (!bFindSel) {
+ if (!(dwState & FWL_ITEMSTATE_LTB_Selected))
continue;
- }
SetSelectionDirect(hItem, FALSE);
- if (!bMulti) {
+ if (!bMulti)
return;
- }
}
}
void CFWL_ListBoxImp::SelectAll() {
@@ -555,7 +541,7 @@ void CFWL_ListBoxImp::DrawBkground(CFX_Graphics* pGraphics,
return;
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_LTB_Background;
+ param.m_iPart = CFWL_Part::Background;
param.m_dwStates = 0;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
@@ -564,7 +550,7 @@ void CFWL_ListBoxImp::DrawBkground(CFX_Graphics* pGraphics,
param.m_pData = &m_rtStatic;
}
if (!IsEnabled()) {
- param.m_dwStates = FWL_PARTSTATE_LTB_Disabled;
+ param.m_dwStates = CFWL_PartState_Disabled;
}
pTheme->DrawBackground(&param);
}
@@ -630,32 +616,29 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
uint32_t dwItemStyles = pData->GetItemStyles(m_pInterface, hItem);
- uint32_t dwPartStates = FWL_PARTSTATE_LTB_Normal;
+ uint32_t dwPartStates = CFWL_PartState_Normal;
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- dwPartStates = FWL_PARTSTATE_LTB_Disabled;
+ dwPartStates = CFWL_PartState_Disabled;
} else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) {
- dwPartStates = FWL_PARTSTATE_LTB_Selected;
+ dwPartStates = CFWL_PartState_Selected;
}
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused &&
dwItemStyles & FWL_ITEMSTATE_LTB_Focused) {
- dwPartStates |= FWL_PARTSTATE_LTB_Focused;
+ dwPartStates |= CFWL_PartState_Focused;
}
- FWL_ListBoxItemData itemData;
- itemData.pDataProvider = pData;
- itemData.iIndex = Index;
{
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_LTB_ListItem;
+ param.m_iPart = CFWL_Part::ListItem;
param.m_dwStates = dwPartStates;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
param.m_rtPart = rtItem;
- param.m_dwData = (uint32_t)(uintptr_t)(&itemData);
+ param.m_bMaximize = true;
CFX_RectF rtFocus(rtItem);
param.m_pData = &rtFocus;
if (m_pVertScrollBar && !m_pHorzScrollBar &&
- (dwPartStates & FWL_PARTSTATE_LTB_Focused)) {
+ (dwPartStates & CFWL_PartState_Focused)) {
param.m_rtPart.left += 1;
param.m_rtPart.width -= (m_fScorllBarWidth + 1);
rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1);
@@ -671,11 +654,11 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
if (pDib) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_LTB_Icon;
+ param.m_iPart = CFWL_Part::Icon;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
param.m_rtPart = rtDIB;
- param.m_dwData = (uint32_t)(uintptr_t)(&itemData);
+ param.m_bMaximize = true;
param.m_pImage = pDib;
pTheme->DrawBackground(&param);
}
@@ -688,16 +671,16 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
pData->SetItemCheckRect(m_pInterface, hItem, rtCheck);
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_LTB_Check;
+ param.m_iPart = CFWL_Part::Check;
param.m_pGraphics = pGraphics;
if (GetItemChecked(hItem)) {
- param.m_dwStates = FWL_PARTSTATE_LTB_Checked;
+ param.m_dwStates = CFWL_PartState_Checked;
} else {
- param.m_dwStates = FWL_PARTSTATE_LTB_UnChecked;
+ param.m_dwStates = CFWL_PartState_Normal;
}
param.m_matrix.Concat(*pMatrix);
param.m_rtPart = rtCheck;
- param.m_dwData = (uint32_t)(uintptr_t)(&itemData);
+ param.m_bMaximize = true;
pTheme->DrawBackground(&param);
}
CFX_WideString wsText;
@@ -706,13 +689,13 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
return;
}
CFX_RectF rtText(rtItem);
- rtText.Deflate(FWL_LISTBOX_ItemTextMargin, FWL_LISTBOX_ItemTextMargin);
+ rtText.Deflate(kItemTextMargin, kItemTextMargin);
if (bHasIcon || bHasCheck) {
rtText.Deflate(rtItem.height, 0, 0, 0);
}
CFWL_ThemeText textParam;
textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_LTB_ListItem;
+ textParam.m_iPart = CFWL_Part::ListItem;
textParam.m_dwStates = dwPartStates;
textParam.m_pGraphics = pGraphics;
textParam.m_matrix.Concat(*pMatrix);
@@ -720,7 +703,7 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
textParam.m_wsText = wsText;
textParam.m_dwTTOStyles = m_dwTTOStyles;
textParam.m_iTTOAlign = m_iTTOAligns;
- textParam.m_dwData = (uint32_t)(uintptr_t)(&itemData);
+ textParam.m_bMaximize = true;
pTheme->DrawText(&textParam);
}
}
@@ -734,8 +717,8 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) {
CFX_RectF rtUIMargin;
rtUIMargin.Set(0, 0, 0, 0);
if (!m_pOuter) {
- CFX_RectF* pUIMargin =
- static_cast<CFX_RectF*>(GetThemeCapacity(FWL_WGTCAPACITY_UIMargin));
+ CFX_RectF* pUIMargin = static_cast<CFX_RectF*>(
+ GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
if (pUIMargin) {
m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
pUIMargin->height);
@@ -752,9 +735,9 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) {
FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i);
CFWL_ThemePart itemPart;
itemPart.m_pWidget = m_pInterface;
- itemPart.m_iPart = FWL_PART_LTB_ListItem;
+ itemPart.m_iPart = CFWL_Part::ListItem;
itemPart.m_pData = m_pProperties->m_pDataProvider;
- itemPart.m_dwData = i;
+ itemPart.m_bMaximize = i > 0;
CFX_RectF r;
m_pProperties->m_pThemeProvider->GetPartRect(&itemPart, r);
if (!bAutoSize) {
@@ -772,7 +755,7 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) {
}
} else {
fWidth = GetMaxTextWidth();
- fWidth += 2 * FWL_LISTBOX_ItemTextMargin;
+ fWidth += 2 * kItemTextMargin;
if (!bAutoSize) {
FX_FLOAT fActualWidth =
m_rtClient.width - rtUIMargin.left - rtUIMargin.width;
@@ -931,18 +914,18 @@ FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() {
return fRet;
}
FX_FLOAT CFWL_ListBoxImp::GetScrollWidth() {
- FX_FLOAT* pfWidth =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>(
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pfWidth)
return 0;
return *pfWidth;
}
FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() {
FX_FLOAT* pfFont =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FontSize));
+ static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize));
if (!pfFont)
return 20;
- return *pfFont + 2 * FWL_LISTBOX_ItemTextMargin;
+ return *pfFont + 2 * kItemTextMargin;
}
void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) {
if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
@@ -957,7 +940,7 @@ void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) {
pScrollBar->Initialize();
(bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
}
-void CFWL_ListBoxImp::SortItem() {}
+
FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) {
IFWL_ScrollBar* pScrollbar =
bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
@@ -982,59 +965,65 @@ void CFWL_ListBoxImp::ProcessSelChanged() {
}
DispatchEvent(&selEvent);
}
+
CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- if (!m_pOwner->IsEnabled()) {
- return 1;
- }
- uint32_t dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
+ return;
+ if (!m_pOwner->IsEnabled())
+ return;
+
+ CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ case CFWL_MessageType::SetFocus: {
+ OnFocusChanged(pMessage, TRUE);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(pMessage, FALSE);
+ break;
+ }
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg);
break;
}
- default: {}
+ default:
+ break;
}
break;
}
- case FWL_MSGHASH_MouseWheel: {
+ case CFWL_MessageType::MouseWheel: {
OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage));
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage);
- if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown)
+ if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown)
OnKeyDown(pMsg);
break;
}
- default: { iRet = 0; }
+ default: {
+ break;
+ }
}
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
}
-FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+
+void CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
if (!pEvent)
- return FWL_ERR_Indefinite;
- if (pEvent->GetClassID() != FWL_EVTHASH_Scroll) {
- return FWL_ERR_Succeeded;
- }
+ return;
+ if (pEvent->GetClassID() != CFWL_EventType::Scroll)
+ return;
+
IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() &&
m_pOwner->m_pVertScrollBar) ||
@@ -1044,12 +1033,13 @@ FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget),
pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos);
}
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) {
if (m_pOwner->m_pVertScrollBar) {
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.h
index 1dd0db1b4c3..f32dece8dc2 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_listboximp.h
@@ -24,26 +24,31 @@ class CFWL_ListBoxImp : public CFWL_WidgetImp {
public:
CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- ~CFWL_ListBoxImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- virtual int32_t CountSelItems();
- virtual FWL_HLISTITEM GetSelItem(int32_t nIndexSel);
- virtual int32_t GetSelIndex(int32_t nIndex);
- virtual FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
- virtual FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText);
- virtual FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
- virtual FWL_ERR* Sort(IFWL_ListBoxCompare* pCom);
+ ~CFWL_ListBoxImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error Update() override;
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+ FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
+
+ int32_t CountSelItems();
+ FWL_HLISTITEM GetSelItem(int32_t nIndexSel);
+ int32_t GetSelIndex(int32_t nIndex);
+ FWL_Error SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
+ FWL_Error GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText);
+ FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
+ FWL_Error* Sort(IFWL_ListBoxCompare* pCom);
protected:
+ friend class CFWL_ListBoxImpDelegate;
+
FWL_HLISTITEM GetItem(FWL_HLISTITEM hItem, uint32_t dwKeyCode);
void SetSelection(FWL_HLISTITEM hStart,
FWL_HLISTITEM hEnd,
@@ -82,11 +87,9 @@ class CFWL_ListBoxImp : public CFWL_WidgetImp {
FX_FLOAT GetScrollWidth();
FX_FLOAT GetItemHeigt();
void InitScrollBar(FX_BOOL bVert = TRUE);
- void SortItem();
FX_BOOL IsShowScrollBar(FX_BOOL bVert);
void ProcessSelChanged();
- protected:
CFX_RectF m_rtClient;
CFX_RectF m_rtStatic;
CFX_RectF m_rtConent;
@@ -99,15 +102,14 @@ class CFWL_ListBoxImp : public CFWL_WidgetImp {
FX_FLOAT m_fScorllBarWidth;
FX_BOOL m_bLButtonDown;
IFWL_ThemeProvider* m_pScrollBarTP;
- friend class CFWL_ListBoxImpDelegate;
};
class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
index d55144a805c..e8672e67dc0 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
@@ -14,7 +14,6 @@
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
@@ -27,6 +26,98 @@
#define MONTHCAL_HEADER_BTN_VMARGIN 7
#define MONTHCAL_HEADER_BTN_HMARGIN 5
+namespace {
+
+CFX_WideString* GetCapacityForDay(IFWL_ThemeProvider* pTheme,
+ CFWL_ThemePart& params,
+ uint32_t day) {
+ ASSERT(day < 7);
+
+ if (day == 0) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Sun));
+ }
+ if (day == 1) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Mon));
+ }
+ if (day == 2) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Tue));
+ }
+ if (day == 3) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Wed));
+ }
+ if (day == 4) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Thu));
+ }
+ if (day == 5) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Fri));
+ }
+
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Sat));
+}
+
+CFX_WideString* GetCapacityForMonth(IFWL_ThemeProvider* pTheme,
+ CFWL_ThemePart& params,
+ uint32_t month) {
+ ASSERT(month < 12);
+
+ if (month == 0) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::January));
+ }
+ if (month == 1) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::February));
+ }
+ if (month == 2) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::March));
+ }
+ if (month == 3) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::April));
+ }
+ if (month == 4) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::May));
+ }
+ if (month == 5) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::June));
+ }
+ if (month == 6) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::July));
+ }
+ if (month == 7) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::August));
+ }
+ if (month == 8) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::September));
+ }
+ if (month == 9) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::October));
+ }
+ if (month == 10) {
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::November));
+ }
+
+ return static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::December));
+}
+
+} // namespace
+
// static
IFWL_MonthCalendar* IFWL_MonthCalendar::Create(
const CFWL_WidgetImpProperties& properties,
@@ -66,8 +157,8 @@ CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
m_iMonth(1),
m_iDay(1),
m_iHovered(-1),
- m_iLBtnPartStates(FWL_PARTSTATE_MCD_Normal),
- m_iRBtnPartStates(FWL_PARTSTATE_MCD_Normal) {
+ m_iLBtnPartStates(CFWL_PartState_Normal),
+ m_iRBtnPartStates(CFWL_PartState_Normal) {
m_rtHead.Reset();
m_rtWeek.Reset();
m_rtLBtn.Reset();
@@ -84,31 +175,37 @@ CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
m_bInit = FALSE;
m_iMaxSel = 1;
}
+
CFWL_MonthCalendarImp::~CFWL_MonthCalendarImp() {
ClearDateItem();
delete m_pDateTime;
m_arrSelDays.RemoveAll();
}
-FWL_ERR CFWL_MonthCalendarImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_MonthCalendarImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_MonthCalendar;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_MonthCalendarImp::GetClassID() const {
- return FWL_CLASSHASH_MonthCalendar;
+
+FWL_Type CFWL_MonthCalendarImp::GetClassID() const {
+ return FWL_Type::MonthCalendar;
}
-FWL_ERR CFWL_MonthCalendarImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_MonthCalendarImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_MonthCalendarImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_MonthCalendarImp::Finalize() {
+
+FWL_Error CFWL_MonthCalendarImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_MonthCalendarImp::GetWidgetRect(CFX_RectF& rect,
- FX_BOOL bAutoSize) {
+FWL_Error CFWL_MonthCalendarImp::GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
if (bAutoSize) {
CFX_SizeF fs = CalcSize(TRUE);
rect.Set(0, 0, fs.x, fs.y);
@@ -116,11 +213,11 @@ FWL_ERR CFWL_MonthCalendarImp::GetWidgetRect(CFX_RectF& rect,
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_MonthCalendarImp::Update() {
+FWL_Error CFWL_MonthCalendarImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
@@ -132,21 +229,21 @@ FWL_ERR CFWL_MonthCalendarImp::Update() {
ClearDateItem();
ReSetDateItem();
LayOut();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_MonthCalendarImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_MonthCalendarImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (m_pProperties->m_pThemeProvider == NULL) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
}
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_MCD_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_MCD_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
DrawBkground(pGraphics, pTheme, pMatrix);
DrawHeadBK(pGraphics, pTheme, pMatrix);
@@ -164,7 +261,7 @@ FWL_ERR CFWL_MonthCalendarImp::DrawWidget(CFX_Graphics* pGraphics,
DrawWeekNumberSep(pGraphics, pTheme, pMatrix);
DrawWeekNumber(pGraphics, pTheme, pMatrix);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_MonthCalendarImp::CountSelect() {
return m_arrSelDays.GetSize();
@@ -192,9 +289,9 @@ void CFWL_MonthCalendarImp::DrawBkground(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_Background;
+ params.m_iPart = CFWL_Part::Background;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_rtPart = m_rtClient;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
@@ -206,9 +303,9 @@ void CFWL_MonthCalendarImp::DrawHeadBK(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_Header;
+ params.m_iPart = CFWL_Part::Header;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_rtPart = m_rtHead;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
@@ -220,7 +317,7 @@ void CFWL_MonthCalendarImp::DrawLButton(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_LBtn;
+ params.m_iPart = CFWL_Part::LBtn;
params.m_pGraphics = pGraphics;
params.m_dwStates = m_iLBtnPartStates;
params.m_rtPart = m_rtLBtn;
@@ -234,7 +331,7 @@ void CFWL_MonthCalendarImp::DrawRButton(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_RBtn;
+ params.m_iPart = CFWL_Part::RBtn;
params.m_pGraphics = pGraphics;
params.m_dwStates = m_iRBtnPartStates;
params.m_rtPart = m_rtRBtn;
@@ -248,8 +345,8 @@ void CFWL_MonthCalendarImp::DrawCaption(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeText textParam;
textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_MCD_Caption;
- textParam.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ textParam.m_iPart = CFWL_Part::Caption;
+ textParam.m_dwStates = CFWL_PartState_Normal;
textParam.m_pGraphics = pGraphics;
int32_t iYear;
int32_t iMonth;
@@ -273,9 +370,9 @@ void CFWL_MonthCalendarImp::DrawSeperator(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_HSeparator;
+ params.m_iPart = CFWL_Part::HSeparator;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_rtPart = m_rtHSep;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
@@ -287,7 +384,7 @@ void CFWL_MonthCalendarImp::DrawDatesInBK(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_DateInBK;
+ params.m_iPart = CFWL_Part::DateInBK;
params.m_pGraphics = pGraphics;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
@@ -296,19 +393,19 @@ void CFWL_MonthCalendarImp::DrawDatesInBK(CFX_Graphics* pGraphics,
for (int32_t j = 0; j < iCount; j++) {
FWL_DATEINFO* pDataInfo = (FWL_DATEINFO*)m_arrDates.GetAt(j);
if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Selected) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Selected;
+ params.m_dwStates |= CFWL_PartState_Selected;
if (((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) ==
0) &&
pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Flagged;
+ params.m_dwStates |= CFWL_PartState_Flagged;
}
if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Focused;
+ params.m_dwStates |= CFWL_PartState_Focused;
}
} else if (j == m_iHovered - 1) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered;
+ params.m_dwStates |= CFWL_PartState_Hovered;
} else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) {
- params.m_dwStates = FWL_PARTSTATE_MCD_Flagged;
+ params.m_dwStates = CFWL_PartState_Flagged;
pTheme->DrawBackground(&params);
}
params.m_rtPart = pDataInfo->rect;
@@ -321,9 +418,9 @@ void CFWL_MonthCalendarImp::DrawWeek(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeText params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_Week;
+ params.m_iPart = CFWL_Part::Week;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
CFX_RectF rtDayOfWeek;
if (pMatrix) {
@@ -332,10 +429,8 @@ void CFWL_MonthCalendarImp::DrawWeek(CFX_Graphics* pGraphics,
for (int32_t i = 0; i < 7; i++) {
rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2),
m_rtWeek.top, m_szCell.x, m_szCell.y);
- CFX_WideString* wsWeekDay = static_cast<CFX_WideString*>(
- pTheme->GetCapacity(&params, i + FWL_MCCAPACITY_Sun));
params.m_rtPart = rtDayOfWeek;
- params.m_wsText = *wsWeekDay;
+ params.m_wsText = *GetCapacityForDay(pTheme, params, i);
params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
pTheme->DrawText(&params);
}
@@ -345,9 +440,9 @@ void CFWL_MonthCalendarImp::DrawWeekNumber(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeText params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_WeekNum;
+ params.m_iPart = CFWL_Part::WeekNum;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
CFX_WideString wsWeekNum;
params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
@@ -377,9 +472,9 @@ void CFWL_MonthCalendarImp::DrawWeekNumberSep(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_WeekNumSep;
+ params.m_iPart = CFWL_Part::WeekNumSep;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_rtPart = m_rtWeekNumSep;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
@@ -394,12 +489,12 @@ void CFWL_MonthCalendarImp::DrawToday(CFX_Graphics* pGraphics,
}
CFWL_ThemeText params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_Today;
+ params.m_iPart = CFWL_Part::Today;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
CFX_WideString* wsDay = static_cast<CFX_WideString*>(
- pTheme->GetCapacity(&params, FWL_MCCAPACITY_Today));
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today));
CFX_WideString wsText;
GetTodayText(m_iYear, m_iMonth, m_iDay, wsText);
params.m_wsText = *wsDay + wsText;
@@ -417,9 +512,9 @@ void CFWL_MonthCalendarImp::DrawDatesIn(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeText params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_DatesIn;
+ params.m_iPart = CFWL_Part::DatesIn;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
@@ -431,7 +526,7 @@ void CFWL_MonthCalendarImp::DrawDatesIn(CFX_Graphics* pGraphics,
params.m_rtPart = pDataInfo->rect;
params.m_dwStates = pDataInfo->dwStates;
if (j + 1 == m_iHovered) {
- params.m_dwStates |= FWL_PARTSTATE_MCD_Hovered;
+ params.m_dwStates |= CFWL_PartState_Hovered;
}
params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
pTheme->DrawText(&params);
@@ -442,9 +537,9 @@ void CFWL_MonthCalendarImp::DrawDatesOut(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeText params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_DatesOut;
+ params.m_iPart = CFWL_Part::DatesOut;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
@@ -468,10 +563,10 @@ void CFWL_MonthCalendarImp::DrawDatesInCircle(CFX_Graphics* pGraphics,
return;
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_DateInCircle;
+ params.m_iPart = CFWL_Part::DateInCircle;
params.m_pGraphics = pGraphics;
params.m_rtPart = pDate->rect;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
}
@@ -488,9 +583,9 @@ void CFWL_MonthCalendarImp::DrawTodayCircle(CFX_Graphics* pGraphics,
}
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_MCD_TodayCircle;
+ params.m_iPart = CFWL_Part::TodayCircle;
params.m_pGraphics = pGraphics;
- params.m_dwStates = FWL_PARTSTATE_MCD_Normal;
+ params.m_dwStates = CFWL_PartState_Normal;
params.m_rtPart = m_rtTodayFlag;
if (pMatrix) {
params.m_matrix.Concat(*pMatrix);
@@ -510,15 +605,16 @@ CFX_SizeF CFWL_MonthCalendarImp::CalcSize(FX_BOOL bAutoSize) {
CFWL_ThemePart params;
params.m_pWidget = m_pInterface;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
- CFX_WideString* wsText = NULL;
FX_FLOAT fMaxWeekW = 0.0f;
FX_FLOAT fMaxWeekH = 0.0f;
- for (uint32_t week = FWL_MCCAPACITY_Sun; week <= FWL_MCCAPACITY_Sat; week++) {
- wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(&params, week));
- CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider);
+
+ for (uint32_t i = 0; i < 7; ++i) {
+ CFX_SizeF sz = CalcTextSize(*GetCapacityForDay(pTheme, params, i),
+ m_pProperties->m_pThemeProvider);
fMaxWeekW = (fMaxWeekW >= sz.x) ? fMaxWeekW : sz.x;
fMaxWeekH = (fMaxWeekH >= sz.y) ? fMaxWeekH : sz.y;
}
+
FX_FLOAT fDayMaxW = 0.0f;
FX_FLOAT fDayMaxH = 0.0f;
for (int day = 10; day <= 31; day++) {
@@ -536,10 +632,10 @@ CFX_SizeF CFWL_MonthCalendarImp::CalcSize(FX_BOOL bAutoSize) {
MONTHCAL_HEADER_BTN_HMARGIN * 2;
FX_FLOAT fMonthMaxW = 0.0f;
FX_FLOAT fMonthMaxH = 0.0f;
- for (uint32_t month = FWL_MCCAPACITY_January;
- month <= FWL_MCCAPACITY_December; month++) {
- wsText = static_cast<CFX_WideString*>(pTheme->GetCapacity(&params, month));
- CFX_SizeF sz = CalcTextSize(*wsText, m_pProperties->m_pThemeProvider);
+
+ for (uint32_t i = 0; i < 12; ++i) {
+ CFX_SizeF sz = CalcTextSize(*GetCapacityForMonth(pTheme, params, i),
+ m_pProperties->m_pThemeProvider);
fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x;
fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y;
}
@@ -552,8 +648,8 @@ CFX_SizeF CFWL_MonthCalendarImp::CalcSize(FX_BOOL bAutoSize) {
fs.x = std::max(fs.x, fMonthMaxW);
CFX_WideString wsToday;
GetTodayText(m_iYear, m_iMonth, m_iDay, wsToday);
- wsText = static_cast<CFX_WideString*>(
- pTheme->GetCapacity(&params, FWL_MCCAPACITY_Today));
+ CFX_WideString* wsText = static_cast<CFX_WideString*>(
+ pTheme->GetCapacity(&params, CFWL_WidgetCapacity::Today));
m_wsToday = *wsText + wsToday;
m_szToday = CalcTextSize(wsToday, m_pProperties->m_pThemeProvider);
m_szToday.y = (m_szToday.y >= m_szCell.y) ? m_szToday.y : m_szCell.y;
@@ -645,60 +741,60 @@ void CFWL_MonthCalendarImp::GetCapValue() {
CFWL_ThemePart part;
part.m_pWidget = m_pInterface;
m_fHeadWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_WIDTH));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderWidth));
m_fHeadHei = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_Height));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderHeight));
m_fHeadBtnWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnWidth));
m_fHeadBtnHei = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnHeight));
m_fHeadBtnHMargin = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnHMargin));
m_fHeadBtnVMargin = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnVMargin));
m_fHeadTextWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderTextWidth));
m_fHeadTextHei = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderTextHeight));
m_fHeadTextHMargin = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderTextHMargin));
m_fHeadTextVMargin = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderTextVMargin));
m_fHSepWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_WIDTH));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HSepWidth));
m_fHSepHei = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HSEP_HEIGHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HSepHeight));
m_fWeekNumWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::WeekNumWidth));
m_fSepDOffset = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_DOFFSET));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::SepDOffset));
m_fSepX = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_X));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::SepX));
m_fSepY = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_SEP_Y));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::SepY));
m_fWeekNumHeigh = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::WeekNumHeight));
m_fWeekWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_WIDTH));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::WeekWidth));
m_fWeekHei = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WEEK_HEIGHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::WeekHeight));
m_fDateCellWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::DatesCellWidth));
m_fDateCellHei = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::DatesCellHeight));
m_fTodayWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_WIDHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayWidth));
m_fTodayHei = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_HEIGHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayHeight));
m_fTodayFlagWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth));
m_fMCWid = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_WIDTH));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width));
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) {
m_fMCWid += m_fWeekNumWid;
}
m_fMCHei = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_MC_HEIGHT));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height));
}
int32_t CFWL_MonthCalendarImp::CalWeekNumber(int32_t iYear,
int32_t iMonth,
@@ -859,7 +955,7 @@ FX_BOOL CFWL_MonthCalendarImp::RemoveSelDay(int32_t iDay, FX_BOOL bAll) {
return TRUE;
}
FX_BOOL CFWL_MonthCalendarImp::AddSelDay(int32_t iDay) {
- FXSYS_assert(iDay > 0);
+ ASSERT(iDay > 0);
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
} else {
if (m_arrSelDays.Find(iDay) == -1) {
@@ -889,7 +985,7 @@ FX_BOOL CFWL_MonthCalendarImp::JumpToToday() {
void CFWL_MonthCalendarImp::GetHeadText(int32_t iYear,
int32_t iMonth,
CFX_WideString& wsHead) {
- FXSYS_assert(iMonth > 0 && iMonth < 13);
+ ASSERT(iMonth > 0 && iMonth < 13);
static const FX_WCHAR* const pMonth[] = {
L"January", L"February", L"March", L"April",
L"May", L"June", L"July", L"August",
@@ -922,59 +1018,62 @@ FX_BOOL CFWL_MonthCalendarImp::GetDayRect(int32_t iDay, CFX_RectF& rtDay) {
rtDay = pDateInfo->rect;
return TRUE;
}
+
CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate(
CFWL_MonthCalendarImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage(
- CFWL_Message* pMessage) {
+
+void CFWL_MonthCalendarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
+ return;
+
+ CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ case CFWL_MessageType::SetFocus: {
+ OnFocusChanged(pMessage, TRUE);
+ break;
+ }
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(pMessage, FALSE);
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMouse->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMouse->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMouse);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMouse);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMouse);
break;
}
- case FWL_MSGMOUSECMD_MouseLeave: {
+ case FWL_MouseCommand::Leave: {
OnMouseLeave(pMouse);
break;
}
- default: { break; }
+ default:
+ break;
}
break;
}
default: {
- iRet = 0;
break;
}
}
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
}
-FWL_ERR CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
void CFWL_MonthCalendarImpDelegate::OnActivate(CFWL_Message* pMsg) {}
@@ -990,11 +1089,11 @@ void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
}
void CFWL_MonthCalendarImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = FWL_PARTSTATE_MCD_Pressed;
+ m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed;
m_pOwner->PrevMonth();
m_pOwner->Repaint(&m_pOwner->m_rtClient);
} else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates |= FWL_PARTSTATE_MCD_Pressed;
+ m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed;
m_pOwner->NextMonth();
m_pOwner->Repaint(&m_pOwner->m_rtClient);
} else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.h
index c67848fd1d4..e44a17a1d39 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_monthcalendarimp.h
@@ -9,33 +9,38 @@
#include "xfa/fgas/localization/fgas_datetime.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
+#include "xfa/fwl/core/ifwl_widget.h"
class CFWL_MonthCalendarImpDelegate;
class CFWL_MsgMouse;
class CFWL_WidgetImpProperties;
class IFWL_Widget;
+struct FWL_DATEINFO;
+
extern uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth);
class CFWL_MonthCalendarImp : public CFWL_WidgetImp {
public:
CFWL_MonthCalendarImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- ~CFWL_MonthCalendarImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual int32_t CountSelect();
- virtual FX_BOOL GetSelect(int32_t& iYear,
- int32_t& iMonth,
- int32_t& iDay,
- int32_t nIndex = 0);
- virtual FX_BOOL SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay);
+ ~CFWL_MonthCalendarImp() override;
+
+ // FWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error Update() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+ int32_t CountSelect();
+ FX_BOOL GetSelect(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay,
+ int32_t nIndex = 0);
+ FX_BOOL SetSelect(int32_t iYear, int32_t iMonth, int32_t iDay);
protected:
struct DATE {
@@ -160,7 +165,7 @@ class CFWL_MonthCalendarImp : public CFWL_WidgetImp {
CFX_WideString m_wsHead;
CFX_WideString m_wsToday;
CFX_DateTime* m_pDateTime;
- CFX_PtrArray m_arrDates;
+ CFX_ArrayTemplate<FWL_DATEINFO*> m_arrDates;
int32_t m_iCurYear;
int32_t m_iCurMonth;
int32_t m_iYear;
@@ -227,9 +232,9 @@ struct FWL_DATEINFO {
class CFWL_MonthCalendarImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_MonthCalendarImpDelegate(CFWL_MonthCalendarImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnActivate(CFWL_Message* pMsg);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.cpp
index 2787423d6e0..a84cc8c5e8e 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.cpp
@@ -7,7 +7,6 @@
#include "xfa/fwl/basewidget/fwl_pictureboximp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/lightwidget/cfwl_picturebox.h"
@@ -35,30 +34,37 @@ CFWL_PictureBoxImp::CFWL_PictureBoxImp(
m_rtImage.Reset();
m_matrix.SetIdentity();
}
+
CFWL_PictureBoxImp::~CFWL_PictureBoxImp() {}
-FWL_ERR CFWL_PictureBoxImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_PictureBoxImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_PictureBox;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_PictureBoxImp::GetClassID() const {
- return FWL_CLASSHASH_PictureBox;
+
+FWL_Type CFWL_PictureBoxImp::GetClassID() const {
+ return FWL_Type::PictureBox;
}
-FWL_ERR CFWL_PictureBoxImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_PictureBoxImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_PictureBoxImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PictureBoxImp::Finalize() {
+
+FWL_Error CFWL_PictureBoxImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_PictureBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_PictureBoxImp::GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
if (!m_pProperties->m_pDataProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
CFX_DIBitmap* pBitmap =
static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider)
->GetPicture(m_pInterface);
@@ -70,33 +76,33 @@ FWL_ERR CFWL_PictureBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PictureBoxImp::Update() {
+FWL_Error CFWL_PictureBoxImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
}
GetClientRect(m_rtClient);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PictureBoxImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_PictureBoxImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ThemeProvider* pTheme = GetAvailableTheme();
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_PTB_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_PTB_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
DrawBkground(pGraphics, pTheme, pMatrix);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_PictureBoxImp::DrawBkground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
@@ -142,10 +148,12 @@ FX_BOOL CFWL_PictureBoxImp::VStyle(FX_BOOL dwStyle) {
}
return FALSE;
}
+
CFWL_PictureBoxImpDelegate::CFWL_PictureBoxImpDelegate(
CFWL_PictureBoxImp* pOwner)
: m_pOwner(pOwner) {}
-FWL_ERR CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.h
index f2e67124f63..9fa065216a7 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pictureboximp.h
@@ -8,6 +8,7 @@
#define XFA_FWL_BASEWIDGET_FWL_PICTUREBOXIMP_H_
#include "xfa/fwl/core/fwl_widgetimp.h"
+#include "xfa/fwl/core/ifwl_widget.h"
class CFWL_WidgetImpProperties;
class IFWL_Widget;
@@ -17,20 +18,25 @@ class CFWL_PictureBoxImp : public CFWL_WidgetImp {
public:
CFWL_PictureBoxImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- ~CFWL_PictureBoxImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ ~CFWL_PictureBoxImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error Update() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
protected:
+ friend class CFWL_PictureBoxImpDelegate;
+
void DrawBkground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix = NULL);
+
FX_BOOL VStyle(FX_BOOL dwStyle);
CFX_RectF m_rtClient;
CFX_RectF m_rtImage;
@@ -38,13 +44,13 @@ class CFWL_PictureBoxImp : public CFWL_WidgetImp {
FX_BOOL m_bTop;
FX_BOOL m_bVCenter;
FX_BOOL m_bButton;
- friend class CFWL_PictureBoxImpDelegate;
};
+
class CFWL_PictureBoxImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_PictureBoxImpDelegate(CFWL_PictureBoxImp* pOwner);
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
CFWL_PictureBoxImp* m_pOwner;
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp
index 89654d02713..77c93f4537a 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp
@@ -12,7 +12,6 @@
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
@@ -39,26 +38,33 @@ CFWL_PushButtonImp::CFWL_PushButtonImp(
m_rtClient.Set(0, 0, 0, 0);
m_rtCaption.Set(0, 0, 0, 0);
}
+
CFWL_PushButtonImp::~CFWL_PushButtonImp() {}
-FWL_ERR CFWL_PushButtonImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_PushButtonImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_PushButton;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_PushButtonImp::GetClassID() const {
- return FWL_CLASSHASH_PushButton;
+
+FWL_Type CFWL_PushButtonImp::GetClassID() const {
+ return FWL_Type::PushButton;
}
-FWL_ERR CFWL_PushButtonImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_PushButtonImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_PushButtonImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PushButtonImp::Finalize() {
+
+FWL_Error CFWL_PushButtonImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
if (m_pProperties->m_pThemeProvider == NULL) {
@@ -76,24 +82,26 @@ FWL_ERR CFWL_PushButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
rect.Set(0, 0, sz.x, sz.y);
}
FX_FLOAT* fcaption =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin));
+ static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin));
rect.Inflate(*fcaption, *fcaption);
CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PushButtonImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
+
+void CFWL_PushButtonImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
if ((dwStates & FWL_WGTSTATE_Disabled) && bSet) {
m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled;
- return FWL_ERR_Succeeded;
+ return;
}
- return CFWL_WidgetImp::SetStates(dwStates, bSet);
+ CFWL_WidgetImp::SetStates(dwStates, bSet);
}
-FWL_ERR CFWL_PushButtonImp::Update() {
+
+FWL_Error CFWL_PushButtonImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
@@ -102,26 +110,26 @@ FWL_ERR CFWL_PushButtonImp::Update() {
GetClientRect(m_rtClient);
m_rtCaption = m_rtClient;
FX_FLOAT* fcaption =
- static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_PSB_Margin));
+ static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin));
m_rtCaption.Inflate(-*fcaption, -*fcaption);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_PushButtonDP* pData =
static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider);
CFX_DIBitmap* pPicture = NULL;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_PSB_Border, m_pProperties->m_pThemeProvider,
+ DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider,
pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_PSB_Edge, m_pProperties->m_pThemeProvider,
+ DrawEdge(pGraphics, CFWL_Part::Edge, m_pProperties->m_pThemeProvider,
pMatrix);
}
DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix);
@@ -292,14 +300,14 @@ FWL_ERR CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics,
DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix);
break;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_PushButtonImp::DrawBkground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_PSB_Background;
+ param.m_iPart = CFWL_Part::Background;
param.m_dwStates = GetPartStates();
param.m_pGraphics = pGraphics;
if (pMatrix) {
@@ -323,7 +331,7 @@ void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics,
}
CFWL_ThemeText param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_PSB_Caption;
+ param.m_iPart = CFWL_Part::Caption;
param.m_dwStates = GetPartStates();
param.m_pGraphics = pGraphics;
if (pMatrix) {
@@ -336,18 +344,18 @@ void CFWL_PushButtonImp::DrawText(CFX_Graphics* pGraphics,
pTheme->DrawText(&param);
}
uint32_t CFWL_PushButtonImp::GetPartStates() {
- uint32_t dwStates = FWL_PARTSTATE_PSB_Normal;
+ uint32_t dwStates = CFWL_PartState_Normal;
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- dwStates |= FWL_PARTSTATE_PSB_Focused;
+ dwStates |= CFWL_PartState_Focused;
}
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
- dwStates = FWL_PARTSTATE_PSB_Disabled;
+ dwStates = CFWL_PartState_Disabled;
} else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
- dwStates |= FWL_PARTSTATE_PSB_Pressed;
+ dwStates |= CFWL_PartState_Pressed;
} else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
- dwStates |= FWL_PARTSTATE_PSB_Hovered;
+ dwStates |= CFWL_PartState_Hovered;
} else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) {
- dwStates |= FWL_PARTSTATE_PSB_Default;
+ dwStates |= CFWL_PartState_Default;
}
return dwStates;
}
@@ -398,69 +406,71 @@ void CFWL_PushButtonImp::UpdateTextOutStyles() {
m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
}
}
+
CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate(
CFWL_PushButtonImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- if (!m_pOwner->IsEnabled()) {
- return 1;
- }
- int32_t iRet = 1;
- uint32_t dwMsgCode = pMessage->GetClassID();
+ return;
+ if (!m_pOwner->IsEnabled())
+ return;
+
+ CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ case CFWL_MessageType::SetFocus: {
+ OnFocusChanged(pMessage, TRUE);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(pMessage, FALSE);
+ break;
+ }
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseLeave: {
+ case FWL_MouseCommand::Leave: {
OnMouseLeave(pMsg);
break;
}
- default: {}
+ default:
+ break;
}
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
OnKeyDown(pKey);
- }
break;
}
default: {
- iRet = 0;
break;
}
}
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
-}
-FWL_ERR CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_PushButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
+
+void CFWL_PushButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_PushButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
FX_BOOL bSet) {
if (bSet) {
@@ -540,7 +550,7 @@ void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
if (pMsg->m_dwKeyCode == FWL_VKEY_Return) {
CFWL_EvtMouse wmMouse;
wmMouse.m_pSrcTarget = m_pOwner->m_pInterface;
- wmMouse.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp;
+ wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
m_pOwner->DispatchEvent(&wmMouse);
CFWL_EvtClick wmClick;
wmClick.m_pSrcTarget = m_pOwner->m_pInterface;
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.h
index be6941249cb..79a4859cc9d 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_pushbuttonimp.h
@@ -8,6 +8,7 @@
#define XFA_FWL_BASEWIDGET_FWL_PUSHBUTTONIMP_H_
#include "xfa/fwl/core/fwl_widgetimp.h"
+#include "xfa/fwl/core/ifwl_widget.h"
class CFWL_MsgMouse;
class CFWL_WidgetImpProperties;
@@ -18,18 +19,22 @@ class CFWL_PushButtonImp : public CFWL_WidgetImp {
public:
CFWL_PushButtonImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual ~CFWL_PushButtonImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ ~CFWL_PushButtonImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override;
+ FWL_Error Update() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
protected:
+ friend class CFWL_PushButtonImpDelegate;
+
void DrawBkground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix);
@@ -38,21 +43,21 @@ class CFWL_PushButtonImp : public CFWL_WidgetImp {
const CFX_Matrix* pMatrix);
uint32_t GetPartStates();
void UpdateTextOutStyles();
+
CFX_RectF m_rtClient;
CFX_RectF m_rtCaption;
FX_BOOL m_bBtnDown;
uint32_t m_dwTTOStyles;
int32_t m_iTTOAlign;
- friend class CFWL_PushButtonImpDelegate;
};
class CFWL_PushButtonImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_PushButtonImpDelegate(CFWL_PushButtonImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
index 23bda25d58a..17f98059bec 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
@@ -11,7 +11,6 @@
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
@@ -32,34 +31,34 @@ IFWL_ScrollBar::IFWL_ScrollBar() {}
FX_BOOL IFWL_ScrollBar::IsVertical() {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->IsVertical();
}
-FWL_ERR IFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
+FWL_Error IFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetRange(fMin, fMax);
}
-FWL_ERR IFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
+FWL_Error IFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetRange(fMin, fMax);
}
FX_FLOAT IFWL_ScrollBar::GetPageSize() {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetPageSize();
}
-FWL_ERR IFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) {
+FWL_Error IFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetPageSize(fPageSize);
}
FX_FLOAT IFWL_ScrollBar::GetStepSize() {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetStepSize();
}
-FWL_ERR IFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) {
+FWL_Error IFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetStepSize(fStepSize);
}
FX_FLOAT IFWL_ScrollBar::GetPos() {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetPos();
}
-FWL_ERR IFWL_ScrollBar::SetPos(FX_FLOAT fPos) {
+FWL_Error IFWL_ScrollBar::SetPos(FX_FLOAT fPos) {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetPos(fPos);
}
FX_FLOAT IFWL_ScrollBar::GetTrackPos() {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetTrackPos();
}
-FWL_ERR IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) {
+FWL_Error IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) {
return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetTrackPos(fTrackPos);
}
FX_BOOL IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) {
@@ -75,11 +74,11 @@ CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties,
m_fStepSize(0),
m_fPos(0),
m_fTrackPos(0),
- m_iMinButtonState(FWL_PARTSTATE_SCB_Normal),
- m_iMaxButtonState(FWL_PARTSTATE_SCB_Normal),
- m_iThumbButtonState(FWL_PARTSTATE_SCB_Normal),
- m_iMinTrackState(FWL_PARTSTATE_SCB_Normal),
- m_iMaxTrackState(FWL_PARTSTATE_SCB_Normal),
+ m_iMinButtonState(CFWL_PartState_Normal),
+ m_iMaxButtonState(CFWL_PartState_Normal),
+ m_iThumbButtonState(CFWL_PartState_Normal),
+ m_iMinTrackState(CFWL_PartState_Normal),
+ m_iMaxTrackState(CFWL_PartState_Normal),
m_fLastTrackPos(0),
m_cpTrackPointX(0),
m_cpTrackPointY(0),
@@ -99,32 +98,38 @@ CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties,
m_rtMinTrack.Reset();
m_rtMaxTrack.Reset();
}
+
CFWL_ScrollBarImp::~CFWL_ScrollBarImp() {}
-FWL_ERR CFWL_ScrollBarImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_ScrollBarImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_ScrollBar;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_ScrollBarImp::GetClassID() const {
- return FWL_CLASSHASH_ScrollBar;
+
+FWL_Type CFWL_ScrollBarImp::GetClassID() const {
+ return FWL_Type::ScrollBar;
}
-FWL_ERR CFWL_ScrollBarImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_ScrollBarImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_ScrollBarImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ScrollBarImp::Finalize() {
+
+FWL_Error CFWL_ScrollBarImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_ScrollBarImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_ScrollBarImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
FX_FLOAT* pfMinWidth = static_cast<FX_FLOAT*>(
- GetThemeCapacity(FWL_WGTCAPACITY_ScrollBarWidth));
+ GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pfMinWidth)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (IsVertical()) {
rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3);
} else {
@@ -134,81 +139,81 @@ FWL_ERR CFWL_ScrollBarImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ScrollBarImp::Update() {
+FWL_Error CFWL_ScrollBarImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
}
Layout();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ScrollBarImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_ScrollBarImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_SCB_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_SCB_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
DrawTrack(pGraphics, pTheme, TRUE, pMatrix);
DrawTrack(pGraphics, pTheme, FALSE, pMatrix);
DrawArrowBtn(pGraphics, pTheme, TRUE, pMatrix);
DrawArrowBtn(pGraphics, pTheme, FALSE, pMatrix);
DrawThumb(pGraphics, pTheme, pMatrix);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
inline FX_BOOL CFWL_ScrollBarImp::IsVertical() {
return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert;
}
-FWL_ERR CFWL_ScrollBarImp::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
+FWL_Error CFWL_ScrollBarImp::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
fMin = m_fRangeMin;
fMax = m_fRangeMax;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ScrollBarImp::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
+FWL_Error CFWL_ScrollBarImp::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
m_fRangeMin = fMin;
m_fRangeMax = fMax;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_ScrollBarImp::GetPageSize() {
return m_fPageSize;
}
-FWL_ERR CFWL_ScrollBarImp::SetPageSize(FX_FLOAT fPageSize) {
+FWL_Error CFWL_ScrollBarImp::SetPageSize(FX_FLOAT fPageSize) {
m_fPageSize = fPageSize;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_ScrollBarImp::GetStepSize() {
return m_fStepSize;
}
-FWL_ERR CFWL_ScrollBarImp::SetStepSize(FX_FLOAT fStepSize) {
+FWL_Error CFWL_ScrollBarImp::SetStepSize(FX_FLOAT fStepSize) {
m_fStepSize = fStepSize;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_ScrollBarImp::GetPos() {
return m_fPos;
}
-FWL_ERR CFWL_ScrollBarImp::SetPos(FX_FLOAT fPos) {
+FWL_Error CFWL_ScrollBarImp::SetPos(FX_FLOAT fPos) {
m_fPos = fPos;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_ScrollBarImp::GetTrackPos() {
return m_fTrackPos;
}
-FWL_ERR CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos) {
+FWL_Error CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos) {
m_fTrackPos = fTrackPos;
CalcThumbButtonRect(m_rtThumb);
CalcMinTrackRect(m_rtMinTrack);
CalcMaxTrackRect(m_rtMaxTrack);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_ScrollBarImp::DoScroll(uint32_t dwCode, FX_FLOAT fPos) {
switch (dwCode) {
@@ -237,9 +242,9 @@ int32_t CFWL_ScrollBarImp::Run(FWL_HTIMER hTimer) {
}
return 1;
}
-FWL_ERR CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) {
+FWL_Error CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) {
m_pOuter = pOuter;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
@@ -247,9 +252,9 @@ void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = bLower ? FWL_PART_SCB_LowerTrack : FWL_PART_SCB_UpperTrack;
+ param.m_iPart = bLower ? CFWL_Part::LowerTrack : CFWL_Part::UpperTrack;
param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: (bLower ? m_iMinTrackState : m_iMaxTrackState);
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
@@ -262,9 +267,9 @@ void CFWL_ScrollBarImp::DrawArrowBtn(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = bMinBtn ? FWL_PART_SCB_ForeArrow : FWL_PART_SCB_BackArrow;
+ param.m_iPart = bMinBtn ? CFWL_Part::ForeArrow : CFWL_Part::BackArrow;
param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: (bMinBtn ? m_iMinButtonState : m_iMaxButtonState);
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
@@ -280,9 +285,9 @@ void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics* pGraphics,
}
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_SCB_Thumb;
+ param.m_iPart = CFWL_Part::Thumb;
param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: m_iThumbButtonState;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
@@ -294,7 +299,7 @@ void CFWL_ScrollBarImp::Layout() {
CFWL_ThemePart part;
part.m_pWidget = m_pInterface;
m_fMinThumb = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_CAPACITY_SCB_Size));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Size));
m_bCustomLayout = pTheme->IsCustomizedLayout(m_pInterface);
GetClientRect(m_rtClient);
CalcButtonLen();
@@ -320,9 +325,9 @@ void CFWL_ScrollBarImp::CalcMinButtonRect(CFX_RectF& rect) {
CFWL_ThemePart pPart;
pPart.m_rtPart = m_rtMinBtn;
pPart.m_pWidget = m_pInterface;
- pPart.m_iPart = FWL_PART_SCB_ForeArrow;
+ pPart.m_iPart = CFWL_Part::ForeArrow;
pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: m_iMinButtonState;
pTheme->GetPartRect(&pPart, rect);
} else {
@@ -338,9 +343,9 @@ void CFWL_ScrollBarImp::CalcMaxButtonRect(CFX_RectF& rect) {
CFWL_ThemePart pPart;
pPart.m_rtPart = m_rtMaxBtn;
pPart.m_pWidget = m_pInterface;
- pPart.m_iPart = FWL_PART_SCB_BackArrow;
+ pPart.m_iPart = CFWL_Part::BackArrow;
pPart.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
- ? FWL_PARTSTATE_SCB_Disabled
+ ? CFWL_PartState_Disabled
: m_iMaxButtonState;
pTheme->GetPartRect(&pPart, rect);
} else {
@@ -592,19 +597,19 @@ void CFWL_ScrollBarImp::GetTrackRect(CFX_RectF& rect, FX_BOOL bLower) {
}
}
FX_BOOL CFWL_ScrollBarImp::SendEvent() {
- if (m_iMinButtonState == FWL_PARTSTATE_SCB_Pressed) {
+ if (m_iMinButtonState == CFWL_PartState_Pressed) {
DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos);
return FALSE;
}
- if (m_iMaxButtonState == FWL_PARTSTATE_SCB_Pressed) {
+ if (m_iMaxButtonState == CFWL_PartState_Pressed) {
DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos);
return FALSE;
}
- if (m_iMinTrackState == FWL_PARTSTATE_SCB_Pressed) {
+ if (m_iMinTrackState == CFWL_PartState_Pressed) {
DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos);
return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
}
- if (m_iMaxTrackState == FWL_PARTSTATE_SCB_Pressed) {
+ if (m_iMaxTrackState == CFWL_PartState_Pressed) {
DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos);
return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
}
@@ -625,48 +630,50 @@ FX_BOOL CFWL_ScrollBarImp::OnScroll(uint32_t dwCode, FX_FLOAT fPos) {
DispatchEvent(&ev);
return bRet;
}
+
CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- int32_t iRet = 1;
- uint32_t dwMsgCode = pMessage->GetClassID();
- if (dwMsgCode == FWL_MSGHASH_Mouse) {
+ return;
+
+ CFWL_MessageType dwMsgCode = pMessage->GetClassID();
+ if (dwMsgCode == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
break;
}
- case FWL_MSGMOUSECMD_MouseLeave: {
+ case FWL_MouseCommand::Leave: {
OnMouseLeave();
break;
}
- default: { iRet = 0; }
+ default: {
+ break;
+ }
}
- } else if (dwMsgCode == FWL_MSGHASH_MouseWheel) {
+ } else if (dwMsgCode == CFWL_MessageType::MouseWheel) {
CFWL_MsgMouseWheel* pMsg = static_cast<CFWL_MsgMouseWheel*>(pMessage);
OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX,
pMsg->m_fDeltaY);
- } else {
- iRet = 0;
}
- return iRet;
}
-FWL_ERR CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_ScrollBarImpDelegate::OnLButtonDown(uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
@@ -748,10 +755,10 @@ void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem,
if (!rtItem.Contains(fx, fy)) {
return;
}
- if (iState == FWL_PARTSTATE_SCB_Pressed) {
+ if (iState == CFWL_PartState_Pressed) {
return;
}
- iState = FWL_PARTSTATE_SCB_Pressed;
+ iState = CFWL_PartState_Pressed;
m_pOwner->Repaint(&rtItem);
}
void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem,
@@ -759,8 +766,8 @@ void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem,
int32_t& iState,
FX_FLOAT fx,
FX_FLOAT fy) {
- int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered
- : FWL_PARTSTATE_SCB_Normal;
+ int32_t iNewState =
+ rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal;
if (iState == iNewState) {
return;
}
@@ -774,15 +781,15 @@ void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem,
FX_FLOAT fx,
FX_FLOAT fy) {
if (!m_pOwner->m_bMouseDown) {
- int32_t iNewState = rtItem.Contains(fx, fy) ? FWL_PARTSTATE_SCB_Hovered
- : FWL_PARTSTATE_SCB_Normal;
+ int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered
+ : CFWL_PartState_Normal;
if (iState == iNewState) {
return;
}
iState = iNewState;
m_pOwner->Repaint(&rtItem);
} else if ((2 == iItem) &&
- (m_pOwner->m_iThumbButtonState == FWL_PARTSTATE_SCB_Pressed)) {
+ (m_pOwner->m_iThumbButtonState == CFWL_PartState_Pressed)) {
FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy);
m_pOwner->m_fTrackPos = fPos;
m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos);
@@ -791,18 +798,18 @@ void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem,
void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem,
const CFX_RectF& rtItem,
int32_t& iState) {
- if (iState == FWL_PARTSTATE_SCB_Normal) {
+ if (iState == CFWL_PartState_Normal) {
return;
}
- iState = FWL_PARTSTATE_SCB_Normal;
+ iState = CFWL_PartState_Normal;
m_pOwner->Repaint(&rtItem);
}
void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem,
const CFX_RectF& rtItem,
int32_t& iState) {
- if (iState == FWL_PARTSTATE_SCB_Hovered) {
+ if (iState == CFWL_PartState_Hovered) {
return;
}
- iState = FWL_PARTSTATE_SCB_Hovered;
+ iState = CFWL_PartState_Hovered;
m_pOwner->Repaint(&rtItem);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.h
index 08f7c69bf7e..ad10e207db9 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_scrollbarimp.h
@@ -9,6 +9,7 @@
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_timer.h"
+#include "xfa/fwl/core/ifwl_widget.h"
class CFWL_WidgetImpProperties;
class IFWL_Widget;
@@ -18,31 +19,38 @@ class CFWL_ScrollBarImp : public CFWL_WidgetImp, public IFWL_Timer {
public:
CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- ~CFWL_ScrollBarImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FX_BOOL IsVertical();
- virtual FWL_ERR GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
- virtual FWL_ERR SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
- virtual FX_FLOAT GetPageSize();
- virtual FWL_ERR SetPageSize(FX_FLOAT fPageSize);
- virtual FX_FLOAT GetStepSize();
- virtual FWL_ERR SetStepSize(FX_FLOAT fStepSize);
- virtual FX_FLOAT GetPos();
- virtual FWL_ERR SetPos(FX_FLOAT fPos);
- virtual FX_FLOAT GetTrackPos();
- virtual FWL_ERR SetTrackPos(FX_FLOAT fTrackPos);
- virtual FX_BOOL DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f);
- virtual FWL_ERR SetOuter(IFWL_Widget* pOuter);
- virtual int32_t Run(FWL_HTIMER hTimer);
+ ~CFWL_ScrollBarImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error Update() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+
+ // IFWL_Timer
+ int32_t Run(FWL_HTIMER hTimer) override;
+
+ FX_BOOL IsVertical();
+ FWL_Error GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
+ FWL_Error SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
+ FX_FLOAT GetPageSize();
+ FWL_Error SetPageSize(FX_FLOAT fPageSize);
+ FX_FLOAT GetStepSize();
+ FWL_Error SetStepSize(FX_FLOAT fStepSize);
+ FX_FLOAT GetPos();
+ FWL_Error SetPos(FX_FLOAT fPos);
+ FX_FLOAT GetTrackPos();
+ FWL_Error SetTrackPos(FX_FLOAT fTrackPos);
+ FX_BOOL DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f);
+ FWL_Error SetOuter(IFWL_Widget* pOuter);
protected:
+ friend class CFWL_ScrollBarImpDelegate;
+
void DrawTrack(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
FX_BOOL bLower = TRUE,
@@ -96,14 +104,14 @@ class CFWL_ScrollBarImp : public CFWL_WidgetImp, public IFWL_Timer {
CFX_RectF m_rtMaxTrack;
FX_BOOL m_bCustomLayout;
FX_FLOAT m_fMinThumb;
- friend class CFWL_ScrollBarImpDelegate;
};
+
class CFWL_ScrollBarImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp
index 9f276b7281b..25c8a359832 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp
@@ -11,15 +11,18 @@
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
#include "xfa/fwl/core/ifwl_timer.h"
-#define FWL_SPN_MinWidth 18
-#define FWL_SPN_MinHeight 32
-#define FWL_SPIN_Elapse 200
+namespace {
+
+const int kMinWidth = 18;
+const int kMinHeight = 32;
+const int kElapseTime = 200;
+
+} // namespace
// static
IFWL_SpinButton* IFWL_SpinButton::Create(
@@ -33,7 +36,7 @@ IFWL_SpinButton* IFWL_SpinButton::Create(
return pSpinButton;
}
IFWL_SpinButton::IFWL_SpinButton() {}
-FWL_ERR IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
+FWL_Error IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
return static_cast<CFWL_SpinButtonImp*>(GetImpl())
->EnableButton(bEnable, bUp);
}
@@ -45,8 +48,8 @@ CFWL_SpinButtonImp::CFWL_SpinButtonImp(
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_WidgetImp(properties, pOuter),
- m_dwUpState(FWL_PARTSTATE_SPB_Normal),
- m_dwDnState(FWL_PARTSTATE_SPB_Normal),
+ m_dwUpState(CFWL_PartState_Normal),
+ m_dwDnState(CFWL_PartState_Normal),
m_iButtonIndex(0),
m_bLButtonDwn(FALSE),
m_hTimer(NULL) {
@@ -55,37 +58,44 @@ CFWL_SpinButtonImp::CFWL_SpinButtonImp(
m_rtDnButton.Reset();
m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
}
+
CFWL_SpinButtonImp::~CFWL_SpinButtonImp() {}
-FWL_ERR CFWL_SpinButtonImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_SpinButtonImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_SpinButton;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_SpinButtonImp::GetClassID() const {
- return FWL_CLASSHASH_SpinButton;
+
+FWL_Type CFWL_SpinButtonImp::GetClassID() const {
+ return FWL_Type::SpinButton;
}
-FWL_ERR CFWL_SpinButtonImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_SpinButtonImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_SpinButtonImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_SpinButtonImp::Finalize() {
+
+FWL_Error CFWL_SpinButtonImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_SpinButtonImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_SpinButtonImp::GetWidgetRect(CFX_RectF& rect,
+ FX_BOOL bAutoSize) {
if (bAutoSize) {
- rect.Set(0, 0, FWL_SPN_MinWidth, FWL_SPN_MinHeight);
+ rect.Set(0, 0, kMinWidth, kMinHeight);
CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_SpinButtonImp::Update() {
+FWL_Error CFWL_SpinButtonImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
GetClientRect(m_rtClient);
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) {
@@ -99,48 +109,43 @@ FWL_ERR CFWL_SpinButtonImp::Update() {
m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top,
m_rtClient.width / 2, m_rtClient.height);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_SpinButtonImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
- if (m_rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
- if (HasBorder() && (m_rtClient.Contains(fx, fy))) {
- return FWL_WGTHITTEST_Border;
- }
+FWL_WidgetHit CFWL_SpinButtonImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ if (m_rtClient.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
+ if (HasBorder() && (m_rtClient.Contains(fx, fy)))
+ return FWL_WidgetHit::Border;
if (HasEdge()) {
CFX_RectF rtEdge;
GetEdgeRect(rtEdge);
- if (rtEdge.Contains(fx, fy)) {
- return FWL_PART_SPB_Edge;
- }
- }
- if (m_rtUpButton.Contains(fx, fy)) {
- return FWL_WGTHITTEST_SPB_UpButton;
- }
- if (m_rtDnButton.Contains(fx, fy)) {
- return FWL_WGTHITTEST_SPB_DownButton;
- }
- return FWL_WGTHITTEST_Unknown;
+ if (rtEdge.Contains(fx, fy))
+ return FWL_WidgetHit::Left;
+ }
+ if (m_rtUpButton.Contains(fx, fy))
+ return FWL_WidgetHit::UpButton;
+ if (m_rtDnButton.Contains(fx, fy))
+ return FWL_WidgetHit::DownButton;
+ return FWL_WidgetHit::Unknown;
}
-FWL_ERR CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
CFX_RectF rtClip(m_rtClient);
if (pMatrix != NULL) {
pMatrix->TransformRect(rtClip);
}
IFWL_ThemeProvider* pTheme = GetAvailableTheme();
if (HasBorder()) {
- DrawBorder(pGraphics, FWL_PART_SPB_Border, pTheme, pMatrix);
+ DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
}
if (HasEdge()) {
- DrawEdge(pGraphics, FWL_PART_SPB_Edge, pTheme, pMatrix);
+ DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
}
DrawUpButton(pGraphics, pTheme, pMatrix);
DrawDownButton(pGraphics, pTheme, pMatrix);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_SpinButtonImp::Run(FWL_HTIMER hTimer) {
if (m_hTimer) {
@@ -151,34 +156,34 @@ int32_t CFWL_SpinButtonImp::Run(FWL_HTIMER hTimer) {
}
return 1;
}
-FWL_ERR CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
+FWL_Error CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
if (bUp) {
if (bEnable) {
- m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ m_dwUpState = CFWL_PartState_Normal;
} else {
- m_dwUpState = FWL_PARTSTATE_SPB_Disabled;
+ m_dwUpState = CFWL_PartState_Disabled;
}
} else {
if (bEnable) {
- m_dwDnState = FWL_PARTSTATE_SPB_Normal;
+ m_dwDnState = CFWL_PartState_Normal;
} else {
- m_dwDnState = FWL_PARTSTATE_SPB_Disabled;
+ m_dwDnState = CFWL_PartState_Disabled;
}
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_SpinButtonImp::IsButtonEnable(FX_BOOL bUp) {
if (bUp) {
- return (m_dwUpState != FWL_PARTSTATE_SPB_Disabled);
+ return (m_dwUpState != CFWL_PartState_Disabled);
}
- return (m_dwDnState != FWL_PARTSTATE_SPB_Disabled);
+ return (m_dwDnState != CFWL_PartState_Disabled);
}
void CFWL_SpinButtonImp::DrawUpButton(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_SPB_UpButton;
+ params.m_iPart = CFWL_Part::UpButton;
params.m_pGraphics = pGraphics;
params.m_dwStates = m_dwUpState + 1;
if (pMatrix) {
@@ -192,7 +197,7 @@ void CFWL_SpinButtonImp::DrawDownButton(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground params;
params.m_pWidget = m_pInterface;
- params.m_iPart = FWL_PART_SPB_DownButton;
+ params.m_iPart = CFWL_Part::DownButton;
params.m_pGraphics = pGraphics;
params.m_dwStates = m_dwDnState + 1;
if (pMatrix) {
@@ -201,66 +206,69 @@ void CFWL_SpinButtonImp::DrawDownButton(CFX_Graphics* pGraphics,
params.m_rtPart = m_rtDnButton;
pTheme->DrawBackground(&params);
}
+
CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate(
CFWL_SpinButtonImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- int32_t iRet = 1;
- uint32_t dwMsgCode = pMessage->GetClassID();
+ return;
+
+ CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case FWL_MSGHASH_SetFocus:
- case FWL_MSGHASH_KillFocus: {
- OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus);
+ case CFWL_MessageType::SetFocus: {
+ OnFocusChanged(pMessage, TRUE);
+ break;
+ }
+ case CFWL_MessageType::KillFocus: {
+ OnFocusChanged(pMessage, FALSE);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- uint32_t dwCmd = pMsg->m_dwCmd;
- switch (dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseLeave: {
+ case FWL_MouseCommand::Leave: {
OnMouseLeave(pMsg);
break;
}
- default: {}
+ default:
+ break;
}
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
- if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) {
+ if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
OnKeyDown(pKey);
- }
break;
}
default: {
- iRet = 0;
break;
}
}
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
- return iRet;
-}
-FWL_ERR CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_SpinButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
+
+void CFWL_SpinButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_SpinButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
FX_BOOL bSet) {
if (bSet) {
@@ -285,11 +293,11 @@ void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
}
if (bUpPress) {
m_pOwner->m_iButtonIndex = 0;
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Pressed;
+ m_pOwner->m_dwUpState = CFWL_PartState_Pressed;
}
if (bDnPress) {
m_pOwner->m_iButtonIndex = 1;
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Pressed;
+ m_pOwner->m_dwDnState = CFWL_PartState_Pressed;
}
CFWL_EvtSpbClick wmPosChanged;
wmPosChanged.m_pSrcTarget = m_pOwner->m_pInterface;
@@ -297,10 +305,10 @@ void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
m_pOwner->DispatchEvent(&wmPosChanged);
m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton
: &m_pOwner->m_rtDnButton);
- m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SPIN_Elapse);
+ m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, kElapseTime);
}
void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_pProperties->m_dwStates & FWL_PARTSTATE_SPB_Disabled) {
+ if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) {
return;
}
m_pOwner->m_bLButtonDwn = FALSE;
@@ -312,14 +320,14 @@ void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
}
FX_BOOL bRepaint = FALSE;
CFX_RectF rtInvalidate;
- if (m_pOwner->m_dwUpState == FWL_PARTSTATE_SPB_Pressed &&
+ if (m_pOwner->m_dwUpState == CFWL_PartState_Pressed &&
m_pOwner->IsButtonEnable(TRUE)) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ m_pOwner->m_dwUpState = CFWL_PartState_Normal;
bRepaint = TRUE;
rtInvalidate = m_pOwner->m_rtUpButton;
- } else if (m_pOwner->m_dwDnState == FWL_PARTSTATE_SPB_Pressed &&
+ } else if (m_pOwner->m_dwDnState == CFWL_PartState_Pressed &&
m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
+ m_pOwner->m_dwDnState = CFWL_PartState_Normal;
bRepaint = TRUE;
rtInvalidate = m_pOwner->m_rtDnButton;
}
@@ -338,14 +346,14 @@ void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
rtInvlidate.Reset();
if (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
if (m_pOwner->IsButtonEnable(TRUE)) {
- if (m_pOwner->m_dwUpState == FWL_PARTSTATE_SPB_Hovered) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Hovered;
+ if (m_pOwner->m_dwUpState == CFWL_PartState_Hovered) {
+ m_pOwner->m_dwUpState = CFWL_PartState_Hovered;
bRepaint = TRUE;
rtInvlidate = m_pOwner->m_rtUpButton;
}
- if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal &&
+ if (m_pOwner->m_dwDnState != CFWL_PartState_Normal &&
m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
+ m_pOwner->m_dwDnState = CFWL_PartState_Normal;
if (bRepaint) {
rtInvlidate.Union(m_pOwner->m_rtDnButton);
} else {
@@ -359,14 +367,14 @@ void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
}
} else if (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
if (m_pOwner->IsButtonEnable(FALSE)) {
- if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Hovered) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Hovered;
+ if (m_pOwner->m_dwDnState != CFWL_PartState_Hovered) {
+ m_pOwner->m_dwDnState = CFWL_PartState_Hovered;
bRepaint = TRUE;
rtInvlidate = m_pOwner->m_rtDnButton;
}
- if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal &&
+ if (m_pOwner->m_dwUpState != CFWL_PartState_Normal &&
m_pOwner->IsButtonEnable(TRUE)) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ m_pOwner->m_dwUpState = CFWL_PartState_Normal;
if (bRepaint) {
rtInvlidate.Union(m_pOwner->m_rtUpButton);
} else {
@@ -375,15 +383,15 @@ void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
bRepaint = TRUE;
}
}
- } else if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal ||
- m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal) {
- if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ } else if (m_pOwner->m_dwUpState != CFWL_PartState_Normal ||
+ m_pOwner->m_dwDnState != CFWL_PartState_Normal) {
+ if (m_pOwner->m_dwUpState != CFWL_PartState_Normal) {
+ m_pOwner->m_dwUpState = CFWL_PartState_Normal;
bRepaint = TRUE;
rtInvlidate = m_pOwner->m_rtUpButton;
}
- if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
+ if (m_pOwner->m_dwDnState != CFWL_PartState_Normal) {
+ m_pOwner->m_dwDnState = CFWL_PartState_Normal;
if (bRepaint) {
rtInvlidate.Union(m_pOwner->m_rtDnButton);
} else {
@@ -399,13 +407,13 @@ void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
if (!pMsg)
return;
- if (m_pOwner->m_dwUpState != FWL_PARTSTATE_SPB_Normal &&
+ if (m_pOwner->m_dwUpState != CFWL_PartState_Normal &&
m_pOwner->IsButtonEnable(TRUE)) {
- m_pOwner->m_dwUpState = FWL_PARTSTATE_SPB_Normal;
+ m_pOwner->m_dwUpState = CFWL_PartState_Normal;
}
- if (m_pOwner->m_dwDnState != FWL_PARTSTATE_SPB_Normal &&
+ if (m_pOwner->m_dwDnState != CFWL_PartState_Normal &&
m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->m_dwDnState = FWL_PARTSTATE_SPB_Normal;
+ m_pOwner->m_dwDnState = CFWL_PartState_Normal;
}
m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.h
index 71e2a6dd618..068fbd888f2 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_spinbuttonimp.h
@@ -19,27 +19,35 @@ class CFWL_SpinButtonImp : public CFWL_WidgetImp, public IFWL_Timer {
public:
CFWL_SpinButtonImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- ~CFWL_SpinButtonImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual int32_t Run(FWL_HTIMER hTimer);
- FWL_ERR EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE);
+ ~CFWL_SpinButtonImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error Update() override;
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+
+ // IFWL_Timer
+ int32_t Run(FWL_HTIMER hTimer) override;
+
+ FWL_Error EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE);
FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE);
protected:
+ friend class CFWL_SpinButtonImpDelegate;
+
void DrawUpButton(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix);
void DrawDownButton(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix);
+
CFX_RectF m_rtClient;
CFX_RectF m_rtUpButton;
CFX_RectF m_rtDnButton;
@@ -48,15 +56,14 @@ class CFWL_SpinButtonImp : public CFWL_WidgetImp, public IFWL_Timer {
int32_t m_iButtonIndex;
FX_BOOL m_bLButtonDwn;
FWL_HTIMER m_hTimer;
- friend class CFWL_SpinButtonImpDelegate;
};
class CFWL_SpinButtonImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_SpinButtonImpDelegate(CFWL_SpinButtonImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
index 97ead0e44c8..9ac9c311603 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
@@ -13,11 +13,10 @@
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/fwl_formimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_panelimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
#include "xfa/fwl/core/ifwl_tooltiptarget.h"
+#include "xfa/fwl/theme/cfwl_widgettp.h"
// static
IFWL_ToolTip* IFWL_ToolTip::Create(const CFWL_WidgetImpProperties& properties,
@@ -28,16 +27,21 @@ IFWL_ToolTip* IFWL_ToolTip::Create(const CFWL_WidgetImpProperties& properties,
pToolTipImpl->SetInterface(pToolTip);
return pToolTip;
}
-FWL_ERR IFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) {
- return static_cast<CFWL_ToolTipImp*>(GetImpl())->SetAnchor(rtAnchor);
+
+void IFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) {
+ static_cast<CFWL_ToolTipImp*>(GetImpl())->SetAnchor(rtAnchor);
}
-FWL_ERR IFWL_ToolTip::Show() {
- return static_cast<CFWL_ToolTipImp*>(GetImpl())->Show();
+
+void IFWL_ToolTip::Show() {
+ static_cast<CFWL_ToolTipImp*>(GetImpl())->Show();
}
-FWL_ERR IFWL_ToolTip::Hide() {
- return static_cast<CFWL_ToolTipImp*>(GetImpl())->Hide();
+
+void IFWL_ToolTip::Hide() {
+ static_cast<CFWL_ToolTipImp*>(GetImpl())->Hide();
}
+
IFWL_ToolTip::IFWL_ToolTip() {}
+
CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_FormImp(properties, pOuter),
@@ -53,33 +57,39 @@ CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
m_TimerShow.m_pToolTip = this;
m_TimerHide.m_pToolTip = this;
}
+
CFWL_ToolTipImp::~CFWL_ToolTipImp() {
if (m_pTimer) {
delete m_pTimer;
m_pTimer = NULL;
}
}
-FWL_ERR CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_ToolTip;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_ToolTipImp::GetClassID() const {
- return FWL_CLASSHASH_ToolTip;
+
+FWL_Type CFWL_ToolTipImp::GetClassID() const {
+ return FWL_Type::ToolTip;
}
-FWL_ERR CFWL_ToolTipImp::Initialize() {
+
+FWL_Error CFWL_ToolTipImp::Initialize() {
m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup;
m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child;
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
+
m_pDelegate = new CFWL_ToolTipImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ToolTipImp::Finalize() {
+
+FWL_Error CFWL_ToolTipImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
if (m_pProperties->m_pThemeProvider == NULL) {
@@ -95,18 +105,18 @@ FWL_ERR CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (iLen > 0) {
CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider);
rect.Set(0, 0, sz.x, sz.y);
- rect.width += FWL_WGTCAPACITY_CXBorder * 25;
- rect.height += FWL_WGTCAPACITY_CYBorder * 8;
+ rect.width += 25;
+ rect.height += 16;
}
CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ToolTipImp::Update() {
+FWL_Error CFWL_ToolTipImp::Update() {
if (IsLocked()) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
@@ -114,9 +124,9 @@ FWL_ERR CFWL_ToolTipImp::Update() {
UpdateTextOutStyles();
GetClientRect(m_rtClient);
m_rtCaption = m_rtClient;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ToolTipImp::GetClientRect(CFX_RectF& rect) {
+FWL_Error CFWL_ToolTipImp::GetClientRect(CFX_RectF& rect) {
FX_FLOAT x = 0;
FX_FLOAT y = 0;
FX_FLOAT t = 0;
@@ -125,37 +135,37 @@ FWL_ERR CFWL_ToolTipImp::GetClientRect(CFX_RectF& rect) {
CFWL_ThemePart part;
part.m_pWidget = m_pInterface;
x = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder));
y = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder));
}
rect = m_pProperties->m_rtWidget;
rect.Offset(-rect.left, -rect.top);
rect.Deflate(x, t, x, y);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ToolTipImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_ToolTipImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
IFWL_ToolTipTarget* toolTipTarget =
CFWL_ToolTipContainer::getInstance()->GetCurrentToolTipTarget();
if (toolTipTarget && !toolTipTarget->UseDefaultTheme()) {
return toolTipTarget->DrawToolTip(pGraphics, pMatrix, m_pInterface);
}
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
DrawBkground(pGraphics, pTheme, pMatrix);
DrawText(pGraphics, pTheme, pMatrix);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_ToolTipImp::DrawBkground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_TTP_Background;
+ param.m_iPart = CFWL_Part::Background;
param.m_dwStates = m_pProperties->m_dwStates;
param.m_pGraphics = pGraphics;
if (pMatrix) {
@@ -179,7 +189,7 @@ void CFWL_ToolTipImp::DrawText(CFX_Graphics* pGraphics,
}
CFWL_ThemeText param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_TTP_Caption;
+ param.m_iPart = CFWL_Part::Caption;
param.m_dwStates = m_pProperties->m_dwStates;
param.m_pGraphics = pGraphics;
if (pMatrix) {
@@ -201,40 +211,41 @@ void CFWL_ToolTipImp::UpdateTextOutStyles() {
m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine;
}
}
-FWL_ERR CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) {
+
+void CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) {
m_rtAnchor = rtAnchor;
- return TRUE;
}
-FWL_ERR CFWL_ToolTipImp::Show() {
+
+void CFWL_ToolTipImp::Show() {
IFWL_ToolTipDP* pData =
static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider);
int32_t nInitDelay = pData->GetInitialDelay(m_pInterface);
- if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) {
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible))
m_hTimerShow = FWL_StartTimer(&m_TimerShow, nInitDelay, FALSE);
- }
- return TRUE;
}
-FWL_ERR CFWL_ToolTipImp::Hide() {
+
+void CFWL_ToolTipImp::Hide() {
SetStates(FWL_WGTSTATE_Invisible, TRUE);
if (m_hTimerHide) {
FWL_StopTimer(m_hTimerHide);
- m_hTimerHide = NULL;
+ m_hTimerHide = nullptr;
}
if (m_hTimerShow) {
FWL_StopTimer(m_hTimerShow);
- m_hTimerShow = NULL;
+ m_hTimerShow = nullptr;
}
- return TRUE;
}
-FWL_ERR CFWL_ToolTipImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
+
+void CFWL_ToolTipImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) {
IFWL_ToolTipDP* pData =
static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider);
int32_t nAutoPopDelay = pData->GetAutoPopDelay(m_pInterface);
m_hTimerHide = FWL_StartTimer(&m_TimerHide, nAutoPopDelay, FALSE);
}
- return CFWL_WidgetImp::SetStates(dwStates, bSet);
+ CFWL_WidgetImp::SetStates(dwStates, bSet);
}
+
void CFWL_ToolTipImp::RefreshToolTipPos() {
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) {
CFX_RectF rtPopup;
@@ -283,15 +294,17 @@ int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer) {
}
return TRUE;
}
+
CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
-}
-FWL_ERR CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- return FWL_ERR_Succeeded;
+
+void CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+ CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
}
-FWL_ERR CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+
+void CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
+
+void CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
index 119c3e11594..6d7af8dc89b 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
@@ -19,38 +19,48 @@ class CFWL_ToolTipImp : public CFWL_FormImp {
public:
CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual ~CFWL_ToolTipImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet);
- virtual FWL_ERR GetClientRect(CFX_RectF& rect);
- FWL_ERR SetAnchor(const CFX_RectF& rtAnchor);
- FWL_ERR Show();
- FWL_ERR Hide();
+ ~CFWL_ToolTipImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error Update() override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+ void SetStates(uint32_t dwStates, FX_BOOL bSet) override;
+ FWL_Error GetClientRect(CFX_RectF& rect) override;
+
+ void SetAnchor(const CFX_RectF& rtAnchor);
+ void Show();
+ void Hide();
protected:
- void DrawBkground(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix);
- void DrawText(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix);
- void UpdateTextOutStyles();
- void RefreshToolTipPos();
+ friend class CFWL_ToolTipImpDelegate;
+ friend class CFWL_ToolTipTimer;
+
class CFWL_ToolTipTimer : public IFWL_Timer {
public:
CFWL_ToolTipTimer() {}
~CFWL_ToolTipTimer() {}
+
CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip);
virtual int32_t Run(FWL_HTIMER hTimer);
+
CFWL_ToolTipImp* m_pToolTip;
};
+
+ void DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void DrawText(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix);
+ void UpdateTextOutStyles();
+ void RefreshToolTipPos();
+
CFX_RectF m_rtClient;
CFX_RectF m_rtCaption;
FX_BOOL m_bBtnDown;
@@ -62,16 +72,15 @@ class CFWL_ToolTipImp : public CFWL_FormImp {
CFWL_ToolTipTimer* m_pTimer;
CFWL_ToolTipTimer m_TimerShow;
CFWL_ToolTipTimer m_TimerHide;
- friend class CFWL_ToolTipImpDelegate;
- friend class CFWL_ToolTipTimer;
};
+
class CFWL_ToolTipImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.cpp b/chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.cpp
index 9792c6f7cc9..a67952caa6a 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.cpp
@@ -16,6 +16,7 @@
#include "xfa/fxbarcode/cbc_pdf417i.h"
#include "xfa/fxbarcode/cbc_qrcode.h"
#include "xfa/fxbarcode/cbc_upca.h"
+#include "xfa/fxbarcode/utils.h"
static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) {
switch (type) {
@@ -46,13 +47,13 @@ static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) {
return NULL;
}
}
+
CFX_Barcode::CFX_Barcode() {}
+
CFX_Barcode::~CFX_Barcode() {
- if (m_pBCEngine) {
- delete m_pBCEngine;
- m_pBCEngine = NULL;
- }
+ delete m_pBCEngine;
}
+
FX_BOOL CFX_Barcode::Create(BC_TYPE type) {
m_pBCEngine = FX_Barcode_CreateBarCodeEngineObject(type);
return m_pBCEngine != NULL;
@@ -320,15 +321,7 @@ FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) {
return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE)
: FALSE;
}
-#ifndef BCExceptionNO
-#define BCExceptionNO 0
-#endif
-#ifndef BCExceptionFormatException
-#define BCExceptionFormatException 8
-#endif
-#ifndef BCExceptionUnSupportedBarcode
-#define BCExceptionUnSupportedBarcode 18
-#endif
+
FX_BOOL CFX_Barcode::Encode(const CFX_WideStringC& contents,
FX_BOOL isDevice,
int32_t& e) {
@@ -338,12 +331,12 @@ FX_BOOL CFX_Barcode::Encode(const CFX_WideStringC& contents,
return m_pBCEngine->Encode(contents, isDevice, e);
}
FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
if (!m_pBCEngine) {
return FALSE;
}
- return m_pBCEngine->RenderDevice(device, matirx, e);
+ return m_pBCEngine->RenderDevice(device, matrix, e);
}
FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
if (!m_pBCEngine) {
@@ -351,13 +344,12 @@ FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
}
return m_pBCEngine->RenderBitmap(pOutBitmap, e);
}
-#define BC_TYPE_MIN BC_CODE39
-#define BC_TYPE_MAX BC_DATAMATRIX
+
CFX_WideString CFX_Barcode::Decode(uint8_t* buf,
int32_t width,
int32_t height,
int32_t& errorCode) {
- for (BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX;
+ for (BC_TYPE t = BC_CODE39; t <= BC_DATAMATRIX;
t = (BC_TYPE)((int32_t)t + 1)) {
CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t);
if (!pTmpEngine) {
@@ -372,7 +364,7 @@ CFX_WideString CFX_Barcode::Decode(uint8_t* buf,
return CFX_WideString();
}
CFX_WideString CFX_Barcode::Decode(CFX_DIBitmap* pBitmap, int32_t& errorCode) {
- for (BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX;
+ for (BC_TYPE t = BC_CODE39; t <= BC_DATAMATRIX;
t = (BC_TYPE)((int32_t)t + 1)) {
CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t);
if (!pTmpEngine) {
@@ -386,11 +378,3 @@ CFX_WideString CFX_Barcode::Decode(CFX_DIBitmap* pBitmap, int32_t& errorCode) {
errorCode = BCExceptionUnSupportedBarcode;
return CFX_WideString();
}
-IFX_Barcode* FX_Barcode_Create(BC_TYPE type) {
- CFX_Barcode* pBarcode = new CFX_Barcode;
- if (pBarcode->Create(type)) {
- return pBarcode;
- }
- pBarcode->Release();
- return NULL;
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.h
index bcad0489e6e..eca41d05a6e 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/fxmath_barcodeimp.h
@@ -7,53 +7,55 @@
#ifndef XFA_FWL_BASEWIDGET_FXMATH_BARCODEIMP_H_
#define XFA_FWL_BASEWIDGET_FXMATH_BARCODEIMP_H_
+#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/basewidget/ifx_barcode.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/include/BC_Library.h"
class CBC_CodeBase;
+class CFX_Font;
+class CFX_RenderDevice;
+class CFX_Matrix;
-class CFX_Barcode : public IFX_Barcode {
+class CFX_Barcode {
public:
CFX_Barcode();
~CFX_Barcode();
FX_BOOL Create(BC_TYPE type);
- virtual void Release();
- virtual BC_TYPE GetType();
- virtual FX_BOOL Encode(const CFX_WideStringC& contents,
- FX_BOOL isDevice,
- int32_t& e);
- virtual FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e);
- virtual FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
- virtual CFX_WideString Decode(uint8_t* buf,
- int32_t width,
- int32_t height,
- int32_t& errorCode);
- virtual CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& errorCode);
- virtual FX_BOOL SetCharEncoding(BC_CHAR_ENCODING encoding);
- virtual FX_BOOL SetModuleHeight(int32_t moduleHeight);
- virtual FX_BOOL SetModuleWidth(int32_t moduleWidth);
- virtual FX_BOOL SetHeight(int32_t height);
- virtual FX_BOOL SetWidth(int32_t width);
- virtual FX_BOOL CheckContentValidity(const CFX_WideStringC& contents);
- virtual FX_BOOL SetPrintChecksum(FX_BOOL checksum);
- virtual FX_BOOL SetDataLength(int32_t length);
- virtual FX_BOOL SetCalChecksum(int32_t state);
- virtual FX_BOOL SetFont(CFX_Font* pFont);
- virtual FX_BOOL SetFontSize(FX_FLOAT size);
- virtual FX_BOOL SetFontStyle(int32_t style);
- virtual FX_BOOL SetFontColor(FX_ARGB color);
- virtual FX_BOOL SetTextLocation(BC_TEXT_LOC location);
- virtual FX_BOOL SetWideNarrowRatio(int32_t ratio);
- virtual FX_BOOL SetStartChar(FX_CHAR start);
- virtual FX_BOOL SetEndChar(FX_CHAR end);
- virtual FX_BOOL SetVersion(int32_t version);
- virtual FX_BOOL SetErrorCorrectionLevel(int32_t level);
- virtual FX_BOOL SetTruncated(FX_BOOL truncated);
+ void Release();
+ BC_TYPE GetType();
+ FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
+ FX_BOOL RenderDevice(CFX_RenderDevice* device,
+ const CFX_Matrix* matrix,
+ int32_t& e);
+ FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& errorCode);
+ CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& errorCode);
+ FX_BOOL SetCharEncoding(BC_CHAR_ENCODING encoding);
+ FX_BOOL SetModuleHeight(int32_t moduleHeight);
+ FX_BOOL SetModuleWidth(int32_t moduleWidth);
+ FX_BOOL SetHeight(int32_t height);
+ FX_BOOL SetWidth(int32_t width);
+ FX_BOOL CheckContentValidity(const CFX_WideStringC& contents);
+ FX_BOOL SetPrintChecksum(FX_BOOL checksum);
+ FX_BOOL SetDataLength(int32_t length);
+ FX_BOOL SetCalChecksum(int32_t state);
+ FX_BOOL SetFont(CFX_Font* pFont);
+ FX_BOOL SetFontSize(FX_FLOAT size);
+ FX_BOOL SetFontStyle(int32_t style);
+ FX_BOOL SetFontColor(FX_ARGB color);
+ FX_BOOL SetTextLocation(BC_TEXT_LOC location);
+ FX_BOOL SetWideNarrowRatio(int32_t ratio);
+ FX_BOOL SetStartChar(FX_CHAR start);
+ FX_BOOL SetEndChar(FX_CHAR end);
+ FX_BOOL SetVersion(int32_t version);
+ FX_BOOL SetErrorCorrectionLevel(int32_t level);
+ FX_BOOL SetTruncated(FX_BOOL truncated);
protected:
CBC_CodeBase* m_pBCEngine;
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_barcode.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_barcode.h
index 0dbdcb03c1b..13652009ebc 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_barcode.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_barcode.h
@@ -13,24 +13,23 @@
class CFWL_WidgetImpProperties;
#define FWL_CLASS_Barcode L"FWL_BARCODE"
-#define FWL_CLASSHASH_Barcode 366886968
-#define FWL_BCDATTRIBUTE_CHARENCODING (1L << 0)
-#define FWL_BCDATTRIBUTE_MODULEHEIGHT (1L << 1)
-#define FWL_BCDATTRIBUTE_MODULEWIDTH (1L << 2)
-#define FWL_BCDATTRIBUTE_DATALENGTH (1L << 3)
-#define FWL_BCDATTRIBUTE_CALCHECKSUM (1L << 4)
-#define FWL_BCDATTRIBUTE_PRINTCHECKSUM (1L << 5)
-#define FWL_BCDATTRIBUTE_TEXTLOCATION (1L << 6)
-#define FWL_BCDATTRIBUTE_WIDENARROWRATIO (1L << 7)
-#define FWL_BCDATTRIBUTE_STARTCHAR (1L << 8)
-#define FWL_BCDATTRIBUTE_ENDCHAR (1L << 9)
-#define FWL_BCDATTRIBUTE_VERSION (1L << 10)
-#define FWL_BCDATTRIBUTE_ECLEVEL (1L << 11)
-#define FWL_BCDATTRIBUTE_TRUNCATED (1L << 12)
-#define FWL_PART_BCD_Border 1
-#define FWL_PART_BCD_Edge 2
-#define FWL_PART_BCD_Background 3
-#define FWL_BCUPDATECMD_Data FWL_WGTUPDATECMD_User
+
+enum FWL_BCDAttribute {
+ FWL_BCDATTRIBUTE_NONE = 0,
+ FWL_BCDATTRIBUTE_CHARENCODING = 1 << 0,
+ FWL_BCDATTRIBUTE_MODULEHEIGHT = 1 << 1,
+ FWL_BCDATTRIBUTE_MODULEWIDTH = 1 << 2,
+ FWL_BCDATTRIBUTE_DATALENGTH = 1 << 3,
+ FWL_BCDATTRIBUTE_CALCHECKSUM = 1 << 4,
+ FWL_BCDATTRIBUTE_PRINTCHECKSUM = 1 << 5,
+ FWL_BCDATTRIBUTE_TEXTLOCATION = 1 << 6,
+ FWL_BCDATTRIBUTE_WIDENARROWRATIO = 1 << 7,
+ FWL_BCDATTRIBUTE_STARTCHAR = 1 << 8,
+ FWL_BCDATTRIBUTE_ENDCHAR = 1 << 9,
+ FWL_BCDATTRIBUTE_VERSION = 1 << 10,
+ FWL_BCDATTRIBUTE_ECLEVEL = 1 << 11,
+ FWL_BCDATTRIBUTE_TRUNCATED = 1 << 12
+};
class IFWL_BarcodeDP : public IFWL_EditDP {
public:
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_caret.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_caret.h
index 229bf121984..8648ca0a4bc 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_caret.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_caret.h
@@ -11,20 +11,17 @@
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#define FWL_CLASS_Caret L"FWL_CARET"
-#define FWL_CLASSHASH_Caret 671181879
#define FWL_STATE_CAT_HightLight 1
-#define FWL_PART_CAT_Background 1
-#define FWL_PARTSTATE_CAT_HightLight 1
class IFWL_Caret : public IFWL_Widget {
public:
static IFWL_Caret* Create(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- FWL_ERR ShowCaret(FX_BOOL bFlag = TRUE);
- FWL_ERR GetFrequency(uint32_t& elapse);
- FWL_ERR SetFrequency(uint32_t elapse);
- FWL_ERR SetColor(CFX_Color crFill);
+ void ShowCaret(FX_BOOL bFlag = TRUE);
+ FWL_Error GetFrequency(uint32_t& elapse);
+ FWL_Error SetFrequency(uint32_t elapse);
+ FWL_Error SetColor(CFX_Color crFill);
protected:
IFWL_Caret();
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_checkbox.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_checkbox.h
index 3b634553d04..26b82443fa0 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_checkbox.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_checkbox.h
@@ -13,7 +13,6 @@
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#define FWL_CLASS_CheckBox L"FWL_CHECKBOX"
-#define FWL_CLASSHASH_CheckBox 4107183823
#define FWL_STYLEEXT_CKB_Left (0L << 0)
#define FWL_STYLEEXT_CKB_Center (1L << 0)
#define FWL_STYLEEXT_CKB_Right (2L << 0)
@@ -44,26 +43,9 @@
#define FWL_STATE_CKB_Checked (1 << (FWL_WGTSTATE_MAX + 2))
#define FWL_STATE_CKB_Neutral (2 << (FWL_WGTSTATE_MAX + 2))
#define FWL_STATE_CKB_CheckMask (3L << (FWL_WGTSTATE_MAX + 2))
-#define FWL_PART_CKB_Border 1
-#define FWL_PART_CKB_Edge 2
-#define FWL_PART_CKB_Background 3
-#define FWL_PART_CKB_CheckBox 4
-#define FWL_PART_CKB_Caption 5
-#define FWL_PARTSTATE_CKB_Normal (0L << 0)
-#define FWL_PARTSTATE_CKB_Pressed (1L << 0)
-#define FWL_PARTSTATE_CKB_Hovered (2L << 0)
-#define FWL_PARTSTATE_CKB_Disabled (3L << 0)
-#define FWL_PARTSTATE_CKB_UnChecked (0L << 2)
-#define FWL_PARTSTATE_CKB_Checked (1L << 2)
-#define FWL_PARTSTATE_CKB_Neutral (2L << 2)
-#define FWL_PARTSTATE_CKB_Focused (1L << 4)
-#define FWL_PARTSTATE_CKB_Mask1 (3L << 0)
-#define FWL_PARTSTATE_CKB_Mask2 (3L << 2)
-#define FWL_EVT_CKB_CheckStateChanged L"FWL_EVENT_CKB_CheckStateChanged"
-#define FWL_EVTHASH_CKB_CheckStateChanged 2503252963
BEGIN_FWL_EVENT_DEF(CFWL_EvtCkbCheckStateChanged,
- FWL_EVTHASH_CKB_CheckStateChanged)
+ CFWL_EventType::CheckStateChanged)
END_FWL_EVENT_DEF
class IFWL_CheckBoxDP : public IFWL_DataProvider {
@@ -76,7 +58,7 @@ class IFWL_CheckBox : public IFWL_Widget {
static IFWL_CheckBox* Create(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
int32_t GetCheckState();
- FWL_ERR SetCheckState(int32_t iCheck);
+ FWL_Error SetCheckState(int32_t iCheck);
protected:
IFWL_CheckBox();
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_combobox.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_combobox.h
index 98a6750278a..916e60b5bbe 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_combobox.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_combobox.h
@@ -14,7 +14,6 @@ class CFWL_WidgetImpProperties;
class IFWL_ComboBox;
#define FWL_CLASS_ComboBox L"FWL_COMBOBOX"
-#define FWL_CLASSHASH_ComboBox 602353697
#define FWL_STYLEEXT_CMB_DropList (0L << 0)
#define FWL_STYLEEXT_CMB_DropDown (1L << 0)
#define FWL_STYLEEXT_CMB_Sort (1L << 1)
@@ -38,64 +37,32 @@ class IFWL_ComboBox;
#define FWL_STYLEEXT_CMB_ListItemIconText (1L << 12)
#define FWL_STYLEEXT_CMB_ListItemAlignMask (3L << 12)
#define FWL_STYLEEXT_CMB_ReadOnly (1L << 13)
-#define FWL_PART_CMB_Border 1
-#define FWL_PART_CMB_Edge 2
-#define FWL_PART_CMB_Background 3
-#define FWL_PART_CMB_DropDownButton 4
-#define FWL_PART_CMB_Caption 5
-#define FWL_PART_CMB_StretcgHandler 6
-#define FWL_PARTSTATE_CMB_Normal (0L << 0)
-#define FWL_PARTSTATE_CMB_Hovered (1L << 0)
-#define FWL_PARTSTATE_CMB_Pressed (2L << 0)
-#define FWL_PARTSTATE_CMB_Disabled (3L << 0)
-#define FWL_PARTSTATE_CMB_Selected (1L << 2)
-#define FWL_WGTCAPACITY_CMB_ComboFormHandler (FWL_WGTCAPACITY_MAX + 7)
-#define FWL_EVT_CMB_DropDown L"FWL_EVENT_CMB_PreDropDown"
-#define FWL_EVT_CMB_PostDropDown L"FWL_EVENT_CMB_PostDropDown"
-#define FWL_EVT_CMB_CloseUp L"FWL_EVENT_CMB_CloseUp"
-#define FWL_EVT_CMB_EditChanged L"FWL_EVENT_CMB_EditChanged"
-#define FWL_EVT_CMB_SelChanged L"FWL_EVENT_CMB_SelChanged"
-#define FWL_EVT_CMB_HoverChanged L"FWL_EVENT_CMB_HoverChanged"
-#define FWL_EVT_CMB_DrawItem L"FWL_EVENT_CMB_DrawItem"
-#define FWL_EVTHASH_CMB_PreDropDown 1357646798
-#define FWL_EVTHASH_CMB_PostDropDown 3677010285
-#define FWL_EVTHASH_CMB_CloseUp 2871271190
-#define FWL_EVTHASH_CMB_EditChanged 1527034762
-#define FWL_EVTHASH_CMB_SelChanged 2923227784
-#define FWL_EVTHASH_CMB_HoverChanged 944325448
-#define FWL_EVTHASH_CMB_DrawItem 917354551
-
-enum FWL_CMB_TEXTCHANGED {
- FWL_CMB_TEXTCHANGED_Insert = 0,
- FWL_CMB_TEXTCHANGED_Delete,
- FWL_CMB_TEXTCHANGED_Replace,
-};
-BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPreDropDown, FWL_EVTHASH_CMB_PreDropDown)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPreDropDown, CFWL_EventType::PreDropDown)
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPostDropDown, FWL_EVTHASH_CMB_PostDropDown)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPostDropDown, CFWL_EventType::PostDropDown)
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbCloseUp, FWL_EVTHASH_CMB_CloseUp)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbCloseUp, CFWL_EventType::CloseUp)
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbEditChanged, FWL_EVTHASH_CMB_EditChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbEditChanged, CFWL_EventType::EditChanged)
int32_t nChangeType;
CFX_WideString wsInsert;
CFX_WideString wsDelete;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbSelChanged, FWL_EVTHASH_CMB_SelChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbSelChanged, CFWL_EventType::SelectChanged)
CFX_Int32Array iArraySels;
FX_BOOL bLButtonUp;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbHoverChanged, FWL_EVTHASH_CMB_HoverChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbHoverChanged, CFWL_EventType::HoverChanged)
int32_t m_iCurHover;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbDrawItem, FWL_EVTHASH_CMB_DrawItem)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbDrawItem, CFWL_EventType::DrawItem)
CFX_Graphics* m_pGraphics;
CFX_Matrix m_matrix;
int32_t m_index;
@@ -112,22 +79,22 @@ class IFWL_ComboBox : public IFWL_Widget {
static IFWL_ComboBox* Create(const CFWL_WidgetImpProperties& properties);
int32_t GetCurSel();
- FWL_ERR SetCurSel(int32_t iSel);
- FWL_ERR SetEditText(const CFX_WideString& wsText);
+ FWL_Error SetCurSel(int32_t iSel);
+ FWL_Error SetEditText(const CFX_WideString& wsText);
int32_t GetEditTextLength() const;
- FWL_ERR GetEditText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
- FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1);
+ FWL_Error GetEditText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ FWL_Error SetEditSelRange(int32_t nStart, int32_t nCount = -1);
int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
int32_t GetEditLimit();
- FWL_ERR SetEditLimit(int32_t nLimit);
- FWL_ERR EditDoClipboard(int32_t iCmd);
+ FWL_Error SetEditLimit(int32_t nLimit);
+ FWL_Error EditDoClipboard(int32_t iCmd);
FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
IFWL_ListBox* GetListBoxt();
FX_BOOL AfterFocusShowDropList();
- FX_ERR OpenDropDownList(FX_BOOL bActivate);
+ FWL_Error OpenDropDownList(FX_BOOL bActivate);
FX_BOOL EditCanUndo();
FX_BOOL EditCanRedo();
FX_BOOL EditUndo();
@@ -141,9 +108,9 @@ class IFWL_ComboBox : public IFWL_Widget {
FX_BOOL EditSelectAll();
FX_BOOL EditDelete();
FX_BOOL EditDeSelect();
- FWL_ERR GetBBox(CFX_RectF& rect);
- FWL_ERR EditModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
+ FWL_Error GetBBox(CFX_RectF& rect);
+ FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
protected:
IFWL_ComboBox();
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_datetimepicker.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_datetimepicker.h
index f2a91aba647..7aba68b5a04 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_datetimepicker.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_datetimepicker.h
@@ -13,7 +13,6 @@
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#define FWL_CLASS_DateTimePicker L"FWL_DATETIMEPICKER"
-#define FWL_CLASSHASH_DateTimePicker 3851176257
#define FWL_STYLEEXT_DTP_AllowEdit (1L << 0)
#define FWL_STYLEEXT_DTP_LongDateFormat (0L << 1)
#define FWL_STYLEEXT_DTP_ShortDateFormat (1L << 1)
@@ -30,40 +29,22 @@
#define FWL_STYLEEXT_DTP_EditHAlignMask (3L << 4)
#define FWL_STYLEEXT_DTP_EditVAlignMask (3L << 6)
#define FWL_STYLEEXT_DTP_EditHAlignModeMask (3L << 8)
-#define FWL_PART_DTP_Border 1
-#define FWL_PART_DTP_Edge 2
-#define FWL_PART_DTP_Background 3
-#define FWL_PART_DTP_DropDownButton 4
-#define FWL_PARTSTATE_DTP_Normal (0L << 0)
-#define FWL_PARTSTATE_DTP_Hovered (1L << 0)
-#define FWL_PARTSTATE_DTP_Pressed (2L << 0)
-#define FWL_PARTSTATE_DTP_Disabled (3L << 0)
-#define FWL_EVT_DTP_DropDown L"FWL_EVENT_DTP_DropDown"
-#define FWL_EVTHASH_DTP_DropDown 264728733
-#define FWL_EVT_DTP_CloseUp L"FWL_EVENT_DTP_CloseUp"
-#define FWL_EVTHASH_DTP_CloseUp 4280973803
-#define FWL_EVT_DTP_EditChanged L"FWL_EVENT_DTP_EditChanged"
-#define FWL_EVTHASH_DTP_EditChanged 4009610944
-#define FWL_EVT_DTP_HoverChanged L"FWL_EVENT_DTP_HoverChanged"
-#define FWL_EVTHASH_DTP_HoverChanged 686674750
-#define FWL_EVT_DTP_SelectChanged L"FWL_EVENT_DTP_SelectChanged"
-#define FWL_EVTHASH_DTP_SelectChanged 1589616858
-BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpDropDown, FWL_EVTHASH_DTP_DropDown)
+BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpDropDown, CFWL_EventType::DropDown)
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpCloseUp, FWL_EVTHASH_DTP_CloseUp)
+BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpCloseUp, CFWL_EventType::CloseUp)
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpEditChanged, FWL_EVTHASH_DTP_EditChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpEditChanged, CFWL_EventType::EditChanged)
CFX_WideString m_wsText;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpHoverChanged, FWL_EVTHASH_DTP_HoverChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpHoverChanged, CFWL_EventType::HoverChanged)
int32_t hoverday;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpSelectChanged, FWL_EVTHASH_DTP_SelectChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpSelectChanged, CFWL_EventType::SelectChanged)
int32_t iYear;
int32_t iMonth;
int32_t iDay;
@@ -71,10 +52,10 @@ END_FWL_EVENT_DEF
class IFWL_DateTimePickerDP : public IFWL_DataProvider {
public:
- virtual FWL_ERR GetToday(IFWL_Widget* pWidget,
- int32_t& iYear,
- int32_t& iMonth,
- int32_t& iDay) = 0;
+ virtual FWL_Error GetToday(IFWL_Widget* pWidget,
+ int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) = 0;
};
class IFWL_DateTimePicker : public IFWL_Widget {
@@ -82,12 +63,12 @@ class IFWL_DateTimePicker : public IFWL_Widget {
static IFWL_DateTimePicker* Create(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- FWL_ERR GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
- FWL_ERR SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
- FWL_ERR SetEditText(const CFX_WideString& wsText);
- FWL_ERR GetEditText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
+ FWL_Error GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
+ FWL_Error SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
+ FWL_Error SetEditText(const CFX_WideString& wsText);
+ FWL_Error GetEditText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
int32_t CountSelRanges();
int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
FX_BOOL CanUndo();
@@ -103,10 +84,10 @@ class IFWL_DateTimePicker : public IFWL_Widget {
FX_BOOL SelectAll();
FX_BOOL Delete();
FX_BOOL DeSelect();
- FWL_ERR GetBBox(CFX_RectF& rect);
- FWL_ERR SetEditLimit(int32_t nLimit);
- FWL_ERR ModifyEditStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
+ FWL_Error GetBBox(CFX_RectF& rect);
+ FWL_Error SetEditLimit(int32_t nLimit);
+ FWL_Error ModifyEditStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
protected:
IFWL_DateTimePicker();
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_edit.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_edit.h
index b27f8b48983..5650bce4dc2 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_edit.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_edit.h
@@ -9,11 +9,11 @@
#include <vector>
+#include "xfa/fwl/core/cfwl_event.h"
#include "xfa/fwl/core/ifwl_dataprovider.h"
#include "xfa/fwl/lightwidget/cfwl_widget.h"
#define FWL_CLASS_Edit L"FWL_EDIT"
-#define FWL_CLASSHASH_Edit 2893987822
#define FWL_STYLEEXT_EDT_ReadOnly (1L << 0)
#define FWL_STYLEEXT_EDT_MultiLine (1L << 1)
#define FWL_STYLEEXT_EDT_WantReturn (1L << 2)
@@ -47,32 +47,6 @@
#define FWL_STYLEEXT_EDT_ShowScrollbarFocus (1L << 25)
#define FWL_STYLEEXT_EDT_OuterScrollbar (1L << 26)
#define FWL_STYLEEXT_EDT_LastLineHeight (1L << 27)
-#define FWL_STATE_EDT_Editing (1 << FWL_WGTSTATE_MAX)
-#define FWL_PART_EDT_Border 1
-#define FWL_PART_EDT_Edge 2
-#define FWL_PART_EDT_Background 3
-#define FWL_PART_EDT_CombTextLine 4
-#define FWL_PARTDATA_EDT_Background 0
-#define FWL_PARTDATA_EDT_StaticBackground 1
-#define FWL_PARTSTATE_EDT_Normal (0L << 0)
-#define FWL_PARTSTATE_EDT_ReadOnly (1L << 0)
-#define FWL_PARTSTATE_EDT_Disable (2L << 0)
-#define FWL_EVT_EDT_TextChanged L"FWL_EVENT_EDT_TextChanged"
-#define FWL_EVTHASH_EDT_TextChanged 1064022132
-#define FWL_EVT_EDT_PreSelfAdaption L"FWL_EVENT_PreSelfAdaption"
-#define FWL_EVTHASH_EDT_PreSelfAdaption 1001979178
-#define FWL_EVT_EDT_Validate L"FWL_EVTHASH_EDT_Validate"
-#define FWL_EVTHASH_EDT_Validate 3373308608
-#define FWL_EVT_EDT_CheckWord L"FWL_EVTHASH_EDT_CheckWord"
-#define FWL_EVTHASH_EDT_CheckWord 2897181520
-#define FWL_EVT_EDT_GetSuggestWords L"FWL_EVTHASH_EDT_GetSuggestWords"
-#define FWL_EVTHASH_EDT_GetSuggestWords 315782791
-#define FWL_EVT_EDT_TextFull L"FWL_EVTHASH_EDT_TextFull"
-#define FWL_EVTHASH_EDT_TextFull 2158580174
-#define FWL_EDT_FIND_FLAGS_Prev (0L << 0)
-#define FWL_EDT_FIND_FLAGS_Next (1L << 0)
-#define FWL_EDT_FIND_FLAGS_WholeWord (1L << 1)
-#define FWL_EDT_FIND_FLAGS_NoCase (1L << 2)
typedef struct FWL_HEDTFIND_ { void* pData; } * FWL_HEDTFIND;
@@ -82,34 +56,35 @@ enum FWL_EDT_TEXTCHANGED {
FWL_EDT_TEXTCHANGED_Replace,
};
-BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextChanged, FWL_EVTHASH_EDT_TextChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextChanged, CFWL_EventType::TextChanged)
int32_t nChangeType;
CFX_WideString wsInsert;
CFX_WideString wsDelete;
CFX_WideString wsPrevText;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextFull, FWL_EVTHASH_EDT_TextFull)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextFull, CFWL_EventType::TextFull)
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, FWL_EVTHASH_EDT_PreSelfAdaption)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, CFWL_EventType::PreSelfAdaption)
FX_BOOL bHSelfAdaption;
FX_BOOL bVSelfAdaption;
CFX_RectF rtAfterChange;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtValidate, FWL_EVTHASH_EDT_Validate)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtValidate, CFWL_EventType::Validate)
IFWL_Widget* pDstWidget;
CFX_WideString wsInsert;
FX_BOOL bValidate;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, FWL_EVTHASH_EDT_CheckWord)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, CFWL_EventType::CheckWord)
CFX_ByteString bsWord;
FX_BOOL bCheckWord;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, FWL_EVTHASH_EDT_GetSuggestWords)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords,
+ CFWL_EventType::GetSuggestedWords)
FX_BOOL bSuggestWords;
CFX_ByteString bsWord;
std::vector<CFX_ByteString> bsArraySuggestWords;
@@ -126,30 +101,29 @@ class IFWL_Edit : public IFWL_Widget {
static IFWL_Edit* CreateComboEdit(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- FWL_ERR SetText(const CFX_WideString& wsText);
+ FWL_Error SetText(const CFX_WideString& wsText);
int32_t GetTextLength() const;
- FWL_ERR GetText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
- FWL_ERR ClearText();
+ FWL_Error GetText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ FWL_Error ClearText();
int32_t GetCaretPos() const;
int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE);
- FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1);
+ FWL_Error AddSelRange(int32_t nStart, int32_t nCount = -1);
int32_t CountSelRanges();
int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
- FWL_ERR ClearSelections();
+ FWL_Error ClearSelections();
int32_t GetLimit();
- FWL_ERR SetLimit(int32_t nLimit);
- FWL_ERR SetAliasChar(FX_WCHAR wAlias);
- FWL_ERR SetFormatString(const CFX_WideString& wsFormat);
- FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
- FWL_ERR DeleteSelections();
- FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1);
- FWL_ERR ReplaceSelections(const CFX_WideStringC& wsReplace);
- FWL_ERR Replace(int32_t nStart,
- int32_t nLen,
- const CFX_WideStringC& wsReplace);
- FWL_ERR DoClipboard(int32_t iCmd);
+ FWL_Error SetLimit(int32_t nLimit);
+ FWL_Error SetAliasChar(FX_WCHAR wAlias);
+ FWL_Error SetFormatString(const CFX_WideString& wsFormat);
+ FWL_Error Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
+ FWL_Error DeleteSelections();
+ FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1);
+ FWL_Error Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace);
+ FWL_Error DoClipboard(int32_t iCmd);
FX_BOOL Copy(CFX_WideString& wsCopy);
FX_BOOL Cut(CFX_WideString& wsCut);
FX_BOOL Paste(const CFX_WideString& wsPaste);
@@ -160,11 +134,11 @@ class IFWL_Edit : public IFWL_Widget {
FX_BOOL Redo();
FX_BOOL CanUndo();
FX_BOOL CanRedo();
- FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
- FWL_ERR SetOuter(IFWL_Widget* pOuter);
- FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax);
- FWL_ERR SetBackColor(uint32_t dwColor);
- FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
+ FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
+ FWL_Error SetOuter(IFWL_Widget* pOuter);
+ FWL_Error SetNumberRange(int32_t iMin, int32_t iMax);
+ FWL_Error SetBackColor(uint32_t dwColor);
+ FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
void SetScrollOffset(FX_FLOAT fScrollOffset);
FX_BOOL GetSuggestWords(CFX_PointF pointf,
std::vector<CFX_ByteString>& sSuggest);
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_listbox.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_listbox.h
index 1225eafcbab..9782cbbc295 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_listbox.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_listbox.h
@@ -13,9 +13,7 @@
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#define FWL_CLASS_ListBox L"FWL_LISTBOX"
-#define FWL_CLASSHASH_ListBox 1777358317
#define FWL_STYLEEXT_LTB_MultiSelection (1L << 0)
-#define FWL_STYLEEXT_LTB_Sort (1L << 1)
#define FWL_STYLEEXT_LTB_ShowScrollBarAlaways (1L << 2)
#define FWL_STYLEEXT_LTB_MultiColumn (1L << 3)
#define FWL_STYLEEXT_LTB_LeftAlign (0L << 4)
@@ -30,42 +28,16 @@
#define FWL_ITEMSTATE_LTB_Selected (1L << 0)
#define FWL_ITEMSTATE_LTB_Focused (1L << 1)
#define FWL_ITEMSTATE_LTB_Checked (1L << 2)
-#define FWL_PART_LTB_Border 1
-#define FWL_PART_LTB_Edge 2
-#define FWL_PART_LTB_Background 3
-#define FWL_PART_LTB_ListItem 4
-#define FWL_PART_LTB_Check 5
-#define FWL_PART_LTB_Icon 6
-#define FWL_PARTSTATE_LTB_Normal (0L << 0)
-#define FWL_PARTSTATE_LTB_Selected (1L << 0)
-#define FWL_PARTSTATE_LTB_Disabled (2L << 0)
-#define FWL_PARTSTATE_LTB_Focused (1L << 2)
-#define FWL_PARTSTATE_LTB_UnChecked (0L << 3)
-#define FWL_PARTSTATE_LTB_Checked (1L << 3)
-#define FWL_PARTSTATE_LTB_Mask (3L << 0)
-#define FWL_WGTHITTEST_LTB_Item FWL_WGTHITTEST_MAX + 1
-#define FWL_WGTHITTEST_LTB_HScrollBar FWL_WGTHITTEST_MAX + 2
-#define FWL_WGTHITTEST_LTB_VScrollBar FWL_WGTHITTEST_MAX + 3
-#define FWL_EVT_LTB_SelChanged L"FWL_EVENT_LTB_SelChanged"
-#define FWL_EVT_LTB_DrawItem L"FWL_EVENT_LTB_DrawItem"
-#define FWL_EVTHASH_LTB_SelChanged 1701781688
-#define FWL_EVTHASH_LTB_DrawItem 1050853991
typedef struct FWL_HLISTITEM_ { void* pData; } * FWL_HLISTITEM;
class CFX_DIBitmap;
-class IFWL_ListBoxDP;
-struct FWL_ListBoxItemData {
- IFWL_ListBoxDP* pDataProvider;
- int32_t iIndex;
-};
-
-BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbSelChanged, FWL_EVTHASH_LTB_SelChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbSelChanged, CFWL_EventType::SelectChanged)
CFX_Int32Array iarraySels;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbDrawItem, FWL_EVTHASH_LTB_DrawItem)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbDrawItem, CFWL_EventType::DrawItem)
CFX_Graphics* m_pGraphics;
CFX_Matrix m_matrix;
int32_t m_index;
@@ -81,36 +53,36 @@ class IFWL_ListBoxDP : public IFWL_DataProvider {
FWL_HLISTITEM hItem,
int32_t nIndex) = 0;
virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) = 0;
- virtual FWL_ERR GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_WideString& wsText) = 0;
- virtual FWL_ERR GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtItem) = 0;
+ virtual FWL_Error GetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) = 0;
+ virtual FWL_Error GetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtItem) = 0;
virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) = 0;
- virtual FWL_ERR SetItemStyles(IFWL_Widget* pWidget,
+ virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwStyle) = 0;
+ virtual FWL_Error SetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const FX_WCHAR* pszText) = 0;
+ virtual FWL_Error SetItemRect(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem,
- uint32_t dwStyle) = 0;
- virtual FWL_ERR SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const FX_WCHAR* pszText) = 0;
- virtual FWL_ERR SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const CFX_RectF& rtItem) = 0;
+ const CFX_RectF& rtItem) = 0;
virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) = 0;
virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem) = 0;
- virtual FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtCheck) = 0;
- virtual FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const CFX_RectF& rtCheck) = 0;
+ virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtCheck) = 0;
+ virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtCheck) = 0;
virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem) = 0;
- virtual FWL_ERR SetItemCheckState(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- uint32_t dwCheckState) = 0;
+ virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwCheckState) = 0;
};
class IFWL_ListBoxCompare {
@@ -130,10 +102,9 @@ class IFWL_ListBox : public IFWL_Widget {
int32_t CountSelItems();
FWL_HLISTITEM GetSelItem(int32_t nIndexSel);
int32_t GetSelIndex(int32_t nIndex);
- FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
- FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText);
- FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
- FWL_ERR* Sort(IFWL_ListBoxCompare* pCom);
+ FWL_Error SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
+ FWL_Error GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText);
+ FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
protected:
IFWL_ListBox();
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_monthcalendar.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_monthcalendar.h
index 8f9ab9ae3e1..027d25b4261 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_monthcalendar.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_monthcalendar.h
@@ -13,100 +13,21 @@
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#define FWL_CLASS_MonthCalendar L"FWL_MONTHCALENDAR"
-#define FWL_CLASSHASH_MonthCalendar 2733931374
#define FWL_STYLEEXT_MCD_MultiSelect (1L << 0)
#define FWL_STYLEEXT_MCD_NoToday (1L << 1)
#define FWL_STYLEEXT_MCD_NoTodayCircle (1L << 2)
#define FWL_STYLEEXT_MCD_WeekNumbers (1L << 3)
-#define FWL_WGTCAPACITY_MC_HEADER_WIDTH 12
-#define FWL_WGTCAPACITY_MC_HEADER_Height 13
-#define FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH 14
-#define FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT 15
-#define FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN 16
-#define FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN 17
-#define FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT 18
-#define FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT 19
-#define FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN 20
-#define FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN 21
-#define FWL_WGTCAPACITY_MC_HSEP_WIDTH 22
-#define FWL_WGTCAPACITY_MC_HSEP_HEIGHT 23
-#define FWL_WGTCAPACITY_MC_VSEP_WIDTH 24
-#define FWL_WGTCAPACITY_MC_VSEP_HEIGHT 25
-#define FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH 26
-#define FWL_WGTCAPACITY_MC_SEP_DOFFSET 40
-#define FWL_WGTCAPACITY_MC_SEP_X 27
-#define FWL_WGTCAPACITY_MC_SEP_Y 28
-#define FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT 29
-#define FWL_WGTCAPACITY_MC_WEEK_WIDTH 30
-#define FWL_WGTCAPACITY_MC_WEEK_HEIGHT 31
-#define FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH 32
-#define FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT 33
-#define FWL_WGTCAPACITY_MC_TODAY_WIDHT 34
-#define FWL_WGTCAPACITY_MC_TODAY_HEIGHT 35
-#define FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT 36
-#define FWL_WGTCAPACITY_MC_WIDTH 37
-#define FWL_WGTCAPACITY_MC_HEIGHT 38
#define FWL_ITEMSTATE_MCD_Nomal (0L << 0)
#define FWL_ITEMSTATE_MCD_Flag (1L << 0)
#define FWL_ITEMSTATE_MCD_Selected (1L << 1)
#define FWL_ITEMSTATE_MCD_Focused (1L << 2)
-#define FWL_PART_MCD_Border 1
-#define FWL_PART_MCD_Edge 2
-#define FWL_PART_MCD_Background 3
-#define FWL_PART_MCD_LBtn 4
-#define FWL_PART_MCD_RBtn 5
-#define FWL_PART_MCD_HSeparator 6
-#define FWL_PART_MCD_VSeparator 7
-#define FWL_PART_MCD_TodayCircle 8
-#define FWL_PART_MCD_DateInCircle 9
-#define FWL_PART_MCD_DateInBK 10
-#define FWL_PART_MCD_Caption 9
-#define FWL_PART_MCD_DatesIn 10
-#define FWL_PART_MCD_DatesOut 11
-#define FWL_PART_MCD_Week 12
-#define FWL_PART_MCD_Today 13
-#define FWL_PART_MCD_Header 14
-#define FWL_PART_MCD_WeekNum 15
-#define FWL_PART_MCD_WeekNumSep 16
-#define FWL_PARTSTATE_MCD_Normal (0L << 0)
-#define FWL_PARTSTATE_MCD_Pressed (1L << 0)
-#define FWL_PARTSTATE_MCD_Hovered (2L << 0)
-#define FWL_PARTSTATE_MCD_Selected (3L << 0)
-#define FWL_PARTSTATE_MCD_LSelected (1L << 2)
-#define FWL_PARTSTATE_MCD_RSelected (2L << 2)
-#define FWL_PARTSTATE_MCD_Flagged (1L << 3)
-#define FWL_PARTSTATE_MCD_Focused (1L << 4)
-#define FWL_MCCAPACITY_Sun FWL_WGTCAPACITY_MAX + 5
-#define FWL_MCCAPACITY_Mon FWL_WGTCAPACITY_MAX + 6
-#define FWL_MCCAPACITY_Tue FWL_WGTCAPACITY_MAX + 7
-#define FWL_MCCAPACITY_Wed FWL_WGTCAPACITY_MAX + 8
-#define FWL_MCCAPACITY_Thu FWL_WGTCAPACITY_MAX + 9
-#define FWL_MCCAPACITY_Fri FWL_WGTCAPACITY_MAX + 10
-#define FWL_MCCAPACITY_Sat FWL_WGTCAPACITY_MAX + 11
-#define FWL_MCCAPACITY_January FWL_WGTCAPACITY_MAX + 12
-#define FWL_MCCAPACITY_February FWL_WGTCAPACITY_MAX + 13
-#define FWL_MCCAPACITY_March FWL_WGTCAPACITY_MAX + 14
-#define FWL_MCCAPACITY_April FWL_WGTCAPACITY_MAX + 15
-#define FWL_MCCAPACITY_May FWL_WGTCAPACITY_MAX + 16
-#define FWL_MCCAPACITY_June FWL_WGTCAPACITY_MAX + 17
-#define FWL_MCCAPACITY_July FWL_WGTCAPACITY_MAX + 18
-#define FWL_MCCAPACITY_August FWL_WGTCAPACITY_MAX + 19
-#define FWL_MCCAPACITY_September FWL_WGTCAPACITY_MAX + 20
-#define FWL_MCCAPACITY_October FWL_WGTCAPACITY_MAX + 21
-#define FWL_MCCAPACITY_November FWL_WGTCAPACITY_MAX + 22
-#define FWL_MCCAPACITY_December FWL_WGTCAPACITY_MAX + 23
-#define FWL_MCCAPACITY_Today FWL_WGTCAPACITY_MAX + 24
-#define FWL_EVENT_MCD_DATESELECTED L"FWL_EVENT_MCD_DateSelected"
-#define FWL_EVT_MCD_DateChanged L"FWL_EVENT_MCD_DateChanged"
-#define FWL_NOTEHASH_MCD_DATASELECTED 1085596932
-#define FWL_EVTHASH_MCD_DateChanged 54212227
-BEGIN_FWL_EVENT_DEF(CFWL_Event_McdDateSelected, FWL_NOTEHASH_MCD_DATASELECTED)
+BEGIN_FWL_EVENT_DEF(CFWL_Event_McdDateSelected, CFWL_EventType::DataSelected)
int32_t m_iStartDay;
int32_t m_iEndDay;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EventMcdDateChanged, FWL_EVTHASH_MCD_DateChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_EventMcdDateChanged, CFWL_EventType::DateChanged)
int32_t m_iOldYear;
int32_t m_iOldMonth;
int32_t m_iStartDay;
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_picturebox.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_picturebox.h
index acc34f78d40..8ff4981e11c 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_picturebox.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_picturebox.h
@@ -14,7 +14,6 @@
#include "xfa/fwl/core/fwl_error.h"
#define FWL_CLASS_PictureBox L"FWL_PICTUREBOX"
-#define FWL_CLASSHASH_PictureBox 2974721741
#define FWL_STYLEEXT_PTB_Left 0L << 0
#define FWL_STYLEEXT_PTB_Center 1L << 0
#define FWL_STYLEEXT_PTB_Right 2L << 0
@@ -29,11 +28,6 @@
#define FWL_STYLEEXT_PTB_HAlignMask 3L << 0
#define FWL_STYLEEXT_PTB_VAlignMask 3L << 2
#define FWL_STYLEEXT_PTB_StretchAlignMask 7L << 4
-#define FWL_PART_PTB_Border 1
-#define FWL_PART_PTB_Edge 2
-#define FWL_PART_PTB_Image 3
-#define FWL_PARTSTATE_PTB_Normal (0L << 0)
-#define FWL_PARTSTATE_PTB_Disabled (1L << 0)
class CFX_DIBitmap;
@@ -44,7 +38,7 @@ class IFWL_PictureBoxDP : public IFWL_DataProvider {
virtual CFX_DIBitmap* GetInitialPicture(IFWL_Widget* pWidget) = 0;
virtual int32_t GetOpacity(IFWL_Widget* pWidget) = 0;
virtual int32_t GetFlipMode(IFWL_Widget* pWidget) = 0;
- virtual FWL_ERR GetMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) = 0;
+ virtual FWL_Error GetMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) = 0;
};
class IFWL_PictureBox : public IFWL_Widget {
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_pushbutton.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_pushbutton.h
index 400b0c1b384..aa8392d9db7 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_pushbutton.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_pushbutton.h
@@ -13,7 +13,6 @@
#include "xfa/fwl/core/ifwl_widget.h"
#define FWL_CLASS_PushButton L"FWL_PUSHBUTTON"
-#define FWL_CLASSHASH_PushButton 3521614244
#define FWL_STYLEEXT_PSB_Left (0L << 0)
#define FWL_STYLEEXT_PSB_Center (1L << 0)
#define FWL_STYLEEXT_PSB_Right (2L << 0)
@@ -29,18 +28,6 @@
#define FWL_STATE_PSB_Hovered (1 << FWL_WGTSTATE_MAX)
#define FWL_STATE_PSB_Pressed (1 << (FWL_WGTSTATE_MAX + 1))
#define FWL_STATE_PSB_Default (1 << (FWL_WGTSTATE_MAX + 2))
-#define FWL_WGTCAPACITY_PSB_Margin (FWL_WGTCAPACITY_MAX + 1)
-#define FWL_PART_PSB_Border 1
-#define FWL_PART_PSB_Edge 2
-#define FWL_PART_PSB_Background 3
-#define FWL_PART_PSB_Caption 4
-#define FWL_PARTSTATE_PSB_Normal (0L << 0)
-#define FWL_PARTSTATE_PSB_Pressed (1L << 0)
-#define FWL_PARTSTATE_PSB_Hovered (2L << 0)
-#define FWL_PARTSTATE_PSB_Default (3L << 0)
-#define FWL_PARTSTATE_PSB_Disabled (4L << 0)
-#define FWL_PARTSTATE_PSB_Focused (1L << 3)
-#define FWL_PARTSTATE_PSB_Mask (7L << 0)
class CFX_DIBitmap;
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_scrollbar.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_scrollbar.h
index a5b17eab90b..bc5c722ca92 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_scrollbar.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_scrollbar.h
@@ -15,27 +15,8 @@
#include "xfa/fwl/core/fwl_error.h"
#define FWL_CLASS_ScrollBar L"FWL_SCROLLBAR"
-#define FWL_CLASSHASH_ScrollBar 2826584844
#define FWL_STYLEEXT_SCB_Horz (0L << 0)
#define FWL_STYLEEXT_SCB_Vert (1L << 0)
-#define FWL_PART_SCB_Border 1
-#define FWL_PART_SCB_Edge 2
-#define FWL_PART_SCB_Background 3
-#define FWL_PART_SCB_ForeArrow 4
-#define FWL_PART_SCB_BackArrow 5
-#define FWL_PART_SCB_Thumb 6
-#define FWL_PART_SCB_LowerTrack 7
-#define FWL_PART_SCB_UpperTrack 8
-#define FWL_PARTSTATE_SCB_Normal (0L << 0)
-#define FWL_PARTSTATE_SCB_Hovered (1L << 0)
-#define FWL_PARTSTATE_SCB_Pressed (2L << 0)
-#define FWL_PARTSTATE_SCB_Disabled (3L << 0)
-#define FWL_WGTHITTEST_SCB_ForeArrow FWL_WGTHITTEST_MAX + 1
-#define FWL_WGTHITTEST_SCB_BackArrow FWL_WGTHITTEST_MAX + 2
-#define FWL_WGTHITTEST_SCB_LowerTrack FWL_WGTHITTEST_MAX + 3
-#define FWL_WGTHITTEST_SCB_UpperTrack FWL_WGTHITTEST_MAX + 4
-#define FWL_WGTHITTEST_SCB_Thumb FWL_WGTHITTEST_MAX + 5
-#define FWL_CAPACITY_SCB_Size FWL_WGTCAPACITY_MAX
enum FWL_SCBCODE {
FWL_SCBCODE_None = 1,
@@ -58,16 +39,16 @@ class IFWL_ScrollBar : public IFWL_Widget {
IFWL_Widget* pOuter);
FX_BOOL IsVertical();
- FWL_ERR GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
- FWL_ERR SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
+ FWL_Error GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
+ FWL_Error SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
FX_FLOAT GetPageSize();
- FWL_ERR SetPageSize(FX_FLOAT fPageSize);
+ FWL_Error SetPageSize(FX_FLOAT fPageSize);
FX_FLOAT GetStepSize();
- FWL_ERR SetStepSize(FX_FLOAT fStepSize);
+ FWL_Error SetStepSize(FX_FLOAT fStepSize);
FX_FLOAT GetPos();
- FWL_ERR SetPos(FX_FLOAT fPos);
+ FWL_Error SetPos(FX_FLOAT fPos);
FX_FLOAT GetTrackPos();
- FWL_ERR SetTrackPos(FX_FLOAT fTrackPos);
+ FWL_Error SetTrackPos(FX_FLOAT fTrackPos);
FX_BOOL DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f);
protected:
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_spinbutton.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_spinbutton.h
index f68ab0f2515..0b433d407a4 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_spinbutton.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_spinbutton.h
@@ -10,22 +10,9 @@
#include "xfa/fwl/core/fwl_widgetimp.h"
#define FWL_CLASS_SpinButton L"FWL_SPINBUTTON"
-#define FWL_CLASSHASH_SpinButton 3793043646
#define FWL_STYLEEXE_SPB_Vert (1L << 0)
-#define FWL_PART_SPB_Border 1
-#define FWL_PART_SPB_Edge 2
-#define FWL_PART_SPB_UpButton 3
-#define FWL_PART_SPB_DownButton 4
-#define FWL_PARTSTATE_SPB_Normal (0L << 0)
-#define FWL_PARTSTATE_SPB_Hovered (1L << 0)
-#define FWL_PARTSTATE_SPB_Pressed (2L << 0)
-#define FWL_PARTSTATE_SPB_Disabled (3L << 0)
-#define FWL_WGTHITTEST_SPB_UpButton (FWL_WGTHITTEST_MAX + 1)
-#define FWL_WGTHITTEST_SPB_DownButton (FWL_WGTHITTEST_MAX + 2)
-#define FWL_EVT_SPB_Click L"FWL_EVENT_SPB_Click"
-#define FWL_EVTHASH_SPB_Click 2927651187
-
-BEGIN_FWL_EVENT_DEF(CFWL_EvtSpbClick, FWL_EVTHASH_SPB_Click)
+
+BEGIN_FWL_EVENT_DEF(CFWL_EvtSpbClick, CFWL_EventType::Click)
FX_BOOL m_bUp;
END_FWL_EVENT_DEF
@@ -34,7 +21,7 @@ class IFWL_SpinButton : public IFWL_Widget {
static IFWL_SpinButton* Create(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- FWL_ERR EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE);
+ FWL_Error EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE);
FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE);
protected:
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_tooltip.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_tooltip.h
index 278544b459c..5b8dff1b3be 100644
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_tooltip.h
+++ b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifwl_tooltip.h
@@ -13,20 +13,16 @@ class CFWL_WidgetImpProperties;
class IFWL_ToolTip;
#define FWL_CLASS_ToolTip L"FWL_TOOLTIP"
-#define FWL_CLASSHASH_ToolTip 1111984755
#define FWL_STYLEEXT_TTP_Rectangle (0L << 3)
#define FWL_STYLEEXT_TTP_RoundCorner (1L << 3)
#define FWL_STYLEEXT_TTP_Balloon (1L << 4)
#define FWL_STYLEEXT_TTP_Multiline (1L << 5)
#define FWL_STYLEEXT_TTP_NoAnchor (1L << 6)
-#define FWL_PART_TTP_Border 1
-#define FWL_PART_TTP_Background 2
-#define FWL_PART_TTP_Caption 3
class IFWL_ToolTipDP : public IFWL_DataProvider {
public:
- virtual FWL_ERR GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) = 0;
+ virtual FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) = 0;
virtual int32_t GetInitialDelay(IFWL_Widget* pWidget) = 0;
virtual int32_t GetAutoPopDelay(IFWL_Widget* pWidget) = 0;
virtual CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget) = 0;
@@ -38,9 +34,9 @@ class IFWL_ToolTip : public IFWL_Form {
static IFWL_ToolTip* Create(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- FWL_ERR SetAnchor(const CFX_RectF& rtAnchor);
- FWL_ERR Show();
- FWL_ERR Hide();
+ void SetAnchor(const CFX_RectF& rtAnchor);
+ void Show();
+ void Hide();
protected:
IFWL_ToolTip();
diff --git a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifx_barcode.h b/chromium/third_party/pdfium/xfa/fwl/basewidget/ifx_barcode.h
deleted file mode 100644
index a44a01ba8d1..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/basewidget/ifx_barcode.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_BASEWIDGET_IFX_BARCODE_H_
-#define XFA_FWL_BASEWIDGET_IFX_BARCODE_H_
-
-#include "core/fxcrt/include/fx_string.h"
-#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
-#include "xfa/fxbarcode/include/BC_Library.h"
-
-class CFX_Font;
-class CFX_Matrix;
-class CFX_RenderDevice;
-
-class IFX_Barcode {
- public:
- virtual ~IFX_Barcode() {}
-
- virtual void Release() = 0;
-
- virtual BC_TYPE GetType() = 0;
- virtual FX_BOOL Encode(const CFX_WideStringC& contents,
- FX_BOOL isDevice,
- int32_t& e) = 0;
- virtual FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e) = 0;
- virtual FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) = 0;
- virtual CFX_WideString Decode(uint8_t* buf,
- int32_t width,
- int32_t height,
- int32_t& errorCode) = 0;
- virtual CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& errorCode) = 0;
- virtual FX_BOOL SetCharEncoding(BC_CHAR_ENCODING encoding) = 0;
- virtual FX_BOOL SetModuleHeight(int32_t moduleHeight) = 0;
- virtual FX_BOOL SetModuleWidth(int32_t moduleWidth) = 0;
- virtual FX_BOOL SetHeight(int32_t height) = 0;
- virtual FX_BOOL SetWidth(int32_t width) = 0;
- virtual FX_BOOL CheckContentValidity(const CFX_WideStringC& contents) = 0;
- virtual FX_BOOL SetPrintChecksum(FX_BOOL checksum) = 0;
- virtual FX_BOOL SetDataLength(int32_t length) = 0;
- virtual FX_BOOL SetCalChecksum(int32_t state) = 0;
- virtual FX_BOOL SetFont(CFX_Font* pFont) = 0;
- virtual FX_BOOL SetFontSize(FX_FLOAT size) = 0;
- virtual FX_BOOL SetFontStyle(int32_t style) = 0;
- virtual FX_BOOL SetFontColor(FX_ARGB color) = 0;
- virtual FX_BOOL SetTextLocation(BC_TEXT_LOC location) = 0;
- virtual FX_BOOL SetWideNarrowRatio(int32_t ratio) = 0;
- virtual FX_BOOL SetStartChar(FX_CHAR start) = 0;
- virtual FX_BOOL SetEndChar(FX_CHAR end) = 0;
- virtual FX_BOOL SetVersion(int32_t version) = 0;
- virtual FX_BOOL SetErrorCorrectionLevel(int32_t level) = 0;
- virtual FX_BOOL SetTruncated(FX_BOOL truncated) = 0;
-};
-
-IFX_Barcode* FX_Barcode_Create(BC_TYPE type);
-
-#endif // XFA_FWL_BASEWIDGET_IFX_BARCODE_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_event.h b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_event.h
index 5f7a135372c..d9decac3341 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_event.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_event.h
@@ -10,37 +10,45 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/cfwl_note.h"
+#include "xfa/fwl/core/cfwl_message.h"
#include "xfa/fwl/core/fwl_error.h"
-#define FWL_EVT_Mouse L"FWL_EVENT_Mouse"
-#define FWL_EVT_MouseWheel L"FWL_EVENT_MouseWheel"
-#define FWL_EVT_Key L"FWL_EVENT_Key"
-#define FWL_EVT_SetFocus L"FWL_EVENT_SetFocus"
-#define FWL_EVT_KillFocus L"FWL_EVENT_KillFocus"
-#define FWL_EVT_Click L"FWL_EVENT_Click"
-#define FWL_EVT_Draw L"FWL_EVENT_Draw"
-#define FWL_EVT_Scroll L"FWL_EVENT_Scroll"
-#define FWL_EVT_Close L"FWL_EVENT_Close"
-#define FWL_EVT_ContextMenu L"FWL_EVENT_ContextMenu"
-#define FWL_EVT_MenuCommand L"FWL_EVENT_MenuCommand"
-#define FWL_EVT_SizeChanged L"FWL_EVENT_SizeChanged"
-
-#define FWL_EVTHASH_Mouse 1765258002
-#define FWL_EVTHASH_MouseWheel 3907114407
-#define FWL_EVTHASH_Key 2408354450
-#define FWL_EVTHASH_SetFocus 3909721269
-#define FWL_EVTHASH_KillFocus 1779363253
-#define FWL_EVTHASH_Draw 2430713303
-#define FWL_EVTHASH_Click 4026328783
-#define FWL_EVTHASH_Scroll 2965158968
-#define FWL_EVTHASH_Close 4036693599
-#define FWL_EVTHASH_ContextMenu 2717307715
-#define FWL_EVTHASH_MenuCommand 497763741
-#define FWL_EVTHASH_SizeChanged 3083958510
-#define FWL_EVTHASH_Idle 839546759
-
-typedef enum {
+enum class CFWL_EventType {
+ None = 0,
+
+ CheckStateChanged,
+ CheckWord,
+ Click,
+ Close,
+ CloseUp,
+ ContextMenu,
+ DataSelected,
+ DateChanged,
+ Draw,
+ DrawItem,
+ DropDown,
+ EditChanged,
+ GetSuggestedWords,
+ HoverChanged,
+ Idle,
+ Key,
+ KillFocus,
+ MenuCommand,
+ Mouse,
+ MouseWheel,
+ PostDropDown,
+ PreDropDown,
+ PreSelfAdaption,
+ Scroll,
+ SelectChanged,
+ SetFocus,
+ SizeChanged,
+ TextChanged,
+ TextFull,
+ Validate
+};
+
+enum FWLEventMask {
FWL_EVENT_MOUSE_MASK = 1 << 0,
FWL_EVENT_MOUSEWHEEL_MASK = 1 << 1,
FWL_EVENT_KEY_MASK = 1 << 2,
@@ -51,39 +59,59 @@ typedef enum {
FWL_EVENT_IDLE_MASK = 1 << 7,
FWL_EVENT_CONTROL_MASK = 1 << 8,
FWL_EVENT_ALL_MASK = 0xFF
-} FWLEventMask;
+};
class CFX_Graphics;
class IFWL_Widget;
-class CFWL_Event : public CFWL_Note {
+class CFWL_Event {
public:
- CFWL_Event() : CFWL_Note(TRUE) {}
+ CFWL_Event()
+ : m_pSrcTarget(nullptr), m_pDstTarget(nullptr), m_dwRefCount(1) {}
virtual ~CFWL_Event() {}
+
+ virtual FWL_Error GetClassName(CFX_WideString& wsClass) const {
+ return FWL_Error::Succeeded;
+ }
+ virtual CFWL_EventType GetClassID() const { return CFWL_EventType::None; }
+
+ uint32_t Release() {
+ m_dwRefCount--;
+ uint32_t dwRefCount = m_dwRefCount;
+ if (!m_dwRefCount)
+ delete this;
+ return dwRefCount;
+ }
+
+ IFWL_Widget* m_pSrcTarget;
+ IFWL_Widget* m_pDstTarget;
+
+ private:
+ uint32_t m_dwRefCount;
};
-#define BEGIN_FWL_EVENT_DEF(classname, eventhashcode) \
- class classname : public CFWL_Event { \
- public: \
- classname() : CFWL_Event() {} \
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { \
- wsClass = L## #classname; \
- return FWL_ERR_Succeeded; \
- } \
- virtual uint32_t GetClassID() const { return eventhashcode; }
+#define BEGIN_FWL_EVENT_DEF(classname, eventType) \
+ class classname : public CFWL_Event { \
+ public: \
+ classname() : CFWL_Event() {} \
+ virtual FWL_Error GetClassName(CFX_WideString& wsClass) const { \
+ wsClass = L## #classname; \
+ return FWL_Error::Succeeded; \
+ } \
+ virtual CFWL_EventType GetClassID() const { return eventType; }
#define END_FWL_EVENT_DEF \
} \
; // NOLINT
-BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, FWL_EVTHASH_Mouse)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, CFWL_EventType::Mouse)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
uint32_t m_dwFlags;
-uint32_t m_dwCmd;
+FWL_MouseCommand m_dwCmd;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, FWL_EVTHASH_MouseWheel)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, CFWL_EventType::MouseWheel)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
FX_FLOAT m_fDeltaX;
@@ -91,55 +119,55 @@ FX_FLOAT m_fDeltaY;
uint32_t m_dwFlags;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, FWL_EVTHASH_Key)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, CFWL_EventType::Key)
uint32_t m_dwKeyCode;
uint32_t m_dwFlags;
-uint32_t m_dwCmd;
+FWL_KeyCommand m_dwCmd;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, FWL_EVTHASH_SetFocus)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, CFWL_EventType::SetFocus)
IFWL_Widget* m_pSetFocus;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtKillFocus, FWL_EVTHASH_KillFocus)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtKillFocus, CFWL_EventType::KillFocus)
IFWL_Widget* m_pKillFocus;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtDraw, FWL_EVTHASH_Draw)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtDraw, CFWL_EventType::Draw)
CFX_Graphics* m_pGraphics;
IFWL_Widget* m_pWidget;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtClick, FWL_EVTHASH_Click)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtClick, CFWL_EventType::Click)
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtScroll, FWL_EVTHASH_Scroll)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtScroll, CFWL_EventType::Scroll)
uint32_t m_iScrollCode;
FX_FLOAT m_fPos;
FX_BOOL* m_pRet;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtClose, FWL_EVTHASH_Close)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtClose, CFWL_EventType::Close)
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtContextMenu, FWL_EVTHASH_ContextMenu)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtContextMenu, CFWL_EventType::ContextMenu)
FX_FLOAT m_fPosX;
FX_FLOAT m_fPosY;
IFWL_Widget* m_pOwner;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtMenuCommand, FWL_EVTHASH_MenuCommand)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtMenuCommand, CFWL_EventType::MenuCommand)
int32_t m_iCommand;
void* m_pData;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtSizeChanged, FWL_EVTHASH_SizeChanged)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtSizeChanged, CFWL_EventType::SizeChanged)
IFWL_Widget* m_pWidget;
CFX_RectF m_rtOld;
CFX_RectF m_rtNew;
END_FWL_EVENT_DEF
-BEGIN_FWL_EVENT_DEF(CFWL_EvtIdle, FWL_EVTHASH_Idle)
+BEGIN_FWL_EVENT_DEF(CFWL_EvtIdle, CFWL_EventType::Idle)
END_FWL_EVENT_DEF
#endif // XFA_FWL_CORE_CFWL_EVENT_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_message.h b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_message.h
index 7bd6af1977f..74401c3e344 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_message.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_message.h
@@ -9,95 +9,113 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/cfwl_note.h"
#include "xfa/fwl/core/fwl_error.h"
-#define FWL_MSGHASH_Activate 2410369469
-#define FWL_MSGHASH_Deactivate 1184214790
-#define FWL_MSGHASH_SetFocus 4174512504
-#define FWL_MSGHASH_KillFocus 1557903832
-#define FWL_MSGHASH_Mouse 706128309
-#define FWL_MSGHASH_MouseWheel 893703466
-#define FWL_MSGHASH_Key 3751372405
-#define FWL_MSGHASH_Cursor 3182626218
-#define FWL_MSGHASH_Size 160077735
-#define FWL_MSGHASH_WindowMove 1032269377
-#define FWL_MSGHASH_DropFiles 2004165236
-#define FWL_MSGHASH_TaskClicked 3128231086
-#define FWL_MSGHASH_Close 2977563906
-#define FWL_MSGHASH_Post 1969633074
-#define FWL_MSGHASH_WindowWillMove 2229175763
-
-#define FWL_MSG_Activate L"FWL_MESSAGE_Activate"
-#define FWL_MSG_Deactivate L"FWL_MESSAGE_Deactivate"
-#define FWL_MSG_SetFocus L"FWL_MESSAGE_SetFocus"
-#define FWL_MSG_KillFocus L"FWL_MESSAGE_KillFocus"
-#define FWL_MSG_Mouse L"FWL_MESSAGE_Mouse"
-#define FWL_MSG_MouseWheel L"FWL_MESSAGE_MouseWheel"
-#define FWL_MSG_Key L"FWL_MESSAGE_Key"
-#define FWL_MSG_Cursor L"FWL_MESSAGE_Cursor"
-#define FWL_MSG_Size L"FWL_MESSAGE_Size"
-#define FWL_MSG_WindowMove L"FWL_MESSAGE_WindowMove"
-#define FWL_MSG_DropFiles L"FWL_MESSAGE_DropFiles"
-#define FWL_MSG_TaskClicked L"FWL_MESSAGE_TaskClicked"
-#define FWL_MSG_Close L"FWL_MESSAGE_Close"
-#define FWL_MSG_Post L"FWL_MESSAGE_Post"
-#define FWL_MSG_WindowWillMove L"FWL_MESSAGE_WindowWillMove"
-
-#define FWL_MSGMOUSECMD_LButtonDown 1
-#define FWL_MSGMOUSECMD_LButtonUp 2
-#define FWL_MSGMOUSECMD_LButtonDblClk 3
-#define FWL_MSGMOUSECMD_RButtonDown 4
-#define FWL_MSGMOUSECMD_RButtonUp 5
-#define FWL_MSGMOUSECMD_RButtonDblClk 6
-#define FWL_MSGMOUSECMD_MButtonDown 7
-#define FWL_MSGMOUSECMD_MButtonUp 8
-#define FWL_MSGMOUSECMD_MButtonDblClk 9
-#define FWL_MSGMOUSECMD_MouseMove 10
-#define FWL_MSGMOUSECMD_MouseEnter 11
-#define FWL_MSGMOUSECMD_MouseLeave 12
-#define FWL_MSGMOUSECMD_MouseHover 13
-#define FWL_MSGKEYCMD_KeyDown 1
-#define FWL_MSGKEYCMD_KeyUp 2
-#define FWL_MSGKEYCMD_Char 3
+enum class CFWL_MessageType {
+ None = 0,
+
+ Activate,
+ Close,
+ Cursor,
+ Deactivate,
+ DropFiles,
+ Key,
+ KillFocus,
+ Mouse,
+ MouseWheel,
+ Post,
+ SetFocus,
+ Size,
+ TaskClicked,
+ WindowMove,
+ WindowWillMove
+};
+
+enum class FWL_MouseCommand {
+ LeftButtonDown,
+ LeftButtonUp,
+ LeftButtonDblClk,
+ RightButtonDown,
+ RightButtonUp,
+ RightButtonDblClk,
+ MiddleButtonDown,
+ MiddleButtonUp,
+ MiddleButtonDblClk,
+ Move,
+ Enter,
+ Leave,
+ Hover
+};
+
+enum class FWL_KeyCommand { KeyDown, KeyUp, Char };
class IFWL_Widget;
-class CFWL_Message : public CFWL_Note {
+class CFWL_Message {
public:
- CFWL_Message() : CFWL_Note(FALSE) {}
+ CFWL_Message()
+ : m_pSrcTarget(nullptr),
+ m_pDstTarget(nullptr),
+ m_dwExtend(0),
+ m_dwRefCount(1) {}
virtual ~CFWL_Message() {}
+
+ virtual CFWL_Message* Clone() { return nullptr; }
+ virtual FWL_Error GetClassName(CFX_WideString& wsClass) const {
+ return FWL_Error::Succeeded;
+ }
+ virtual CFWL_MessageType GetClassID() const { return CFWL_MessageType::None; }
+
+ uint32_t Release() {
+ m_dwRefCount--;
+ uint32_t dwRefCount = m_dwRefCount;
+ if (!m_dwRefCount)
+ delete this;
+ return dwRefCount;
+ }
+
+ CFWL_Message* Retain() {
+ m_dwRefCount++;
+ return this;
+ }
+
+ IFWL_Widget* m_pSrcTarget;
+ IFWL_Widget* m_pDstTarget;
+ uint32_t m_dwExtend;
+
+ private:
+ uint32_t m_dwRefCount;
};
-#define BEGIN_FWL_MESSAGE_DEF(classname, msghashcode) \
- class classname : public CFWL_Message { \
- public: \
- classname() : CFWL_Message() {} \
- virtual CFWL_Note* Clone() { return new classname(*this); } \
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { \
- wsClass = L## #classname; \
- return FWL_ERR_Succeeded; \
- } \
- virtual uint32_t GetClassID() const { return msghashcode; }
+#define BEGIN_FWL_MESSAGE_DEF(classname, msgType) \
+ class classname : public CFWL_Message { \
+ public: \
+ classname() : CFWL_Message() {} \
+ CFWL_Message* Clone() override { return new classname(*this); } \
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override { \
+ wsClass = L## #classname; \
+ return FWL_Error::Succeeded; \
+ } \
+ CFWL_MessageType GetClassID() const override { return msgType; }
#define END_FWL_MESSAGE_DEF \
} \
; // NOLINT
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, FWL_MSGHASH_Activate)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate)
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, FWL_MSGHASH_Deactivate)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate)
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, FWL_MSGHASH_Mouse)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
uint32_t m_dwFlags;
-uint32_t m_dwCmd;
+FWL_MouseCommand m_dwCmd;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, FWL_MSGHASH_MouseWheel)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
FX_FLOAT m_fDeltaX;
@@ -105,34 +123,34 @@ FX_FLOAT m_fDeltaY;
uint32_t m_dwFlags;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, FWL_MSGHASH_SetFocus)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, CFWL_MessageType::SetFocus)
IFWL_Widget* m_pKillFocus;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, FWL_MSGHASH_KillFocus)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, CFWL_MessageType::KillFocus)
IFWL_Widget* m_pSetFocus;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, FWL_MSGHASH_Key)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key)
uint32_t m_dwKeyCode;
uint32_t m_dwFlags;
-uint32_t m_dwCmd;
+FWL_KeyCommand m_dwCmd;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, FWL_MSGHASH_Cursor)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, CFWL_MessageType::Cursor)
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, FWL_MSGHASH_Size)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, CFWL_MessageType::Size)
int32_t m_iWidth;
int32_t m_iHeight;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, FWL_MSGHASH_WindowMove)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, CFWL_MessageType::WindowMove)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, FWL_MSGHASH_DropFiles)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, CFWL_MessageType::DropFiles)
CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) {
m_pDstTarget = copy.m_pDstTarget;
m_pSrcTarget = copy.m_pSrcTarget;
@@ -145,15 +163,15 @@ FX_FLOAT m_fy;
CFX_WideStringArray m_files;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, FWL_MSGHASH_TaskClicked)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, CFWL_MessageType::TaskClicked)
FX_FLOAT m_fx;
FX_FLOAT m_fy;
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, FWL_MSGHASH_Close)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close)
END_FWL_MESSAGE_DEF
-BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, FWL_MSGHASH_WindowWillMove)
+BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove)
END_FWL_MESSAGE_DEF
#endif // XFA_FWL_CORE_CFWL_MESSAGE_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_note.h b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_note.h
deleted file mode 100644
index d173dc6f766..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_note.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_CFWL_NOTE_H_
-#define XFA_FWL_CORE_CFWL_NOTE_H_
-
-#include "core/fxcrt/include/fx_string.h"
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-class IFWL_Widget;
-
-// Separate hierarchy not related to IFWL_* hierarchy. These should not
-// get cast to IFWL_* types.
-class CFWL_Note {
- public:
- virtual uint32_t Release() {
- m_dwRefCount--;
- uint32_t dwRefCount = m_dwRefCount;
- if (!m_dwRefCount)
- delete this;
- return dwRefCount;
- }
-
- virtual CFWL_Note* Retain() {
- m_dwRefCount++;
- return this;
- }
-
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const {
- wsClass = L"CFWL_Note";
- return FWL_ERR_Succeeded;
- }
-
- virtual uint32_t GetClassID() const { return 0; }
-
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const {
- return TRUE;
- }
-
- virtual CFWL_Note* Clone() { return NULL; }
- FX_BOOL IsEvent() const { return m_bIsEvent; }
-
- IFWL_Widget* m_pSrcTarget;
- IFWL_Widget* m_pDstTarget;
- uint32_t m_dwExtend;
-
- protected:
- CFWL_Note(FX_BOOL bIsEvent)
- : m_pSrcTarget(NULL),
- m_pDstTarget(NULL),
- m_dwExtend(0),
- m_dwRefCount(1),
- m_bIsEvent(bIsEvent) {}
-
- virtual ~CFWL_Note() {}
- virtual FX_BOOL Initialize() { return TRUE; }
- virtual int32_t Finalize() { return 0; }
-
- uint32_t m_dwRefCount;
- FX_BOOL m_bIsEvent;
-};
-
-#endif // XFA_FWL_CORE_CFWL_NOTE_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_themebackground.h b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_themebackground.h
index cdab5b27295..9761183011b 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_themebackground.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_themebackground.h
@@ -7,7 +7,7 @@
#ifndef XFA_FWL_CORE_CFWL_THEMEBACKGROUND_H_
#define XFA_FWL_CORE_CFWL_THEMEBACKGROUND_H_
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fwl/core/cfwl_themepart.h"
class CFX_DIBitmpa;
@@ -16,7 +16,9 @@ class CFX_Path;
class CFWL_ThemeBackground : public CFWL_ThemePart {
public:
- CFWL_ThemeBackground() : m_pGraphics(NULL), m_pImage(NULL), m_pPath(NULL) {}
+ CFWL_ThemeBackground()
+ : m_pGraphics(nullptr), m_pImage(nullptr), m_pPath(nullptr) {}
+
CFX_Graphics* m_pGraphics;
CFX_DIBitmap* m_pImage;
CFX_Path* m_pPath;
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_themepart.h b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_themepart.h
index 884f38101ff..5bdf1530a51 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/cfwl_themepart.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/cfwl_themepart.h
@@ -9,12 +9,85 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/ifwl_widget.h"
+
+enum class CFWL_Part {
+ None = 0,
+
+ BackArrow,
+ Background,
+ Border,
+ Caption,
+ Check,
+ CheckBox,
+ CloseBox,
+ CombTextLine,
+ DateInBK,
+ DateInCircle,
+ DatesIn,
+ DatesOut,
+ DownButton,
+ DropDownButton,
+ Edge,
+ ForeArrow,
+ HSeparator,
+ HeadText,
+ Header,
+ Icon,
+ Image,
+ LBtn,
+ ListItem,
+ LowerTrack,
+ MinimizeBox,
+ MaximizeBox,
+ NarrowCaption,
+ RBtn,
+ StretchHandler,
+ Thumb,
+ ThumbBackArrow,
+ ThumbForeArrow,
+ ThumbLowerTrack,
+ ThumbThumb,
+ ThumbUpperTrack,
+ Today,
+ TodayCircle,
+ UpButton,
+ UpperTrack,
+ VSeparator,
+ Week,
+ WeekNum,
+ WeekNumSep
+};
+
+enum CFWL_PartState {
+ CFWL_PartState_Normal = 0,
+
+ CFWL_PartState_Checked = 1 << 1,
+ CFWL_PartState_Default = 1 << 2,
+ CFWL_PartState_Disabled = 1 << 3,
+ CFWL_PartState_Flagged = 1 << 4,
+ CFWL_PartState_Focused = 1 << 5,
+ CFWL_PartState_HightLight = 1 << 6,
+ CFWL_PartState_Hovered = 1 << 7,
+ CFWL_PartState_Inactive = 1 << 8,
+ CFWL_PartState_Neutral = 1 << 9,
+ CFWL_PartState_Pressed = 1 << 10,
+ CFWL_PartState_ReadOnly = 1 << 11,
+ CFWL_PartState_LSelected = 1 << 12,
+ CFWL_PartState_RSelected = 1 << 13,
+ CFWL_PartState_Selected = 1 << 14
+};
+
+class IFWL_Widget;
class CFWL_ThemePart {
public:
CFWL_ThemePart()
- : m_pWidget(NULL), m_iPart(0), m_dwStates(0), m_dwData(0), m_pData(NULL) {
+ : m_pWidget(nullptr),
+ m_iPart(CFWL_Part::None),
+ m_dwStates(CFWL_PartState_Normal),
+ m_bMaximize(false),
+ m_bStaticBackground(false),
+ m_pData(nullptr) {
m_rtPart.Reset();
m_matrix.SetIdentity();
}
@@ -22,9 +95,10 @@ class CFWL_ThemePart {
CFX_Matrix m_matrix;
CFX_RectF m_rtPart;
IFWL_Widget* m_pWidget;
- int32_t m_iPart;
+ CFWL_Part m_iPart;
uint32_t m_dwStates;
- uint32_t m_dwData;
+ bool m_bMaximize;
+ bool m_bStaticBackground;
void* m_pData;
};
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.cpp
index 2cff349f82c..d7fa8bc1c06 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.cpp
@@ -7,108 +7,108 @@
#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_widget.h"
+#include "xfa/fxfa/app/xfa_fwladapter.h"
-IFWL_App* IFWL_App::Create(IFWL_AdapterNative* pAdapter) {
+IFWL_App* IFWL_App::Create(CXFA_FFApp* pAdapter) {
IFWL_App* pApp = new IFWL_App;
pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter));
return pApp;
}
-FWL_ERR IFWL_App::Initialize() {
+
+void IFWL_App::Release() {}
+
+FWL_Error IFWL_App::Initialize() {
return static_cast<CFWL_AppImp*>(GetImpl())->Initialize();
}
-FWL_ERR IFWL_App::Finalize() {
+
+FWL_Error IFWL_App::Finalize() {
return static_cast<CFWL_AppImp*>(GetImpl())->Finalize();
}
-IFWL_AdapterNative* IFWL_App::GetAdapterNative() {
+
+CXFA_FFApp* IFWL_App::GetAdapterNative() {
return static_cast<CFWL_AppImp*>(GetImpl())->GetAdapterNative();
}
+
IFWL_WidgetMgr* IFWL_App::GetWidgetMgr() {
return static_cast<CFWL_AppImp*>(GetImpl())->GetWidgetMgr();
}
+
IFWL_ThemeProvider* IFWL_App::GetThemeProvider() {
return static_cast<CFWL_AppImp*>(GetImpl())->GetThemeProvider();
}
-FWL_ERR IFWL_App::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
- return static_cast<CFWL_AppImp*>(GetImpl())->SetThemeProvider(pThemeProvider);
+
+void IFWL_App::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+ static_cast<CFWL_AppImp*>(GetImpl())->SetThemeProvider(pThemeProvider);
}
-FWL_ERR IFWL_App::Exit(int32_t iExitCode) {
- return static_cast<CFWL_AppImp*>(GetImpl())->Exit(iExitCode);
+
+void IFWL_App::Exit(int32_t iExitCode) {
+ static_cast<CFWL_AppImp*>(GetImpl())->Exit(iExitCode);
}
-CFWL_AppImp::CFWL_AppImp(IFWL_App* pIface, IFWL_AdapterNative* pAdapter)
- : CFWL_NoteThreadImp(pIface),
- m_pAdapterNative(pAdapter),
- m_pThemeProvider(nullptr) {}
+CFWL_NoteDriver* IFWL_App::GetNoteDriver() const {
+ return static_cast<CFWL_AppImp*>(GetImpl())->GetNoteDriver();
+}
+
+CFWL_AppImp::CFWL_AppImp(IFWL_App* pIface, CXFA_FFApp* pAdapter)
+ : m_pAdapterNative(pAdapter),
+ m_pThemeProvider(nullptr),
+ m_pNoteDriver(new CFWL_NoteDriver),
+ m_pIface(pIface) {}
CFWL_AppImp::~CFWL_AppImp() {
CFWL_ToolTipContainer::DeleteInstance();
}
-FWL_ERR CFWL_AppImp::Initialize() {
+FWL_Error CFWL_AppImp::Initialize() {
if (!m_pWidgetMgr) {
m_pWidgetMgr.reset(new CFWL_WidgetMgr(m_pAdapterNative));
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_AppImp::Finalize() {
+FWL_Error CFWL_AppImp::Finalize() {
m_pWidgetMgr.reset();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative() const {
+CXFA_FFApp* CFWL_AppImp::GetAdapterNative() const {
return m_pAdapterNative;
}
-IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
+CXFA_FWLAdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
return static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr())
->GetAdapterWidgetMgr();
}
IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() const {
return m_pWidgetMgr.get();
}
-FWL_ERR CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+
+void CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
m_pThemeProvider = pThemeProvider;
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_AppImp::Exit(int32_t iExitCode) {
+
+void CFWL_AppImp::Exit(int32_t iExitCode) {
while (m_pNoteDriver->PopNoteLoop()) {
continue;
}
- return m_pWidgetMgr->GetAdapterWidgetMgr()->Exit(0);
}
+
IFWL_ThemeProvider* CFWL_AppImp::GetThemeProvider() const {
return m_pThemeProvider;
}
-IFWL_AdapterNative* FWL_GetAdapterNative() {
+
+CXFA_FFApp* FWL_GetAdapterNative() {
IFWL_App* pApp = FWL_GetApp();
if (!pApp)
return NULL;
return pApp->GetAdapterNative();
}
-IFWL_ThemeProvider* FWL_GetThemeProvider() {
- return NULL;
-}
-static IFWL_App* _theApp = NULL;
+
+static IFWL_App* g_theApp = nullptr;
IFWL_App* FWL_GetApp() {
- return _theApp;
+ return g_theApp;
}
+
void FWL_SetApp(IFWL_App* pApp) {
- _theApp = pApp;
-}
-FWL_ERR FWL_SetFullScreen(IFWL_Widget* pWidget, FX_BOOL bFullScreen) {
- if (!pWidget)
- return FWL_ERR_Succeeded;
- IFWL_NoteThread* pNoteTread = pWidget->GetOwnerThread();
- if (!pNoteTread)
- return FWL_ERR_Succeeded;
- CFWL_NoteDriver* pNoteDriver =
- static_cast<CFWL_NoteDriver*>(pNoteTread->GetNoteDriver());
- if (!pNoteTread)
- return FWL_ERR_Succeeded;
- pNoteDriver->NotifyFullScreenMode(pWidget, bFullScreen);
- return FWL_GetAdapterWidgetMgr()->SetFullScreen(pWidget, bFullScreen);
+ g_theApp = pApp;
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.h
index f9ccabf9bc2..b138ccb5be6 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_appimp.h
@@ -9,30 +9,37 @@
#include <memory>
-#include "xfa/fwl/core/fwl_threadimp.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
class CFWL_WidgetMgr;
-class IFWL_AdapterNative;
-class IFWL_WidgetMgr;
-class IFWL_ThemeProvider;
+class CXFA_FFApp;
class IFWL_App;
+class IFWL_NoteThread;
+class IFWL_ThemeProvider;
+class IFWL_WidgetMgr;
-class CFWL_AppImp : public CFWL_NoteThreadImp {
+class CFWL_AppImp {
public:
- CFWL_AppImp(IFWL_App* pIface, IFWL_AdapterNative* pAdapter);
- virtual ~CFWL_AppImp();
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual IFWL_AdapterNative* GetAdapterNative() const;
- virtual IFWL_WidgetMgr* GetWidgetMgr() const;
- virtual IFWL_ThemeProvider* GetThemeProvider() const;
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- virtual FWL_ERR Exit(int32_t iExitCode = 0);
-
- protected:
- IFWL_AdapterNative* const m_pAdapterNative;
+ CFWL_AppImp(IFWL_App* pIface, CXFA_FFApp* pAdapter);
+ ~CFWL_AppImp();
+
+ IFWL_App* GetInterface() const { return m_pIface; }
+ CFWL_NoteDriver* GetNoteDriver() const { return m_pNoteDriver.get(); }
+
+ FWL_Error Initialize();
+ FWL_Error Finalize();
+ CXFA_FFApp* GetAdapterNative() const;
+ IFWL_WidgetMgr* GetWidgetMgr() const;
+ IFWL_ThemeProvider* GetThemeProvider() const;
+ void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ void Exit(int32_t iExitCode);
+
+ private:
+ CXFA_FFApp* const m_pAdapterNative;
std::unique_ptr<CFWL_WidgetMgr> m_pWidgetMgr;
IFWL_ThemeProvider* m_pThemeProvider;
+ std::unique_ptr<CFWL_NoteDriver> m_pNoteDriver;
+ IFWL_App* const m_pIface;
};
#endif // XFA_FWL_CORE_FWL_APPIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_contentimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_contentimp.cpp
deleted file mode 100644
index 5bfac08df49..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_contentimp.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/core/fwl_contentimp.h"
-
-#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
-#include "xfa/fwl/core/fwl_widgetimp.h"
-#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_content.h"
-
-FWL_ERR IFWL_Content::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->InsertWidget(pChild, nIndex);
-}
-FWL_ERR IFWL_Content::RemoveWidget(IFWL_Widget* pWidget) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->RemoveWidget(pWidget);
-}
-FWL_ERR IFWL_Content::RemoveAllWidgets() {
- return static_cast<CFWL_ContentImp*>(GetImpl())->RemoveAllWidgets();
-}
-FWL_ERR IFWL_Content::GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->GetMinSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->SetMinSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->GetMaxSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->SetMaxSize(fWidth, fHeight);
-}
-IFWL_Content::IFWL_Content() {}
-CFWL_ContentImp::CFWL_ContentImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter),
- m_fWidthMin(0),
- m_fWidthMax(10000),
- m_fHeightMin(0),
- m_fHeightMax(10000) {}
-CFWL_ContentImp::~CFWL_ContentImp() {}
-FWL_ERR CFWL_ContentImp::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
- if (!pChild)
- return FWL_ERR_Indefinite;
- pChild->SetParent(m_pInterface);
- if (nIndex == -1) {
- return FWL_ERR_Succeeded;
- }
- CFWL_WidgetMgr* pMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pMgr)
- return FWL_ERR_Indefinite;
- pMgr->SetWidgetIndex(pChild, nIndex);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::RemoveWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FWL_ERR_Indefinite;
- pWidget->SetParent(NULL);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::RemoveAllWidgets() {
- CFWL_WidgetMgr* pMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pMgr)
- return FWL_ERR_Indefinite;
- while (IFWL_Widget* widget =
- pMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild)) {
- pMgr->SetParent(NULL, widget);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- fWidth = m_fWidthMin;
- fHeight = m_fHeightMin;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
- m_fWidthMin = fWidth;
- m_fHeightMin = fHeight;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- fWidth = m_fWidthMax;
- fHeight = m_fHeightMax;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
- m_fWidthMax = fWidth;
- m_fHeightMax = fHeight;
- return FWL_ERR_Succeeded;
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_contentimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_contentimp.h
deleted file mode 100644
index b7a44d3a530..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_contentimp.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_FWL_CONTENTIMP_H_
-#define XFA_FWL_CORE_FWL_CONTENTIMP_H_
-
-#include "xfa/fwl/core/fwl_widgetimp.h"
-
-class IFWL_Widget;
-
-class CFWL_ContentImp : public CFWL_WidgetImp {
- public:
- CFWL_ContentImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
-
- virtual ~CFWL_ContentImp();
- virtual FWL_ERR InsertWidget(IFWL_Widget* pChild, int32_t nIndex = -1);
- virtual FWL_ERR RemoveWidget(IFWL_Widget* pWidget);
- virtual FWL_ERR RemoveAllWidgets();
- FWL_ERR GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight);
- FWL_ERR SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
- FWL_ERR GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight);
- FWL_ERR SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
-
- protected:
- FX_FLOAT m_fWidthMin;
- FX_FLOAT m_fWidthMax;
- FX_FLOAT m_fHeightMin;
- FX_FLOAT m_fHeightMax;
-};
-
-#endif // XFA_FWL_CORE_FWL_CONTENTIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_error.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_error.h
index 92a483f4e8c..e29f89e0129 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_error.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_error.h
@@ -7,16 +7,14 @@
#ifndef XFA_FWL_CORE_FWL_ERROR_H_
#define XFA_FWL_CORE_FWL_ERROR_H_
-#include <stdint.h>
-
-typedef int32_t FWL_ERR;
-
-#define FWL_ERR_Succeeded 0
-#define FWL_ERR_Indefinite -1
-#define FWL_ERR_Parameter_Invalid -100
-#define FWL_ERR_Property_Invalid -200
-#define FWL_ERR_Intermediate_Value__Invalid -300
-#define FWL_ERR_Method_Not_Supported -400
-#define FWL_ERR_Out_Of_Memory -500
+enum class FWL_Error {
+ Succeeded = 0,
+ Indefinite,
+ ParameterInvalid,
+ PropertyInvalid,
+ IntermediateValueInvalid,
+ MethodNotSupported,
+ OutOfMemory
+};
#endif // XFA_FWL_CORE_FWL_ERROR_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.cpp
index 5a5cc5e59bb..bcaba2c1536 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.cpp
@@ -14,20 +14,25 @@
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_panelimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_content.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
+#include "xfa/fwl/theme/cfwl_widgettp.h"
-#define FWL_SYSBTNSIZE 21
-#define FWL_SYSBTNMARGIN 5
-#define FWL_SYSBTNSPAN 2
-#define FWL_CornerEnlarge 10
+namespace {
+
+const int kSystemButtonSize = 21;
+const int kSystemButtonMargin = 5;
+const int kSystemButtonSpan = 2;
+
+} // namespace
+
+namespace {
+
+const uint8_t kCornerEnlarge = 10;
+
+} // namespace
// static
IFWL_Form* IFWL_Form::CreateFormProxy(CFWL_WidgetImpProperties& properties,
@@ -43,7 +48,7 @@ IFWL_Form::IFWL_Form() {}
FWL_FORMSIZE IFWL_Form::GetFormSize() {
return static_cast<CFWL_FormImp*>(GetImpl())->GetFormSize();
}
-FWL_ERR IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) {
+FWL_Error IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) {
return static_cast<CFWL_FormImp*>(GetImpl())->SetFormSize(eFormSize);
}
IFWL_Widget* IFWL_Form::DoModal() {
@@ -52,22 +57,22 @@ IFWL_Widget* IFWL_Form::DoModal() {
IFWL_Widget* IFWL_Form::DoModal(uint32_t& dwCommandID) {
return static_cast<CFWL_FormImp*>(GetImpl())->DoModal(dwCommandID);
}
-FWL_ERR IFWL_Form::EndDoModal() {
+FWL_Error IFWL_Form::EndDoModal() {
return static_cast<CFWL_FormImp*>(GetImpl())->EndDoModal();
}
-FWL_ERR IFWL_Form::SetBorderRegion(CFX_Path* pPath) {
+FWL_Error IFWL_Form::SetBorderRegion(CFX_Path* pPath) {
return static_cast<CFWL_FormImp*>(GetImpl())->SetBorderRegion(pPath);
}
CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : CFWL_PanelImp(properties, pOuter),
- m_pCloseBox(NULL),
- m_pMinBox(NULL),
- m_pMaxBox(NULL),
- m_pCaptionBox(NULL),
- m_pNoteLoop(NULL),
- m_pSubFocus(NULL),
+ : CFWL_WidgetImp(properties, pOuter),
+ m_pCloseBox(nullptr),
+ m_pMinBox(nullptr),
+ m_pMaxBox(nullptr),
+ m_pCaptionBox(nullptr),
+ m_pNoteLoop(nullptr),
+ m_pSubFocus(nullptr),
m_fCXBorder(0),
m_fCYBorder(0),
m_iCaptureBtn(-1),
@@ -79,8 +84,8 @@ CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
m_bCustomizeLayout(FALSE),
m_eFormSize(FWL_FORMSIZE_Manual),
m_bDoModalFlag(FALSE),
- m_pBigIcon(NULL),
- m_pSmallIcon(NULL),
+ m_pBigIcon(nullptr),
+ m_pSmallIcon(nullptr),
m_bMouseIn(FALSE) {
m_rtRelative.Reset();
m_rtCaption.Reset();
@@ -88,73 +93,71 @@ CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
m_rtCaptionText.Reset();
m_rtIcon.Reset();
}
+
CFWL_FormImp::~CFWL_FormImp() {
RemoveSysButtons();
delete m_pNoteLoop;
}
-FWL_ERR CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const {
+
+FWL_Error CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_Form;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_FormImp::GetClassID() const {
- return FWL_CLASSHASH_Form;
+
+FWL_Type CFWL_FormImp::GetClassID() const {
+ return FWL_Type::Form;
}
+
FX_BOOL CFWL_FormImp::IsInstance(const CFX_WideStringC& wsClass) const {
- if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) {
+ if (wsClass == CFX_WideStringC(FWL_CLASS_Form))
return TRUE;
- }
- return CFWL_PanelImp::IsInstance(wsClass);
+ return CFWL_WidgetImp::IsInstance(wsClass);
}
-FWL_ERR CFWL_FormImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
+
+FWL_Error CFWL_FormImp::Initialize() {
+ if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+ return FWL_Error::Indefinite;
RegisterForm();
RegisterEventTarget();
m_pDelegate = new CFWL_FormImpDelegate(this);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_FormImp::Finalize() {
+FWL_Error CFWL_FormImp::Finalize() {
delete m_pDelegate;
m_pDelegate = nullptr;
UnregisterEventTarget();
UnRegisterForm();
return CFWL_WidgetImp::Finalize();
}
-FWL_ERR CFWL_FormImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_FormImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Reset();
FX_FLOAT fCapHeight = GetCaptionHeight();
FX_FLOAT fCXBorder = GetBorderSize(TRUE);
FX_FLOAT fCYBorder = GetBorderSize(FALSE);
FX_FLOAT fEdge = GetEdgeWidth();
- if (m_pContent) {
- m_pContent->GetWidgetRect(rect, TRUE);
- }
rect.height += fCapHeight + fCYBorder + fEdge + fEdge;
rect.width += fCXBorder + fCXBorder + fEdge + fEdge;
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_FormImp::GetClientRect(CFX_RectF& rect) {
+FWL_Error CFWL_FormImp::GetClientRect(CFX_RectF& rect) {
if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) {
rect = m_pProperties->m_rtWidget;
rect.Offset(-rect.left, -rect.top);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
#ifdef FWL_UseMacSystemBorder
rect = m_rtRelative;
CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
if (!pWidgetMgr)
- return FWL_ERR_Indefinite;
- IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- adapterWidgetMgr->GetSystemBorder(l, t, r, b);
- rect.Deflate(l, t, r, b);
- rect.left = rect.top = 0;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+
+ rect.left = 0;
+ rect.top = 0;
+ return FWL_Error::Succeeded;
#else
FX_FLOAT x = 0;
FX_FLOAT y = 0;
@@ -164,21 +167,21 @@ FWL_ERR CFWL_FormImp::GetClientRect(CFX_RectF& rect) {
CFWL_ThemePart part;
part.m_pWidget = m_pInterface;
x = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder));
y = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder));
t = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FRM_CYCaption));
+ pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYCaption));
}
rect = m_pProperties->m_rtWidget;
rect.Offset(-rect.left, -rect.top);
rect.Deflate(x, t, x, y);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
#endif
}
-FWL_ERR CFWL_FormImp::Update() {
+FWL_Error CFWL_FormImp::Update() {
if (m_iLock > 0) {
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
if (!m_pProperties->m_pThemeProvider) {
m_pProperties->m_pThemeProvider = GetAvailableTheme();
@@ -192,90 +195,74 @@ FWL_ERR CFWL_FormImp::Update() {
#endif
UpdateCaption();
Layout();
- return FWL_ERR_Succeeded;
-}
-uint32_t CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
- (void)GetAvailableTheme();
- if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_CloseBox;
- }
- if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_MaxBox;
- }
- if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_MinBox;
- }
+ return FWL_Error::Succeeded;
+}
+FWL_WidgetHit CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ GetAvailableTheme();
+ if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy))
+ return FWL_WidgetHit::CloseBox;
+ if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy))
+ return FWL_WidgetHit::MaxBox;
+ if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy))
+ return FWL_WidgetHit::MinBox;
CFX_RectF rtCap;
rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder,
- m_rtCaption.width - FWL_SYSBTNSIZE * m_iSysBox - 2 * m_fCYBorder,
+ m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder,
m_rtCaption.height - m_fCXBorder);
- if (rtCap.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Titlebar;
- }
+ if (rtCap.Contains(fx, fy))
+ return FWL_WidgetHit::Titlebar;
if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) {
- FX_FLOAT fWidth =
- m_rtRelative.width - 2 * (m_fCYBorder + FWL_CornerEnlarge);
- FX_FLOAT fHeight =
- m_rtRelative.height - 2 * (m_fCXBorder + FWL_CornerEnlarge);
+ FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + kCornerEnlarge);
+ FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + kCornerEnlarge);
CFX_RectF rt;
- rt.Set(0, m_fCXBorder + FWL_CornerEnlarge, m_fCYBorder, fHeight);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Left;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + FWL_CornerEnlarge,
+ rt.Set(0, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight);
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::Left;
+ rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + kCornerEnlarge,
m_fCYBorder, fHeight);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Right;
- }
- rt.Set(m_fCYBorder + FWL_CornerEnlarge, 0, fWidth, m_fCXBorder);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Top;
- }
- rt.Set(m_fCYBorder + FWL_CornerEnlarge, m_rtRelative.height - m_fCXBorder,
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::Right;
+ rt.Set(m_fCYBorder + kCornerEnlarge, 0, fWidth, m_fCXBorder);
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::Top;
+ rt.Set(m_fCYBorder + kCornerEnlarge, m_rtRelative.height - m_fCXBorder,
fWidth, m_fCXBorder);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Bottom;
- }
- rt.Set(0, 0, m_fCYBorder + FWL_CornerEnlarge,
- m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_LeftTop;
- }
- rt.Set(0, m_rtRelative.height - m_fCXBorder - FWL_CornerEnlarge,
- m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_LeftBottom;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder - FWL_CornerEnlarge, 0,
- m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_RightTop;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder - FWL_CornerEnlarge,
- m_rtRelative.height - m_fCXBorder - FWL_CornerEnlarge,
- m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_RightBottom;
- }
- }
- return FWL_WGTHITTEST_Client;
-}
-FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::Bottom;
+ rt.Set(0, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::LeftTop;
+ rt.Set(0, m_rtRelative.height - m_fCXBorder - kCornerEnlarge,
+ m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::LeftBottom;
+ rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 0,
+ m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::RightTop;
+ rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge,
+ m_rtRelative.height - m_fCXBorder - kCornerEnlarge,
+ m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::RightBottom;
+ }
+ return FWL_WidgetHit::Client;
+}
+FWL_Error CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
FX_BOOL bInactive = !IsActive();
- int32_t iState =
- bInactive ? FWL_PARTSTATE_FRM_Inactive : FWL_PARTSTATE_FRM_Normal;
+ int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal;
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) {
DrawBackground(pGraphics, pTheme);
}
#ifdef FWL_UseMacSystemBorder
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
#endif
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
@@ -286,33 +273,33 @@ FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
param.m_matrix.Concat(*pMatrix);
}
if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
- param.m_iPart = FWL_PART_FRM_Border;
+ param.m_iPart = CFWL_Part::Border;
pTheme->DrawBackground(&param);
}
if ((m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_EdgeMask) !=
FWL_WGTSTYLE_EdgeNone) {
CFX_RectF rtEdge;
GetEdgeRect(rtEdge);
- param.m_iPart = FWL_PART_FRM_Edge;
+ param.m_iPart = CFWL_Part::Edge;
param.m_rtPart = rtEdge;
param.m_dwStates = iState;
pTheme->DrawBackground(&param);
}
if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
- param.m_iPart = FWL_PART_FRM_Caption;
+ param.m_iPart = CFWL_Part::Caption;
param.m_dwStates = iState;
param.m_rtPart = m_rtCaption;
pTheme->DrawBackground(&param);
DrawCaptionText(pGraphics, pTheme, pMatrix);
} else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
- param.m_iPart = FWL_PART_FRM_NarrowCaption;
+ param.m_iPart = CFWL_Part::NarrowCaption;
param.m_dwStates = iState;
param.m_rtPart = m_rtCaption;
pTheme->DrawBackground(&param);
DrawCaptionText(pGraphics, pTheme, pMatrix);
}
if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) {
- param.m_iPart = FWL_PART_FRM_Icon;
+ param.m_iPart = CFWL_Part::Icon;
if (HasIcon()) {
DrawIconImage(pGraphics, pTheme, pMatrix);
}
@@ -320,35 +307,35 @@ FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
#if (_FX_OS_ == _FX_MACOSX_)
{
if (m_pCloseBox) {
- param.m_iPart = FWL_PART_FRM_CloseBox;
+ param.m_iPart = CFWL_Part::CloseBox;
param.m_dwStates = m_pCloseBox->GetPartState();
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
+ param.m_dwStates = CFWL_PartState_Disabled;
+ } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) {
+ param.m_dwStates = CFWL_PartState_Hovered;
}
param.m_rtPart = m_pCloseBox->m_rtBtn;
pTheme->DrawBackground(&param);
}
if (m_pMaxBox) {
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
+ param.m_iPart = CFWL_Part::MaximizeBox;
param.m_dwStates = m_pMaxBox->GetPartState();
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
+ param.m_dwStates = CFWL_PartState_Disabled;
+ } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) {
+ param.m_dwStates = CFWL_PartState_Hovered;
}
param.m_rtPart = m_pMaxBox->m_rtBtn;
- param.m_dwData = m_bMaximized;
+ param.m_bMaximize = m_bMaximized;
pTheme->DrawBackground(&param);
}
if (m_pMinBox) {
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
+ param.m_iPart = CFWL_Part::MinimizeBox;
param.m_dwStates = m_pMinBox->GetPartState();
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
+ param.m_dwStates = CFWL_PartState_Disabled;
+ } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) {
+ param.m_dwStates = CFWL_PartState_Hovered;
}
param.m_rtPart = m_pMinBox->m_rtBtn;
pTheme->DrawBackground(&param);
@@ -358,42 +345,44 @@ FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
#else
{
if (m_pCloseBox) {
- param.m_iPart = FWL_PART_FRM_CloseBox;
+ param.m_iPart = CFWL_Part::CloseBox;
param.m_dwStates = m_pCloseBox->GetPartState();
param.m_rtPart = m_pCloseBox->m_rtBtn;
pTheme->DrawBackground(&param);
}
if (m_pMaxBox) {
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
+ param.m_iPart = CFWL_Part::MaximizeBox;
param.m_dwStates = m_pMaxBox->GetPartState();
param.m_rtPart = m_pMaxBox->m_rtBtn;
- param.m_dwData = m_bMaximized;
+ param.m_bMaximize = m_bMaximized;
pTheme->DrawBackground(&param);
}
if (m_pMinBox) {
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
+ param.m_iPart = CFWL_Part::MinimizeBox;
param.m_dwStates = m_pMinBox->GetPartState();
param.m_rtPart = m_pMinBox->m_rtBtn;
pTheme->DrawBackground(&param);
}
}
#endif
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FWL_FORMSIZE CFWL_FormImp::GetFormSize() {
return m_eFormSize;
}
-FWL_ERR CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize) {
+FWL_Error CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize) {
m_eFormSize = eFormSize;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
IFWL_Widget* CFWL_FormImp::DoModal() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return NULL;
- IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
+ return nullptr;
+
+ CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
if (!pDriver)
- return NULL;
+ return nullptr;
+
m_pNoteLoop = new CFWL_NoteLoop(this);
pDriver->PushNoteLoop(m_pNoteLoop);
m_bDoModalFlag = TRUE;
@@ -410,35 +399,37 @@ IFWL_Widget* CFWL_FormImp::DoModal() {
IFWL_Widget* CFWL_FormImp::DoModal(uint32_t& dwCommandID) {
return DoModal();
}
-FWL_ERR CFWL_FormImp::EndDoModal() {
+FWL_Error CFWL_FormImp::EndDoModal() {
if (!m_pNoteLoop)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
m_bDoModalFlag = FALSE;
#if (_FX_OS_ == _FX_MACOSX_)
m_pNoteLoop->EndModalLoop();
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return FWL_ERR_Indefinite;
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
+ return FWL_Error::Indefinite;
+
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
if (!pDriver)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
pDriver->PopNoteLoop();
SetStates(FWL_WGTSTATE_Invisible, TRUE);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
#else
SetStates(FWL_WGTSTATE_Invisible, TRUE);
return m_pNoteLoop->EndModalLoop();
#endif
}
-FWL_ERR CFWL_FormImp::SetBorderRegion(CFX_Path* pPath) {
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_FormImp::SetBorderRegion(CFX_Path* pPath) {
+ return FWL_Error::Succeeded;
}
void CFWL_FormImp::DrawBackground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Background;
+ param.m_iPart = CFWL_Part::Background;
param.m_pGraphics = pGraphics;
param.m_rtPart = m_rtRelative;
param.m_rtPart.Deflate(m_fCYBorder, m_rtCaption.height, m_fCYBorder,
@@ -451,20 +442,7 @@ CFWL_WidgetImp* CFWL_FormImp::GetSubFocus() {
void CFWL_FormImp::SetSubFocus(CFWL_WidgetImp* pWidget) {
m_pSubFocus = pWidget;
}
-CFX_MapAccelerators& CFWL_FormImp::GetAccelerator() {
- return m_mapAccelerators;
-}
-void CFWL_FormImp::SetAccelerator(CFX_MapAccelerators* pAccelerators) {
- if (!pAccelerators)
- return;
- m_mapAccelerators.RemoveAll();
- uint32_t vrKey, rValue;
- FX_POSITION pos = pAccelerators->GetStartPosition();
- while (pos) {
- pAccelerators->GetNextAssoc(pos, vrKey, rValue);
- m_mapAccelerators.SetAt(vrKey, rValue);
- }
-}
+
void CFWL_FormImp::ShowChildWidget(IFWL_Widget* pParent) {
IFWL_App* pApp = FWL_GetApp();
if (!pApp)
@@ -476,30 +454,23 @@ void CFWL_FormImp::ShowChildWidget(IFWL_Widget* pParent) {
IFWL_Widget* pChild =
pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
while (pChild) {
- pWidgetMgr->ShowWidget_Native(pChild);
ShowChildWidget(pChild);
pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling);
}
}
+
void CFWL_FormImp::RemoveSysButtons() {
m_rtCaption.Reset();
- if (m_pCloseBox) {
- delete m_pCloseBox;
- m_pCloseBox = NULL;
- }
- if (m_pMinBox) {
- delete m_pMinBox;
- m_pMinBox = NULL;
- }
- if (m_pMaxBox) {
- delete m_pMaxBox;
- m_pMaxBox = NULL;
- }
- if (m_pCaptionBox) {
- delete m_pCaptionBox;
- m_pCaptionBox = NULL;
- }
+ delete m_pCloseBox;
+ m_pCloseBox = nullptr;
+ delete m_pMinBox;
+ m_pMinBox = nullptr;
+ delete m_pMaxBox;
+ m_pMaxBox = nullptr;
+ delete m_pCaptionBox;
+ m_pCaptionBox = nullptr;
}
+
void CFWL_FormImp::CalcContentRect(CFX_RectF& rtContent) {
#ifdef FWL_UseMacSystemBorder
rtContent = m_rtRelative;
@@ -542,42 +513,43 @@ CFWL_SysBtn* CFWL_FormImp::GetSysBtnByState(uint32_t dwState) {
return NULL;
}
CFWL_SysBtn* CFWL_FormImp::GetSysBtnByIndex(int32_t nIndex) {
- if (nIndex < 0) {
- return NULL;
- }
- CFX_PtrArray arrBtn;
- if (m_pMinBox) {
+ if (nIndex < 0)
+ return nullptr;
+
+ CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn;
+ if (m_pMinBox)
arrBtn.Add(m_pMinBox);
- }
- if (m_pMaxBox) {
+
+ if (m_pMaxBox)
arrBtn.Add(m_pMaxBox);
- }
- if (m_pCloseBox) {
+
+ if (m_pCloseBox)
arrBtn.Add(m_pCloseBox);
- }
- return static_cast<CFWL_SysBtn*>(arrBtn[nIndex]);
+
+ return arrBtn[nIndex];
}
int32_t CFWL_FormImp::GetSysBtnIndex(CFWL_SysBtn* pBtn) {
- CFX_PtrArray arrBtn;
- if (m_pMinBox) {
+ CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn;
+ if (m_pMinBox)
arrBtn.Add(m_pMinBox);
- }
- if (m_pMaxBox) {
+
+ if (m_pMaxBox)
arrBtn.Add(m_pMaxBox);
- }
- if (m_pCloseBox) {
+
+ if (m_pCloseBox)
arrBtn.Add(m_pCloseBox);
- }
+
return arrBtn.Find(pBtn);
}
FX_FLOAT CFWL_FormImp::GetCaptionHeight() {
- uint32_t dwCapacity = 0;
+ CFWL_WidgetCapacity dwCapacity = CFWL_WidgetCapacity::None;
+
if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
- dwCapacity = FWL_WGTCAPACITY_FRM_CYCaption;
+ dwCapacity = CFWL_WidgetCapacity::CYCaption;
} else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
- dwCapacity = FWL_WGTCAPACITY_FRM_CYNarrowCaption;
+ dwCapacity = CFWL_WidgetCapacity::CYNarrowCaption;
}
- if (dwCapacity > 0) {
+ if (dwCapacity != CFWL_WidgetCapacity::None) {
FX_FLOAT* pfCapHeight =
static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity));
return pfCapHeight ? *pfCapHeight : 0;
@@ -595,8 +567,8 @@ void CFWL_FormImp::DrawCaptionText(CFX_Graphics* pGs,
}
CFWL_ThemeText textParam;
textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_FRM_Caption;
- textParam.m_dwStates = FWL_PARTSTATE_FRM_Normal;
+ textParam.m_iPart = CFWL_Part::Caption;
+ textParam.m_dwStates = CFWL_PartState_Normal;
textParam.m_pGraphics = pGs;
if (pMatrix) {
textParam.m_matrix.Concat(*pMatrix);
@@ -625,7 +597,7 @@ void CFWL_FormImp::DrawIconImage(CFX_Graphics* pGs,
static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Icon;
+ param.m_iPart = CFWL_Part::Icon;
param.m_pGraphics = pGs;
param.m_pImage = pData->GetIcon(m_pInterface, FALSE);
param.m_rtPart = m_rtIcon;
@@ -648,7 +620,6 @@ void CFWL_FormImp::SetWorkAreaRect() {
if (!pWidgetMgr)
return;
m_bSetMaximize = TRUE;
- pWidgetMgr->SetMaximize_Native(m_pInterface);
Repaint(&m_rtRelative);
}
void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {}
@@ -657,18 +628,12 @@ void CFWL_FormImp::Layout() {
#ifndef FWL_UseMacSystemBorder
ReSetSysBtn();
#endif
- if (m_pContent) {
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- m_pContent->SetWidgetRect(rtClient);
- m_pContent->Update();
- }
}
void CFWL_FormImp::ReSetSysBtn() {
m_fCXBorder =
- *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_CXBorder));
+ *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder));
m_fCYBorder =
- *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_CYBorder));
+ *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder));
RemoveSysButtons();
IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
m_bCustomizeLayout = pTheme->IsCustomizedLayout(m_pInterface);
@@ -683,12 +648,12 @@ void CFWL_FormImp::ReSetSysBtn() {
if (m_bCustomizeLayout) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_CloseBox;
+ param.m_iPart = CFWL_Part::CloseBox;
pTheme->GetPartRect(&param, m_pCloseBox->m_rtBtn);
} else {
m_pCloseBox->m_rtBtn.Set(
- m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize,
+ kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize);
}
m_iSysBox++;
}
@@ -697,17 +662,17 @@ void CFWL_FormImp::ReSetSysBtn() {
if (m_bCustomizeLayout) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
+ param.m_iPart = CFWL_Part::MaximizeBox;
pTheme->GetPartRect(&param, m_pMaxBox->m_rtBtn);
} else {
if (m_pCloseBox) {
m_pMaxBox->m_rtBtn.Set(
- m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pCloseBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize,
+ m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize);
} else {
m_pMaxBox->m_rtBtn.Set(
- m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize,
+ kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize);
}
}
m_iSysBox++;
@@ -717,21 +682,21 @@ void CFWL_FormImp::ReSetSysBtn() {
if (m_bCustomizeLayout) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
+ param.m_iPart = CFWL_Part::MinimizeBox;
pTheme->GetPartRect(&param, m_pMinBox->m_rtBtn);
} else {
if (m_pMaxBox) {
m_pMinBox->m_rtBtn.Set(
- m_pMaxBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pMaxBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ m_pMaxBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize,
+ m_pMaxBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize);
} else if (m_pCloseBox) {
m_pMinBox->m_rtBtn.Set(
- m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pCloseBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize,
+ m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize);
} else {
m_pMinBox->m_rtBtn.Set(
- m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
+ m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize,
+ kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize);
}
}
m_iSysBox++;
@@ -743,7 +708,7 @@ void CFWL_FormImp::ReSetSysBtn() {
if (m_bCustomizeLayout) {
CFWL_ThemeBackground param;
param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Icon;
+ param.m_iPart = CFWL_Part::Icon;
CFX_WideString wsText;
m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsText);
param.m_pData = &wsText;
@@ -756,29 +721,33 @@ void CFWL_FormImp::ReSetSysBtn() {
if (m_bCustomizeLayout) {
CFWL_ThemeText parma;
parma.m_pWidget = m_pInterface;
- parma.m_iPart = FWL_PART_FRM_HeadText;
+ parma.m_iPart = CFWL_Part::HeadText;
m_pProperties->m_pDataProvider->GetCaption(m_pInterface, parma.m_wsText);
pTheme->GetPartRect(&parma, m_rtCaptionText);
}
}
void CFWL_FormImp::RegisterForm() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
return;
+
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
if (!pDriver)
return;
+
pDriver->RegisterForm(this);
}
void CFWL_FormImp::UnRegisterForm() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
return;
+
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
if (!pDriver)
return;
+
pDriver->UnRegisterForm(this);
}
FX_BOOL CFWL_FormImp::IsDoModal() {
@@ -786,9 +755,9 @@ FX_BOOL CFWL_FormImp::IsDoModal() {
}
void CFWL_FormImp::SetThemeData() {
m_fSmallIconSz =
- *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FRM_SmallIcon));
+ *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::SmallIcon));
m_fBigIconSz =
- *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FRM_BigIcon));
+ *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::BigIcon));
}
FX_BOOL CFWL_FormImp::HasIcon() {
IFWL_FormDP* pData =
@@ -803,14 +772,10 @@ void CFWL_FormImp::UpdateIcon() {
static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
CFX_DIBitmap* pBigIcon = pData->GetIcon(m_pInterface, TRUE);
CFX_DIBitmap* pSmallIcon = pData->GetIcon(m_pInterface, FALSE);
- if (pBigIcon && pBigIcon != m_pBigIcon) {
+ if (pBigIcon)
m_pBigIcon = pBigIcon;
- pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, TRUE);
- }
- if (pSmallIcon && pSmallIcon != m_pSmallIcon) {
+ if (pSmallIcon)
m_pSmallIcon = pSmallIcon;
- pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, FALSE);
- }
}
void CFWL_FormImp::UpdateCaption() {
CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
@@ -822,7 +787,6 @@ void CFWL_FormImp::UpdateCaption() {
return;
CFX_WideString text;
pData->GetCaption(m_pInterface, text);
- pWidgetMgr->SetWidgetCaption_Native(m_pInterface, text.AsWideStringC());
}
void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft,
FX_FLOAT& fWidth,
@@ -873,143 +837,144 @@ void CFWL_FormImp::DoHeightLimit(FX_FLOAT& fTop,
}
}
}
+
CFWL_FormImpDelegate::CFWL_FormImpDelegate(CFWL_FormImp* pOwner)
: m_pOwner(pOwner) {}
-int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
#ifdef FWL_UseMacSystemBorder
+void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
+ return;
+
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::Activate: {
m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
m_pOwner->Repaint(&m_pOwner->m_rtRelative);
break;
}
- case FWL_MSGHASH_Deactivate: {
+ case CFWL_MessageType::Deactivate: {
m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
m_pOwner->Repaint(&m_pOwner->m_rtRelative);
break;
}
+ default:
+ break;
}
- return FWL_ERR_Succeeded;
+}
#else
+void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
- uint32_t dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
+ return;
+
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::Activate: {
m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread();
+ IFWL_App* pApp = m_pOwner->GetOwnerApp();
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus();
IFWL_Widget* pSubFocus =
- pSubFocusImp ? pSubFocusImp->GetInterface() : NULL;
- if (pSubFocus && pSubFocus != pDriver->GetFocus()) {
+ pSubFocusImp ? pSubFocusImp->GetInterface() : nullptr;
+ if (pSubFocus && pSubFocus != pDriver->GetFocus())
pDriver->SetFocus(pSubFocus);
- }
+
m_pOwner->Repaint(&m_pOwner->m_rtRelative);
break;
}
- case FWL_MSGHASH_Deactivate: {
+ case CFWL_MessageType::Deactivate: {
m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
- IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread();
+ IFWL_App* pApp = m_pOwner->GetOwnerApp();
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus();
IFWL_Widget* pSubFocus =
- pSubFocusImp ? pSubFocusImp->GetInterface() : NULL;
+ pSubFocusImp ? pSubFocusImp->GetInterface() : nullptr;
if (pSubFocus) {
if (pSubFocus == pDriver->GetFocus()) {
- pDriver->SetFocus(NULL);
+ pDriver->SetFocus(nullptr);
} else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) {
CFWL_MsgKillFocus ms;
- IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(NULL);
- if (pDelegate) {
+ IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(nullptr);
+ if (pDelegate)
pDelegate->OnProcessMessage(&ms);
- }
}
}
m_pOwner->Repaint(&m_pOwner->m_rtRelative);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown: {
OnLButtonDown(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp: {
OnLButtonUp(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseMove: {
+ case FWL_MouseCommand::Move: {
OnMouseMove(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseHover: {
+ case FWL_MouseCommand::Hover: {
OnMouseHover(pMsg);
break;
}
- case FWL_MSGMOUSECMD_MouseLeave: {
+ case FWL_MouseCommand::Leave: {
OnMouseLeave(pMsg);
break;
}
- case FWL_MSGMOUSECMD_LButtonDblClk: {
+ case FWL_MouseCommand::LeftButtonDblClk: {
OnLButtonDblClk(pMsg);
break;
}
+ default:
+ break;
}
break;
}
- case FWL_MSGHASH_Size: {
+ case CFWL_MessageType::Size: {
CFWL_WidgetMgr* pWidgetMgr =
static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
if (!pWidgetMgr)
- return 0;
+ return;
+
pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface);
- if (!m_pOwner->m_bSetMaximize) {
+ if (!m_pOwner->m_bSetMaximize)
break;
- }
+
m_pOwner->m_bSetMaximize = FALSE;
CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage);
- CFX_RectF rt;
- pWidgetMgr->GetWidgetRect_Native(m_pOwner->m_pInterface, rt);
- m_pOwner->m_pProperties->m_rtWidget.left = rt.left;
- m_pOwner->m_pProperties->m_rtWidget.top = rt.top;
+ m_pOwner->m_pProperties->m_rtWidget.left = 0;
+ m_pOwner->m_pProperties->m_rtWidget.top = 0;
m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth;
m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight;
m_pOwner->Update();
break;
}
- case FWL_MSGHASH_WindowMove: {
+ case CFWL_MessageType::WindowMove: {
OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage));
break;
}
- case FWL_MSGHASH_Close: {
+ case CFWL_MessageType::Close: {
OnClose(static_cast<CFWL_MsgClose*>(pMessage));
break;
}
- default: { iRet = 0; }
- }
- return iRet;
-#endif
-}
-FWL_ERR CFWL_FormImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- if (!pEvent)
- return FWL_ERR_Indefinite;
- if (pEvent->GetClassID() == FWL_EVTHASH_Close &&
- pEvent->m_pSrcTarget == m_pOwner->m_pInterface) {
+ default: {
+ break;
+ }
}
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
+#endif // FWL_UseMacSystemBorder
+
+void CFWL_FormImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
+
+void CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOwner->DrawWidget(pGraphics, pMatrix);
}
+
void CFWL_FormImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
m_pOwner->SetGrab(TRUE);
m_pOwner->m_bLButtonDown = TRUE;
@@ -1019,7 +984,8 @@ void CFWL_FormImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
CFX_RectF rtCap;
rtCap.Set(m_pOwner->m_rtCaption.left + m_pOwner->m_fCYBorder,
m_pOwner->m_rtCaption.top + m_pOwner->m_fCXBorder,
- m_pOwner->m_rtCaption.width - FWL_SYSBTNSIZE * m_pOwner->m_iSysBox -
+ m_pOwner->m_rtCaption.width -
+ kSystemButtonSize * m_pOwner->m_iSysBox -
2 * m_pOwner->m_fCYBorder,
m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder);
if (pPressBtn) {
@@ -1060,13 +1026,7 @@ void CFWL_FormImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
m_pOwner->Update();
}
m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized;
- } else if (pPressedBtn == m_pOwner->m_pMinBox) {
- CFWL_WidgetMgr* pWidgetMgr =
- static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return;
- pWidgetMgr->SetMinimize_Native(m_pOwner->m_pInterface);
- } else {
+ } else if (pPressedBtn != m_pOwner->m_pMinBox) {
CFWL_EvtClose eClose;
eClose.m_pSrcTarget = m_pOwner->m_pInterface;
m_pOwner->DispatchEvent(&eClose);
@@ -1144,14 +1104,13 @@ void CFWL_FormImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
pHover->SetNormal();
m_pOwner->Repaint(&pHover->m_rtBtn);
}
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave &&
- !m_pOwner->m_bLButtonDown) {
+ if (pMsg->m_dwCmd == FWL_MouseCommand::Leave && !m_pOwner->m_bLButtonDown) {
m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
}
}
void CFWL_FormImpDelegate::OnLButtonDblClk(CFWL_MsgMouse* pMsg) {
if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
- m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WGTHITTEST_Titlebar) {
+ m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) {
if (m_pOwner->m_bMaximized) {
m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore);
} else {
@@ -1170,10 +1129,3 @@ void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) {
eClose.m_pSrcTarget = m_pOwner->m_pInterface;
m_pOwner->DispatchEvent(&eClose);
}
-FWL_ERR FWL_Accelerator_SetForm(IFWL_Form* pFrom,
- CFX_MapAccelerators* pMapAccel) {
- CFWL_FormImp* pImp = static_cast<CFWL_FormImp*>(pFrom->GetImpl());
- if (!pImp)
- return FWL_ERR_Indefinite;
- return FWL_ERR_Succeeded;
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.h
index fbfdfae271d..9d2d394d036 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_formimp.h
@@ -7,7 +7,6 @@
#ifndef XFA_FWL_CORE_FWL_FORMIMP_H_
#define XFA_FWL_CORE_FWL_FORMIMP_H_
-#include "xfa/fwl/core/fwl_panelimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_form.h"
@@ -25,6 +24,7 @@ class CFWL_FormImpDelegate;
#define FWL_SYSBUTTONSTATE_Hover 0x0001
#define FWL_SYSBUTTONSTATE_Pressed 0x0002
#define FWL_SYSBUTTONSTATE_Disabled 0x0010
+
class CFWL_SysBtn {
public:
CFWL_SysBtn() {
@@ -32,9 +32,8 @@ class CFWL_SysBtn {
m_dwState = 0;
}
- FX_BOOL IsHover() { return m_dwState & FWL_SYSBUTTONSTATE_Hover; }
- FX_BOOL IsPressed() { return m_dwState & FWL_SYSBUTTONSTATE_Pressed; }
- FX_BOOL IsDisabled() { return m_dwState & FWL_SYSBUTTONSTATE_Disabled; }
+ bool IsDisabled() { return !!(m_dwState & FWL_SYSBUTTONSTATE_Disabled); }
+
void SetNormal() { m_dwState &= 0xFFF0; }
void SetPressed() {
SetNormal();
@@ -49,56 +48,51 @@ class CFWL_SysBtn {
: m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled;
}
int32_t GetPartState() {
- return (IsDisabled() ? FWL_PARTSTATE_FRM_Disabled : (m_dwState + 1));
+ return (IsDisabled() ? CFWL_PartState_Disabled : (m_dwState + 1));
}
CFX_RectF m_rtBtn;
uint32_t m_dwState;
};
+
enum FORM_RESIZETYPE {
FORM_RESIZETYPE_None = 0,
FORM_RESIZETYPE_Cap,
- FORM_RESIZETYPE_Left,
- FORM_RESIZETYPE_Top,
- FORM_RESIZETYPE_Right,
- FORM_RESIZETYPE_Bottom,
- FORM_RESIZETYPE_LeftTop,
- FORM_RESIZETYPE_LeftBottom,
- FORM_RESIZETYPE_RightTop,
- FORM_RESIZETYPE_RightBottom
};
+
typedef struct RestoreResizeInfo {
CFX_PointF m_ptStart;
CFX_SizeF m_szStart;
} RestoreInfo;
-class CFWL_FormImp : public CFWL_PanelImp {
+
+class CFWL_FormImp : public CFWL_WidgetImp {
public:
CFWL_FormImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
- virtual ~CFWL_FormImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR GetClientRect(CFX_RectF& rect);
- virtual FWL_ERR Update();
- virtual uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FWL_FORMSIZE GetFormSize();
- virtual FWL_ERR SetFormSize(FWL_FORMSIZE eFormSize);
- virtual IFWL_Widget* DoModal();
- virtual IFWL_Widget* DoModal(uint32_t& dwCommandID);
- virtual FWL_ERR EndDoModal();
- virtual FWL_ERR SetBorderRegion(CFX_Path* pPath);
- virtual void DrawBackground(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme);
+ ~CFWL_FormImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error GetClientRect(CFX_RectF& rect) override;
+ FWL_Error Update() override;
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+
+ FWL_FORMSIZE GetFormSize();
+ FWL_Error SetFormSize(FWL_FORMSIZE eFormSize);
+ IFWL_Widget* DoModal();
+ IFWL_Widget* DoModal(uint32_t& dwCommandID);
+ FWL_Error EndDoModal();
+ FWL_Error SetBorderRegion(CFX_Path* pPath);
+ void DrawBackground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme);
CFWL_WidgetImp* GetSubFocus();
void SetSubFocus(CFWL_WidgetImp* pWidget);
- CFX_MapAccelerators& GetAccelerator();
- void SetAccelerator(CFX_MapAccelerators* pAccelerators);
protected:
void ShowChildWidget(IFWL_Widget* pParent);
@@ -141,7 +135,7 @@ class CFWL_FormImp : public CFWL_PanelImp {
FX_FLOAT fLimitMin,
FX_FLOAT fLimitMax,
FX_BOOL bTop);
- CFX_MapAccelerators m_mapAccelerators;
+
CFX_RectF m_rtRestore;
CFX_RectF m_rtCaptionText;
CFX_RectF m_rtRelative;
@@ -172,13 +166,14 @@ class CFWL_FormImp : public CFWL_PanelImp {
FX_BOOL m_bMouseIn;
friend class CFWL_FormImpDelegate;
};
+
class CFWL_FormImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_FormImpDelegate(CFWL_FormImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
protected:
void OnLButtonDown(CFWL_MsgMouse* pMsg);
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_gridimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_gridimp.cpp
deleted file mode 100644
index 77e4c245cd0..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_gridimp.cpp
+++ /dev/null
@@ -1,1382 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/core/fwl_gridimp.h"
-
-#include "xfa/fwl/core/cfwl_message.h"
-#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
-#include "xfa/fwl/core/fwl_contentimp.h"
-#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
-#include "xfa/fwl/core/fwl_widgetimp.h"
-#include "xfa/fxgraphics/cfx_color.h"
-#include "xfa/fxgraphics/cfx_path.h"
-
-// static
-IFWL_Grid* IFWL_Grid::Create(const CFWL_WidgetImpProperties& properties) {
- IFWL_Grid* pGrid = new IFWL_Grid;
- CFWL_GridImp* pGridImpl = new CFWL_GridImp(properties, nullptr);
- pGrid->SetImpl(pGridImpl);
- pGridImpl->SetInterface(pGrid);
- return pGrid;
-}
-IFWL_Grid::IFWL_Grid() {}
-FWL_HGRIDCOLROW IFWL_Grid::InsertColRow(FX_BOOL bColumn, int32_t nIndex) {
- return static_cast<CFWL_GridImp*>(GetImpl())->InsertColRow(bColumn, nIndex);
-}
-int32_t IFWL_Grid::CountColRows(FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())->CountColRows(bColumn);
-}
-FWL_HGRIDCOLROW IFWL_Grid::GetColRow(FX_BOOL bColumn, int32_t nIndex) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetColRow(bColumn, nIndex);
-}
-int32_t IFWL_Grid::GetIndex(FWL_HGRIDCOLROW hColRow) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetIndex(hColRow);
-}
-FX_FLOAT IFWL_Grid::GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->SetSize(hColRow, fSize, eUnit);
-}
-FX_FLOAT IFWL_Grid::GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetMinSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetMinSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetMinSize(hColRow, fSize, eUnit);
-}
-FX_FLOAT IFWL_Grid::GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetMaxSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetMaxSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetMaxSize(hColRow, fSize, eUnit);
-}
-FX_BOOL IFWL_Grid::DeleteColRow(FWL_HGRIDCOLROW hColRow) {
- return static_cast<CFWL_GridImp*>(GetImpl())->DeleteColRow(hColRow);
-}
-FX_BOOL IFWL_Grid::IsColumn(FWL_HGRIDCOLROW hColRow) {
- return static_cast<CFWL_GridImp*>(GetImpl())->IsColumn(hColRow);
-}
-int32_t IFWL_Grid::GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetWidgetPos(pWidget, bColumn);
-}
-FWL_ERR IFWL_Grid::SetWidgetPos(IFWL_Widget* pWidget,
- int32_t iPos,
- FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetWidgetPos(pWidget, iPos, bColumn);
-}
-int32_t IFWL_Grid::GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetWidgetSpan(pWidget, bColumn);
-}
-FWL_ERR IFWL_Grid::SetWidgetSpan(IFWL_Widget* pWidget,
- int32_t iSpan,
- FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetWidgetSpan(pWidget, iSpan, bColumn);
-}
-FX_FLOAT IFWL_Grid::GetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->GetWidgetSize(pWidget, eSize, eUnit);
-}
-FWL_ERR IFWL_Grid::SetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetWidgetSize(pWidget, eSize, fSize, eUit);
-}
-FX_BOOL IFWL_Grid::GetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT& fMargin) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->GetWidgetMargin(pWidget, eMargin, fMargin);
-}
-FWL_ERR IFWL_Grid::SetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT fMargin) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetWidgetMargin(pWidget, eMargin, fMargin);
-}
-FWL_ERR IFWL_Grid::RemoveWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->RemoveWidgetMargin(pWidget, eMargin);
-}
-FX_FLOAT IFWL_Grid::GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetGridSize(eSize, eUnit);
-}
-FWL_ERR IFWL_Grid::SetGridSize(FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->SetGridSize(eSize, fSize, eUit);
-}
-
-CFWL_GridImp::CFWL_GridImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_ContentImp(properties, pOuter) {
- m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Width].fLength = 0;
- m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Height].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
-}
-CFWL_GridImp::~CFWL_GridImp() {
- int32_t iCount = m_Columns.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- delete static_cast<CFWL_GridColRow*>(m_Columns[i]);
- }
- m_Columns.RemoveAll();
- iCount = m_Rows.GetSize();
- for (int32_t j = 0; j < iCount; j++) {
- delete static_cast<CFWL_GridColRow*>(m_Rows[j]);
- }
- m_Rows.RemoveAll();
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget;
- CFWL_GridWidgetInfo* pInfo;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- delete pInfo;
- }
- m_mapWidgetInfo.RemoveAll();
- delete m_pDelegate;
- m_pDelegate = nullptr;
-}
-FWL_ERR CFWL_GridImp::GetClassName(CFX_WideString& wsClass) const {
- wsClass = FWL_CLASS_Grid;
- return FWL_ERR_Succeeded;
-}
-uint32_t CFWL_GridImp::GetClassID() const {
- return FWL_CLASSHASH_Grid;
-}
-FWL_ERR CFWL_GridImp::Initialize() {
- if (CFWL_ContentImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
- m_pDelegate = new CFWL_GridImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::Finalize() {
- if (CFWL_ContentImp::Finalize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
- delete m_pDelegate;
- m_pDelegate = nullptr;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (bAutoSize) {
- rect.left = 0;
- rect.top = 0;
- rect.width = ProcessUnCertainColumns();
- rect.height = ProcessUnCertainRows();
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::SetWidgetRect(const CFX_RectF& rect) {
- CFWL_WidgetImp::SetWidgetRect(rect);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::Update() {
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- ProcessColumns(m_pProperties->m_rtWidget.width);
- ProcessRows(m_pProperties->m_rtWidget.height);
- SetAllWidgetsRect();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- if (!pGraphics)
- return FWL_ERR_Indefinite;
- if ((m_pProperties->m_dwStyleExes & FWL_GRIDSTYLEEXT_ShowGridLines) == 0) {
- return FWL_ERR_Succeeded;
- }
- pGraphics->SaveGraphState();
- if (pMatrix) {
- pGraphics->ConcatMatrix(pMatrix);
- }
- {
- FX_BOOL bDrawLine = FALSE;
- CFX_Path path;
- path.Create();
- int32_t iColumns = m_Columns.GetSize();
- for (int32_t i = 1; i < iColumns; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Columns[i]);
- if (!pColRow) {
- continue;
- }
- bDrawLine = TRUE;
- path.AddLine(pColRow->m_fActualPos, 0, pColRow->m_fActualPos,
- m_pProperties->m_rtWidget.height);
- }
- int32_t iRows = m_Rows.GetSize();
- for (int32_t j = 1; j < iRows; j++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[j]);
- if (!pColRow) {
- continue;
- }
- bDrawLine = TRUE;
- path.AddLine(0, pColRow->m_fActualPos, m_pProperties->m_rtWidget.width,
- pColRow->m_fActualPos);
- }
- if (bDrawLine) {
- CFX_Color cr(0xFFFF0000);
- pGraphics->SetStrokeColor(&cr);
- pGraphics->StrokePath(&path);
- }
- }
- pGraphics->RestoreGraphState();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
- if (!pChild)
- return FWL_ERR_Indefinite;
- CFWL_ContentImp::InsertWidget(pChild, nIndex);
- if (!m_mapWidgetInfo.GetValueAt(pChild)) {
- CFWL_GridWidgetInfo* pInfo = new CFWL_GridWidgetInfo;
- m_mapWidgetInfo.SetAt(pChild, pInfo);
- m_Widgets.Add(pChild);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::RemoveWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FWL_ERR_Indefinite;
- CFWL_ContentImp::RemoveWidget(pWidget);
- if (CFWL_GridWidgetInfo* pInfo = static_cast<CFWL_GridWidgetInfo*>(
- m_mapWidgetInfo.GetValueAt(pWidget))) {
- m_mapWidgetInfo.RemoveKey(pWidget);
- delete pInfo;
- int32_t nIndex = m_Widgets.Find(pWidget);
- m_Widgets.RemoveAt(nIndex, 1);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_HGRIDCOLROW CFWL_GridImp::InsertColRow(FX_BOOL bColumn, int32_t nIndex) {
- if (bColumn) {
- if (nIndex < 0 || nIndex > m_Columns.GetSize()) {
- nIndex = m_Columns.GetSize();
- }
- CFWL_GridColRow* pColumn = new CFWL_GridColRow;
- m_Columns.InsertAt(nIndex, pColumn, 1);
- return (FWL_HGRIDCOLROW)pColumn;
- }
- if (nIndex < 0 || nIndex > m_Rows.GetSize()) {
- nIndex = m_Rows.GetSize();
- }
- CFWL_GridColRow* pRow = new CFWL_GridColRow;
- m_Rows.InsertAt(nIndex, pRow, 1);
- return (FWL_HGRIDCOLROW)pRow;
-}
-int32_t CFWL_GridImp::CountColRows(FX_BOOL bColumn) {
- if (bColumn) {
- return m_Columns.GetSize();
- }
- return m_Rows.GetSize();
-}
-FWL_HGRIDCOLROW CFWL_GridImp::GetColRow(FX_BOOL bColumn, int32_t nIndex) {
- if (bColumn) {
- if (nIndex < 0 || nIndex >= m_Columns.GetSize()) {
- return NULL;
- }
- return (FWL_HGRIDCOLROW)m_Columns[nIndex];
- }
- if (nIndex < 0 || nIndex >= m_Rows.GetSize()) {
- return NULL;
- }
- return (FWL_HGRIDCOLROW)m_Rows[nIndex];
-}
-int32_t CFWL_GridImp::GetIndex(FWL_HGRIDCOLROW hColRow) {
- if (IsColumn(hColRow)) {
- return m_Columns.Find(hColRow);
- }
- return m_Rows.Find(hColRow);
-}
-FX_FLOAT CFWL_GridImp::GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
- if (!hColRow)
- return -1;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- eUnit = pColRow->m_Size.eUnit;
- return pColRow->m_Size.fLength;
-}
-FWL_ERR CFWL_GridImp::SetSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- if (!hColRow)
- return FWL_ERR_Indefinite;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- pColRow->m_Size.eUnit = eUnit;
- pColRow->m_Size.fLength = fSize;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetMinSize(FWL_HGRIDCOLROW hColRow,
- FWL_GRIDUNIT& eUnit) {
- if (!hColRow)
- return -1;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- eUnit = pColRow->m_MinSize.eUnit;
- return pColRow->m_MinSize.fLength;
-}
-FWL_ERR CFWL_GridImp::SetMinSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- if (!hColRow)
- return FWL_ERR_Indefinite;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- pColRow->m_MinSize.eUnit = eUnit;
- pColRow->m_MinSize.fLength = fSize;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetMaxSize(FWL_HGRIDCOLROW hColRow,
- FWL_GRIDUNIT& eUnit) {
- if (!hColRow)
- return -1;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- eUnit = pColRow->m_MaxSize.eUnit;
- return pColRow->m_MaxSize.fLength;
-}
-FWL_ERR CFWL_GridImp::SetMaxSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- if (!hColRow)
- return FWL_ERR_Indefinite;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- pColRow->m_MaxSize.eUnit = eUnit;
- pColRow->m_MaxSize.fLength = fSize;
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_GridImp::DeleteColRow(FWL_HGRIDCOLROW hColRow) {
- int32_t nIndex = m_Columns.Find(hColRow);
- if (nIndex >= 0) {
- m_Columns.RemoveAt(nIndex);
- delete reinterpret_cast<CFWL_GridColRow*>(hColRow);
- return TRUE;
- }
- nIndex = m_Rows.Find(hColRow);
- if (nIndex >= 0) {
- delete reinterpret_cast<CFWL_GridColRow*>(hColRow);
- m_Rows.RemoveAt(nIndex);
- return TRUE;
- }
- return FALSE;
-}
-FX_BOOL CFWL_GridImp::IsColumn(FWL_HGRIDCOLROW hColRow) {
- return m_Columns.Find(hColRow) != -1;
-}
-int32_t CFWL_GridImp::GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- return bColumn ? pInfo->m_iColumn : pInfo->m_iRow;
- }
- return -1;
-}
-FWL_ERR CFWL_GridImp::SetWidgetPos(IFWL_Widget* pWidget,
- int32_t iPos,
- FX_BOOL bColumn) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- bColumn ? pInfo->m_iColumn = iPos : pInfo->m_iRow = iPos;
- }
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_GridImp::GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- return bColumn ? pInfo->m_iColumnSpan : pInfo->m_iRowSpan;
- }
- return 0;
-}
-FWL_ERR CFWL_GridImp::SetWidgetSpan(IFWL_Widget* pWidget,
- int32_t iSpan,
- FX_BOOL bColumn) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- bColumn ? pInfo->m_iColumnSpan = iSpan : pInfo->m_iRowSpan = iSpan;
- }
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FWL_GRIDUNIT& eUnit) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- eUnit = pInfo->m_Size[eSize].eUnit;
- return pInfo->m_Size[eSize].fLength;
- }
- return 0;
-}
-FWL_ERR CFWL_GridImp::SetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- pInfo->m_Size[eSize].fLength = fSize;
- pInfo->m_Size[eSize].eUnit = eUit;
- }
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_GridImp::GetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT& fMargin) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- fMargin = pInfo->m_Margin[eMargin];
- return (pInfo->m_dwMarginFlag & (1 << eMargin)) != 0;
- }
- return FALSE;
-}
-FWL_ERR CFWL_GridImp::SetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT fMargin) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- pInfo->m_Margin[eMargin] = fMargin;
- pInfo->m_dwMarginFlag |= (1 << eMargin);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::RemoveWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- pInfo->m_dwMarginFlag &= ~(1 << eMargin);
- }
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit) {
- eUnit = m_Size[eSize].eUnit;
- return m_Size[eSize].fLength;
-}
-FWL_ERR CFWL_GridImp::SetGridSize(FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit) {
- m_Size[eSize].fLength = fSize;
- m_Size[eSize].eUnit = eUit;
- return FWL_ERR_Succeeded;
-}
-CFWL_GridWidgetInfo* CFWL_GridImp::GetWidgetInfo(IFWL_Widget* pWidget) {
- return static_cast<CFWL_GridWidgetInfo*>(m_mapWidgetInfo.GetValueAt(pWidget));
-}
-void CFWL_GridImp::ProcFixedColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_FLOAT fColRowSize,
- FX_BOOL bColumn) {
- pColRow->m_fActualSize = fColRowSize;
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- void* key = nullptr;
- void* value = nullptr;
- m_mapWidgetInfo.GetNextAssoc(ps, key, value);
- IFWL_Widget* pWidget = static_cast<IFWL_Widget*>(key);
- CFWL_GridWidgetInfo* pInfo = static_cast<CFWL_GridWidgetInfo*>(value);
- if (bColumn) {
- if (pInfo->m_iColumn == nIndex && pInfo->m_iColumnSpan == 1) {
- CalcWidgetWidth(pWidget, pInfo, pColRow->m_fActualSize);
- }
- } else {
- if (pInfo->m_iRow == nIndex && pInfo->m_iRowSpan == 1) {
- CalcWidgetHeigt(pWidget, pInfo, pColRow->m_fActualSize);
- }
- }
- }
-}
-void CFWL_GridImp::ProcAutoColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_BOOL bColumn) {
- if (!pColRow)
- return;
- FX_FLOAT fMaxSize = 0, fWidgetSize = 0;
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pWidget || !pInfo) {
- continue;
- }
- if (bColumn) {
- if (pInfo->m_iColumn != nIndex || pInfo->m_iColumnSpan != 1) {
- continue;
- }
- fWidgetSize = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fMaxSize < fWidgetSize) {
- fMaxSize = fWidgetSize;
- }
- } else {
- if (pInfo->m_iRow != nIndex || pInfo->m_iRowSpan != 1) {
- continue;
- }
- fWidgetSize = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fMaxSize < fWidgetSize) {
- fMaxSize = fWidgetSize;
- }
- }
- }
- SetColRowActualSize(pColRow, fMaxSize);
-}
-void CFWL_GridImp::ProcScaledColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_FLOAT fColRowSize,
- FX_BOOL bColumn) {
- if (fColRowSize > 0) {
- ProcFixedColRow(pColRow, nIndex, fColRowSize, bColumn);
- }
-}
-void CFWL_GridImp::CalcWidgetWidth(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fColunmWidth) {
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
- } else {
- FX_FLOAT fWidth = 0;
- FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- if (bLeftMargin && bRightMargin) {
- fWidth = fColunmWidth - fLeftMargin - fRightMargin;
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- fWidth = rtAuto.Width();
- }
- SetWidgetActualWidth(pInfo, fWidth);
- }
-}
-void CFWL_GridImp::CalcWidgetHeigt(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fRowHeigt) {
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
- } else {
- FX_FLOAT fHeight = 0;
- FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- if (bTopMargin && bBottomMargin) {
- fHeight = fRowHeigt - fTopMargin - fBottomMargin;
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- fHeight = rtAuto.Height();
- }
- SetWidgetActualHeight(pInfo, fHeight);
- }
-}
-FX_FLOAT CFWL_GridImp::CalcAutoColumnWidgetWidth(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo) {
- FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- FX_FLOAT fWidth = rtAuto.width;
- SetWidgetActualWidth(pInfo, fWidth);
- }
- FX_FLOAT fTotal = pInfo->m_fActualWidth;
- if (bLeftMargin) {
- fTotal += fLeftMargin;
- }
- if (bRightMargin) {
- fTotal += fRightMargin;
- }
- return fTotal;
-}
-FX_FLOAT CFWL_GridImp::CalcAutoColumnWidgetHeight(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo) {
- FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- FX_FLOAT fHeight = rtAuto.height;
- SetWidgetActualHeight(pInfo, fHeight);
- }
- FX_FLOAT fTotal = pInfo->m_fActualHeight;
- if (bTopMargin) {
- fTotal += fTopMargin;
- }
- if (bBottomMargin) {
- fTotal += fBottomMargin;
- }
- return fTotal;
-}
-FX_FLOAT CFWL_GridImp::ProcessColumns(FX_FLOAT fWidth) {
- if (fWidth <= 0) {
- return ProcessUnCertainColumns();
- }
- int32_t iColumns = m_Columns.GetSize();
- if (iColumns < 1) {
- return fWidth;
- }
- FX_FLOAT fFixedWidth = 0;
- FX_FLOAT fAutoWidth = 0;
- CFX_PtrArray autoColumns;
- CFX_PtrArray scaledColumns;
- FX_FLOAT fScaledColumnNum = 0;
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Columns[i]);
- if (!pColRow) {
- continue;
- }
- switch (pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedWidth += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, TRUE);
- autoColumns.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- fScaledColumnNum += pColRow->m_Size.fLength;
- scaledColumns.Add(pColRow);
- SetColRowActualSize(pColRow, 0);
- }
- }
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iColumnSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoColumns;
- FX_FLOAT fSpanSize = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) {
- CFWL_GridColRow* pColumn = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(TRUE, pInfo->m_iColumn + i));
- if (!pColumn) {
- break;
- }
- fSpanSize += pColumn->m_fActualSize;
- if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoColumns.Add(pColumn);
- } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- }
- }
- if (iAutoColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fWidgetWidth > fSpanSize) {
- if (iScaledColRows > 0) {
- } else {
- SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize);
- }
- }
- }
- int32_t iAutoCols = autoColumns.GetSize();
- for (int32_t k = 0; k < iAutoCols; k++) {
- fAutoWidth += static_cast<CFWL_GridColRow*>(autoColumns[k])->m_fActualSize;
- }
- FX_FLOAT fScaledWidth = fWidth - fFixedWidth - fAutoWidth;
- if (fScaledWidth > 0 && fScaledColumnNum > 0) {
- SetScaledColRowsSize(scaledColumns, fScaledWidth, fScaledColumnNum);
- }
- return fWidth;
-}
-FX_FLOAT CFWL_GridImp::ProcessRows(FX_FLOAT fHeight) {
- if (fHeight <= 0) {
- return ProcessUnCertainRows();
- }
- int32_t iRows = m_Rows.GetSize();
- if (iRows < 1) {
- return fHeight;
- }
- FX_FLOAT fFixedHeight = 0;
- FX_FLOAT fAutoHeigt = 0;
- CFX_PtrArray autoRows;
- CFX_PtrArray scaledRows;
- FX_FLOAT fScaledRowNum = 0;
- for (int32_t i = 0; i < iRows; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[i]);
- if (!pColRow) {
- continue;
- }
- switch (pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedHeight += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, FALSE);
- autoRows.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- fScaledRowNum += pColRow->m_Size.fLength;
- scaledRows.Add(pColRow);
- SetColRowActualSize(pColRow, 0);
- break;
- }
- }
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iRowSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoRows;
- FX_FLOAT fSpanSize = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) {
- CFWL_GridColRow* pRow = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(FALSE, pInfo->m_iRow + i));
- if (!pRow) {
- break;
- }
- fSpanSize += pRow->m_fActualSize;
- if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoRows.Add(pRow);
- } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- }
- }
- if (iAutoColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fWidgetHeight > fSpanSize) {
- if (iScaledColRows > 0) {
- } else {
- SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize);
- }
- }
- }
- int32_t iAutoRows = autoRows.GetSize();
- for (int32_t k = 0; k < iAutoRows; k++) {
- fAutoHeigt +=
- reinterpret_cast<CFWL_GridColRow*>(autoRows[k])->m_fActualSize;
- }
- FX_FLOAT fScaledHeight = fHeight - fFixedHeight - fAutoHeigt;
- if (fScaledHeight > 0 && fScaledRowNum > 0) {
- SetScaledColRowsSize(scaledRows, fScaledHeight, fScaledRowNum);
- }
- return fHeight;
-}
-FX_FLOAT CFWL_GridImp::ProcessUnCertainColumns() {
- int32_t iColumns = m_Columns.GetSize();
- if (iColumns < 1) {
- CFWL_GridColRow* pColRow = new CFWL_GridColRow;
- pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto;
- ProcAutoColRow(pColRow, 0, TRUE);
- FX_FLOAT fWidth = pColRow->m_fActualSize;
- delete pColRow;
- return fWidth;
- }
- FX_FLOAT fFixedWidth = 0;
- CFX_PtrArray autoColumns;
- CFX_PtrArray scaledColumns;
- FX_FLOAT fScaledColumnNum = 0;
- FX_FLOAT fScaledMaxPerWidth = 0;
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(m_Columns[i]);
- if (!pColRow) {
- continue;
- }
- switch (pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedWidth += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, TRUE);
- autoColumns.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- ProcAutoColRow(pColRow, i, TRUE);
- fScaledColumnNum += pColRow->m_Size.fLength;
- scaledColumns.Add(pColRow);
- if (pColRow->m_Size.fLength <= 0) {
- break;
- }
- FX_FLOAT fPerWidth = pColRow->m_fActualSize / pColRow->m_Size.fLength;
- if (fPerWidth > fScaledMaxPerWidth) {
- fScaledMaxPerWidth = fPerWidth;
- }
- }
- }
- }
- iColumns = scaledColumns.GetSize();
- for (int32_t j = 0; j < iColumns; j++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(scaledColumns[j]);
- if (!pColRow) {
- continue;
- }
- SetColRowActualSize(pColRow, fScaledMaxPerWidth * pColRow->m_Size.fLength);
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iColumnSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoColumns;
- CFX_PtrArray spanScaledColumns;
- FX_FLOAT fSpanSize = 0;
- FX_FLOAT fScaledSum = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) {
- CFWL_GridColRow* pColumn = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(TRUE, pInfo->m_iColumn + i));
- if (!pColumn) {
- break;
- }
- fSpanSize += pColumn->m_fActualSize;
- if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoColumns.Add(pColumn);
- } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- fScaledSum += pColumn->m_Size.fLength;
- spanScaledColumns.Add(pColumn);
- }
- }
- if (iAutoColRows < 1 && iScaledColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fWidgetWidth > fSpanSize) {
- if (iScaledColRows > 0) {
- if (fScaledSum <= 0) {
- continue;
- }
- SetSpanScaledColRowSize(spanScaledColumns, fWidgetWidth - fSpanSize,
- fScaledSum);
- } else {
- SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize);
- }
- }
- }
- FX_FLOAT fAutoWidth = 0;
- int32_t iAutoCols = autoColumns.GetSize();
- for (int32_t m = 0; m < iAutoCols; m++) {
- fAutoWidth += static_cast<CFWL_GridColRow*>(autoColumns[m])->m_fActualSize;
- }
- FX_FLOAT fScaledWidth = 0;
- iColumns = scaledColumns.GetSize();
- for (int32_t n = 0; n < iColumns; n++) {
- fScaledWidth +=
- static_cast<CFWL_GridColRow*>(scaledColumns[n])->m_fActualSize;
- }
- return fFixedWidth + fAutoWidth + fScaledWidth;
-}
-FX_FLOAT CFWL_GridImp::ProcessUnCertainRows() {
- int32_t iRows = m_Rows.GetSize();
- if (iRows < 1) {
- CFWL_GridColRow* pColRow = new CFWL_GridColRow;
- pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto;
- ProcAutoColRow(pColRow, 0, FALSE);
- FX_FLOAT fWidth = pColRow->m_fActualSize;
- delete pColRow;
- return fWidth;
- }
- FX_FLOAT fFixedHeight = 0;
- CFX_PtrArray autoRows;
- CFX_PtrArray scaledRows;
- FX_FLOAT fScaledRowNum = 0;
- FX_FLOAT fScaledMaxPerHeight = 0;
- for (int32_t i = 0; i < iRows; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[i]);
- if (!pColRow) {
- continue;
- }
- switch (pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedHeight += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, FALSE);
- autoRows.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- ProcAutoColRow(pColRow, i, FALSE);
- fScaledRowNum += pColRow->m_Size.fLength;
- scaledRows.Add(pColRow);
- if (pColRow->m_Size.fLength > 0) {
- FX_FLOAT fPerHeight =
- pColRow->m_fActualSize / pColRow->m_Size.fLength;
- if (fPerHeight > fScaledMaxPerHeight) {
- fScaledMaxPerHeight = fPerHeight;
- }
- }
- break;
- }
- }
- }
- iRows = scaledRows.GetSize();
- for (int32_t j = 0; j < iRows; j++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(scaledRows[j]);
- if (!pColRow) {
- continue;
- }
- SetColRowActualSize(pColRow, fScaledMaxPerHeight * pColRow->m_Size.fLength);
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- void* key = nullptr;
- void* value = nullptr;
- m_mapWidgetInfo.GetNextAssoc(ps, key, value);
- IFWL_Widget* pWidget = static_cast<IFWL_Widget*>(key);
- CFWL_GridWidgetInfo* pInfo = static_cast<CFWL_GridWidgetInfo*>(value);
- if (pInfo->m_iRowSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoRows;
- CFX_PtrArray spanScaledRows;
- FX_FLOAT fSpanSize = 0;
- FX_FLOAT fScaledSum = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) {
- CFWL_GridColRow* pRow = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(FALSE, pInfo->m_iRow + i));
- if (!pRow) {
- break;
- }
- fSpanSize += pRow->m_fActualSize;
- if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoRows.Add(pRow);
- } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- fScaledSum += pRow->m_Size.fLength;
- spanScaledRows.Add(pRow);
- }
- }
- if (iAutoColRows < 1 && iScaledColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fWidgetHeight > fSpanSize) {
- if (iScaledColRows > 0) {
- if (fScaledSum <= 0) {
- continue;
- }
- SetSpanScaledColRowSize(spanScaledRows, fWidgetHeight - fSpanSize,
- fScaledSum);
- } else {
- SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize);
- }
- }
- }
- FX_FLOAT fAutoHeigt = 0;
- int32_t iAutoRows = autoRows.GetSize();
- for (int32_t m = 0; m < iAutoRows; m++) {
- fAutoHeigt += static_cast<CFWL_GridColRow*>(autoRows[m])->m_fActualSize;
- }
- FX_FLOAT fScaledHeight = 0;
- iRows = scaledRows.GetSize();
- for (int32_t n = 0; n < iRows; n++) {
- fScaledHeight +=
- static_cast<CFWL_GridColRow*>(scaledRows[n])->m_fActualSize;
- }
- return fFixedHeight + fAutoHeigt + fScaledHeight;
-}
-FX_BOOL CFWL_GridImp::SetColRowActualSize(CFWL_GridColRow* pColRow,
- FX_FLOAT fSize,
- FX_BOOL bSetBeyond) {
- if (pColRow->m_MinSize.eUnit == FWL_GRIDUNIT_Fixed &&
- fSize < pColRow->m_MinSize.fLength) {
- pColRow->m_fActualSize = pColRow->m_MinSize.fLength;
- return FALSE;
- }
- if (pColRow->m_MaxSize.eUnit == FWL_GRIDUNIT_Fixed &&
- fSize > pColRow->m_MaxSize.fLength) {
- pColRow->m_fActualSize = pColRow->m_MaxSize.fLength;
- return FALSE;
- }
- if (bSetBeyond) {
- return TRUE;
- }
- pColRow->m_fActualSize = fSize;
- return TRUE;
-}
-FX_FLOAT CFWL_GridImp::SetWidgetActualWidth(CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fWidth) {
- if (pInfo->m_Size[FWL_GRIDSIZE_MinWidth].eUnit == FWL_GRIDUNIT_Fixed &&
- fWidth < pInfo->m_Size[FWL_GRIDSIZE_MinWidth].fLength) {
- fWidth = pInfo->m_Size[FWL_GRIDSIZE_MinWidth].fLength;
- }
- if (pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].eUnit == FWL_GRIDUNIT_Fixed &&
- fWidth > pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].fLength) {
- fWidth = pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].fLength;
- }
- pInfo->m_fActualWidth = fWidth;
- return fWidth;
-}
-FX_FLOAT CFWL_GridImp::SetWidgetActualHeight(CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fHeight) {
- if (pInfo->m_Size[FWL_GRIDSIZE_MinHeight].eUnit == FWL_GRIDUNIT_Fixed &&
- fHeight < pInfo->m_Size[FWL_GRIDSIZE_MinHeight].fLength) {
- fHeight = pInfo->m_Size[FWL_GRIDSIZE_MinHeight].fLength;
- }
- if (pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].eUnit == FWL_GRIDUNIT_Fixed &&
- fHeight > pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].fLength) {
- fHeight = pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].fLength;
- }
- pInfo->m_fActualHeight = fHeight;
- return fHeight;
-}
-void CFWL_GridImp::SetAllWidgetsRect() {
- FX_FLOAT fStartLeft = 0;
- int32_t iColumns = m_Columns.GetSize();
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Columns[i]);
- if (!pColRow) {
- continue;
- }
- pColRow->m_fActualPos = fStartLeft;
- fStartLeft += pColRow->m_fActualSize;
- }
- FX_FLOAT fStartTop = 0;
- int32_t iRows = m_Rows.GetSize();
- for (int32_t j = 0; j < iRows; j++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[j]);
- if (!pColRow) {
- continue;
- }
- pColRow->m_fActualPos = fStartTop;
- fStartTop += pColRow->m_fActualSize;
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pWidget || !pInfo) {
- continue;
- }
- FX_FLOAT fColumnStart = 0;
- CFWL_GridColRow* pColumn =
- reinterpret_cast<CFWL_GridColRow*>(GetColRow(TRUE, pInfo->m_iColumn));
- if (pColumn) {
- fColumnStart = pColumn->m_fActualPos;
- }
- FX_FLOAT fRowStart = 0;
- CFWL_GridColRow* pRow =
- reinterpret_cast<CFWL_GridColRow*>(GetColRow(FALSE, pInfo->m_iRow));
- if (pRow) {
- fRowStart = pRow->m_fActualPos;
- }
- FX_FLOAT fColumnWidth = 0;
- if (iColumns > 0) {
- for (int32_t j = 0; j < pInfo->m_iColumnSpan; j++) {
- CFWL_GridColRow* pCol = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(TRUE, pInfo->m_iColumn + j));
- if (!pCol) {
- break;
- }
- fColumnWidth += pCol->m_fActualSize;
- }
- } else {
- fColumnWidth = m_pProperties->m_rtWidget.width;
- }
- FX_FLOAT fRowHeight = 0;
- if (iRows > 0) {
- for (int32_t k = 0; k < pInfo->m_iRowSpan; k++) {
- CFWL_GridColRow* pR = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(FALSE, pInfo->m_iRow + k));
- if (!pR) {
- break;
- }
- fRowHeight += pR->m_fActualSize;
- }
- } else {
- fRowHeight = m_pProperties->m_rtWidget.height;
- }
- FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
- } else {
- if (bLeftMargin && bRightMargin) {
- SetWidgetActualWidth(pInfo, fColumnWidth - fLeftMargin - fRightMargin);
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- SetWidgetActualWidth(pInfo, rtAuto.width);
- }
- }
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
- } else {
- if (bTopMargin && bBottomMargin) {
- SetWidgetActualHeight(pInfo, fRowHeight - fTopMargin - fBottomMargin);
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- SetWidgetActualHeight(pInfo, rtAuto.height);
- }
- }
- if (bLeftMargin && bRightMargin &&
- pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- fLeftMargin =
- fColumnStart + fLeftMargin +
- (fColumnWidth - fLeftMargin - fRightMargin - pInfo->m_fActualWidth) /
- 2;
- } else if (bLeftMargin) {
- fLeftMargin = fColumnStart + fLeftMargin;
- } else if (bRightMargin) {
- fLeftMargin =
- fColumnStart + fColumnWidth - fRightMargin - pInfo->m_fActualWidth;
- } else {
- fLeftMargin = fColumnStart;
- }
- if (bTopMargin && bBottomMargin &&
- pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- fTopMargin =
- fRowStart + fTopMargin +
- (fRowHeight - fTopMargin - fBottomMargin - pInfo->m_fActualHeight) /
- 2;
- } else if (bTopMargin) {
- fTopMargin = fRowStart + fTopMargin;
- } else if (bBottomMargin) {
- fTopMargin =
- fRowStart + fRowHeight - fBottomMargin - pInfo->m_fActualHeight;
- } else {
- fTopMargin = fRowStart;
- }
- CFX_RectF rtWidget, rtOld;
- rtWidget.Set(fLeftMargin, fTopMargin, pInfo->m_fActualWidth,
- pInfo->m_fActualHeight);
- pWidget->GetWidgetRect(rtOld);
- if (rtWidget == rtOld) {
- continue;
- }
- pWidget->SetWidgetRect(rtWidget);
- if (rtWidget.width == rtOld.width && rtWidget.height == rtOld.height) {
- continue;
- }
- pWidget->Update();
- }
-}
-FX_BOOL CFWL_GridImp::IsGrid(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_Grid;
-}
-void CFWL_GridImp::SetSpanAutoColRowSize(const CFX_PtrArray& spanAutos,
- FX_FLOAT fTotalSize) {
- int32_t iAutoColRows = spanAutos.GetSize();
- if (iAutoColRows < 1) {
- return;
- }
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fAutoPer = fTotalSize / iAutoColRows;
- for (int32_t j = 0; j < iAutoColRows; j++) {
- CFWL_GridColRow* pColumn = static_cast<CFWL_GridColRow*>(spanAutos[j]);
- FX_FLOAT fOrgSize = pColumn->m_fActualSize;
- if (SetColRowActualSize(pColumn, pColumn->m_fActualSize + fAutoPer, TRUE)) {
- autoNoMinMaxs.Add(pColumn);
- } else {
- fTotalSize -= pColumn->m_fActualSize - fOrgSize;
- int32_t iNoMinMax = iAutoColRows - (j + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fAutoPer = fTotalSize / iNoMinMax;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iAutoColRows) {
- fAutoPer = fTotalSize / iNormals;
- for (int32_t k = 0; k < iNormals; k++) {
- CFWL_GridColRow* pColumn =
- static_cast<CFWL_GridColRow*>(autoNoMinMaxs[k]);
- pColumn->m_fActualSize += fAutoPer;
- }
- } else {
- SetSpanAutoColRowSize(autoNoMinMaxs, fTotalSize);
- }
- } else {
- }
-}
-void CFWL_GridImp::SetSpanScaledColRowSize(const CFX_PtrArray& spanScaleds,
- FX_FLOAT fTotalSize,
- FX_FLOAT fTotalScaledNum) {
- int32_t iScaledColRows = spanScaleds.GetSize();
- if (iScaledColRows < 1) {
- return;
- }
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iScaledColRows; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(spanScaleds[i]);
- if (SetColRowActualSize(pColRow, pColRow->m_fActualSize +
- fPerSize * pColRow->m_Size.fLength,
- TRUE)) {
- autoNoMinMaxs.Add(pColRow);
- } else {
- fTotalSize -= pColRow->m_fActualSize;
- fTotalScaledNum -= pColRow->m_Size.fLength;
- int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fPerSize = fTotalSize / fTotalScaledNum;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iScaledColRows) {
- fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t j = 0; j < iNormals; j++) {
- CFWL_GridColRow* pColumn =
- static_cast<CFWL_GridColRow*>(autoNoMinMaxs[j]);
- pColumn->m_fActualSize += fPerSize * pColumn->m_Size.fLength;
- }
- } else {
- SetSpanScaledColRowSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum);
- }
- } else {
- }
-}
-void CFWL_GridImp::SetScaledColRowsSize(const CFX_PtrArray& spanScaleds,
- FX_FLOAT fTotalSize,
- FX_FLOAT fTotalScaledNum) {
- int32_t iScaledColRows = spanScaleds.GetSize();
- if (iScaledColRows < 1) {
- return;
- }
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iScaledColRows; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(spanScaleds[i]);
- if (!pColRow) {
- continue;
- }
- FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength;
- FX_FLOAT fOrgSize = pColRow->m_fActualSize;
- if (SetColRowActualSize(pColRow, fSize, TRUE)) {
- autoNoMinMaxs.Add(pColRow);
- } else {
- fTotalSize -= pColRow->m_fActualSize - fOrgSize;
- fTotalScaledNum -= pColRow->m_Size.fLength;
- int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fPerSize = fTotalSize / fTotalScaledNum;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iScaledColRows) {
- fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iNormals; i++) {
- CFWL_GridColRow* pColRow =
- static_cast<CFWL_GridColRow*>(autoNoMinMaxs[i]);
- if (!pColRow) {
- continue;
- }
- FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength;
- pColRow->m_fActualSize = fSize;
- }
- } else {
- SetScaledColRowsSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum);
- }
- } else {
- }
-}
-CFWL_GridImpDelegate::CFWL_GridImpDelegate(CFWL_GridImp* pOwner)
- : m_pOwner(pOwner) {}
-int32_t CFWL_GridImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- if (pMessage->GetClassID() != FWL_MSGHASH_Mouse) {
- return 0;
- }
- CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- if (pMsg->m_dwCmd != FWL_MSGMOUSECMD_LButtonDown) {
- return 0;
- }
- return 1;
-}
-FWL_ERR CFWL_GridImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_gridimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_gridimp.h
deleted file mode 100644
index 1ba773d95bb..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_gridimp.h
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_FWL_GRIDIMP_H_
-#define XFA_FWL_CORE_FWL_GRIDIMP_H_
-
-#include "xfa/fwl/core/fwl_contentimp.h"
-#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_content.h"
-#include "xfa/fwl/core/ifwl_grid.h"
-
-class CFWL_GridLength {
- public:
- CFWL_GridLength() : fLength(0), eUnit(FWL_GRIDUNIT_Fixed) {}
- CFWL_GridLength(FX_FLOAT fValue, FWL_GRIDUNIT e)
- : fLength(fValue), eUnit(e) {}
- FX_FLOAT fLength;
- FWL_GRIDUNIT eUnit;
-};
-
-class CFWL_GridColRow {
- public:
- CFWL_GridColRow()
- : m_Size(1, FWL_GRIDUNIT_Scaled),
- m_MinSize(0, FWL_GRIDUNIT_Fixed),
- m_MaxSize(0, FWL_GRIDUNIT_Infinity),
- m_fActualSize(0),
- m_fActualPos(0) {}
- CFWL_GridLength m_Size;
- CFWL_GridLength m_MinSize;
- CFWL_GridLength m_MaxSize;
- FX_FLOAT m_fActualSize;
- FX_FLOAT m_fActualPos;
-};
-
-class CFWL_GridWidgetInfo {
- public:
- CFWL_GridWidgetInfo()
- : m_iColumn(0),
- m_iColumnSpan(1),
- m_iRow(0),
- m_iRowSpan(1),
- m_dwMarginFlag(0),
- m_fActualWidth(0),
- m_fActualHeight(0) {
- m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Width].fLength = 0;
- m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Height].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
- m_Margin[0] = m_Margin[1] = m_Margin[2] = m_Margin[3] = 0;
- }
- int32_t m_iColumn;
- int32_t m_iColumnSpan;
- int32_t m_iRow;
- int32_t m_iRowSpan;
- CFWL_GridLength m_Size[6];
- uint32_t m_dwMarginFlag;
- FX_FLOAT m_Margin[4];
- FX_FLOAT m_fActualWidth;
- FX_FLOAT m_fActualHeight;
-};
-
-class CFWL_GridImp : public CFWL_ContentImp {
- public:
- CFWL_GridImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
- virtual ~CFWL_GridImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
-
- virtual FWL_ERR InsertWidget(IFWL_Widget* pChild, int32_t nIndex = -1);
- virtual FWL_ERR RemoveWidget(IFWL_Widget* pWidget);
- virtual FWL_HGRIDCOLROW InsertColRow(FX_BOOL bColumn, int32_t nIndex = -1);
- virtual int32_t CountColRows(FX_BOOL bColumn);
- virtual FWL_HGRIDCOLROW GetColRow(FX_BOOL bColumn, int32_t nIndex);
- virtual int32_t GetIndex(FWL_HGRIDCOLROW hColRow);
- virtual FX_FLOAT GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- virtual FWL_ERR SetSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit);
- FX_FLOAT GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- FWL_ERR SetMinSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit);
- FX_FLOAT GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- FWL_ERR SetMaxSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit);
- virtual FX_BOOL DeleteColRow(FWL_HGRIDCOLROW hColRow);
- virtual FX_BOOL IsColumn(FWL_HGRIDCOLROW hColRow);
- virtual int32_t GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn);
- virtual FWL_ERR SetWidgetPos(IFWL_Widget* pWidget,
- int32_t iPos,
- FX_BOOL bColumn);
- virtual int32_t GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn);
- virtual FWL_ERR SetWidgetSpan(IFWL_Widget* pWidget,
- int32_t iSpan,
- FX_BOOL bColumn);
- virtual FX_FLOAT GetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FWL_GRIDUNIT& eUnit);
- virtual FWL_ERR SetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit);
- virtual FX_BOOL GetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT& fMargin);
- virtual FWL_ERR SetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT fMargin);
- virtual FWL_ERR RemoveWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin);
- virtual FX_FLOAT GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit);
- virtual FWL_ERR SetGridSize(FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit);
-
- protected:
- CFWL_GridWidgetInfo* GetWidgetInfo(IFWL_Widget* pWidget);
- void ProcFixedColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_FLOAT fColRowSize,
- FX_BOOL bColumn);
- void ProcAutoColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_BOOL bColumn);
- void ProcScaledColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_FLOAT fColRowSize,
- FX_BOOL bColumn);
- void CalcWidgetWidth(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fColunmWidth);
- void CalcWidgetHeigt(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fRowHeigt);
- FX_FLOAT CalcAutoColumnWidgetWidth(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo);
- FX_FLOAT CalcAutoColumnWidgetHeight(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo);
- FX_FLOAT ProcessColumns(FX_FLOAT fWidth);
- FX_FLOAT ProcessRows(FX_FLOAT fHeight);
- FX_FLOAT ProcessUnCertainColumns();
- FX_FLOAT ProcessUnCertainRows();
- FX_BOOL SetColRowActualSize(CFWL_GridColRow* pColRow,
- FX_FLOAT fSize,
- FX_BOOL bSetBeyond = FALSE);
- FX_FLOAT SetWidgetActualWidth(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fWidth);
- FX_FLOAT SetWidgetActualHeight(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fHeight);
- void SetAllWidgetsRect();
- FX_BOOL IsGrid(IFWL_Widget* pWidget);
- void SetSpanAutoColRowSize(const CFX_PtrArray& spanAutos,
- FX_FLOAT fTotalSize);
- void SetSpanScaledColRowSize(const CFX_PtrArray& spanScaleds,
- FX_FLOAT fTotalSize,
- FX_FLOAT fTotalScaledNum);
- void SetScaledColRowsSize(const CFX_PtrArray& spanScaleds,
- FX_FLOAT fTotalSize,
- FX_FLOAT fTotalScaledNum);
- CFX_PtrArray m_Rows;
- CFX_PtrArray m_Columns;
- CFX_PtrArray m_Widgets;
- CFX_MapPtrToPtr m_mapWidgetInfo;
- CFWL_GridLength m_Size[6];
- friend class CFWL_GridImpDelegate;
-};
-
-class CFWL_GridImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_GridImpDelegate(CFWL_GridImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
-
- protected:
- CFWL_GridImp* m_pOwner;
-};
-
-#endif // XFA_FWL_CORE_FWL_GRIDIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.cpp
index dbb9a952864..4db2d6bb5f6 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.cpp
@@ -12,40 +12,30 @@
#include "xfa/fwl/core/cfwl_message.h"
#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_formimp.h"
-#include "xfa/fwl/core/fwl_panelimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_grid.h"
#include "xfa/fwl/core/ifwl_tooltiptarget.h"
CFWL_NoteLoop::CFWL_NoteLoop(CFWL_WidgetImp* pForm)
: m_pForm(pForm), m_bContinueModal(TRUE) {}
-FX_BOOL CFWL_NoteLoop::PreProcessMessage(CFWL_Message* pMessage) {
- if (!m_pForm) {
- return FALSE;
- }
- return TranslateAccelerator(pMessage);
-}
-FWL_ERR CFWL_NoteLoop::Idle(int32_t count) {
+
+FWL_Error CFWL_NoteLoop::Idle(int32_t count) {
#if (_FX_OS_ == _FX_WIN32_DESKTOP_)
if (count <= 0) {
#endif
CFWL_EvtIdle ev;
IFWL_App* pApp = FWL_GetApp();
if (!pApp)
- return FWL_ERR_Indefinite;
- IFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
+ return FWL_Error::Indefinite;
+ CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
if (!pDriver)
- return FWL_ERR_Indefinite;
- pDriver->SendNote(&ev);
+ return FWL_Error::Indefinite;
+ pDriver->SendEvent(&ev);
#if (_FX_OS_ == _FX_WIN32_DESKTOP_)
}
#endif
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
CFWL_WidgetImp* CFWL_NoteLoop::GetForm() {
return m_pForm;
@@ -53,171 +43,113 @@ CFWL_WidgetImp* CFWL_NoteLoop::GetForm() {
FX_BOOL CFWL_NoteLoop::ContinueModal() {
return m_bContinueModal;
}
-FWL_ERR CFWL_NoteLoop::EndModalLoop() {
+FWL_Error CFWL_NoteLoop::EndModalLoop() {
m_bContinueModal = FALSE;
-#if (_FX_OS_ == _FX_MACOSX_)
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- adapterWidgetMgr->EndLoop();
-#endif
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_BOOL CFWL_NoteLoop::TranslateAccelerator(CFWL_Message* pMessage) {
- if (pMessage->GetClassID() != FWL_MSGHASH_Key) {
- return FALSE;
- }
- CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage);
- if (pMsgKey->m_dwCmd != FWL_MSGKEYCMD_KeyDown) {
- return FALSE;
- }
- CFX_MapAccelerators& accel =
- static_cast<CFWL_FormImp*>(m_pForm)->GetAccelerator();
- FX_POSITION pos = accel.GetStartPosition();
- if (!pos) {
- return FALSE;
- }
- uint32_t vrKey, rValue;
- while (pos) {
- accel.GetNextAssoc(pos, vrKey, rValue);
- uint32_t dwFlags = (vrKey & 0xFF00) >> 8;
- uint32_t m_dwKeyCode = vrKey & 0x00FF;
- if (pMsgKey->m_dwFlags == dwFlags && pMsgKey->m_dwKeyCode == m_dwKeyCode) {
- GenerateCommondEvent(rValue);
- return TRUE;
- }
- }
- return FALSE;
-}
-FWL_ERR CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) {
+
+FWL_Error CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) {
m_pForm = pForm;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) {
CFWL_EvtMenuCommand ev;
ev.m_iCommand = dwCommand;
- IFWL_NoteThread* pThread = m_pForm->GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = m_pForm->GetOwnerApp();
+ if (!pApp)
return;
- IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+
+ CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
if (!pDriver)
return;
- pDriver->SendNote(&ev);
+
+ pDriver->SendEvent(&ev);
}
CFWL_NoteDriver::CFWL_NoteDriver()
- : m_sendEventCalled(0),
- m_maxSize(500),
- m_bFullScreen(FALSE),
- m_pHover(nullptr),
+ : m_pHover(nullptr),
m_pFocus(nullptr),
m_pGrab(nullptr),
- m_hook(nullptr) {
- m_pNoteLoop = new CFWL_NoteLoop;
+ m_pNoteLoop(new CFWL_NoteLoop) {
PushNoteLoop(m_pNoteLoop);
}
CFWL_NoteDriver::~CFWL_NoteDriver() {
delete m_pNoteLoop;
ClearInvalidEventTargets(TRUE);
}
-FX_BOOL CFWL_NoteDriver::SendNote(CFWL_Note* pNote) {
- if (pNote->IsEvent()) {
- int32_t iCount = m_eventTargets.GetCount();
- if (iCount < 1) {
- return TRUE;
- }
- if (FWL_EVTHASH_Mouse == static_cast<CFWL_Event*>(pNote)->GetClassID()) {
- CFWL_EvtMouse* pMouse = static_cast<CFWL_EvtMouse*>(pNote);
- if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) {
- if (m_pNoteLoop->GetForm() &&
- CFWL_ToolTipContainer::getInstance()->ProcessEnter(
- pMouse, m_pNoteLoop->GetForm()->GetInterface())) {
- }
- } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) {
- if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) {
- }
- } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) &&
- (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) {
- if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) {
- }
- }
- }
- m_sendEventCalled++;
- FX_POSITION pos = m_eventTargets.GetStartPosition();
- while (pos) {
- void* key = NULL;
- CFWL_EventTarget* pEventTarget;
- m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
- if (pEventTarget && !pEventTarget->IsInvalid()) {
- pEventTarget->ProcessEvent(static_cast<CFWL_Event*>(pNote));
+
+void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) {
+ if (m_eventTargets.empty())
+ return;
+ if (CFWL_EventType::Mouse == pNote->GetClassID()) {
+ CFWL_EvtMouse* pMouse = static_cast<CFWL_EvtMouse*>(pNote);
+ if (FWL_MouseCommand::Hover == pMouse->m_dwCmd) {
+ if (m_pNoteLoop->GetForm() &&
+ CFWL_ToolTipContainer::getInstance()->ProcessEnter(
+ pMouse, m_pNoteLoop->GetForm()->GetInterface())) {
}
- }
- m_sendEventCalled--;
- } else {
- if (!pNote->m_pDstTarget)
- return FALSE;
- IFWL_WidgetDelegate* pDelegate = pNote->m_pDstTarget->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(static_cast<CFWL_Message*>(pNote));
+ } else if (FWL_MouseCommand::Leave == pMouse->m_dwCmd) {
+ CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse);
+ } else if ((FWL_MouseCommand::LeftButtonDown <= pMouse->m_dwCmd) &&
+ (FWL_MouseCommand::MiddleButtonDblClk >= pMouse->m_dwCmd)) {
+ CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse);
}
}
- return TRUE;
+ for (const auto& pair : m_eventTargets) {
+ CFWL_EventTarget* pEventTarget = pair.second;
+ if (pEventTarget && !pEventTarget->IsInvalid())
+ pEventTarget->ProcessEvent(pNote);
+ }
}
#define FWL_NoteDriver_EventKey 1100
-FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
- IFWL_Widget* pEventSource,
- uint32_t dwFilter) {
- uint32_t dwkey = (uint32_t)(uintptr_t)pListener->GetPrivateData(
+FWL_Error CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
+ IFWL_Widget* pEventSource,
+ uint32_t dwFilter) {
+ uint32_t key = (uint32_t)(uintptr_t)pListener->GetPrivateData(
(void*)(uintptr_t)FWL_NoteDriver_EventKey);
- if (dwkey == 0) {
+ if (key == 0) {
void* random = FX_Random_MT_Start(0);
- dwkey = rand();
+ key = rand();
FX_Random_MT_Close(random);
pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey,
- (void*)(uintptr_t)dwkey, NULL);
+ (void*)(uintptr_t)key, NULL);
}
- CFWL_EventTarget* value = NULL;
- if (!m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
- value = new CFWL_EventTarget(this, pListener);
- m_eventTargets.SetAt((void*)(uintptr_t)dwkey, value);
- }
- value->SetEventSource(pEventSource, dwFilter);
- return FWL_ERR_Succeeded;
+ if (!m_eventTargets[key])
+ m_eventTargets[key] = new CFWL_EventTarget(this, pListener);
+
+ m_eventTargets[key]->SetEventSource(pEventSource, dwFilter);
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) {
- uint32_t dwkey = (uint32_t)(uintptr_t)pListener->GetPrivateData(
+
+FWL_Error CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) {
+ uint32_t key = (uint32_t)(uintptr_t)pListener->GetPrivateData(
(void*)(uintptr_t)FWL_NoteDriver_EventKey);
- if (dwkey == 0) {
- return FWL_ERR_Indefinite;
- }
- CFWL_EventTarget* value = NULL;
- if (m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
- value->FlagInvalid();
- }
- return FWL_ERR_Succeeded;
+ if (key == 0)
+ return FWL_Error::Indefinite;
+
+ auto it = m_eventTargets.find(key);
+ if (it != m_eventTargets.end())
+ it->second->FlagInvalid();
+
+ return FWL_Error::Succeeded;
}
+
void CFWL_NoteDriver::ClearEventTargets(FX_BOOL bRemoveAll) {
ClearInvalidEventTargets(bRemoveAll);
}
-int32_t CFWL_NoteDriver::GetQueueMaxSize() const {
- return m_maxSize;
-}
-FWL_ERR CFWL_NoteDriver::SetQueueMaxSize(const int32_t size) {
- m_maxSize = size;
- return FWL_ERR_Succeeded;
-}
-IFWL_NoteThread* CFWL_NoteDriver::GetOwnerThread() const {
+IFWL_App* CFWL_NoteDriver::GetOwnerApp() const {
return FWL_GetApp();
}
-FWL_ERR CFWL_NoteDriver::PushNoteLoop(IFWL_NoteLoop* pNoteLoop) {
+FWL_Error CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) {
m_noteLoopQueue.Add(pNoteLoop);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-IFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
+CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
int32_t pos = m_noteLoopQueue.GetSize();
if (pos <= 0)
- return NULL;
- IFWL_NoteLoop* p =
- static_cast<IFWL_NoteLoop*>(m_noteLoopQueue.GetAt(pos - 1));
+ return nullptr;
+
+ CFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1);
m_noteLoopQueue.RemoveAt(pos - 1);
return p;
}
@@ -261,64 +193,26 @@ FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) {
}
return TRUE;
}
-FWL_ERR CFWL_NoteDriver::Run() {
+FWL_Error CFWL_NoteDriver::Run() {
CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
if (!pWidgetMgr)
- return FWL_ERR_Indefinite;
-#if (_FX_OS_ == _FX_MACOSX_)
- IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- CFWL_NoteLoop* pTopLoop = GetTopLoop();
- if (pTopLoop) {
- CFWL_WidgetImp* formImp = pTopLoop->GetForm();
- if (formImp) {
- IFWL_Widget* pForm = formImp->GetInterface();
- adapterWidgetMgr->RunLoop(pForm);
- }
+ return FWL_Error::Indefinite;
+
+#if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \
+ _FX_OS_ == _FX_WIN64_)
+ CFWL_NoteLoop* pTopLoop = NULL;
+ for (;;) {
+ pTopLoop = GetTopLoop();
+ if (!pTopLoop || !pTopLoop->ContinueModal())
+ break;
+ if (UnqueueMessage(pTopLoop))
+ continue;
}
-#elif(_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
- FX_BOOL bIdle = TRUE;
- int32_t iIdleCount = 0;
- CFWL_NoteLoop* pTopLoop = NULL;
- for (;;) {
- pTopLoop = GetTopLoop();
- if (!pTopLoop || !pTopLoop->ContinueModal()) {
- break;
- }
- if (UnqueueMessage(pTopLoop)) {
- continue;
- }
- while (bIdle && !(pWidgetMgr->CheckMessage_Native())) {
- if (FWL_ERR_Indefinite == pTopLoop->Idle(iIdleCount++)) {
- bIdle = FALSE;
- }
- }
- do {
- if (FWL_ERR_Indefinite == pWidgetMgr->DispatchMessage_Native()) {
- break;
- }
- if (pWidgetMgr->IsIdleMessage_Native()) {
- bIdle = TRUE;
- iIdleCount = 0;
- }
- } while (pWidgetMgr->CheckMessage_Native());
- }
-#elif(_FX_OS_ == _FX_LINUX_DESKTOP_)
- CFWL_NoteLoop* pTopLoop = NULL;
- for (;;) {
- pTopLoop = GetTopLoop();
- if (!pTopLoop || !pTopLoop->ContinueModal()) {
- break;
- }
- if (UnqueueMessage(pTopLoop)) {
- continue;
- }
- if (pWidgetMgr->CheckMessage_Native()) {
- pWidgetMgr->DispatchMessage_Native();
- }
- }
#endif
- return FWL_ERR_Succeeded;
+
+ return FWL_Error::Succeeded;
}
+
IFWL_Widget* CFWL_NoteDriver::GetFocus() {
return m_pFocus;
}
@@ -367,35 +261,32 @@ void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) {
}
}
}
-void CFWL_NoteDriver::NotifyFullScreenMode(IFWL_Widget* pNoteTarget,
- FX_BOOL bFullScreen) {
- m_bFullScreen = bFullScreen;
-}
-FWL_ERR CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) {
+
+FWL_Error CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) {
if (!pForm)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (m_forms.Find(pForm) >= 0) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
m_forms.Add(pForm);
if (m_forms.GetSize() == 1) {
CFWL_NoteLoop* pLoop =
static_cast<CFWL_NoteLoop*>(m_noteLoopQueue.GetAt(0));
if (!pLoop)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
pLoop->SetMainForm(pForm);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) {
+FWL_Error CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) {
if (!pForm)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
int32_t nIndex = m_forms.Find(pForm);
if (nIndex < 0) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
m_forms.RemoveAt(nIndex);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) {
pMessage->Retain();
@@ -406,35 +297,27 @@ FX_BOOL CFWL_NoteDriver::UnqueueMessage(CFWL_NoteLoop* pNoteLoop) {
if (m_noteQueue.GetSize() < 1) {
return FALSE;
}
- CFWL_Message* pMessage = static_cast<CFWL_Message*>(m_noteQueue[0]);
+ CFWL_Message* pMessage = m_noteQueue[0];
m_noteQueue.RemoveAt(0);
if (!IsValidMessage(pMessage)) {
pMessage->Release();
return TRUE;
}
- FX_BOOL bHookMessage = FALSE;
- if (m_hook) {
- bHookMessage = (*m_hook)(pMessage, m_hookInfo);
- }
- if (!bHookMessage && !pNoteLoop->PreProcessMessage(pMessage)) {
- ProcessMessage(pMessage);
- }
+ ProcessMessage(pMessage);
+
pMessage->Release();
return TRUE;
}
CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() {
int32_t size = m_noteLoopQueue.GetSize();
if (size <= 0)
- return NULL;
+ return nullptr;
return static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[size - 1]);
}
int32_t CFWL_NoteDriver::CountLoop() {
return m_noteLoopQueue.GetSize();
}
-void CFWL_NoteDriver::SetHook(FWLMessageHookCallback callback, void* info) {
- m_hook = callback;
- m_hookInfo = info;
-}
+
FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) {
CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
IFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled()
@@ -443,61 +326,61 @@ FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) {
if (!pMessageForm)
return FALSE;
if (DispatchMessage(pMessage, pMessageForm)) {
- if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) {
+ if (pMessage->GetClassID() == CFWL_MessageType::Mouse)
MouseSecondary(static_cast<CFWL_MsgMouse*>(pMessage));
- }
return TRUE;
}
return FALSE;
}
+
FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage,
IFWL_Widget* pMessageForm) {
FX_BOOL bRet = FALSE;
switch (pMessage->GetClassID()) {
- case FWL_MSGHASH_Activate: {
+ case CFWL_MessageType::Activate: {
bRet = DoActivate(static_cast<CFWL_MsgActivate*>(pMessage), pMessageForm);
break;
}
- case FWL_MSGHASH_Deactivate: {
+ case CFWL_MessageType::Deactivate: {
bRet = DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage),
pMessageForm);
break;
}
- case FWL_MSGHASH_SetFocus: {
+ case CFWL_MessageType::SetFocus: {
bRet = DoSetFocus(static_cast<CFWL_MsgSetFocus*>(pMessage), pMessageForm);
break;
}
- case FWL_MSGHASH_KillFocus: {
+ case CFWL_MessageType::KillFocus: {
bRet =
DoKillFocus(static_cast<CFWL_MsgKillFocus*>(pMessage), pMessageForm);
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
bRet = DoKey(static_cast<CFWL_MsgKey*>(pMessage), pMessageForm);
break;
}
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::Mouse: {
bRet = DoMouse(static_cast<CFWL_MsgMouse*>(pMessage), pMessageForm);
break;
}
- case FWL_MSGHASH_MouseWheel: {
+ case CFWL_MessageType::MouseWheel: {
bRet = DoWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage), pMessageForm);
break;
}
- case FWL_MSGHASH_Size: {
+ case CFWL_MessageType::Size: {
bRet = DoSize(static_cast<CFWL_MsgSize*>(pMessage));
break;
}
- case FWL_MSGHASH_Cursor: {
+ case CFWL_MessageType::Cursor: {
bRet = TRUE;
break;
}
- case FWL_MSGHASH_WindowMove: {
+ case CFWL_MessageType::WindowMove: {
bRet = DoWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage),
pMessageForm);
break;
}
- case FWL_MSGHASH_DropFiles: {
+ case CFWL_MessageType::DropFiles: {
bRet =
DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm);
break;
@@ -509,25 +392,19 @@ FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage,
}
if (bRet) {
IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL);
- if (pDelegate) {
+ if (pDelegate)
pDelegate->OnProcessMessage(pMessage);
- }
}
return bRet;
}
+
FX_BOOL CFWL_NoteDriver::DoActivate(CFWL_MsgActivate* pMsg,
IFWL_Widget* pMessageForm) {
- if (m_bFullScreen) {
- return FALSE;
- }
pMsg->m_pDstTarget = pMessageForm;
return (pMsg->m_pDstTarget)->GetStates() & FWL_WGTSTATE_Deactivated;
}
FX_BOOL CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate* pMsg,
IFWL_Widget* pMessageForm) {
- if (m_bFullScreen) {
- return FALSE;
- }
int32_t iTrackLoop = m_noteLoopQueue.GetSize();
if (iTrackLoop <= 0)
return FALSE;
@@ -539,7 +416,8 @@ FX_BOOL CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate* pMsg,
pMsg->m_pSrcTarget->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
return FALSE;
}
- if (pMsg->m_pSrcTarget && pMsg->m_pSrcTarget->GetClassID() == 1111984755) {
+ if (pMsg->m_pSrcTarget &&
+ pMsg->m_pSrcTarget->GetClassID() == FWL_Type::ToolTip) {
return FALSE;
}
return TRUE;
@@ -605,7 +483,7 @@ FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg,
}
FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
#if (_FX_OS_ != _FX_MACOSX_)
- if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown &&
+ if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown &&
pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
CFWL_WidgetMgr* pWidgetMgr =
static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
@@ -633,7 +511,7 @@ FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
}
#endif
if (!m_pFocus) {
- if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown &&
+ if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown &&
pMsg->m_dwKeyCode == FWL_VKEY_Return) {
CFWL_WidgetMgr* pWidgetMgr =
static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
@@ -650,9 +528,9 @@ FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
}
FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse* pMsg,
IFWL_Widget* pMessageForm) {
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave ||
- pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseHover ||
- pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) {
+ if (pMsg->m_dwCmd == FWL_MouseCommand::Leave ||
+ pMsg->m_dwCmd == FWL_MouseCommand::Hover ||
+ pMsg->m_dwCmd == FWL_MouseCommand::Enter) {
return pMsg->m_pDstTarget != NULL;
}
if (pMsg->m_pDstTarget != pMessageForm) {
@@ -668,13 +546,12 @@ FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg,
CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
if (!pWidgetMgr)
return FALSE;
+
IFWL_Widget* pDst =
pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
if (!pDst)
return FALSE;
- while (pDst && pDst->GetClassID() == FWL_CLASSHASH_Grid) {
- pDst = pDst->GetParent();
- }
+
pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy);
pMsg->m_pDstTarget = pDst;
return TRUE;
@@ -706,9 +583,6 @@ FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg,
if (!pTarget) {
pTarget =
pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
- while (pTarget && pTarget->GetClassID() == FWL_CLASSHASH_Grid) {
- pTarget = pTarget->GetParent();
- }
}
if (pTarget) {
if (pMessageForm != pTarget) {
@@ -732,11 +606,11 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) {
msLeave.m_fy = pMsg->m_fy;
pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy);
msLeave.m_dwFlags = 0;
- msLeave.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave;
- DispatchMessage(&msLeave, NULL);
+ msLeave.m_dwCmd = FWL_MouseCommand::Leave;
+ DispatchMessage(&msLeave, nullptr);
}
- if (pTarget->GetClassID() == FWL_CLASSHASH_Form) {
- m_pHover = NULL;
+ if (pTarget->GetClassID() == FWL_Type::Form) {
+ m_pHover = nullptr;
return;
}
m_pHover = pTarget;
@@ -745,67 +619,66 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) {
msHover.m_fx = pMsg->m_fx;
msHover.m_fy = pMsg->m_fy;
msHover.m_dwFlags = 0;
- msHover.m_dwCmd = FWL_MSGMOUSECMD_MouseHover;
- DispatchMessage(&msHover, NULL);
+ msHover.m_dwCmd = FWL_MouseCommand::Hover;
+ DispatchMessage(&msHover, nullptr);
}
FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) {
- if (pMessage->GetClassID() == FWL_MSGHASH_Post) {
+ if (pMessage->GetClassID() == CFWL_MessageType::Post)
return TRUE;
- }
+
int32_t iCount = m_noteLoopQueue.GetSize();
for (int32_t i = 0; i < iCount; i++) {
CFWL_NoteLoop* pNoteLoop = static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[i]);
CFWL_WidgetImp* pForm = pNoteLoop->GetForm();
- if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) {
+ if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget))
return TRUE;
- }
}
iCount = m_forms.GetSize();
for (int32_t j = 0; j < iCount; j++) {
CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[j]);
- if (pForm->GetInterface() == pMessage->m_pDstTarget) {
+ if (pForm->GetInterface() == pMessage->m_pDstTarget)
return TRUE;
- }
}
return FALSE;
}
+
IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) {
int32_t iTrackLoop = m_noteLoopQueue.GetSize();
if (iTrackLoop <= 0)
- return NULL;
- IFWL_Widget* pMessageForm = NULL;
+ return nullptr;
+ IFWL_Widget* pMessageForm = nullptr;
if (iTrackLoop > 1) {
CFWL_NoteLoop* pNootLoop =
static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[iTrackLoop - 1]);
pMessageForm = pNootLoop->GetForm()->GetInterface();
- } else {
- pMessageForm = (m_forms.Find(pDstTarget) < 0) ? NULL : pDstTarget;
+ } else if (m_forms.Find(pDstTarget->GetImpl()) < 0) {
+ pMessageForm = pDstTarget;
}
if (!pMessageForm && pDstTarget) {
CFWL_WidgetMgr* pWidgetMgr =
static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
if (!pWidgetMgr)
- return NULL;
+ return nullptr;
pMessageForm =
pWidgetMgr->GetWidget(pDstTarget, FWL_WGTRELATION_SystemForm);
}
return pMessageForm;
}
+
void CFWL_NoteDriver::ClearInvalidEventTargets(FX_BOOL bRemoveAll) {
- FX_POSITION pos = m_eventTargets.GetStartPosition();
- while (pos) {
- void* key = NULL;
- CFWL_EventTarget* pEventTarget = NULL;
- m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
- if (pEventTarget && (bRemoveAll || pEventTarget->IsInvalid())) {
- m_eventTargets.RemoveKey(key);
- delete pEventTarget;
+ auto it = m_eventTargets.begin();
+ while (it != m_eventTargets.end()) {
+ auto old = it++;
+ if (old->second && (bRemoveAll || old->second->IsInvalid())) {
+ delete old->second;
+ m_eventTargets.erase(old);
}
}
}
+
class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
public:
- FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
+ FWL_Error GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
int32_t GetInitialDelay(IFWL_Widget* pWidget);
int32_t GetAutoPopDelay(IFWL_Widget* pWidget);
CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget);
@@ -823,10 +696,10 @@ CFWL_CoreToolTipDP::CFWL_CoreToolTipDP() {
m_nAutoPopDelayTime = 50000;
m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
}
-FWL_ERR CFWL_CoreToolTipDP::GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) {
+FWL_Error CFWL_CoreToolTipDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_CoreToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
return m_nInitDelayTime;
@@ -854,6 +727,7 @@ int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource,
}
return 1;
}
+
FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) {
IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL);
if (!pDelegate)
@@ -868,7 +742,7 @@ FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) {
uint32_t dwFilter = 0;
m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter);
if (pSource == pEvent->m_pSrcTarget ||
- pEvent->GetClassID() == FWL_EVTHASH_Idle) {
+ pEvent->GetClassID() == CFWL_EventType::Idle) {
if (IsFilterEvent(pEvent, dwFilter)) {
pDelegate->OnProcessEvent(pEvent);
return TRUE;
@@ -877,51 +751,32 @@ FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) {
}
return FALSE;
}
+
FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) {
- if (dwFilter == FWL_EVENT_ALL_MASK) {
+ if (dwFilter == FWL_EVENT_ALL_MASK)
return TRUE;
- }
- FX_BOOL bRet = FALSE;
+
switch (pEvent->GetClassID()) {
- case FWL_EVTHASH_Mouse: {
- bRet = dwFilter & FWL_EVENT_MOUSE_MASK;
- break;
- }
- case FWL_EVTHASH_MouseWheel: {
- bRet = dwFilter & FWL_EVENT_MOUSEWHEEL_MASK;
- break;
- }
- case FWL_EVTHASH_Key: {
- bRet = dwFilter & FWL_EVENT_KEY_MASK;
- break;
- }
- case FWL_EVTHASH_SetFocus:
- case FWL_EVTHASH_KillFocus: {
- bRet = dwFilter & FWL_EVENT_FOCUSCHANGED_MASK;
- break;
- }
- case FWL_EVTHASH_Draw: {
- bRet = dwFilter & FWL_EVENT_DRAW_MASK;
- break;
- }
- case FWL_EVTHASH_Close: {
- bRet = dwFilter & FWL_EVENT_CLOSE_MASK;
- break;
- }
- case FWL_EVTHASH_SizeChanged: {
- bRet = dwFilter & FWL_EVENT_SIZECHANGED_MASK;
- break;
- }
- case FWL_EVTHASH_Idle: {
- bRet = dwFilter & FWL_EVENT_IDLE_MASK;
- break;
- }
- default: {
- bRet = dwFilter & FWL_EVENT_CONTROL_MASK;
- break;
- }
+ case CFWL_EventType::Mouse:
+ return !!(dwFilter & FWL_EVENT_MOUSE_MASK);
+ case CFWL_EventType::MouseWheel:
+ return !!(dwFilter & FWL_EVENT_MOUSEWHEEL_MASK);
+ case CFWL_EventType::Key:
+ return !!(dwFilter & FWL_EVENT_KEY_MASK);
+ case CFWL_EventType::SetFocus:
+ case CFWL_EventType::KillFocus:
+ return !!(dwFilter & FWL_EVENT_FOCUSCHANGED_MASK);
+ case CFWL_EventType::Draw:
+ return !!(dwFilter & FWL_EVENT_DRAW_MASK);
+ case CFWL_EventType::Close:
+ return !!(dwFilter & FWL_EVENT_CLOSE_MASK);
+ case CFWL_EventType::SizeChanged:
+ return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK);
+ case CFWL_EventType::Idle:
+ return !!(dwFilter & FWL_EVENT_IDLE_MASK);
+ default:
+ return !!(dwFilter & FWL_EVENT_CONTROL_MASK);
}
- return bRet;
}
CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = NULL;
@@ -941,39 +796,40 @@ CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
}
delete m_ToolTipDp;
}
+
// static
CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() {
- if (!s_pInstance) {
+ if (!s_pInstance)
s_pInstance = new CFWL_ToolTipContainer;
- }
return s_pInstance;
}
+
// static
void CFWL_ToolTipContainer::DeleteInstance() {
- if (s_pInstance) {
- delete s_pInstance;
- s_pInstance = NULL;
- }
+ delete s_pInstance;
+ s_pInstance = NULL;
}
-FX_ERR CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
- if (m_arrWidget.Find((void*)pTarget) < 0) {
- m_arrWidget.Add((void*)pTarget);
- return FWL_ERR_Succeeded;
+
+FWL_Error CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
+ if (m_arrWidget.Find(pTarget) < 0) {
+ m_arrWidget.Add(pTarget);
+ return FWL_Error::Succeeded;
}
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
-FX_ERR CFWL_ToolTipContainer::RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) {
- int index = m_arrWidget.Find((void*)pTarget);
+FWL_Error CFWL_ToolTipContainer::RemoveToolTipTarget(
+ IFWL_ToolTipTarget* pTarget) {
+ int index = m_arrWidget.Find(pTarget);
if (index >= 0) {
m_arrWidget.RemoveAt(index);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
FX_BOOL CFWL_ToolTipContainer::HasToolTip(IFWL_Widget* pWedget) {
int32_t iCount = m_arrWidget.GetSize();
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ToolTipTarget* p = static_cast<IFWL_ToolTipTarget*>(m_arrWidget[i]);
+ IFWL_ToolTipTarget* p = m_arrWidget[i];
if (p->GetWidget() == pWedget) {
pCurTarget = p;
return TRUE;
@@ -1016,7 +872,7 @@ FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt,
rt.height = r.height;
}
CFX_PointF pt(pEvt->m_fx, pEvt->m_fy);
- if (pCurTarget->GetToolTipPos(pt) == FWL_ERR_Succeeded) {
+ if (pCurTarget->GetToolTipPos(pt) == FWL_Error::Succeeded) {
rt.left = pt.x;
rt.top = pt.y;
m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0);
@@ -1046,50 +902,3 @@ FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) {
IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() {
return pCurTarget;
}
-FX_ERR CFWL_ToolTipContainer::SetToolTipInitialDelay(int32_t nDelayTime) {
- m_ToolTipDp->m_nInitDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
-}
-FX_ERR CFWL_ToolTipContainer::SetToolTipAutoPopDelay(int32_t nDelayTime) {
- m_ToolTipDp->m_nAutoPopDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR FWL_AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
- return CFWL_ToolTipContainer::getInstance()->AddToolTipTarget(pTarget);
-}
-FWL_ERR FWL_RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) {
- return CFWL_ToolTipContainer::getInstance()->RemoveToolTipTarget(pTarget);
-}
-FWL_ERR FWL_SetToolTipInitialDelay(int32_t nDelayTime) {
- return CFWL_ToolTipContainer::getInstance()->SetToolTipInitialDelay(
- nDelayTime);
-}
-FWL_ERR FWL_SetToolTipAutoPopDelay(int32_t nDelayTime) {
- return CFWL_ToolTipContainer::getInstance()->SetToolTipAutoPopDelay(
- nDelayTime);
-}
-IFWL_Widget* FWL_GetCurrentThreadModalWidget(IFWL_NoteThread* pNoteThread) {
- if (!pNoteThread)
- return NULL;
- CFWL_NoteDriver* noteDriver =
- static_cast<CFWL_NoteDriver*>(pNoteThread->GetNoteDriver());
- if (!noteDriver)
- return NULL;
- if (noteDriver->CountLoop() == 1) {
- return NULL;
- }
- CFWL_NoteLoop* topLoop = noteDriver->GetTopLoop();
- if (!topLoop)
- return NULL;
- CFWL_WidgetImp* widget = topLoop->GetForm();
- if (!widget)
- return NULL;
- return widget->GetInterface();
-}
-FWL_ERR FWL_SetHook(IFWL_NoteDriver* driver,
- FWLMessageHookCallback callback,
- void* info) {
- CFWL_NoteDriver* noteDriver = static_cast<CFWL_NoteDriver*>(driver);
- noteDriver->SetHook(callback, info);
- return FWL_ERR_Succeeded;
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.h
index 8f3e0c3737a..9116e31e089 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_noteimp.h
@@ -7,11 +7,26 @@
#ifndef XFA_FWL_CORE_FWL_NOTEIMP_H_
#define XFA_FWL_CORE_FWL_NOTEIMP_H_
-#include "xfa/fwl/core/ifwl_notedriver.h"
-#include "xfa/fwl/core/ifwl_noteloop.h"
+#include <unordered_map>
+
+#include "xfa/fwl/core/cfwl_event.h"
+#include "xfa/fwl/core/cfwl_message.h"
+#include "xfa/fwl/core/fwl_error.h"
+#include "xfa/fwl/core/ifwl_widget.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
+enum FWL_KeyFlag {
+ FWL_KEYFLAG_Ctrl = 1 << 0,
+ FWL_KEYFLAG_Alt = 1 << 1,
+ FWL_KEYFLAG_Shift = 1 << 2,
+ FWL_KEYFLAG_Command = 1 << 3,
+ FWL_KEYFLAG_LButton = 1 << 4,
+ FWL_KEYFLAG_RButton = 1 << 5,
+ FWL_KEYFLAG_MButton = 1 << 6
+};
+
class CFWL_CoreToolTipDP;
+class CFWL_EventTarget;
class CFWL_MsgActivate;
class CFWL_MsgDeactivate;
class CFWL_MsgDropFiles;
@@ -22,24 +37,21 @@ class CFWL_MsgMouseWheel;
class CFWL_MsgSetFocus;
class CFWL_MsgSize;
class CFWL_MsgWindowMove;
+class CFWL_TargetImp;
class CFWL_ToolTipImp;
class CFWL_WidgetImp;
class IFWL_ToolTipTarget;
-class CFWL_NoteLoop : public IFWL_NoteLoop {
+class CFWL_NoteLoop {
public:
- CFWL_NoteLoop(CFWL_WidgetImp* pForm = NULL);
-
- // IFWL_NoteLoop:
- ~CFWL_NoteLoop() override {}
- FX_BOOL PreProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR Idle(int32_t count) override;
+ CFWL_NoteLoop(CFWL_WidgetImp* pForm = nullptr);
+ ~CFWL_NoteLoop() {}
+ FWL_Error Idle(int32_t count);
CFWL_WidgetImp* GetForm();
FX_BOOL ContinueModal();
- FWL_ERR EndModalLoop();
- FX_BOOL TranslateAccelerator(CFWL_Message* pMessage);
- FWL_ERR SetMainForm(CFWL_WidgetImp* pForm);
+ FWL_Error EndModalLoop();
+ FWL_Error SetMainForm(CFWL_WidgetImp* pForm);
protected:
void GenerateCommondEvent(uint32_t dwCommand);
@@ -48,40 +60,35 @@ class CFWL_NoteLoop : public IFWL_NoteLoop {
FX_BOOL m_bContinueModal;
};
-class CFWL_NoteDriver : public IFWL_NoteDriver {
+class CFWL_NoteDriver {
public:
CFWL_NoteDriver();
- ~CFWL_NoteDriver() override;
-
- // IFWL_NoteDriver:
- FX_BOOL SendNote(CFWL_Note* pNote) override;
- FWL_ERR RegisterEventTarget(IFWL_Widget* pListener,
- IFWL_Widget* pEventSource = NULL,
- uint32_t dwFilter = FWL_EVENT_ALL_MASK) override;
- FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) override;
- void ClearEventTargets(FX_BOOL bRemoveAll) override;
- int32_t GetQueueMaxSize() const override;
- FWL_ERR SetQueueMaxSize(const int32_t size) override;
- IFWL_NoteThread* GetOwnerThread() const override;
- FWL_ERR PushNoteLoop(IFWL_NoteLoop* pNoteLoop) override;
- IFWL_NoteLoop* PopNoteLoop() override;
- IFWL_Widget* GetFocus() override;
- FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE) override;
- void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) override;
- FWL_ERR Run() override;
+ ~CFWL_NoteDriver();
+
+ void SendEvent(CFWL_Event* pNote);
+ FWL_Error RegisterEventTarget(IFWL_Widget* pListener,
+ IFWL_Widget* pEventSource = nullptr,
+ uint32_t dwFilter = FWL_EVENT_ALL_MASK);
+ FWL_Error UnregisterEventTarget(IFWL_Widget* pListener);
+ void ClearEventTargets(FX_BOOL bRemoveAll);
+ IFWL_App* GetOwnerApp() const;
+ FWL_Error PushNoteLoop(CFWL_NoteLoop* pNoteLoop);
+ CFWL_NoteLoop* PopNoteLoop();
+ IFWL_Widget* GetFocus();
+ FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE);
+ void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet);
+ FWL_Error Run();
IFWL_Widget* GetHover();
void SetHover(IFWL_Widget* pHover);
void NotifyTargetHide(IFWL_Widget* pNoteTarget);
void NotifyTargetDestroy(IFWL_Widget* pNoteTarget);
- void NotifyFullScreenMode(IFWL_Widget* pNoteTarget, FX_BOOL bFullScreen);
- FWL_ERR RegisterForm(CFWL_WidgetImp* pForm);
- FWL_ERR UnRegisterForm(CFWL_WidgetImp* pForm);
+ FWL_Error RegisterForm(CFWL_WidgetImp* pForm);
+ FWL_Error UnRegisterForm(CFWL_WidgetImp* pForm);
FX_BOOL QueueMessage(CFWL_Message* pMessage);
FX_BOOL UnqueueMessage(CFWL_NoteLoop* pNoteLoop);
CFWL_NoteLoop* GetTopLoop();
int32_t CountLoop();
- void SetHook(FWLMessageHookCallback callback, void* info);
FX_BOOL ProcessMessage(CFWL_Message* pMessage);
protected:
@@ -101,23 +108,17 @@ class CFWL_NoteDriver : public IFWL_NoteDriver {
FX_BOOL IsValidMessage(CFWL_Message* pMessage);
IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget);
void ClearInvalidEventTargets(FX_BOOL bRemoveAll);
- CFX_PtrArray m_forms;
- CFX_PtrArray m_noteQueue;
- CFX_PtrArray m_noteLoopQueue;
- CFX_MapPtrToPtr m_eventTargets;
- int32_t m_sendEventCalled;
- int32_t m_maxSize;
- FX_BOOL m_bFullScreen;
+
+ CFX_ArrayTemplate<CFWL_WidgetImp*> m_forms;
+ CFX_ArrayTemplate<CFWL_Message*> m_noteQueue;
+ CFX_ArrayTemplate<CFWL_NoteLoop*> m_noteLoopQueue;
+ std::unordered_map<uint32_t, CFWL_EventTarget*> m_eventTargets;
IFWL_Widget* m_pHover;
IFWL_Widget* m_pFocus;
IFWL_Widget* m_pGrab;
CFWL_NoteLoop* m_pNoteLoop;
- FWLMessageHookCallback m_hook;
- void* m_hookInfo;
};
-typedef CFX_MapPtrTemplate<void*, uint32_t> CFWL_EventSource;
-
class CFWL_EventTarget {
public:
CFWL_EventTarget(CFWL_NoteDriver* pNoteDriver, IFWL_Widget* pListener)
@@ -131,7 +132,7 @@ class CFWL_EventTarget {
void FlagInvalid() { m_bInvalid = TRUE; }
protected:
- CFWL_EventSource m_eventSources;
+ CFX_MapPtrTemplate<void*, uint32_t> m_eventSources;
IFWL_Widget* m_pListener;
CFWL_NoteDriver* m_pNoteDriver;
FX_BOOL m_bInvalid;
@@ -142,8 +143,8 @@ class CFWL_ToolTipContainer {
static CFWL_ToolTipContainer* getInstance();
static void DeleteInstance();
- FX_ERR AddToolTipTarget(IFWL_ToolTipTarget* pTarget);
- FX_ERR RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget);
+ FWL_Error AddToolTipTarget(IFWL_ToolTipTarget* pTarget);
+ FWL_Error RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget);
IFWL_ToolTipTarget* GetCurrentToolTipTarget();
FX_BOOL HasToolTip(IFWL_Widget* pWidget);
@@ -151,9 +152,6 @@ class CFWL_ToolTipContainer {
FX_BOOL ProcessEnter(CFWL_EvtMouse* pEvt, IFWL_Widget* pOwner);
FX_BOOL ProcessLeave(CFWL_EvtMouse* pEvt);
- FX_ERR SetToolTipInitialDelay(int32_t iDelayTime);
- FX_ERR SetToolTipAutoPopDelay(int32_t iDelayTime);
-
protected:
CFWL_ToolTipContainer();
virtual ~CFWL_ToolTipContainer();
@@ -161,7 +159,7 @@ class CFWL_ToolTipContainer {
IFWL_ToolTipTarget* pCurTarget;
CFWL_ToolTipImp* m_pToolTipImp;
CFWL_CoreToolTipDP* m_ToolTipDp;
- CFX_PtrArray m_arrWidget;
+ CFX_ArrayTemplate<IFWL_ToolTipTarget*> m_arrWidget;
private:
static CFWL_ToolTipContainer* s_pInstance;
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_panelimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_panelimp.cpp
deleted file mode 100644
index fce89fb4656..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_panelimp.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/core/fwl_panelimp.h"
-
-#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
-#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_widgetimp.h"
-#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_content.h"
-#include "xfa/fwl/core/ifwl_custompanel.h"
-#include "xfa/fwl/core/ifwl_grid.h"
-#include "xfa/fwl/core/ifwl_panel.h"
-#include "xfa/fwl/core/ifwl_proxy.h"
-
-// static
-IFWL_Panel* IFWL_Panel::Create(CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter) {
- IFWL_Panel* pPanel = new IFWL_Panel;
- CFWL_PanelImp* pPanelImpl = new CFWL_PanelImp(properties, pOuter);
- pPanel->SetImpl(pPanelImpl);
- pPanelImpl->SetInterface(pPanel);
- return pPanel;
-}
-IFWL_Panel::IFWL_Panel() {}
-IFWL_Content* IFWL_Panel::GetContent() {
- return static_cast<CFWL_PanelImp*>(GetImpl())->GetContent();
-}
-FWL_ERR IFWL_Panel::SetContent(IFWL_Content* pContent) {
- return static_cast<CFWL_PanelImp*>(GetImpl())->SetContent(pContent);
-}
-
-CFWL_PanelImp::CFWL_PanelImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter), m_pContent(nullptr) {}
-CFWL_PanelImp::~CFWL_PanelImp() {}
-FWL_ERR CFWL_PanelImp::GetClassName(CFX_WideString& wsClass) const {
- wsClass = FWL_CLASS_Panel;
- return FWL_ERR_Succeeded;
-}
-uint32_t CFWL_PanelImp::GetClassID() const {
- return FWL_CLASSHASH_Panel;
-}
-FWL_ERR CFWL_PanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (bAutoSize) {
- if (m_pContent) {
- m_pContent->GetWidgetRect(rect, TRUE);
- }
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PanelImp::Update() {
- if (m_pContent) {
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- FWL_GRIDUNIT eWidth = FWL_GRIDUNIT_Fixed, eHeight = FWL_GRIDUNIT_Fixed;
- IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr();
- if (!pWidgetMgr)
- return FWL_ERR_Indefinite;
- IFWL_Widget* pParent =
- pWidgetMgr->GetWidget(GetInterface(), FWL_WGTRELATION_Parent);
- if (pParent && pParent->GetClassID() == FWL_CLASSHASH_Grid) {
- IFWL_Grid* pGrid = static_cast<IFWL_Grid*>(pParent);
- pGrid->GetWidgetSize(GetInterface(), FWL_GRIDSIZE_Width, eWidth);
- pGrid->GetWidgetSize(GetInterface(), FWL_GRIDSIZE_Height, eHeight);
- }
- m_pContent->SetWidgetRect(rtClient);
- m_pContent->Update();
- }
- return FWL_ERR_Succeeded;
-}
-IFWL_Content* CFWL_PanelImp::GetContent() {
- return m_pContent;
-}
-FWL_ERR CFWL_PanelImp::SetContent(IFWL_Content* pContent) {
- if (!pContent)
- return FWL_ERR_Indefinite;
- m_pContent = pContent;
- return pContent->SetParent(m_pInterface);
-}
-class CFWL_CustomPanelImp : public CFWL_WidgetImp {
- public:
- CFWL_CustomPanelImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
- virtual ~CFWL_CustomPanelImp();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual IFWL_Content* GetContent();
- virtual FWL_ERR SetContent(IFWL_Content* pContent);
- FWL_ERR SetProxy(IFWL_Proxy* pProxy);
-
- protected:
- IFWL_Content* m_pContent;
- IFWL_Proxy* m_pProxy;
-};
-CFWL_CustomPanelImp::CFWL_CustomPanelImp(
- const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter),
- m_pContent(nullptr),
- m_pProxy(nullptr) {}
-CFWL_CustomPanelImp::~CFWL_CustomPanelImp() {}
-FWL_ERR CFWL_CustomPanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (bAutoSize && m_pProxy &&
- (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
- return FWL_ERR_Succeeded;
- }
- return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
-}
-FWL_ERR CFWL_CustomPanelImp::Update() {
- if (m_pProxy) {
- return m_pProxy->Update();
- }
- return CFWL_WidgetImp::Update();
-}
-IFWL_Content* CFWL_CustomPanelImp::GetContent() {
- return m_pContent;
-}
-FWL_ERR CFWL_CustomPanelImp::SetContent(IFWL_Content* pContent) {
- if (!pContent)
- return FWL_ERR_Indefinite;
- m_pContent = pContent;
- return pContent->SetParent(m_pInterface);
-}
-FWL_ERR CFWL_CustomPanelImp::SetProxy(IFWL_Proxy* pProxy) {
- m_pProxy = pProxy;
- return FWL_ERR_Succeeded;
-}
-
-// statuc
-IFWL_CustomPanel* IFWL_CustomPanel::Create(CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter) {
- IFWL_CustomPanel* pCustomPanel = new IFWL_CustomPanel;
- CFWL_CustomPanelImp* pCustomPanelImpl =
- new CFWL_CustomPanelImp(properties, pOuter);
- pCustomPanel->SetImpl(pCustomPanelImpl);
- pCustomPanelImpl->SetInterface(pCustomPanel);
- return pCustomPanel;
-}
-IFWL_CustomPanel::IFWL_CustomPanel() {}
-IFWL_Content* IFWL_CustomPanel::GetContent() {
- return static_cast<CFWL_CustomPanelImp*>(GetImpl())->GetContent();
-}
-FWL_ERR IFWL_CustomPanel::SetContent(IFWL_Content* pContent) {
- return static_cast<CFWL_CustomPanelImp*>(GetImpl())->SetContent(pContent);
-}
-FWL_ERR IFWL_CustomPanel::SetProxy(IFWL_Proxy* pProxy) {
- return static_cast<CFWL_CustomPanelImp*>(GetImpl())->SetProxy(pProxy);
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_panelimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_panelimp.h
deleted file mode 100644
index 81e74c189b1..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_panelimp.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_FWL_PANELIMP_H_
-#define XFA_FWL_CORE_FWL_PANELIMP_H_
-
-#include "xfa/fwl/core/fwl_widgetimp.h"
-
-class CFWL_WidgetImpProperties;
-class IFWL_Widget;
-class IFWL_Content;
-
-class CFWL_PanelImp : public CFWL_WidgetImp {
- public:
- CFWL_PanelImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
- virtual ~CFWL_PanelImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual IFWL_Content* GetContent();
- virtual FWL_ERR SetContent(IFWL_Content* pContent);
-
- protected:
- IFWL_Content* m_pContent;
-};
-
-#endif // XFA_FWL_CORE_FWL_PANELIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_sdadapterimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_sdadapterimp.cpp
deleted file mode 100644
index 2e9d740e400..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_sdadapterimp.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/core/fwl_sdadapterimp.h"
-
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
-#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_adapterthreadmgr.h"
-#include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
-#include "xfa/fwl/core/ifwl_app.h"
-
-CFWL_SDAdapterWidgetMgr::CFWL_SDAdapterWidgetMgr() {}
-CFWL_SDAdapterWidgetMgr::~CFWL_SDAdapterWidgetMgr() {}
-
-FWL_ERR CFWL_SDAdapterWidgetMgr::CreateWidget(IFWL_Widget* pWidget,
- IFWL_Widget* pParent) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::DestroyWidget(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetRect(IFWL_Widget* pWidget,
- const CFX_RectF& rect) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetPosition(IFWL_Widget* pWidget,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetParentWidget(IFWL_Widget* pWidget,
- IFWL_Widget* pParent) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::ShowWidget(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::HideWidget(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetNormal(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMaximize(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMinimize(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RunWidget(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::Exit(int32_t iExitCode) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::CreateWidgetWithNativeId(IFWL_Widget* pWidget,
- void* vp) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetWidgetRect(IFWL_Widget* pWidget,
- CFX_RectF& rect) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetIcon(IFWL_Widget* pWidget,
- const CFX_DIBitmap* pIcon,
- FX_BOOL bBig) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetCaption(
- IFWL_Widget* pWidget,
- const CFX_WideStringC& wsCaption) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetBorderRegion(IFWL_Widget* pWidget,
- CFX_Path* pPath) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetTransparent(IFWL_Widget* pWidget,
- uint32_t dwAlpha) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetFullScreen(IFWL_Widget* pWidget,
- FX_BOOL bFullScreen) {
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_SDAdapterWidgetMgr::CheckMessage() {
- return TRUE;
-}
-FX_BOOL CFWL_SDAdapterWidgetMgr::IsIdleMessage() {
- return TRUE;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::DispatchMessage() {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetWidgetDC(IFWL_Widget* pWidget, void*& pDC) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::ReleaseWidgetDC(IFWL_Widget* pWidget,
- void* pDC,
- CFX_RectF* pClip) {
- return FWL_ERR_Succeeded;
-}
-void* CFWL_SDAdapterWidgetMgr::GetWindow(IFWL_Widget* pWidget) {
- return NULL;
-}
-uint32_t CFWL_SDAdapterWidgetMgr::GetKeyState(uint32_t dwVirtKey) {
- return 0;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RunLoop(IFWL_Widget* widget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::EndLoop() {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::InitMenu(IFWL_Menu* pMenu,
- IFWL_MenuDP* pMenuData) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::UpdateMenu(IFWL_Menu* pMenu,
- const void* hItem,
- int32_t iType) {
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_SDAdapterWidgetMgr::TrackPopupMenu(IFWL_Menu* pMenu,
- IFWL_MenuDP* pMenuData) {
- return 0;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMessageHook(IFWL_AdapterMessageHook* hook) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetSystemBorder(FX_FLOAT& l,
- FX_FLOAT& t,
- FX_FLOAT& r,
- FX_FLOAT& b) {
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_SDAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget,
- FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- return FWL_ERR_Succeeded;
-}
-CFWL_SDAdapterThreadMgr::CFWL_SDAdapterThreadMgr() {}
-CFWL_SDAdapterThreadMgr::~CFWL_SDAdapterThreadMgr() {}
-FWL_ERR CFWL_SDAdapterThreadMgr::Start(IFWL_Thread* pThread,
- FWL_HTHREAD& hThread,
- FX_BOOL bSuspended) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Resume(FWL_HTHREAD hThread) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Suspend(FWL_HTHREAD hThread) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Kill(FWL_HTHREAD hThread, int32_t iExitCode) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Stop(FWL_HTHREAD hThread, int32_t iExitCode) {
- return FWL_ERR_Succeeded;
-}
-IFWL_Thread* CFWL_SDAdapterThreadMgr::GetCurrentThread() {
- return FWL_GetApp();
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_sdadapterimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_sdadapterimp.h
deleted file mode 100644
index 2bc69796fbc..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_sdadapterimp.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_FWL_SDADAPTERIMP_H_
-#define XFA_FWL_CORE_FWL_SDADAPTERIMP_H_
-
-#include "xfa/fwl/core/ifwl_adapterthreadmgr.h"
-#include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
-
-class CFWL_SDAdapterWidgetMgr : public IFWL_AdapterWidgetMgr {
- public:
- CFWL_SDAdapterWidgetMgr();
- ~CFWL_SDAdapterWidgetMgr();
- virtual FWL_ERR CreateWidget(IFWL_Widget* pWidget,
- IFWL_Widget* pParent = NULL);
- virtual FWL_ERR DestroyWidget(IFWL_Widget* pWidget);
- virtual FWL_ERR SetWidgetRect(IFWL_Widget* pWidget, const CFX_RectF& rect);
- virtual FWL_ERR SetWidgetPosition(IFWL_Widget* pWidget,
- FX_FLOAT fx,
- FX_FLOAT fy);
- virtual FWL_ERR SetParentWidget(IFWL_Widget* pWidget, IFWL_Widget* pParent);
- virtual FWL_ERR ShowWidget(IFWL_Widget* pWidget);
- virtual FWL_ERR HideWidget(IFWL_Widget* pWidget);
- virtual FWL_ERR SetNormal(IFWL_Widget* pWidget);
- virtual FWL_ERR SetMaximize(IFWL_Widget* pWidget);
- virtual FWL_ERR SetMinimize(IFWL_Widget* pWidget);
- virtual FWL_ERR RunWidget(IFWL_Widget* pWidget);
- virtual FWL_ERR RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect);
- virtual FWL_ERR Exit(int32_t iExitCode);
- virtual FWL_ERR CreateWidgetWithNativeId(IFWL_Widget* pWidget, void* vp);
- virtual FX_BOOL GetPopupPos(IFWL_Widget* pWidget,
- FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
-
- public:
- virtual FWL_ERR GetWidgetRect(IFWL_Widget* pWidget, CFX_RectF& rect);
- virtual FWL_ERR SetWidgetIcon(IFWL_Widget* pWidget,
- const CFX_DIBitmap* pIcon,
- FX_BOOL bBig);
- virtual FWL_ERR SetWidgetCaption(IFWL_Widget* pWidget,
- const CFX_WideStringC& wsCaption);
- virtual FWL_ERR SetBorderRegion(IFWL_Widget* pWidget, CFX_Path* pPath);
- virtual FWL_ERR SetTransparent(IFWL_Widget* pWidget, uint32_t dwAlpha);
- virtual FWL_ERR SetFullScreen(IFWL_Widget* pWidget, FX_BOOL bFullScreen);
- virtual FX_BOOL CheckMessage();
- virtual FX_BOOL IsIdleMessage();
- virtual FWL_ERR DispatchMessage();
- virtual FWL_ERR GetWidgetDC(IFWL_Widget* pWidget, void*& pDC);
- virtual FWL_ERR ReleaseWidgetDC(IFWL_Widget* pWidget,
- void* pDC,
- CFX_RectF* pClip = 0);
- virtual void* GetWindow(IFWL_Widget* pWidget);
- virtual uint32_t GetKeyState(uint32_t dwVirtKey);
- virtual FWL_ERR RunLoop(IFWL_Widget* widget);
- virtual FWL_ERR EndLoop();
- virtual FWL_ERR InitMenu(IFWL_Menu* pMenu, IFWL_MenuDP* pMenuData);
- virtual FWL_ERR UpdateMenu(IFWL_Menu* pMenu,
- const void* hItem,
- int32_t iType);
- virtual int32_t TrackPopupMenu(IFWL_Menu* pMenu, IFWL_MenuDP* pMenuData);
- virtual FWL_ERR SetMessageHook(IFWL_AdapterMessageHook* hook);
- virtual FWL_ERR GetSystemBorder(FX_FLOAT& l,
- FX_FLOAT& t,
- FX_FLOAT& r,
- FX_FLOAT& b);
-};
-
-class CFWL_SDAdapterThreadMgr : public IFWL_AdapterThreadMgr {
- public:
- CFWL_SDAdapterThreadMgr();
- ~CFWL_SDAdapterThreadMgr();
-
- public:
- virtual FWL_ERR Start(IFWL_Thread* pThread,
- FWL_HTHREAD& hThread,
- FX_BOOL bSuspended = FALSE);
- virtual FWL_ERR Resume(FWL_HTHREAD hThread);
- virtual FWL_ERR Suspend(FWL_HTHREAD hThread);
- virtual FWL_ERR Kill(FWL_HTHREAD hThread, int32_t iExitCode);
- virtual FWL_ERR Stop(FWL_HTHREAD hThread, int32_t iExitCode);
- virtual IFWL_Thread* GetCurrentThread();
-};
-
-#endif // XFA_FWL_CORE_FWL_SDADAPTERIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_targetimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_targetimp.cpp
deleted file mode 100644
index e3e768085a3..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_targetimp.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/core/fwl_targetimp.h"
-
-FWL_ERR IFWL_Target::GetClassName(CFX_WideString& wsClass) const {
- return m_pImpl->GetClassName(wsClass);
-}
-uint32_t IFWL_Target::GetClassID() const {
- return m_pImpl->GetClassID();
-}
-FX_BOOL IFWL_Target::IsInstance(const CFX_WideStringC& wsClass) const {
- return m_pImpl->IsInstance(wsClass);
-}
-FWL_ERR IFWL_Target::Initialize() {
- return m_pImpl->Initialize();
-}
-FWL_ERR IFWL_Target::Finalize() {
- return m_pImpl->Finalize();
-}
-IFWL_Target::~IFWL_Target() {
- delete m_pImpl;
-}
-CFWL_TargetImp::CFWL_TargetImp() {}
-CFWL_TargetImp::~CFWL_TargetImp() {}
-FWL_ERR CFWL_TargetImp::GetClassName(CFX_WideString& wsClass) const {
- wsClass.Empty();
- return FWL_ERR_Succeeded;
-}
-uint32_t CFWL_TargetImp::GetClassID() const {
- return 0;
-}
-FX_BOOL CFWL_TargetImp::IsInstance(const CFX_WideStringC& wsClass) const {
- return FALSE;
-}
-FWL_ERR CFWL_TargetImp::Initialize() {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_TargetImp::Finalize() {
- return FWL_ERR_Succeeded;
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_targetimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_targetimp.h
deleted file mode 100644
index c1a5e56c2a9..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_targetimp.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_FWL_TARGETIMP_H_
-#define XFA_FWL_CORE_FWL_TARGETIMP_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fwl/core/ifwl_target.h"
-
-class CFWL_TargetImp {
- public:
- virtual ~CFWL_TargetImp();
-
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-
- protected:
- CFWL_TargetImp();
-};
-
-#endif // XFA_FWL_CORE_FWL_TARGETIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_threadimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_threadimp.cpp
deleted file mode 100644
index 66c57ebee6d..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_threadimp.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/core/fwl_threadimp.h"
-
-#include "xfa/fwl/core/fwl_appimp.h"
-#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/ifwl_notethread.h"
-
-void IFWL_Thread::Release() {
- delete m_pImpl;
-}
-FWL_ERR IFWL_Thread::Run(FWL_HTHREAD hThread) {
- return m_pImpl->Run(hThread);
-}
-IFWL_NoteDriver* IFWL_NoteThread::GetNoteDriver() {
- return static_cast<CFWL_NoteThreadImp*>(GetImpl())->GetNoteDriver();
-}
-
-FWL_ERR CFWL_ThreadImp::Run(FWL_HTHREAD hThread) {
- return FWL_ERR_Succeeded;
-}
-CFWL_NoteThreadImp::CFWL_NoteThreadImp(IFWL_NoteThread* pIface)
- : CFWL_ThreadImp(pIface), m_pNoteDriver(new CFWL_NoteDriver) {}
-CFWL_NoteThreadImp::~CFWL_NoteThreadImp() {
- delete m_pNoteDriver;
-}
-FWL_ERR CFWL_NoteThreadImp::Run(FWL_HTHREAD hThread) {
- if (!m_pNoteDriver)
- return FWL_ERR_Indefinite;
- return m_pNoteDriver->Run();
-}
-IFWL_NoteDriver* CFWL_NoteThreadImp::GetNoteDriver() {
- return m_pNoteDriver;
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_threadimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_threadimp.h
deleted file mode 100644
index 3806f3ca4be..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_threadimp.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_FWL_THREADIMP_H_
-#define XFA_FWL_CORE_FWL_THREADIMP_H_
-
-#include "xfa/fwl/core/ifwl_thread.h"
-
-class CFWL_NoteDriver;
-class IFWL_NoteDriver;
-class IFWL_NoteThread;
-
-class CFWL_ThreadImp {
- public:
- virtual ~CFWL_ThreadImp() {}
- IFWL_Thread* GetInterface() const { return m_pIface; }
- virtual FWL_ERR Run(FWL_HTHREAD hThread);
-
- protected:
- CFWL_ThreadImp(IFWL_Thread* pIface) : m_pIface(pIface) {}
-
- private:
- IFWL_Thread* const m_pIface;
-};
-
-class CFWL_NoteThreadImp : public CFWL_ThreadImp {
- public:
- CFWL_NoteThreadImp(IFWL_NoteThread* pIface);
- virtual ~CFWL_NoteThreadImp();
-
- FWL_ERR Run(FWL_HTHREAD hThread) override;
- virtual IFWL_NoteDriver* GetNoteDriver();
-
- protected:
- CFWL_NoteDriver* const m_pNoteDriver;
-};
-
-#endif // XFA_FWL_CORE_FWL_THREADIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_timerimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_timerimp.cpp
index 1dfed0c5847..ced5adeb9df 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_timerimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_timerimp.cpp
@@ -5,17 +5,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "xfa/fwl/core/fwl_appimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
-#include "xfa/fwl/core/ifwl_adapternative.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_timer.h"
#include "xfa/fwl/core/include/ifwl_adaptertimermgr.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer,
uint32_t dwElapse,
FX_BOOL bImmediately) {
- IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative();
+ CXFA_FFApp* pAdapterNative = FWL_GetAdapterNative();
if (!pAdapterNative)
return NULL;
IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
@@ -25,12 +23,14 @@ FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer,
pAdapterTimerMgr->Start(pTimer, dwElapse, hTimer, bImmediately);
return hTimer;
}
-int32_t FWL_StopTimer(FWL_HTIMER hTimer) {
- IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative();
+
+FWL_Error FWL_StopTimer(FWL_HTIMER hTimer) {
+ CXFA_FFApp* pAdapterNative = FWL_GetAdapterNative();
if (!pAdapterNative)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
if (!pAdapterTimerMgr)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return pAdapterTimerMgr->Stop(hTimer);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetdef.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetdef.h
index 849ba6fc7b4..f0ef5f5d180 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetdef.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetdef.h
@@ -50,28 +50,7 @@
#define FWL_WGTSTATE_Focused (1L << 4)
#define FWL_WGTSTATE_Invisible (1L << 5)
#define FWL_WGTSTATE_MAX (6)
-#define FWL_WGTHITTEST_Unknown 0
-#define FWL_WGTHITTEST_Client 1
-#define FWL_WGTHITTEST_Left 2
-#define FWL_WGTHITTEST_Top 3
-#define FWL_WGTHITTEST_Right 4
-#define FWL_WGTHITTEST_Bottom 5
-#define FWL_WGTHITTEST_LeftTop 6
-#define FWL_WGTHITTEST_RightTop 7
-#define FWL_WGTHITTEST_LeftBottom 8
-#define FWL_WGTHITTEST_RightBottom 9
-#define FWL_WGTHITTEST_Icon 10
-#define FWL_WGTHITTEST_Titlebar 11
-#define FWL_WGTHITTEST_MinBox 12
-#define FWL_WGTHITTEST_MaxBox 13
-#define FWL_WGTHITTEST_CloseBox 14
-#define FWL_WGTHITTEST_HScrollBar 15
-#define FWL_WGTHITTEST_VScrollBar 16
-#define FWL_WGTHITTEST_Border 17
-#define FWL_WGTHITTEST_Edge 18
-#define FWL_WGTHITTEST_Edit 19
-#define FWL_WGTHITTEST_HyperLink 20
-#define FWL_WGTHITTEST_MAX 21
+
#define FWL_VKEY_LButton 0x01
#define FWL_VKEY_RButton 0x02
#define FWL_VKEY_MButton 0x04
@@ -243,7 +222,5 @@
#define FWL_VKEY_PA1 0xFD
#define FWL_VKEY_OEM_Clear 0xFE
#define FWL_VKEY_Unknown 0
-#define FWL_VKEYSTATE_Toggled 0x0001
-#define FWL_VKEYSTATE_Down 0x0100
#endif // XFA_FWL_CORE_FWL_WIDGETDEF_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.cpp
index 961b60e1729..e72a7f385a0 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.cpp
@@ -17,45 +17,59 @@
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_adapternative.h"
-#include "xfa/fwl/core/ifwl_adapterthreadmgr.h"
-#include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_content.h"
-#include "xfa/fwl/core/ifwl_custom.h"
#include "xfa/fwl/core/ifwl_form.h"
-#include "xfa/fwl/core/ifwl_proxy.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
-#define FWL_CLASSHASH_Menu 3957949655
#define FWL_STYLEEXT_MNU_Vert (1L << 0)
-FWL_ERR IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+IFWL_Widget::~IFWL_Widget() {}
+
+FWL_Error IFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
+ return m_pImpl->GetClassName(wsClass);
+}
+
+FWL_Type IFWL_Widget::GetClassID() const {
+ return m_pImpl->GetClassID();
+}
+
+FX_BOOL IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
+ return m_pImpl->IsInstance(wsClass);
+}
+
+FWL_Error IFWL_Widget::Initialize() {
+ return m_pImpl->Initialize();
+}
+
+FWL_Error IFWL_Widget::Finalize() {
+ return m_pImpl->Finalize();
+}
+
+FWL_Error IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
return static_cast<CFWL_WidgetImp*>(GetImpl())
->GetWidgetRect(rect, bAutoSize);
}
-FWL_ERR IFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
+FWL_Error IFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetGlobalRect(rect);
}
-FWL_ERR IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
+FWL_Error IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->SetWidgetRect(rect);
}
-FWL_ERR IFWL_Widget::GetClientRect(CFX_RectF& rect) {
+FWL_Error IFWL_Widget::GetClientRect(CFX_RectF& rect) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetClientRect(rect);
}
IFWL_Widget* IFWL_Widget::GetParent() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetParent();
}
-FWL_ERR IFWL_Widget::SetParent(IFWL_Widget* pParent) {
+FWL_Error IFWL_Widget::SetParent(IFWL_Widget* pParent) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->SetParent(pParent);
}
IFWL_Widget* IFWL_Widget::GetOwner() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwner();
}
-FWL_ERR IFWL_Widget::SetOwner(IFWL_Widget* pOwner) {
+FWL_Error IFWL_Widget::SetOwner(IFWL_Widget* pOwner) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->SetOwner(pOwner);
}
IFWL_Widget* IFWL_Widget::GetOuter() {
@@ -64,127 +78,123 @@ IFWL_Widget* IFWL_Widget::GetOuter() {
uint32_t IFWL_Widget::GetStyles() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStyles();
}
-FWL_ERR IFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
- uint32_t dwStylesRemoved) {
+FWL_Error IFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
+ uint32_t dwStylesRemoved) {
return static_cast<CFWL_WidgetImp*>(GetImpl())
->ModifyStyles(dwStylesAdded, dwStylesRemoved);
}
uint32_t IFWL_Widget::GetStylesEx() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStylesEx();
}
-FWL_ERR IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error IFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
return static_cast<CFWL_WidgetImp*>(GetImpl())
->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
uint32_t IFWL_Widget::GetStates() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStates();
}
-FWL_ERR IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet);
+void IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
+ static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet);
}
-FWL_ERR IFWL_Widget::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
+FWL_Error IFWL_Widget::SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback) {
return static_cast<CFWL_WidgetImp*>(GetImpl())
->SetPrivateData(module_id, pData, callback);
}
void* IFWL_Widget::GetPrivateData(void* module_id) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetPrivateData(module_id);
}
-FWL_ERR IFWL_Widget::Update() {
+FWL_Error IFWL_Widget::Update() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->Update();
}
-FWL_ERR IFWL_Widget::LockUpdate() {
+FWL_Error IFWL_Widget::LockUpdate() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->LockUpdate();
}
-FWL_ERR IFWL_Widget::UnlockUpdate() {
+FWL_Error IFWL_Widget::UnlockUpdate() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->UnlockUpdate();
}
-uint32_t IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->HitTest(fx, fy);
}
-FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget* pWidget,
- FX_FLOAT& fx,
- FX_FLOAT& fy) {
+FWL_Error IFWL_Widget::TransformTo(IFWL_Widget* pWidget,
+ FX_FLOAT& fx,
+ FX_FLOAT& fy) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->TransformTo(pWidget, fx, fy);
}
-FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) {
+FWL_Error IFWL_Widget::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->TransformTo(pWidget, rt);
}
-FWL_ERR IFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
+FWL_Error IFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetMatrix(matrix, bGlobal);
}
-FWL_ERR IFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
+FWL_Error IFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->SetMatrix(matrix);
}
-FWL_ERR IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
return static_cast<CFWL_WidgetImp*>(GetImpl())
->DrawWidget(pGraphics, pMatrix);
}
IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetThemeProvider();
}
-FWL_ERR IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
return static_cast<CFWL_WidgetImp*>(GetImpl())
->SetThemeProvider(pThemeProvider);
}
-FWL_ERR IFWL_Widget::SetDataProvider(IFWL_DataProvider* pDataProvider) {
+FWL_Error IFWL_Widget::SetDataProvider(IFWL_DataProvider* pDataProvider) {
return static_cast<CFWL_WidgetImp*>(GetImpl())
->SetDataProvider(pDataProvider);
}
IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->SetDelegate(pDelegate);
}
-IFWL_NoteThread* IFWL_Widget::GetOwnerThread() const {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerThread();
+IFWL_App* IFWL_Widget::GetOwnerApp() const {
+ return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerApp();
}
CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent);
}
-FWL_ERR CFWL_WidgetImp::Initialize() {
+
+FWL_Error CFWL_WidgetImp::Initialize() {
IFWL_App* pApp = FWL_GetApp();
if (!pApp)
- return FWL_ERR_Indefinite;
- IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative();
+ return FWL_Error::Indefinite;
+
+ CXFA_FFApp* pAdapter = pApp->GetAdapterNative();
if (!pAdapter)
- return FWL_ERR_Indefinite;
- IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr();
- if (!pAdapterThread)
- return FWL_ERR_Indefinite;
- SetOwnerThread(static_cast<CFWL_NoteThreadImp*>(
- pAdapterThread->GetCurrentThread()->GetImpl()));
+ return FWL_Error::Indefinite;
+
+ SetOwnerApp(static_cast<CFWL_AppImp*>(FWL_GetApp()->GetImpl()));
+
IFWL_Widget* pParent = m_pProperties->m_pParent;
m_pWidgetMgr->InsertWidget(pParent, m_pInterface);
if (!IsChild()) {
- {
- IFWL_Widget* pOwner = m_pProperties->m_pOwner;
- if (pOwner) {
- m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
- }
- }
- m_pWidgetMgr->CreateWidget_Native(m_pInterface);
+ IFWL_Widget* pOwner = m_pProperties->m_pOwner;
+ if (pOwner)
+ m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::Finalize() {
+
+FWL_Error CFWL_WidgetImp::Finalize() {
NotifyDriver();
- IFWL_Form* pForm = static_cast<IFWL_Form*>(
- FWL_GetWidgetMgr()->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm));
- if (pForm && pForm != m_pInterface) {
- IFWL_Content* pContent = pForm->GetContent();
- if (pContent) {
- pContent->RemoveWidget(m_pInterface);
- }
- }
- if (!IsChild()) {
- m_pWidgetMgr->DestroyWidget_Native(m_pInterface);
- }
m_pWidgetMgr->RemoveWidget(m_pInterface);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+
+FWL_Error CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const {
+ wsClass.clear();
+ return FWL_Error::Succeeded;
+}
+
+FX_BOOL CFWL_WidgetImp::IsInstance(const CFX_WideStringC& wsClass) const {
+ return FALSE;
+}
+
+FWL_Error CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
if (HasEdge()) {
FX_FLOAT fEdge = GetEdgeWidth();
@@ -197,21 +207,21 @@ FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
} else {
rect = m_pProperties->m_rtWidget;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::GetGlobalRect(CFX_RectF& rect) {
+FWL_Error CFWL_WidgetImp::GetGlobalRect(CFX_RectF& rect) {
IFWL_Widget* pForm =
m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
if (!pForm)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
rect.Set(0, 0, m_pProperties->m_rtWidget.width,
m_pProperties->m_rtWidget.height);
if (pForm == m_pInterface) {
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
return TransformTo(pForm, rect);
}
-FWL_ERR CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) {
+FWL_Error CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) {
CFX_RectF rtOld = m_pProperties->m_rtWidget;
m_pProperties->m_rtWidget = rect;
if (IsChild()) {
@@ -226,34 +236,34 @@ FWL_ERR CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) {
pDelegate->OnProcessEvent(&ev);
}
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) {
+FWL_Error CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) {
GetEdgeRect(rect);
if (HasEdge()) {
FX_FLOAT fEdge = GetEdgeWidth();
rect.Deflate(fEdge, fEdge);
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
IFWL_Widget* CFWL_WidgetImp::GetParent() {
return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Parent);
}
-FWL_ERR CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) {
+FWL_Error CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) {
m_pProperties->m_pParent = pParent;
m_pWidgetMgr->SetParent(pParent, m_pInterface);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
IFWL_Widget* CFWL_WidgetImp::GetOwner() {
return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Owner);
}
-FWL_ERR CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner) {
+FWL_Error CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner) {
m_pProperties->m_pOwner = pOwner;
m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
IFWL_Widget* CFWL_WidgetImp::GetOuter() {
return m_pOuter;
@@ -261,20 +271,20 @@ IFWL_Widget* CFWL_WidgetImp::GetOuter() {
uint32_t CFWL_WidgetImp::GetStyles() {
return m_pProperties->m_dwStyles;
}
-FWL_ERR CFWL_WidgetImp::ModifyStyles(uint32_t dwStylesAdded,
- uint32_t dwStylesRemoved) {
+FWL_Error CFWL_WidgetImp::ModifyStyles(uint32_t dwStylesAdded,
+ uint32_t dwStylesRemoved) {
m_pProperties->m_dwStyles =
(m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
uint32_t CFWL_WidgetImp::GetStylesEx() {
return m_pProperties->m_dwStyleExes;
}
-FWL_ERR CFWL_WidgetImp::ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error CFWL_WidgetImp::ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
m_pProperties->m_dwStyleExes =
(m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
uint32_t CFWL_WidgetImp::GetStates() {
return m_pProperties->m_dwStates;
@@ -289,82 +299,75 @@ static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr,
child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
}
}
-FWL_ERR CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
+
+void CFWL_WidgetImp::SetStates(uint32_t dwStates, FX_BOOL bSet) {
bSet ? (m_pProperties->m_dwStates |= dwStates)
: (m_pProperties->m_dwStates &= ~dwStates);
- FWL_ERR ret = FWL_ERR_Succeeded;
- if (dwStates & FWL_WGTSTATE_Invisible) {
- if (bSet) {
- ret = m_pWidgetMgr->HideWidget_Native(m_pInterface);
- CFWL_NoteDriver* noteDriver =
- static_cast<CFWL_NoteDriver*>(GetOwnerThread()->GetNoteDriver());
- IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
- noteDriver->NotifyTargetHide(m_pInterface);
- IFWL_Widget* child =
- widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild);
- while (child) {
- noteDriver->NotifyTargetHide(child);
- NotifyHideChildWidget(widgetMgr, child, noteDriver);
- child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- } else {
- ret = m_pWidgetMgr->ShowWidget_Native(m_pInterface);
- }
+ if (!(dwStates & FWL_WGTSTATE_Invisible) || !bSet)
+ return;
+
+ CFWL_NoteDriver* noteDriver =
+ static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver());
+ IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
+ noteDriver->NotifyTargetHide(m_pInterface);
+ IFWL_Widget* child =
+ widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild);
+ while (child) {
+ noteDriver->NotifyTargetHide(child);
+ NotifyHideChildWidget(widgetMgr, child, noteDriver);
+ child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
}
- return ret;
+ return;
}
-FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
+FWL_Error CFWL_WidgetImp::SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback) {
if (!m_pPrivateData) {
m_pPrivateData = new CFX_PrivateData;
}
m_pPrivateData->SetPrivateData(module_id, pData, callback);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void* CFWL_WidgetImp::GetPrivateData(void* module_id) {
if (!m_pPrivateData)
return NULL;
return m_pPrivateData->GetPrivateData(module_id);
}
-FWL_ERR CFWL_WidgetImp::Update() {
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_WidgetImp::Update() {
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::LockUpdate() {
+FWL_Error CFWL_WidgetImp::LockUpdate() {
m_iLock++;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::UnlockUpdate() {
+FWL_Error CFWL_WidgetImp::UnlockUpdate() {
if (IsLocked()) {
m_iLock--;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-uint32_t CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
CFX_RectF rtClient;
GetClientRect(rtClient);
- if (rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
+ if (rtClient.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
if (HasEdge()) {
CFX_RectF rtEdge;
GetEdgeRect(rtEdge);
- if (rtEdge.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edge;
- }
+ if (rtEdge.Contains(fx, fy))
+ return FWL_WidgetHit::Edge;
}
if (HasBorder()) {
CFX_RectF rtRelative;
GetRelativeRect(rtRelative);
- if (rtRelative.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Border;
- }
+ if (rtRelative.Contains(fx, fy))
+ return FWL_WidgetHit::Border;
}
- return FWL_WGTHITTEST_Unknown;
+ return FWL_WidgetHit::Unknown;
}
-FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
- FX_FLOAT& fx,
- FX_FLOAT& fy) {
+FWL_Error CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
+ FX_FLOAT& fx,
+ FX_FLOAT& fy) {
if (m_pWidgetMgr->IsFormDisabled()) {
CFX_SizeF szOffset;
if (IsParent(pWidget)) {
@@ -376,7 +379,7 @@ FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
}
fx += szOffset.x;
fy += szOffset.y;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFX_RectF r;
CFX_Matrix m;
@@ -391,25 +394,17 @@ FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
IFWL_Widget* form1 =
m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
if (!form1)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (!pWidget) {
form1->GetWidgetRect(r);
fx += r.left;
fy += r.top;
-#ifdef FWL_UseMacSystemBorder
- if (form1->GetStyles() & FWL_WGTSTYLE_Caption) {
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b);
- fy += t;
- }
-#endif
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
IFWL_Widget* form2 =
m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm);
if (!form2)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (form1 != form2) {
form1->GetWidgetRect(r);
fx += r.left;
@@ -417,15 +412,6 @@ FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
form2->GetWidgetRect(r);
fx -= r.left;
fy -= r.top;
-#ifdef FWL_UseMacSystemBorder
- if ((form1->GetStyles() & FWL_WGTSTYLE_Caption) !=
- (form2->GetStyles() & FWL_WGTSTYLE_Caption)) {
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b);
- (form1->GetStyles() & FWL_WGTSTYLE_Caption) ? (fy += t) : (fy -= t);
- }
-#endif
}
parent = pWidget->GetParent();
if (parent) {
@@ -438,17 +424,17 @@ FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
fx -= r.left;
fy -= r.top;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) {
+FWL_Error CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) {
return TransformTo(pWidget, rt.left, rt.top);
}
-FWL_ERR CFWL_WidgetImp::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
+FWL_Error CFWL_WidgetImp::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
if (!m_pProperties)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (bGlobal) {
IFWL_Widget* parent = GetParent();
- CFX_PtrArray parents;
+ CFX_ArrayTemplate<IFWL_Widget*> parents;
while (parent) {
parents.Add(parent);
parent = parent->GetParent();
@@ -458,7 +444,7 @@ FWL_ERR CFWL_WidgetImp::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
CFX_RectF rect;
int32_t count = parents.GetSize();
for (int32_t i = count - 2; i >= 0; i--) {
- parent = static_cast<IFWL_Widget*>(parents.GetAt(i));
+ parent = parents.GetAt(i);
parent->GetMatrix(ctmOnParent, FALSE);
parent->GetWidgetRect(rect);
matrix.Concat(ctmOnParent, TRUE);
@@ -469,32 +455,32 @@ FWL_ERR CFWL_WidgetImp::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
} else {
matrix = m_pProperties->m_ctmOnParent;
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::SetMatrix(const CFX_Matrix& matrix) {
+FWL_Error CFWL_WidgetImp::SetMatrix(const CFX_Matrix& matrix) {
if (!m_pProperties)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_Widget* parent = GetParent();
if (!parent) {
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
m_pProperties->m_ctmOnParent = matrix;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return FWL_ERR_Indefinite;
+FWL_Error CFWL_WidgetImp::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ return FWL_Error::Indefinite;
}
IFWL_ThemeProvider* CFWL_WidgetImp::GetThemeProvider() {
return m_pProperties->m_pThemeProvider;
}
-FWL_ERR CFWL_WidgetImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
+FWL_Error CFWL_WidgetImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
m_pProperties->m_pThemeProvider = pThemeProvider;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetImp::SetDataProvider(IFWL_DataProvider* pDataProvider) {
+FWL_Error CFWL_WidgetImp::SetDataProvider(IFWL_DataProvider* pDataProvider) {
m_pProperties->m_pDataProvider = pDataProvider;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate(
IFWL_WidgetDelegate* pDelegate) {
@@ -508,12 +494,12 @@ IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate(
m_pCurDelegate = pDelegate;
return pOldDelegate;
}
-IFWL_NoteThread* CFWL_WidgetImp::GetOwnerThread() const {
- return static_cast<IFWL_NoteThread*>(m_pOwnerThread->GetInterface());
+IFWL_App* CFWL_WidgetImp::GetOwnerApp() const {
+ return static_cast<IFWL_App*>(m_pOwnerApp->GetInterface());
}
-FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread) {
- m_pOwnerThread = pOwnerThread;
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_WidgetImp::SetOwnerApp(CFWL_AppImp* pOwnerApp) {
+ m_pOwnerApp = pOwnerApp;
+ return FWL_Error::Succeeded;
}
IFWL_Widget* CFWL_WidgetImp::GetInterface() const {
return m_pInterface;
@@ -532,7 +518,7 @@ CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
m_iLock(0) {
*m_pProperties = properties;
m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- FXSYS_assert(m_pWidgetMgr != NULL);
+ ASSERT(m_pWidgetMgr != NULL);
}
CFWL_WidgetImp::~CFWL_WidgetImp() {
if (m_pPrivateData) {
@@ -586,28 +572,28 @@ void CFWL_WidgetImp::GetEdgeRect(CFX_RectF& rtEdge) {
}
FX_FLOAT CFWL_WidgetImp::GetBorderSize(FX_BOOL bCX) {
FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity(
- bCX ? FWL_WGTCAPACITY_CXBorder : FWL_WGTCAPACITY_CYBorder));
+ bCX ? CFWL_WidgetCapacity::CXBorder : CFWL_WidgetCapacity::CYBorder));
if (!pfBorder)
return 0;
return *pfBorder;
}
FX_FLOAT CFWL_WidgetImp::GetEdgeWidth() {
- uint32_t dwCapacity = 0;
+ CFWL_WidgetCapacity dwCapacity = CFWL_WidgetCapacity::None;
switch (m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask) {
case FWL_WGTSTYLE_EdgeFlat: {
- dwCapacity = FWL_WGTCAPACITY_EdgeFlat;
+ dwCapacity = CFWL_WidgetCapacity::EdgeFlat;
break;
}
case FWL_WGTSTYLE_EdgeRaised: {
- dwCapacity = FWL_WGTCAPACITY_EdgeRaised;
+ dwCapacity = CFWL_WidgetCapacity::EdgeRaised;
break;
}
case FWL_WGTSTYLE_EdgeSunken: {
- dwCapacity = FWL_WGTCAPACITY_EdgeSunken;
+ dwCapacity = CFWL_WidgetCapacity::EdgeSunken;
break;
}
}
- if (dwCapacity > 0) {
+ if (dwCapacity != CFWL_WidgetCapacity::None) {
FX_FLOAT* fRet = static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity));
return fRet ? *fRet : 0;
}
@@ -617,7 +603,7 @@ void CFWL_WidgetImp::GetRelativeRect(CFX_RectF& rect) {
rect = m_pProperties->m_rtWidget;
rect.left = rect.top = 0;
}
-void* CFWL_WidgetImp::GetThemeCapacity(uint32_t dwCapacity) {
+void* CFWL_WidgetImp::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) {
IFWL_ThemeProvider* pTheme = GetAvailableTheme();
if (!pTheme)
return NULL;
@@ -693,13 +679,16 @@ void CFWL_WidgetImp::CalcTextRect(const CFX_WideString& wsText,
void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) {
if (m_pWidgetMgr->IsFormDisabled())
return;
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
+
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
return;
+
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
if (!pDriver)
return;
+
IFWL_Widget* curFocus = pDriver->GetFocus();
if (bFocus && curFocus != m_pInterface) {
pDriver->SetFocus(m_pInterface);
@@ -708,37 +697,33 @@ void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) {
}
}
void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
return;
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
pDriver->SetGrab(m_pInterface, bSet);
}
+
FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- if (GetClassID() == FWL_CLASSHASH_Menu) {
- return GetPopupPosMenu(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- } else {
- if (GetClassID() == FWL_CLASSHASH_ComboBox) {
- if (m_pWidgetMgr->IsFormDisabled()) {
- return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
- fMaxHeight, rtAnchor, rtPopup);
- } else {
- return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- }
- } else if (GetClassID() == FWL_CLASSHASH_DateTimePicker &&
- m_pWidgetMgr->IsFormDisabled()) {
+ if (GetClassID() == FWL_Type::ComboBox) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
fMaxHeight, rtAnchor, rtPopup);
- } else {
- return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
}
+ return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
}
- return FALSE;
+ if (GetClassID() == FWL_Type::DateTimePicker &&
+ m_pWidgetMgr->IsFormDisabled()) {
+ return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
+ fMaxHeight, rtAnchor, rtPopup);
+ }
+ return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
}
+
FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
@@ -824,21 +809,25 @@ FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) {
}
void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource,
uint32_t dwFilter) {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
return;
- IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+
+ CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
if (!pNoteDriver)
return;
+
pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter);
}
void CFWL_WidgetImp::UnregisterEventTarget() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
return;
- IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+
+ CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
if (!pNoteDriver)
return;
+
pNoteDriver->UnregisterEventTarget(m_pInterface);
}
void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) {
@@ -858,13 +847,13 @@ void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) {
pDelegate->OnProcessEvent(pEvent);
return;
}
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
return;
- IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
if (!pNoteDriver)
return;
- pNoteDriver->SendNote(pEvent);
+ pNoteDriver->SendEvent(pEvent);
}
void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) {
if (pRect) {
@@ -877,7 +866,7 @@ void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) {
m_pWidgetMgr->RepaintWidget(m_pInterface, &rect);
}
void CFWL_WidgetImp::DrawBackground(CFX_Graphics* pGraphics,
- int32_t iPartBk,
+ CFWL_Part iPartBk,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
CFX_RectF rtRelative;
@@ -893,7 +882,7 @@ void CFWL_WidgetImp::DrawBackground(CFX_Graphics* pGraphics,
pTheme->DrawBackground(&param);
}
void CFWL_WidgetImp::DrawBorder(CFX_Graphics* pGraphics,
- int32_t iPartBorder,
+ CFWL_Part iPartBorder,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
CFX_RectF rtRelative;
@@ -909,7 +898,7 @@ void CFWL_WidgetImp::DrawBorder(CFX_Graphics* pGraphics,
pTheme->DrawBackground(&param);
}
void CFWL_WidgetImp::DrawEdge(CFX_Graphics* pGraphics,
- int32_t iPartEdge,
+ CFWL_Part iPartEdge,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix) {
CFX_RectF rtEdge;
@@ -925,13 +914,15 @@ void CFWL_WidgetImp::DrawEdge(CFX_Graphics* pGraphics,
pTheme->DrawBackground(&param);
}
void CFWL_WidgetImp::NotifyDriver() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
+ IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
return;
+
CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
if (!pDriver)
return;
+
pDriver->NotifyTargetDestroy(m_pInterface);
}
CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) {
@@ -963,15 +954,18 @@ FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget* pParent) {
}
return FALSE;
}
+
CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {}
-int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+
+void CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage->m_pDstTarget)
- return 0;
+ return;
+
CFWL_WidgetImp* pWidget =
static_cast<CFWL_WidgetImp*>(pMessage->m_pDstTarget->GetImpl());
- uint32_t dwMsgCode = pMessage->GetClassID();
+ CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case FWL_MSGHASH_Mouse: {
+ case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage);
CFWL_EvtMouse evt;
evt.m_pSrcTarget = pWidget->m_pInterface;
@@ -983,7 +977,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
pWidget->DispatchEvent(&evt);
break;
}
- case FWL_MSGHASH_MouseWheel: {
+ case CFWL_MessageType::MouseWheel: {
CFWL_MsgMouseWheel* pMsgMouseWheel =
static_cast<CFWL_MsgMouseWheel*>(pMessage);
CFWL_EvtMouseWheel evt;
@@ -997,7 +991,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
pWidget->DispatchEvent(&evt);
break;
}
- case FWL_MSGHASH_Key: {
+ case CFWL_MessageType::Key: {
CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage);
CFWL_EvtKey evt;
evt.m_pSrcTarget = pWidget->m_pInterface;
@@ -1008,7 +1002,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
pWidget->DispatchEvent(&evt);
break;
}
- case FWL_MSGHASH_SetFocus: {
+ case CFWL_MessageType::SetFocus: {
CFWL_MsgSetFocus* pMsgSetFocus = static_cast<CFWL_MsgSetFocus*>(pMessage);
CFWL_EvtSetFocus evt;
evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget;
@@ -1017,7 +1011,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
pWidget->DispatchEvent(&evt);
break;
}
- case FWL_MSGHASH_KillFocus: {
+ case CFWL_MessageType::KillFocus: {
CFWL_MsgKillFocus* pMsgKillFocus =
static_cast<CFWL_MsgKillFocus*>(pMessage);
CFWL_EvtKillFocus evt;
@@ -1027,83 +1021,15 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
pWidget->DispatchEvent(&evt);
break;
}
- default: {}
+ default:
+ break;
}
- return 1;
}
-FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- CFWL_EvtDraw evt;
- evt.m_pGraphics = pGraphics;
- return FWL_ERR_Succeeded;
-}
-class CFWL_CustomImp : public CFWL_WidgetImp {
- public:
- CFWL_CustomImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR SetProxy(IFWL_Proxy* pProxy);
- protected:
- IFWL_Proxy* m_pProxy;
-};
-CFWL_CustomImp::CFWL_CustomImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter), m_pProxy(NULL) {}
-FWL_ERR CFWL_CustomImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (m_pProxy &&
- (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
- return FWL_ERR_Succeeded;
- }
- return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
-}
-FWL_ERR CFWL_CustomImp::Update() {
- if (m_pProxy) {
- return m_pProxy->Update();
- }
- return CFWL_WidgetImp::Update();
-}
-FWL_ERR CFWL_CustomImp::SetProxy(IFWL_Proxy* pProxy) {
- m_pProxy = pProxy;
- return FWL_ERR_Succeeded;
-}
+void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
-// static
-IFWL_Custom* IFWL_Custom::Create(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter) {
- IFWL_Custom* pCustom = new IFWL_Custom;
- CFWL_CustomImp* pCustomImpl = new CFWL_CustomImp(properties, pOuter);
- pCustom->SetImpl(pCustomImpl);
- pCustomImpl->SetInterface(pCustom);
- return pCustom;
-}
-IFWL_Custom::IFWL_Custom() {}
-FWL_ERR IFWL_Custom::SetProxy(IFWL_Proxy* pProxy) {
- return static_cast<CFWL_CustomImp*>(GetImpl())->SetProxy(pProxy);
-}
-void FWL_SetWidgetRect(IFWL_Widget* widget, const CFX_RectF& rect) {
- static_cast<CFWL_WidgetImp*>(widget->GetImpl())->m_pProperties->m_rtWidget =
- rect;
-}
-void FWL_SetWidgetStates(IFWL_Widget* widget, uint32_t dwStates) {
- static_cast<CFWL_WidgetImp*>(widget->GetImpl())->m_pProperties->m_dwStates =
- dwStates;
-}
-void FWL_SetWidgetStyles(IFWL_Widget* widget, uint32_t dwStyles) {
- static_cast<CFWL_WidgetImp*>(widget->GetImpl())->m_pProperties->m_dwStyles =
- dwStyles;
-}
-FWL_ERR FWL_EnabelWidget(IFWL_Widget* widget, FX_BOOL bEnable) {
- widget->SetStates(FWL_WGTSTATE_Disabled, !bEnable);
- IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
- IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild);
- while (child) {
- FWL_EnabelWidget(child, bEnable);
- child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return FWL_ERR_Succeeded;
+void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ CFWL_EvtDraw evt;
+ evt.m_pGraphics = pGraphics;
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.h
index e460fb97339..1b1ccc4b742 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetimp.h
@@ -10,68 +10,80 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
#include "xfa/fwl/core/cfwl_event.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
+#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/ifwl_widgetdelegate.h"
+#include "xfa/fwl/core/include/fwl_widgethit.h"
+#include "xfa/fwl/theme/cfwl_widgettp.h"
+class CFWL_AppImp;
class CFWL_MsgKey;
-class CFWL_NoteThreadImp;
class CFWL_WidgetImpProperties;
class CFWL_WidgetMgr;
+class IFWL_App;
class IFWL_DataProvider;
-class IFWL_NoteThread;
class IFWL_ThemeProvider;
class IFWL_Widget;
+enum class FWL_Type;
-class CFWL_WidgetImp : public CFWL_TargetImp {
+class CFWL_WidgetImp {
public:
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ virtual ~CFWL_WidgetImp();
+
+ virtual FWL_Error Initialize();
+ virtual FWL_Error Finalize();
+ virtual FWL_Error GetClassName(CFX_WideString& wsClass) const;
+ virtual FWL_Type GetClassID() const = 0;
+ virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR GetGlobalRect(CFX_RectF& rect);
- virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect);
- virtual FWL_ERR GetClientRect(CFX_RectF& rect);
+ virtual FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ virtual FWL_Error GetGlobalRect(CFX_RectF& rect);
+ virtual FWL_Error SetWidgetRect(const CFX_RectF& rect);
+ virtual FWL_Error GetClientRect(CFX_RectF& rect);
virtual IFWL_Widget* GetParent();
- virtual FWL_ERR SetParent(IFWL_Widget* pParent);
+ virtual FWL_Error SetParent(IFWL_Widget* pParent);
virtual IFWL_Widget* GetOwner();
- virtual FWL_ERR SetOwner(IFWL_Widget* pOwner);
+ virtual FWL_Error SetOwner(IFWL_Widget* pOwner);
virtual IFWL_Widget* GetOuter();
virtual uint32_t GetStyles();
- virtual FWL_ERR ModifyStyles(uint32_t dwStylesAdded,
- uint32_t dwStylesRemoved);
+ virtual FWL_Error ModifyStyles(uint32_t dwStylesAdded,
+ uint32_t dwStylesRemoved);
virtual uint32_t GetStylesEx();
- virtual FWL_ERR ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
+ virtual FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
virtual uint32_t GetStates();
- virtual FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_ERR SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback);
+ virtual void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
+ virtual FWL_Error SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback);
virtual void* GetPrivateData(void* module_id);
- virtual FWL_ERR Update();
- virtual FWL_ERR LockUpdate();
- virtual FWL_ERR UnlockUpdate();
- virtual uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
- virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
- virtual FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
- virtual FWL_ERR SetMatrix(const CFX_Matrix& matrix);
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ virtual FWL_Error Update();
+ virtual FWL_Error LockUpdate();
+ virtual FWL_Error UnlockUpdate();
+ virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_Error TransformTo(IFWL_Widget* pWidget,
+ FX_FLOAT& fx,
+ FX_FLOAT& fy);
+ virtual FWL_Error TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
+ virtual FWL_Error GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
+ virtual FWL_Error SetMatrix(const CFX_Matrix& matrix);
+ virtual FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
virtual IFWL_ThemeProvider* GetThemeProvider();
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- virtual FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider);
+ virtual FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ virtual FWL_Error SetDataProvider(IFWL_DataProvider* pDataProvider);
virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
- virtual IFWL_NoteThread* GetOwnerThread() const;
- FWL_ERR SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread);
+ virtual IFWL_App* GetOwnerApp() const;
+ FWL_Error SetOwnerApp(CFWL_AppImp* pOwnerApp);
IFWL_Widget* GetInterface() const;
void SetInterface(IFWL_Widget* pInterface);
CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
protected:
+ friend class CFWL_WidgetImpDelegate;
+
CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- virtual ~CFWL_WidgetImp();
+
FX_BOOL IsEnabled() const;
FX_BOOL IsVisible() const;
FX_BOOL IsActive() const;
@@ -86,7 +98,7 @@ class CFWL_WidgetImp : public CFWL_TargetImp {
FX_FLOAT GetBorderSize(FX_BOOL bCX = TRUE);
FX_FLOAT GetEdgeWidth();
void GetRelativeRect(CFX_RectF& rect);
- void* GetThemeCapacity(uint32_t dwCapacity);
+ void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity);
IFWL_ThemeProvider* GetAvailableTheme();
CFWL_WidgetImp* GetRootOuter();
CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
@@ -124,22 +136,23 @@ class CFWL_WidgetImp : public CFWL_TargetImp {
void DispatchEvent(CFWL_Event* pEvent);
void Repaint(const CFX_RectF* pRect = NULL);
void DrawBackground(CFX_Graphics* pGraphics,
- int32_t iPartBk,
+ CFWL_Part iPartBk,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix = NULL);
void DrawBorder(CFX_Graphics* pGraphics,
- int32_t iPartBorder,
+ CFWL_Part iPartBorder,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix = NULL);
void DrawEdge(CFX_Graphics* pGraphics,
- int32_t iPartEdge,
+ CFWL_Part iPartEdge,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix = NULL);
void NotifyDriver();
FX_BOOL IsParent(IFWL_Widget* pParent);
+
CFWL_WidgetMgr* m_pWidgetMgr;
- CFWL_NoteThreadImp* m_pOwnerThread;
+ CFWL_AppImp* m_pOwnerApp;
CFWL_WidgetImpProperties* m_pProperties;
CFX_PrivateData* m_pPrivateData;
IFWL_WidgetDelegate* m_pDelegate;
@@ -147,20 +160,16 @@ class CFWL_WidgetImp : public CFWL_TargetImp {
IFWL_Widget* m_pOuter;
IFWL_Widget* m_pInterface;
int32_t m_iLock;
- friend class CFWL_WidgetImpDelegate;
- friend void FWL_SetWidgetRect(IFWL_Widget* widget, const CFX_RectF& rect);
- friend void FWL_SetWidgetStates(IFWL_Widget* widget, uint32_t dwStates);
- friend void FWL_SetWidgetStyles(IFWL_Widget* widget, uint32_t dwStyles);
};
class CFWL_WidgetImpDelegate : public IFWL_WidgetDelegate {
public:
CFWL_WidgetImpDelegate();
~CFWL_WidgetImpDelegate() override {}
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
};
#endif // XFA_FWL_CORE_FWL_WIDGETIMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.cpp b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.cpp
index 97a3cbc1f1b..f4ceb78c48a 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.cpp
@@ -9,13 +9,24 @@
#include "xfa/fwl/core/cfwl_message.h"
#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
-#include "xfa/fwl/core/ifwl_adapternative.h"
-#include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_form.h"
+#include "xfa/fxfa/app/xfa_fwladapter.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+
+namespace {
+
+const int kNeedRepaintHitPoints = 12;
+const int kNeedRepaintHitPiece = 3;
+
+struct FWL_NEEDREPAINTHITDATA {
+ CFX_PointF hitPoint;
+ bool bNotNeedRepaint;
+ bool bNotContainByDirty;
+};
+
+} // namespace
FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) {
#if (_FX_OS_ == _FX_MACOSX_)
@@ -24,23 +35,26 @@ FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) {
return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen;
#endif
}
+
IFWL_WidgetMgr* FWL_GetWidgetMgr() {
IFWL_App* pApp = FWL_GetApp();
if (!pApp)
return NULL;
return pApp->GetWidgetMgr();
}
-CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative)
- : m_dwCapability(0) {
+
+CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) : m_dwCapability(0) {
m_pDelegate = new CFWL_WidgetMgrDelegate(this);
m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate);
- FXSYS_assert(m_pAdapter);
+ ASSERT(m_pAdapter);
CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem;
m_mapWidgetItem.SetAt(NULL, pRoot);
+
#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
m_rtScreen.Reset();
#endif
}
+
CFWL_WidgetMgr::~CFWL_WidgetMgr() {
FX_POSITION ps = m_mapWidgetItem.GetStartPosition();
while (ps) {
@@ -50,11 +64,9 @@ CFWL_WidgetMgr::~CFWL_WidgetMgr() {
delete pItem;
}
m_mapWidgetItem.RemoveAll();
- if (m_pDelegate) {
- delete m_pDelegate;
- m_pDelegate = NULL;
- }
+ delete m_pDelegate;
}
+
int32_t CFWL_WidgetMgr::CountWidgets(IFWL_Widget* pParent) {
CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
return TravelWidgetMgr(pParentItem, NULL, NULL);
@@ -207,10 +219,10 @@ FX_BOOL CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) {
}
return TRUE;
}
-FWL_ERR CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect) {
+FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
+ const CFX_RectF* pRect) {
if (!m_pAdapter)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
IFWL_Widget* pNative = pWidget;
CFX_RectF rect(*pRect);
if (IsFormDisabled()) {
@@ -226,7 +238,7 @@ FWL_ERR CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
} else if (!IsAbleNative(pWidget)) {
pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm);
if (!pNative)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
pWidget->TransformTo(pNative, rect.left, rect.top);
}
AddRedrawCounts(pNative);
@@ -347,10 +359,8 @@ void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) {
}
pItem->pParent = pParentItem;
SetWidgetIndex(pChild, -1);
- if (!m_pAdapter)
- return;
- m_pAdapter->SetParentWidget(pChild, pParent);
}
+
FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) {
IFWL_Widget* pTemp = pChild;
do {
@@ -361,27 +371,9 @@ FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) {
} while (pTemp);
return FALSE;
}
-FWL_ERR CFWL_WidgetMgr::CreateWidget_Native(IFWL_Widget* pWidget) {
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->CreateWidget(pWidget, pWidget->GetOwner());
-}
-FWL_ERR CFWL_WidgetMgr::DestroyWidget_Native(IFWL_Widget* pWidget) {
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->DestroyWidget(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::GetWidgetRect_Native(IFWL_Widget* pWidget,
- CFX_RectF& rect) {
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->GetWidgetRect(pWidget, rect);
-}
-FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget,
- const CFX_RectF& rect) {
+
+FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget,
+ const CFX_RectF& rect) {
if (FWL_UseOffscreen(pWidget)) {
CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
pItem->iRedrawCounter++;
@@ -400,58 +392,9 @@ FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget,
pItem->bOutsideChanged = !m_rtScreen.Contains(rect);
#endif
}
- return m_pAdapter->SetWidgetRect(pWidget, rect);
-}
-FWL_ERR CFWL_WidgetMgr::SetWidgetPosition_Native(IFWL_Widget* pWidget,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- return m_pAdapter->SetWidgetPosition(pWidget, fx, fy);
-}
-FWL_ERR CFWL_WidgetMgr::SetWidgetIcon_Native(IFWL_Widget* pWidget,
- const CFX_DIBitmap* pIcon,
- FX_BOOL bBig) {
- return m_pAdapter->SetWidgetIcon(pWidget, pIcon, bBig);
-}
-FWL_ERR CFWL_WidgetMgr::SetWidgetCaption_Native(
- IFWL_Widget* pWidget,
- const CFX_WideStringC& wsCaption) {
- return m_pAdapter->SetWidgetCaption(pWidget, wsCaption);
-}
-FWL_ERR CFWL_WidgetMgr::SetBorderRegion_Native(IFWL_Widget* pWidget,
- CFX_Path* pPath) {
- return m_pAdapter->SetBorderRegion(pWidget, pPath);
-}
-FWL_ERR CFWL_WidgetMgr::ShowWidget_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->ShowWidget(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::HideWidget_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->HideWidget(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::SetNormal_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->SetNormal(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::SetMaximize_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->SetMaximize(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::SetMinimize_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->SetMinimize(pWidget);
-}
-FX_BOOL CFWL_WidgetMgr::CheckMessage_Native() {
- return m_pAdapter->CheckMessage();
-}
-FWL_ERR CFWL_WidgetMgr::DispatchMessage_Native() {
- return m_pAdapter->DispatchMessage();
-}
-FX_BOOL CFWL_WidgetMgr::IsIdleMessage_Native() {
- return m_pAdapter->IsIdleMessage();
-}
-FWL_ERR CFWL_WidgetMgr::Exit_Native(int32_t iExitCode) {
- return m_pAdapter->Exit(iExitCode);
-}
-FWL_ERR CFWL_WidgetMgr::CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget,
- void* vp) {
- return m_pAdapter->CreateWidgetWithNativeId(pWidget, vp);
+ return FWL_Error::Succeeded;
}
+
IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent,
FX_FLOAT x,
FX_FLOAT y) {
@@ -482,18 +425,18 @@ IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent,
}
return parent;
}
+
void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm,
FX_FLOAT fx,
FX_FLOAT fy) {
- if (!FWL_UseOffscreen(pForm)) {
+ if (!FWL_UseOffscreen(pForm))
return;
- }
+
CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pForm);
- if (pItem->pOffscreen) {
- delete pItem->pOffscreen;
- pItem->pOffscreen = NULL;
- }
+ delete pItem->pOffscreen;
+ pItem->pOffscreen = nullptr;
}
+
IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent,
IFWL_Widget* focus,
FX_BOOL& bFind) {
@@ -518,25 +461,13 @@ IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent,
int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) {
int32_t iRet = 0;
IFWL_Widget* pChild = pFirst;
- while (pChild) {
- if ((pChild->GetStyles() & FWL_WGTSTYLE_Group) &&
- pChild->GetClassID() == 3811304691) {
- iRet++;
- }
+ while (pChild)
pChild = GetWidget(pChild, FWL_WGTRELATION_NextSibling);
- }
return iRet;
}
IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget,
FX_BOOL bNext) {
- while ((pWidget = GetWidget(pWidget, bNext ? FWL_WGTRELATION_NextSibling
- : FWL_WGTRELATION_PriorSibling)) !=
- NULL) {
- if (pWidget->GetClassID() == 3811304691) {
- return pWidget;
- }
- }
- return NULL;
+ return nullptr;
}
IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
IFWL_Widget* pRadioButton) {
@@ -550,10 +481,6 @@ IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
}
}
pNext = GetWidget(pRadioButton, FWL_WGTRELATION_LastSibling);
- if ((pNext->GetStyles() & FWL_WGTSTYLE_Group) &&
- pNext->GetClassID() == 3811304691) {
- return pNext;
- }
while ((pNext = GetSiblingRadioButton(pNext, FALSE)) && pNext &&
pNext != pRadioButton) {
if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
@@ -561,23 +488,17 @@ IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
}
}
pNext = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
- if (pNext && (pNext->GetStyles() == FWL_WGTSTYLE_Group) &&
- pNext->GetClassID() == 3811304691) {
- return pNext;
- }
return GetSiblingRadioButton(pNext, TRUE);
}
-void CFWL_WidgetMgr::GetSameGroupRadioButton(IFWL_Widget* pRadioButton,
- CFX_PtrArray& group) {
+void CFWL_WidgetMgr::GetSameGroupRadioButton(
+ IFWL_Widget* pRadioButton,
+ CFX_ArrayTemplate<IFWL_Widget*>& group) {
IFWL_Widget* pFirst = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
if (!pFirst) {
pFirst = pRadioButton;
}
int32_t iGroup = CountRadioButtonGroup(pFirst);
if (iGroup < 2) {
- if (pFirst->GetClassID() == 3811304691) {
- group.Add(pFirst);
- }
IFWL_Widget* pNext = pFirst;
while ((pNext = GetSiblingRadioButton(pNext, TRUE)) != NULL) {
group.Add(pNext);
@@ -588,24 +509,19 @@ void CFWL_WidgetMgr::GetSameGroupRadioButton(IFWL_Widget* pRadioButton,
do {
group.Add(pNext);
pNext = GetSiblingRadioButton(pNext, TRUE);
- if (!pNext) {
- if (pFirst->GetClassID() == 3811304691) {
- pNext = pFirst;
- } else {
- pNext = GetSiblingRadioButton(pFirst, TRUE);
- }
- }
+ if (!pNext)
+ pNext = GetSiblingRadioButton(pFirst, TRUE);
} while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0));
}
IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) {
- if ((pParent->GetClassID() == 3521614244) &&
+ if ((pParent->GetClassID() == FWL_Type::PushButton) &&
(pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
return pParent;
}
IFWL_Widget* child =
FWL_GetWidgetMgr()->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
while (child) {
- if ((child->GetClassID() == 3521614244) &&
+ if ((child->GetClassID() == FWL_Type::PushButton) &&
(child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
return child;
}
@@ -669,75 +585,82 @@ FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) {
FWL_WGTSTYLE_OverLapper) ||
(dwStyles & FWL_WGTSTYLE_Popup);
}
-FX_BOOL CFWL_WidgetMgr::IsThreadEnabled() {
+
+bool CFWL_WidgetMgr::IsThreadEnabled() {
return !(m_dwCapability & FWL_WGTMGR_DisableThread);
}
-FX_BOOL CFWL_WidgetMgr::IsFormDisabled() {
- return m_dwCapability & FWL_WGTMGR_DisableForm;
+
+bool CFWL_WidgetMgr::IsFormDisabled() {
+ return !!(m_dwCapability & FWL_WGTMGR_DisableForm);
}
+
FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget,
FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- IFWL_AdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr();
+ CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr();
return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor,
rtPopup);
}
CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr)
: m_pWidgetMgr(pWidgetMgr) {}
-FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) {
+FWL_Error CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) {
m_pWidgetMgr->m_dwCapability = dwCapability;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) {
+
+void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) {
if (!pMessage)
- return 0;
+ return;
if (!pMessage->m_pDstTarget)
- return 0;
+ return;
+
IFWL_Widget* pDstWidget = pMessage->m_pDstTarget;
- IFWL_NoteThread* pNoteThread = pDstWidget->GetOwnerThread();
- if (!pNoteThread)
- return 0;
+ IFWL_App* pApp = pDstWidget->GetOwnerApp();
+ if (!pApp)
+ return;
+
CFWL_NoteDriver* pNoteDriver =
- static_cast<CFWL_NoteDriver*>(pNoteThread->GetNoteDriver());
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
if (!pNoteDriver)
- return 0;
- if (m_pWidgetMgr->IsThreadEnabled()) {
+ return;
+
+ if (m_pWidgetMgr->IsThreadEnabled())
pMessage = static_cast<CFWL_Message*>(pMessage->Clone());
- }
- if (m_pWidgetMgr->IsFormDisabled()) {
+ if (m_pWidgetMgr->IsFormDisabled())
pNoteDriver->ProcessMessage(pMessage);
- } else {
+ else
pNoteDriver->QueueMessage(pMessage);
- }
+
#if (_FX_OS_ == _FX_MACOSX_)
CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop();
- if (pTopLoop) {
+ if (pTopLoop)
pNoteDriver->UnqueueMessage(pTopLoop);
- }
#endif
- if (m_pWidgetMgr->IsThreadEnabled()) {
+
+ if (m_pWidgetMgr->IsThreadEnabled())
pMessage->Release();
- }
- return FWL_ERR_Succeeded;
+
+ return;
}
-FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- if (!pWidget)
- return FWL_ERR_Indefinite;
- if (!pGraphics)
- return FWL_ERR_Indefinite;
+
+void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ if (!pWidget || !pGraphics)
+ return;
+
CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix);
CFX_RectF clipCopy;
pWidget->GetWidgetRect(clipCopy);
clipCopy.left = clipCopy.top = 0;
if (bUseOffscreenDirect(pWidget)) {
DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
- return FWL_ERR_Succeeded;
+ return;
}
CFX_RectF clipBounds;
+
#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) || \
(_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_)
IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
@@ -753,61 +676,57 @@ FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget,
} else {
clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d);
const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast.
-#ifdef FWL_UseMacSystemBorder
-#else
-#endif
- {
- IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
- pDelegate->OnDrawWidget(pTemp, pMatrix);
- }
+ IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
+ pDelegate->OnDrawWidget(pTemp, pMatrix);
}
-#endif
+#endif // _FX_OS_ == _FX_MACOSX_
+
if (!m_pWidgetMgr->IsFormDisabled()) {
CFX_RectF rtClient;
pWidget->GetClientRect(rtClient);
clipBounds.Intersect(rtClient);
}
- if (!clipBounds.IsEmpty()) {
+ if (!clipBounds.IsEmpty())
DrawChild(pWidget, clipBounds, pTemp, pMatrix);
- }
+
DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
m_pWidgetMgr->ResetRedrawCounts(pWidget);
- return FWL_ERR_Succeeded;
}
+
void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent,
const CFX_RectF& rtClip,
CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
if (!parent)
return;
+
FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled();
IFWL_Widget* pNextChild =
m_pWidgetMgr->GetWidget(parent, FWL_WGTRELATION_FirstChild);
while (pNextChild) {
IFWL_Widget* child = pNextChild;
pNextChild = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- if (child->GetStates() & FWL_WGTSTATE_Invisible) {
+ if (child->GetStates() & FWL_WGTSTATE_Invisible)
continue;
- }
+
CFX_RectF rtWidget;
child->GetWidgetRect(rtWidget);
- if (rtWidget.IsEmpty()) {
+ if (rtWidget.IsEmpty())
continue;
- }
+
CFX_Matrix widgetMatrix;
CFX_RectF clipBounds(rtWidget);
- if (!bFormDisable) {
+ if (!bFormDisable)
child->GetMatrix(widgetMatrix, TRUE);
- }
- if (pMatrix) {
+ if (pMatrix)
widgetMatrix.Concat(*pMatrix);
- }
+
if (!bFormDisable) {
widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top);
clipBounds.Intersect(rtClip);
- if (clipBounds.IsEmpty()) {
+ if (clipBounds.IsEmpty())
continue;
- }
+
pGraphics->SaveGraphState();
pGraphics->SetClipRect(clipBounds);
}
@@ -819,21 +738,22 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent,
pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
}
}
- if (!bFormDisable) {
+ if (!bFormDisable)
pGraphics->RestoreGraphState();
- }
+
DrawChild(child, clipBounds, pGraphics,
bFormDisable ? &widgetMatrix : pMatrix);
child = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
}
}
+
CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore(
IFWL_Widget* pWidget,
CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
- if (!FWL_UseOffscreen(pWidget)) {
+ if (!FWL_UseOffscreen(pWidget))
return pGraphics;
- }
+
CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
if (!pItem->pOffscreen) {
pItem->pOffscreen = new CFX_Graphics;
@@ -847,6 +767,7 @@ CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore(
pItem->pOffscreen->SetClipRect(rect);
return pItem->pOffscreen;
}
+
void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget,
CFX_Graphics* pGraphics,
CFX_RectF& rtClip,
@@ -863,14 +784,6 @@ void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget,
pItem->iRedrawCounter = 0;
}
-#define FWL_NEEDREPAINTHIT_Point 12
-#define FWL_NEEDREPAINTHIT_Piece 3
-struct FWL_NEEDREPAINTHITDATA {
- CFX_PointF hitPoint;
- FX_BOOL bNotNeedRepaint;
- FX_BOOL bNotContainByDirty;
-};
-
FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget,
CFX_Matrix* pMatrix,
const CFX_RectF& rtDirty) {
@@ -883,36 +796,25 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget,
pWidget->GetWidgetRect(rtWidget);
rtWidget.left = rtWidget.top = 0;
pMatrix->TransformRect(rtWidget);
- if (!rtWidget.IntersectWith(rtDirty)) {
+ if (!rtWidget.IntersectWith(rtDirty))
return FALSE;
- }
+
IFWL_Widget* pChild =
FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild);
- if (!pChild) {
+ if (!pChild)
return TRUE;
- }
- if (pChild->GetClassID() == 3150298670) {
- CFX_RectF rtTemp;
- pChild->GetWidgetRect(rtTemp);
- if (rtTemp.width >= rtWidget.width && rtTemp.height >= rtWidget.height) {
- pChild =
- FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_FirstChild);
- if (!pChild) {
- return TRUE;
- }
- }
- }
+
CFX_RectF rtChilds;
rtChilds.Empty();
FX_BOOL bChildIntersectWithDirty = FALSE;
FX_BOOL bOrginPtIntersectWidthChild = FALSE;
FX_BOOL bOrginPtIntersectWidthDirty =
rtDirty.Contains(rtWidget.left, rtWidget.top);
- static FWL_NEEDREPAINTHITDATA hitPoint[FWL_NEEDREPAINTHIT_Point];
+ static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints];
int32_t iSize = sizeof(FWL_NEEDREPAINTHITDATA);
FXSYS_memset(hitPoint, 0, iSize);
- FX_FLOAT fxPiece = rtWidget.width / FWL_NEEDREPAINTHIT_Piece;
- FX_FLOAT fyPiece = rtWidget.height / FWL_NEEDREPAINTHIT_Piece;
+ FX_FLOAT fxPiece = rtWidget.width / kNeedRepaintHitPiece;
+ FX_FLOAT fyPiece = rtWidget.height / kNeedRepaintHitPiece;
hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left;
hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x =
hitPoint[10].hitPoint.x = fxPiece + rtWidget.left;
@@ -933,144 +835,71 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget,
CFX_RectF r = rect;
r.left += rtWidget.left;
r.top += rtWidget.top;
- if (r.IsEmpty()) {
+ if (r.IsEmpty())
continue;
- }
- if (r.Contains(rtDirty)) {
+ if (r.Contains(rtDirty))
return FALSE;
- }
- if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) {
+ if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty))
bChildIntersectWithDirty = TRUE;
- }
- if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) {
+ if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild)
bOrginPtIntersectWidthChild = rect.Contains(0, 0);
- }
- if (rtChilds.IsEmpty()) {
+
+ if (rtChilds.IsEmpty())
rtChilds = rect;
- } else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) {
+ else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible))
rtChilds.Union(rect);
- }
- for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) {
- if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) {
+
+ for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) {
+ if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint)
continue;
- }
if (!rtDirty.Contains(hitPoint[i].hitPoint)) {
- hitPoint[i].bNotContainByDirty = TRUE;
+ hitPoint[i].bNotContainByDirty = true;
continue;
}
- if (r.Contains(hitPoint[i].hitPoint)) {
- hitPoint[i].bNotNeedRepaint = TRUE;
- }
+ if (r.Contains(hitPoint[i].hitPoint))
+ hitPoint[i].bNotNeedRepaint = true;
}
} while ((pChild = FWL_GetWidgetMgr()->GetWidget(
pChild, FWL_WGTRELATION_NextSibling)) != NULL);
- if (!bChildIntersectWithDirty) {
+
+ if (!bChildIntersectWithDirty)
return TRUE;
- }
- if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) {
+ if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild)
return TRUE;
- }
- if (rtChilds.IsEmpty()) {
+ if (rtChilds.IsEmpty())
return TRUE;
- }
- int32_t repaintPoint = FWL_NEEDREPAINTHIT_Point;
- for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) {
- if (hitPoint[i].bNotNeedRepaint) {
+
+ int32_t repaintPoint = kNeedRepaintHitPoints;
+ for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) {
+ if (hitPoint[i].bNotNeedRepaint)
repaintPoint--;
- }
}
- if (repaintPoint > 0) {
+ if (repaintPoint > 0)
return TRUE;
- }
+
pMatrix->TransformRect(rtChilds);
- if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) {
+ if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget))
return FALSE;
- }
return TRUE;
}
+
FX_BOOL CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) {
CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) {
+ if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen))
return FALSE;
- }
+
#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
if (pItem->bOutsideChanged) {
CFX_RectF r;
pWidget->GetWidgetRect(r);
CFX_RectF temp(m_pWidgetMgr->m_rtScreen);
temp.Deflate(50, 50);
- if (!temp.Contains(r)) {
+ if (!temp.Contains(r))
return FALSE;
- }
+
pItem->bOutsideChanged = FALSE;
}
#endif
+
return pItem->iRedrawCounter == 0;
}
-static void FWL_WriteBMP(CFX_DIBitmap* pBitmap, const FX_CHAR* filename) {
- FILE* file = fopen(filename, "wb");
- if (file == NULL) {
- return;
- }
- int size = 14 + 40 + pBitmap->GetPitch() * pBitmap->GetHeight();
- unsigned char buffer[40];
- buffer[0] = 'B';
- buffer[1] = 'M';
- buffer[2] = (unsigned char)size;
- buffer[3] = (unsigned char)(size >> 8);
- buffer[4] = (unsigned char)(size >> 16);
- buffer[5] = (unsigned char)(size >> 24);
- buffer[6] = buffer[7] = buffer[8] = buffer[9] = 0;
- buffer[10] = 54;
- buffer[11] = buffer[12] = buffer[13] = 0;
- fwrite(buffer, 14, 1, file);
- memset(buffer, 0, 40);
- buffer[0] = 40;
- buffer[4] = (unsigned char)pBitmap->GetWidth();
- buffer[5] = (unsigned char)(pBitmap->GetWidth() >> 8);
- buffer[6] = (unsigned char)(pBitmap->GetWidth() >> 16);
- buffer[7] = (unsigned char)(pBitmap->GetWidth() >> 24);
- buffer[8] = (unsigned char)(-pBitmap->GetHeight());
- buffer[9] = (unsigned char)((-pBitmap->GetHeight()) >> 8);
- buffer[10] = (unsigned char)((-pBitmap->GetHeight()) >> 16);
- buffer[11] = (unsigned char)((-pBitmap->GetHeight()) >> 24);
- buffer[12] = 1;
- buffer[14] = pBitmap->GetBPP();
- fwrite(buffer, 40, 1, file);
- for (int row = 0; row < pBitmap->GetHeight(); row++) {
- uint8_t* scan_line = pBitmap->GetBuffer() + row * pBitmap->GetPitch();
- fwrite(scan_line, pBitmap->GetPitch(), 1, file);
- }
- fclose(file);
-}
-FWL_ERR FWL_WidgetMgrSnapshot(IFWL_Widget* pWidget,
- const CFX_WideString* saveFile,
- const CFX_Matrix* pMatrix) {
- CFX_RectF r;
- pWidget->GetWidgetRect(r);
- CFX_Graphics gs;
- gs.Create((int32_t)r.width, (int32_t)r.height, FXDIB_Argb);
- CFWL_WidgetMgr* widgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- CFWL_WidgetMgrDelegate* delegate = widgetMgr->GetDelegate();
- delegate->OnDrawWidget(pWidget, &gs, pMatrix);
- CFX_DIBitmap* dib = gs.GetRenderDevice()->GetBitmap();
- FWL_WriteBMP(dib, saveFile->UTF8Encode());
- return FWL_ERR_Succeeded;
-}
-FX_BOOL FWL_WidgetIsChild(IFWL_Widget* parent, IFWL_Widget* find) {
- if (!find) {
- return FALSE;
- }
- IFWL_Widget* child =
- FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild);
- while (child) {
- if (child == find) {
- return TRUE;
- }
- if (FWL_WidgetIsChild(child, find)) {
- return TRUE;
- }
- child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return FALSE;
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.h b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.h
index fa489971c56..fe176133643 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/fwl_widgetmgrimp.h
@@ -7,14 +7,21 @@
#ifndef XFA_FWL_CORE_FWL_WIDGETMGRIMP_H_
#define XFA_FWL_CORE_FWL_WIDGETMGRIMP_H_
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fwl/core/fwl_error.h"
#include "xfa/fwl/core/ifwl_widgetmgr.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
-class IFWL_Widget;
-class IFWL_AdapterWidgetMgr;
+#define FWL_WGTMGR_DisableThread 0x00000001
+#define FWL_WGTMGR_DisableForm 0x00000002
+
+class CFWL_Message;
class CFWL_WidgetMgrDelegate;
-class IFWL_AdapterNative;
+class CXFA_FFApp;
+class CXFA_FWLAdapterWidgetMgr;
+class CFX_Graphics;
+class CFX_Matrix;
+class IFWL_Widget;
class CFWL_WidgetMgrItem {
public:
@@ -54,7 +61,7 @@ class CFWL_WidgetMgrItem {
class CFWL_WidgetMgr : public IFWL_WidgetMgr {
public:
- CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative);
+ CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative);
~CFWL_WidgetMgr() override;
// IFWL_WidgetMgr:
@@ -64,8 +71,8 @@ class CFWL_WidgetMgr : public IFWL_WidgetMgr {
FWL_WGTRELATION eRelation) override;
int32_t GetWidgetIndex(IFWL_Widget* pWidget) override;
FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) override;
- FWL_ERR RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect = NULL) override;
+ FWL_Error RepaintWidget(IFWL_Widget* pWidget,
+ const CFX_RectF* pRect = NULL) override;
uint32_t GetCapability() override { return m_dwCapability; }
void AddWidget(IFWL_Widget* pWidget);
@@ -76,44 +83,23 @@ class CFWL_WidgetMgr : public IFWL_WidgetMgr {
void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned);
void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild);
FX_BOOL IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent);
- FWL_ERR CreateWidget_Native(IFWL_Widget* pWidget);
- FWL_ERR DestroyWidget_Native(IFWL_Widget* pWidget);
- FWL_ERR GetWidgetRect_Native(IFWL_Widget* pWidget, CFX_RectF& rect);
- FWL_ERR SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect);
- FWL_ERR SetWidgetPosition_Native(IFWL_Widget* pWidget,
- FX_FLOAT fx,
- FX_FLOAT fy);
- FWL_ERR SetWidgetIcon_Native(IFWL_Widget* pWidget,
- const CFX_DIBitmap* pIcon,
- FX_BOOL bBig);
- FWL_ERR SetWidgetCaption_Native(IFWL_Widget* pWidget,
- const CFX_WideStringC& wsCaption);
- FWL_ERR SetBorderRegion_Native(IFWL_Widget* pWidget, CFX_Path* pPath);
- FWL_ERR ShowWidget_Native(IFWL_Widget* pWidget);
- FWL_ERR HideWidget_Native(IFWL_Widget* pWidget);
- FWL_ERR SetNormal_Native(IFWL_Widget* pWidget);
- FWL_ERR SetMaximize_Native(IFWL_Widget* pWidget);
- FWL_ERR SetMinimize_Native(IFWL_Widget* pWidget);
- FX_BOOL CheckMessage_Native();
- FWL_ERR DispatchMessage_Native();
- FX_BOOL IsIdleMessage_Native();
- FWL_ERR Exit_Native(int32_t iExitCode);
- FWL_ERR CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget, void* vp);
+ FWL_Error SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect);
IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy);
void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy);
IFWL_Widget* nextTab(IFWL_Widget* parent, IFWL_Widget* focus, FX_BOOL& bFind);
int32_t CountRadioButtonGroup(IFWL_Widget* pFirst);
IFWL_Widget* GetSiblingRadioButton(IFWL_Widget* pWidget, FX_BOOL bNext);
IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton);
- void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, CFX_PtrArray& group);
+ void GetSameGroupRadioButton(IFWL_Widget* pRadioButton,
+ CFX_ArrayTemplate<IFWL_Widget*>& group);
IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent);
void AddRedrawCounts(IFWL_Widget* pWidget);
void ResetRedrawCounts(IFWL_Widget* pWidget);
- IFWL_AdapterWidgetMgr* GetAdapterWidgetMgr() { return m_pAdapter; }
- CFWL_WidgetMgrDelegate* GetDelegate() { return m_pDelegate; }
+ CXFA_FWLAdapterWidgetMgr* GetAdapterWidgetMgr() const { return m_pAdapter; }
+ CFWL_WidgetMgrDelegate* GetDelegate() const { return m_pDelegate; }
CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget);
- FX_BOOL IsThreadEnabled();
- FX_BOOL IsFormDisabled();
+ bool IsThreadEnabled();
+ bool IsFormDisabled();
FX_BOOL GetAdapterPopupPos(IFWL_Widget* pWidget,
FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
@@ -127,7 +113,7 @@ class CFWL_WidgetMgr : public IFWL_WidgetMgr {
IFWL_Widget** pWidget = NULL);
FX_BOOL IsAbleNative(IFWL_Widget* pWidget);
CFX_MapPtrToPtr m_mapWidgetItem;
- IFWL_AdapterWidgetMgr* m_pAdapter;
+ CXFA_FWLAdapterWidgetMgr* m_pAdapter;
CFWL_WidgetMgrDelegate* m_pDelegate;
friend class CFWL_WidgetMgrDelegate;
uint32_t m_dwCapability;
@@ -136,18 +122,16 @@ class CFWL_WidgetMgr : public IFWL_WidgetMgr {
#endif
};
-class CFWL_WidgetMgrDelegate : public IFWL_WidgetMgrDelegate {
+class CFWL_WidgetMgrDelegate {
public:
CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr);
- ~CFWL_WidgetMgrDelegate() override {}
+ ~CFWL_WidgetMgrDelegate() {}
- // IFWL_WidgetMgrDelegate:
- FWL_ERR OnSetCapability(
- uint32_t dwCapability = FWL_WGTMGR_DisableThread) override;
- int32_t OnProcessMessageToForm(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) override;
+ FWL_Error OnSetCapability(uint32_t dwCapability = FWL_WGTMGR_DisableThread);
+ void OnProcessMessageToForm(CFWL_Message* pMessage);
+ void OnDrawWidget(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix);
protected:
void DrawChild(IFWL_Widget* pParent,
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapternative.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapternative.h
deleted file mode 100644
index 6c6d8019ffd..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapternative.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_ADAPTERNATIVE_H_
-#define XFA_FWL_CORE_IFWL_ADAPTERNATIVE_H_
-
-class IFWL_WidgetMgrDelegate;
-class IFWL_AdapterWidgetMgr;
-class IFWL_AdapterThreadMgr;
-class IFWL_AdapterTimerMgr;
-
-class IFWL_AdapterNative {
- public:
- virtual ~IFWL_AdapterNative() {}
- virtual IFWL_AdapterWidgetMgr* GetWidgetMgr(
- IFWL_WidgetMgrDelegate* pDelegate) = 0;
- virtual IFWL_AdapterThreadMgr* GetThreadMgr() = 0;
- virtual IFWL_AdapterTimerMgr* GetTimerMgr() = 0;
-};
-
-#endif // XFA_FWL_CORE_IFWL_ADAPTERNATIVE_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapterthreadmgr.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapterthreadmgr.h
deleted file mode 100644
index 821ced31645..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapterthreadmgr.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_ADAPTERTHREADMGR_H_
-#define XFA_FWL_CORE_IFWL_ADAPTERTHREADMGR_H_
-
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-#include "xfa/fwl/core/ifwl_thread.h"
-
-class IFWL_AdapterThreadMgr {
- public:
- virtual ~IFWL_AdapterThreadMgr() {}
- virtual FWL_ERR Start(IFWL_Thread* pThread,
- FWL_HTHREAD& hThread,
- FX_BOOL bSuspended = FALSE) = 0;
- virtual FWL_ERR Resume(FWL_HTHREAD hThread) = 0;
- virtual FWL_ERR Suspend(FWL_HTHREAD hThread) = 0;
- virtual FWL_ERR Kill(FWL_HTHREAD hThread, int32_t iExitCode) = 0;
- virtual FWL_ERR Stop(FWL_HTHREAD hThread, int32_t iExitCode) = 0;
- virtual IFWL_Thread* GetCurrentThread() = 0;
-};
-
-#endif // XFA_FWL_CORE_IFWL_ADAPTERTHREADMGR_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapterwidgetmgr.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapterwidgetmgr.h
deleted file mode 100644
index 1e8405ab2fd..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_adapterwidgetmgr.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_ADAPTERWIDGETMGR_H_
-#define XFA_FWL_CORE_IFWL_ADAPTERWIDGETMGR_H_
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-class IFWL_Widget;
-class IFWL_Menu;
-class IFWL_MenuDP;
-class CFX_Path;
-class CFX_DIBitmap;
-class IFWL_AdapterMessageHook;
-
-class IFWL_AdapterWidgetMgr {
- public:
- virtual ~IFWL_AdapterWidgetMgr() {}
- virtual FWL_ERR CreateWidget(IFWL_Widget* pWidget,
- IFWL_Widget* pParent = NULL) = 0;
- virtual FWL_ERR DestroyWidget(IFWL_Widget* pWidget) = 0;
- virtual FWL_ERR GetWidgetRect(IFWL_Widget* pWidget, CFX_RectF& rect) = 0;
- virtual FWL_ERR SetWidgetRect(IFWL_Widget* pWidget,
- const CFX_RectF& rect) = 0;
- virtual FWL_ERR SetWidgetPosition(IFWL_Widget* pWidget,
- FX_FLOAT fx,
- FX_FLOAT fy) = 0;
- virtual FWL_ERR SetParentWidget(IFWL_Widget* pWidget,
- IFWL_Widget* pParent) = 0;
- virtual FWL_ERR SetWidgetIcon(IFWL_Widget* pWidget,
- const CFX_DIBitmap* pIcon,
- FX_BOOL bBig) = 0;
- virtual FWL_ERR SetWidgetCaption(IFWL_Widget* pWidget,
- const CFX_WideStringC& wsCaption) = 0;
- virtual FWL_ERR SetBorderRegion(IFWL_Widget* pWidget, CFX_Path* pPath) = 0;
- virtual FWL_ERR SetTransparent(IFWL_Widget* pWidget, uint32_t dwAlpha) = 0;
- virtual FWL_ERR ShowWidget(IFWL_Widget* pWidget) = 0;
- virtual FWL_ERR HideWidget(IFWL_Widget* pWidget) = 0;
- virtual FWL_ERR SetNormal(IFWL_Widget* pWidget) = 0;
- virtual FWL_ERR SetMaximize(IFWL_Widget* pWidget) = 0;
- virtual FWL_ERR SetMinimize(IFWL_Widget* pWidget) = 0;
- virtual FWL_ERR SetFullScreen(IFWL_Widget* pWidget, FX_BOOL bFullScreen) = 0;
- virtual FX_BOOL CheckMessage() = 0;
- virtual FX_BOOL IsIdleMessage() = 0;
- virtual FWL_ERR DispatchMessage() = 0;
- virtual FWL_ERR RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect) = 0;
- virtual FWL_ERR Exit(int32_t iExitCode) = 0;
- virtual FWL_ERR CreateWidgetWithNativeId(IFWL_Widget* pWidget,
- void* UserData) = 0;
- virtual FWL_ERR GetWidgetDC(IFWL_Widget* pWidget, void*& pDC) = 0;
- virtual FWL_ERR ReleaseWidgetDC(IFWL_Widget* pWidget,
- void* pDC,
- CFX_RectF* pClip = 0) = 0;
- virtual void* GetWindow(IFWL_Widget* pWidget) = 0;
- virtual uint32_t GetKeyState(uint32_t dwVirtKey) = 0;
- virtual FWL_ERR RunLoop(IFWL_Widget* widget) = 0;
- virtual FWL_ERR EndLoop() = 0;
- virtual FWL_ERR InitMenu(IFWL_Menu* pMenu, IFWL_MenuDP* pMenuData) = 0;
- virtual FWL_ERR UpdateMenu(IFWL_Menu* pMenu,
- const void* hItem,
- int32_t iType) = 0;
- virtual int32_t TrackPopupMenu(IFWL_Menu* pMenu, IFWL_MenuDP* pMenuData) = 0;
- virtual FWL_ERR SetMessageHook(IFWL_AdapterMessageHook* hook) = 0;
- virtual FWL_ERR GetSystemBorder(FX_FLOAT& l,
- FX_FLOAT& t,
- FX_FLOAT& r,
- FX_FLOAT& b) = 0;
- virtual FX_BOOL GetPopupPos(IFWL_Widget* pWidget,
- FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) = 0;
-};
-
-#endif // XFA_FWL_CORE_IFWL_ADAPTERWIDGETMGR_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_app.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_app.h
index ed1fd673b22..41983ef8f51 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_app.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_app.h
@@ -7,39 +7,61 @@
#ifndef XFA_FWL_CORE_IFWL_APP_H_
#define XFA_FWL_CORE_IFWL_APP_H_
+// The FWL app code contains three parallel classes, which reference each
+// other via pointers as follows:
+//
+// m_pIface m_pImpl
+// CXFA_FFApp ------------> IFWL_App -----------> CFWL_AppImp
+// <-----------
+// m_pIface
+
+#include <memory>
+
#include "core/fxcrt/include/fx_string.h"
-#include "xfa/fwl/core/ifwl_notethread.h"
+#include "xfa/fwl/core/fwl_appimp.h"
+#include "xfa/fwl/core/fwl_error.h"
-class IFWL_AdapterNative;
+class CFWL_NoteDriver;
+class CXFA_FFApp;
+class CXFA_FWLAdapterWidgetMgr;
+class IFWL_ThemeProvider;
class IFWL_Widget;
class IFWL_WidgetMgr;
-class IFWL_ThemeProvider;
-class IFWL_AdapterWidgetMgr;
-class IFWL_App : public IFWL_NoteThread {
+class IFWL_App {
public:
- static IFWL_App* Create(IFWL_AdapterNative* pAdapter);
+ static IFWL_App* Create(CXFA_FFApp* pAdapter);
+
+ virtual ~IFWL_App() {}
- FWL_ERR Initialize();
- FWL_ERR Finalize();
- IFWL_AdapterNative* GetAdapterNative();
+ FWL_Error Initialize();
+ FWL_Error Finalize();
+ CXFA_FFApp* GetAdapterNative();
IFWL_WidgetMgr* GetWidgetMgr();
IFWL_ThemeProvider* GetThemeProvider();
- FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- FWL_ERR Exit(int32_t iExitCode);
+ void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ void Exit(int32_t iExitCode);
+
+ // These call into polymorphic methods in the impl; no need to override.
+ void Release();
+
+ CFWL_AppImp* GetImpl() const { return m_pImpl.get(); }
+
+ // Takes ownership of |pImpl|.
+ void SetImpl(CFWL_AppImp* pImpl) { m_pImpl.reset(pImpl); }
+
+ CFWL_NoteDriver* GetNoteDriver() const;
private:
IFWL_App() {}
+
+ std::unique_ptr<CFWL_AppImp> m_pImpl;
};
IFWL_App* FWL_GetApp();
void FWL_SetApp(IFWL_App* pApp);
-IFWL_AdapterNative* FWL_GetAdapterNative();
-IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr();
-IFWL_ThemeProvider* FWL_GetThemeProvider();
-extern FWL_ERR FWL_Execute(const CFX_WideStringC& wsExecutable,
- const CFX_WideStringC& wsParameters);
-FWL_ERR FWL_SetFullScreen(IFWL_Widget* pWidget, FX_BOOL bFullScreen);
-FX_BOOL FWL_AppIsActived();
+
+CXFA_FFApp* FWL_GetAdapterNative();
+CXFA_FWLAdapterWidgetMgr* FWL_GetAdapterWidgetMgr();
#endif // XFA_FWL_CORE_IFWL_APP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_content.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_content.h
deleted file mode 100644
index 76292a609c4..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_content.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_CONTENT_H_
-#define XFA_FWL_CORE_IFWL_CONTENT_H_
-
-#include "xfa/fwl/core/fwl_widgetimp.h"
-#include "xfa/fwl/core/ifwl_widget.h"
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-class IFWL_Content : public IFWL_Widget {
- public:
- static IFWL_Content* Create();
- FWL_ERR InsertWidget(IFWL_Widget* pChild, int32_t nIndex = -1);
- FWL_ERR RemoveWidget(IFWL_Widget* pWidget);
- FWL_ERR RemoveAllWidgets();
- FWL_ERR GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight);
- FWL_ERR SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
- FWL_ERR GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight);
- FWL_ERR SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
-
- protected:
- IFWL_Content();
-};
-
-#endif // XFA_FWL_CORE_IFWL_CONTENT_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_custom.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_custom.h
deleted file mode 100644
index d7f1b40923e..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_custom.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_CUSTOM_H_
-#define XFA_FWL_CORE_IFWL_CUSTOM_H_
-
-#include "xfa/fwl/core/fwl_error.h"
-#include "xfa/fwl/core/ifwl_widget.h"
-
-class IFWL_Proxy;
-
-class IFWL_Custom : public IFWL_Widget {
- public:
- static IFWL_Custom* Create(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
-
- FWL_ERR SetProxy(IFWL_Proxy* pProxy);
-
- protected:
- IFWL_Custom();
-};
-
-#endif // XFA_FWL_CORE_IFWL_CUSTOM_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_custompanel.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_custompanel.h
deleted file mode 100644
index 3491227af07..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_custompanel.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_CUSTOMPANEL_H_
-#define XFA_FWL_CORE_IFWL_CUSTOMPANEL_H_
-
-#include "xfa/fwl/core/fwl_widgetimp.h"
-#include "xfa/fwl/core/ifwl_widget.h"
-
-class IFWL_Proxy;
-
-class IFWL_CustomPanel : public IFWL_Widget {
- public:
- static IFWL_CustomPanel* Create(CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
-
- IFWL_Content* GetContent();
- FWL_ERR SetContent(IFWL_Content* pContent);
- FWL_ERR SetProxy(IFWL_Proxy* pProxy);
-
- protected:
- IFWL_CustomPanel();
-};
-
-#endif // XFA_FWL_CORE_IFWL_CUSTOMPANEL_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_dataprovider.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_dataprovider.h
index 271edb7ac85..5643a3d0797 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_dataprovider.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_dataprovider.h
@@ -15,8 +15,8 @@ class IFWL_Widget;
class IFWL_DataProvider {
public:
virtual ~IFWL_DataProvider() {}
- virtual FWL_ERR GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) = 0;
+ virtual FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) = 0;
};
#endif // XFA_FWL_CORE_IFWL_DATAPROVIDER_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_form.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_form.h
index b5cb72b1811..75bec50d8e8 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_form.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_form.h
@@ -7,15 +7,13 @@
#ifndef XFA_FWL_CORE_IFWL_FORM_H_
#define XFA_FWL_CORE_IFWL_FORM_H_
-#include "xfa/fwl/core/ifwl_panel.h"
#include "xfa/fwl/core/ifwl_dataprovider.h"
+#include "xfa/fwl/core/ifwl_widget.h"
#include "core/fxcrt/include/fx_system.h"
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#define FWL_CLASS_Form L"FWL_FORM"
-#define FWL_CLASSHASH_Form 881567292
#define FWL_CLASS_FormProxy L"FWL_FORMPROXY"
-#define FWL_CLASSHASH_FormProxy 881567291
#define FWL_STYLEEXT_FRM_Resize (1L << 0)
#define FWL_STYLEEXT_FRM_NativeBorder (1L << 1)
#define FWL_STYLEEXT_FRM_RoundCorner (2L << 1)
@@ -28,26 +26,6 @@
#define FWL_UseMacSystemBorder
#endif
-#define FWL_WGTCAPACITY_FRM_CYCaption (FWL_WGTCAPACITY_MAX + 1)
-#define FWL_WGTCAPACITY_FRM_CYNarrowCaption (FWL_WGTCAPACITY_MAX + 2)
-#define FWL_WGTCAPACITY_FRM_BigIcon (FWL_WGTCAPACITY_MAX + 3)
-#define FWL_WGTCAPACITY_FRM_SmallIcon (FWL_WGTCAPACITY_MAX + 4)
-#define FWL_PART_FRM_Border 1
-#define FWL_PART_FRM_Edge 2
-#define FWL_PART_FRM_Background 3
-#define FWL_PART_FRM_Caption 4
-#define FWL_PART_FRM_NarrowCaption 5
-#define FWL_PART_FRM_CloseBox 6
-#define FWL_PART_FRM_MinimizeBox 7
-#define FWL_PART_FRM_MaximizeBox 8
-#define FWL_PART_FRM_HeadText 9
-#define FWL_PART_FRM_Icon 10
-#define FWL_PARTSTATE_FRM_Normal 1
-#define FWL_PARTSTATE_FRM_Hover 2
-#define FWL_PARTSTATE_FRM_Pressed 3
-#define FWL_PARTSTATE_FRM_Inactive 4
-#define FWL_PARTSTATE_FRM_Disabled 5
-
enum FWL_FORMSIZE {
FWL_FORMSIZE_Manual = 0,
FWL_FORMSIZE_Width,
@@ -55,17 +33,6 @@ enum FWL_FORMSIZE {
FWL_FORMSIZE_All,
};
-enum FWL_COMMANDID {
- FWL_COMMANDID_Close = 0,
- FWL_COMMANDID_Ok,
- FWL_COMMANDID_Cancel,
- FWL_COMMANDID_Abort,
- FWL_COMMANDID_Retry,
- FWL_COMMANDID_Ignore,
- FWL_COMMANDID_Yes,
- FWL_COMMANDID_No,
-};
-
class CFX_DIBitmap;
class CFX_WideString;
class CFX_Path;
@@ -77,18 +44,18 @@ class IFWL_FormDP : public IFWL_DataProvider {
virtual CFX_DIBitmap* GetIcon(IFWL_Widget* pWidget, FX_BOOL bBig) = 0;
};
-class IFWL_Form : public IFWL_Panel {
+class IFWL_Form : public IFWL_Widget {
public:
static IFWL_Form* CreateFormProxy(CFWL_WidgetImpProperties& properties,
CFX_WideString* classname,
IFWL_Widget* pOuter);
FWL_FORMSIZE GetFormSize();
- FWL_ERR SetFormSize(FWL_FORMSIZE eFormSize);
+ FWL_Error SetFormSize(FWL_FORMSIZE eFormSize);
IFWL_Widget* DoModal();
IFWL_Widget* DoModal(uint32_t& dwCommandID);
- FWL_ERR EndDoModal();
- FWL_ERR SetBorderRegion(CFX_Path* pPath);
+ FWL_Error EndDoModal();
+ FWL_Error SetBorderRegion(CFX_Path* pPath);
protected:
IFWL_Form();
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_grid.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_grid.h
deleted file mode 100644
index f1ef57f9125..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_grid.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_GRID_H_
-#define XFA_FWL_CORE_IFWL_GRID_H_
-
-#include "xfa/fwl/core/ifwl_content.h"
-
-class IFWL_Widget;
-
-#define FWL_CLASS_Grid L"FWL_GRID"
-#define FWL_CLASSHASH_Grid 3150298670
-#define FWL_GRIDSTYLEEXT_ShowGridLines (1L << 0)
-
-struct FWL_LAYOUTDATA {
- FX_FLOAT fWidth;
- FX_FLOAT fHeight;
-};
-
-enum FWL_GRIDUNIT {
- FWL_GRIDUNIT_Auto = 0,
- FWL_GRIDUNIT_Fixed,
- FWL_GRIDUNIT_Scaled,
- FWL_GRIDUNIT_Infinity,
-};
-
-enum FWL_GRIDMARGIN {
- FWL_GRIDMARGIN_Left = 0,
- FWL_GRIDMARGIN_Top,
- FWL_GRIDMARGIN_Right,
- FWL_GRIDMARGIN_Bottom,
-};
-
-enum FWL_GRIDSIZE {
- FWL_GRIDSIZE_Width = 0,
- FWL_GRIDSIZE_Height,
- FWL_GRIDSIZE_MinWidth,
- FWL_GRIDSIZE_MinHeight,
- FWL_GRIDSIZE_MaxWidth,
- FWL_GRIDSIZE_MaxHeight,
-};
-
-typedef struct FWL_HGRIDCOLROW_ { void* pData; } * FWL_HGRIDCOLROW;
-
-class IFWL_Grid : public IFWL_Content {
- public:
- static IFWL_Grid* Create(const CFWL_WidgetImpProperties& properties);
-
- FWL_HGRIDCOLROW InsertColRow(FX_BOOL bColumn, int32_t nIndex = -1);
- int32_t CountColRows(FX_BOOL bColumn);
- FWL_HGRIDCOLROW GetColRow(FX_BOOL bColumn, int32_t nIndex);
- int32_t GetIndex(FWL_HGRIDCOLROW hColRow);
- FX_FLOAT GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- FWL_ERR SetSize(FWL_HGRIDCOLROW hColRow, FX_FLOAT fSize, FWL_GRIDUNIT eUnit);
- FX_FLOAT GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- FWL_ERR SetMinSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit);
- FX_FLOAT GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- FWL_ERR SetMaxSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit);
- FX_BOOL DeleteColRow(FWL_HGRIDCOLROW hColRow);
- FX_BOOL IsColumn(FWL_HGRIDCOLROW hColRow);
- int32_t GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn);
- FWL_ERR SetWidgetPos(IFWL_Widget* pWidget, int32_t iPos, FX_BOOL bColumn);
- int32_t GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn);
- FWL_ERR SetWidgetSpan(IFWL_Widget* pWidget, int32_t iSpan, FX_BOOL bColumn);
- FX_FLOAT GetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FWL_GRIDUNIT& eUnit);
- FWL_ERR SetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit);
- FX_BOOL GetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT& fMargin);
- FWL_ERR SetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT fMargin);
- FWL_ERR RemoveWidgetMargin(IFWL_Widget* pWidget, FWL_GRIDMARGIN eMargin);
- FX_FLOAT GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit);
- FWL_ERR SetGridSize(FWL_GRIDSIZE eSize, FX_FLOAT fSize, FWL_GRIDUNIT eUit);
-
- protected:
- IFWL_Grid();
-};
-
-#endif // XFA_FWL_CORE_IFWL_GRID_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_notedriver.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_notedriver.h
deleted file mode 100644
index 706e97af152..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_notedriver.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_NOTEDRIVER_H_
-#define XFA_FWL_CORE_IFWL_NOTEDRIVER_H_
-
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/cfwl_event.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-#define FWL_KEYFLAG_Ctrl (1 << 0)
-#define FWL_KEYFLAG_Alt (1 << 1)
-#define FWL_KEYFLAG_Shift (1 << 2)
-#define FWL_KEYFLAG_Command (1 << 3)
-#define FWL_KEYFLAG_LButton (1 << 4)
-#define FWL_KEYFLAG_RButton (1 << 5)
-#define FWL_KEYFLAG_MButton (1 << 6)
-
-class CFWL_Message;
-class CFWL_Note;
-class IFWL_NoteLoop;
-class IFWL_NoteThread;
-class IFWL_Widget;
-
-class IFWL_NoteDriver {
- public:
- virtual ~IFWL_NoteDriver() {}
-
- virtual FX_BOOL SendNote(CFWL_Note* pNote) = 0;
- virtual FWL_ERR RegisterEventTarget(
- IFWL_Widget* pListener,
- IFWL_Widget* pEventSource = NULL,
- uint32_t dwFilter = FWL_EVENT_ALL_MASK) = 0;
- virtual FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) = 0;
- virtual void ClearEventTargets(FX_BOOL bRemoveAll) = 0;
- virtual int32_t GetQueueMaxSize() const = 0;
- virtual FWL_ERR SetQueueMaxSize(const int32_t size) = 0;
- virtual IFWL_NoteThread* GetOwnerThread() const = 0;
- virtual FWL_ERR PushNoteLoop(IFWL_NoteLoop* pNoteLoop) = 0;
- virtual IFWL_NoteLoop* PopNoteLoop() = 0;
- virtual IFWL_Widget* GetFocus() = 0;
- virtual FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE) = 0;
- virtual void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) = 0;
- virtual FWL_ERR Run() = 0;
-};
-
-IFWL_Widget* FWL_GetCurrentThreadModalWidget(IFWL_NoteThread* pNoteThread);
-
-typedef FX_BOOL (*FWLMessageHookCallback)(CFWL_Message* msg, void* info);
-FWL_ERR FWL_SetHook(IFWL_NoteDriver* driver,
- FWLMessageHookCallback callback,
- void* info);
-
-#endif // XFA_FWL_CORE_IFWL_NOTEDRIVER_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_noteloop.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_noteloop.h
deleted file mode 100644
index a56d880b4a8..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_noteloop.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_NOTELOOP_H_
-#define XFA_FWL_CORE_IFWL_NOTELOOP_H_
-
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-class CFWL_Message;
-
-class IFWL_NoteLoop {
- public:
- virtual ~IFWL_NoteLoop() {}
- virtual FX_BOOL PreProcessMessage(CFWL_Message* pMessage) = 0;
- virtual FWL_ERR Idle(int32_t count) = 0;
-};
-
-#endif // XFA_FWL_CORE_IFWL_NOTELOOP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_notethread.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_notethread.h
deleted file mode 100644
index 30a29b5a9c3..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_notethread.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_NOTETHREAD_H_
-#define XFA_FWL_CORE_IFWL_NOTETHREAD_H_
-
-#include "xfa/fwl/core/ifwl_thread.h"
-
-class IFWL_NoteDriver;
-
-class IFWL_NoteThread : public IFWL_Thread {
- public:
- IFWL_NoteDriver* GetNoteDriver();
-};
-
-#endif // XFA_FWL_CORE_IFWL_NOTETHREAD_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_panel.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_panel.h
deleted file mode 100644
index ec9b02d3f7c..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_panel.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_PANEL_H_
-#define XFA_FWL_CORE_IFWL_PANEL_H_
-
-#include "xfa/fwl/core/fwl_widgetimp.h"
-#include "xfa/fwl/core/ifwl_widget.h"
-
-class IFWL_Content;
-
-#define FWL_CLASS_Panel L"FWL_Panel"
-#define FWL_CLASSHASH_Panel 881567292
-
-class IFWL_Panel : public IFWL_Widget {
- public:
- static IFWL_Panel* Create(CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
-
- IFWL_Content* GetContent();
- FWL_ERR SetContent(IFWL_Content* pContent);
-
- protected:
- IFWL_Panel();
-};
-
-#endif // XFA_FWL_CORE_IFWL_PANEL_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_proxy.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_proxy.h
deleted file mode 100644
index 80393c53821..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_proxy.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_PROXY_H_
-#define XFA_FWL_CORE_IFWL_PROXY_H_
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-class IFWL_Proxy {
- public:
- virtual ~IFWL_Proxy() {}
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) = 0;
- virtual FWL_ERR Update() = 0;
-};
-
-#endif // XFA_FWL_CORE_IFWL_PROXY_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_target.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_target.h
deleted file mode 100644
index f0de3b13ee1..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_target.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_TARGET_H_
-#define XFA_FWL_CORE_IFWL_TARGET_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-// FWL contains three parallel inheritance hierarchies, which reference each
-// other via pointers as follows:
-//
-// m_pImpl
-// (nonesuch) IFWL_Target ----------> CFWL_TargetImp
-// | |
-// A A
-// m_pIface | |
-// CFWL_Widget ----------> IFWL_Widget CFWL_WidgetImp
-// | | |
-// A A A
-// | | |
-// CFWL_... IFWL_... CFWL_...Imp
-//
-
-class CFWL_TargetImp;
-
-class IFWL_Target {
- public:
- IFWL_Target() : m_pImpl(nullptr) {}
- virtual ~IFWL_Target();
-
- // These call into equivalent polymorphic methods of m_pImpl. There
- // should be no need to override these in subclasses.
- FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- uint32_t GetClassID() const;
- FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- FWL_ERR Initialize();
- FWL_ERR Finalize();
-
- CFWL_TargetImp* GetImpl() const { return m_pImpl; }
-
- protected:
- void SetImpl(CFWL_TargetImp* pImpl) { m_pImpl = pImpl; }
-
- private:
- CFWL_TargetImp* m_pImpl;
-};
-
-#endif // XFA_FWL_CORE_IFWL_TARGET_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_themeprovider.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_themeprovider.h
index f0fb1492a89..274b27958ab 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_themeprovider.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_themeprovider.h
@@ -10,21 +10,7 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
#include "xfa/fwl/core/fwl_error.h"
-
-#define FWL_WGTCAPACITY_CXBorder 1
-#define FWL_WGTCAPACITY_CYBorder 2
-#define FWL_WGTCAPACITY_ScrollBarWidth 3
-#define FWL_WGTCAPACITY_EdgeFlat 4
-#define FWL_WGTCAPACITY_EdgeRaised 5
-#define FWL_WGTCAPACITY_EdgeSunken 6
-#define FWL_WGTCAPACITY_Font 7
-#define FWL_WGTCAPACITY_FontSize 8
-#define FWL_WGTCAPACITY_TextColor 9
-#define FWL_WGTCAPACITY_TextSelColor 10
-#define FWL_WGTCAPACITY_LineHeight 11
-#define FWL_WGTCAPACITY_UIMargin 12
-#define FWL_WGTCAPACITY_SpaceAboveBelow 13
-#define FWL_WGTCAPACITY_MAX 65535
+#include "xfa/fwl/theme/cfwl_widgettp.h"
class CFWL_ThemeBackground;
class CFWL_ThemePart;
@@ -34,21 +20,22 @@ class IFWL_Widget;
class IFWL_ThemeProvider {
public:
virtual ~IFWL_ThemeProvider() {}
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget) = 0;
+ virtual bool IsValidWidget(IFWL_Widget* pWidget) = 0;
virtual uint32_t GetThemeID(IFWL_Widget* pWidget) = 0;
virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren = TRUE) = 0;
- virtual FWL_ERR GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) = 0;
- virtual FWL_ERR SetThemeMatrix(IFWL_Widget* pWidget,
- const CFX_Matrix& matrix) = 0;
+ virtual FWL_Error GetThemeMatrix(IFWL_Widget* pWidget,
+ CFX_Matrix& matrix) = 0;
+ virtual FWL_Error SetThemeMatrix(IFWL_Widget* pWidget,
+ const CFX_Matrix& matrix) = 0;
virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) = 0;
virtual FX_BOOL DrawText(CFWL_ThemeText* pParams) = 0;
virtual void* GetCapacity(CFWL_ThemePart* pThemePart,
- uint32_t dwCapacity) = 0;
+ CFWL_WidgetCapacity dwCapacity) = 0;
virtual FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget) = 0;
- virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart,
- CFX_RectF& rtPart) = 0;
+ virtual FWL_Error GetPartRect(CFWL_ThemePart* pThemePart,
+ CFX_RectF& rtPart) = 0;
virtual FX_BOOL IsInPart(CFWL_ThemePart* pThemePart,
FX_FLOAT fx,
FX_FLOAT fy) = 0;
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_thread.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_thread.h
deleted file mode 100644
index c6f0c445d14..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_thread.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_THREAD_H_
-#define XFA_FWL_CORE_IFWL_THREAD_H_
-
-// The FWL thread/app code contains three parallel inheritance hierarchies,
-// which reference each other via pointers as follows:
-//
-// m_pImpl
-// (nonesuch) IFWL_Thread ----------> CFWL_ThreadImp
-// | <---------- |
-// A m_pIface A
-// | |
-// (nonesuch) IFWL_NoteThread CFWL_NoteThreadImp
-// | |
-// A A
-// m_pIface | |
-// CFWL_App --------------> IFWL_App CFWL_AppImp
-//
-
-#include "xfa/fwl/core/fwl_error.h"
-
-class CFWL_ThreadImp;
-class IFWL_NoteDriver;
-
-typedef struct FWL_HTHREAD_ { void* pData; } * FWL_HTHREAD;
-
-class IFWL_Thread {
- public:
- // These call into polymorphic methods in the impl; no need to override.
- void Release();
- FWL_ERR Run(FWL_HTHREAD hThread);
-
- CFWL_ThreadImp* GetImpl() const { return m_pImpl; }
- void SetImpl(CFWL_ThreadImp* pImpl) { m_pImpl = pImpl; }
-
- protected:
- virtual ~IFWL_Thread() {}
-
- private:
- CFWL_ThreadImp* m_pImpl;
-};
-
-#endif // XFA_FWL_CORE_IFWL_THREAD_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_timer.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_timer.h
index 5f113bc021e..01435604103 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_timer.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_timer.h
@@ -19,6 +19,6 @@ class IFWL_Timer {
FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer,
uint32_t dwElapse,
FX_BOOL bImmediately = TRUE);
-int32_t FWL_StopTimer(FWL_HTIMER hTimer);
+FWL_Error FWL_StopTimer(FWL_HTIMER hTimer);
#endif // XFA_FWL_CORE_IFWL_TIMER_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_tooltiptarget.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_tooltiptarget.h
index b0bbe44a7ab..7489e73efd0 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_tooltiptarget.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_tooltiptarget.h
@@ -20,18 +20,15 @@ class IFWL_ToolTipTarget {
virtual ~IFWL_ToolTipTarget() {}
virtual IFWL_Widget* GetWidget() = 0;
virtual FX_BOOL IsShowed() = 0;
- virtual FWL_ERR DrawToolTip(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix,
- IFWL_Widget* pToolTip) = 0;
+ virtual FWL_Error DrawToolTip(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix,
+ IFWL_Widget* pToolTip) = 0;
virtual FX_BOOL UseDefaultTheme() = 0;
- virtual FWL_ERR GetCaption(CFX_WideString& wsCaption) = 0;
- virtual FWL_ERR GetToolTipSize(CFX_SizeF& sz) = 0;
- virtual FWL_ERR GetToolTipPos(CFX_PointF& pt) { return FWL_ERR_Indefinite; }
+ virtual FWL_Error GetCaption(CFX_WideString& wsCaption) = 0;
+ virtual FWL_Error GetToolTipSize(CFX_SizeF& sz) = 0;
+ virtual FWL_Error GetToolTipPos(CFX_PointF& pt) {
+ return FWL_Error::Indefinite;
+ }
};
-FWL_ERR FWL_AddToolTipTarget(IFWL_ToolTipTarget* pTarget);
-FWL_ERR FWL_RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget);
-FWL_ERR FWL_SetToolTipInitialDelay(int32_t iDelayTime);
-FWL_ERR FWL_SetToolTipAutoPopDelay(int32_t iDelayTime);
-
#endif // XFA_FWL_CORE_IFWL_TOOLTIPTARGET_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widget.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widget.h
index eb1183fdf19..8bbf8da469e 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widget.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widget.h
@@ -7,63 +7,111 @@
#ifndef XFA_FWL_CORE_IFWL_WIDGET_H_
#define XFA_FWL_CORE_IFWL_WIDGET_H_
-#include "xfa/fwl/core/fwl_error.h"
+#include <memory>
+
+#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fwl/core/ifwl_target.h"
+#include "xfa/fwl/core/fwl_error.h"
+#include "xfa/fwl/core/fwl_widgetimp.h"
+
+// FWL contains three parallel inheritance hierarchies, which reference each
+// other via pointers as follows:
+//
+// m_pIface m_pImpl
+// CFWL_Widget ----------> IFWL_Widget ----------> CFWL_WidgetImp
+// | | |
+// A A A
+// | | |
+// CFWL_... IFWL_... CFWL_...Imp
+//
+
+enum class FWL_Type {
+ Unknown = 0,
+ Barcode,
+ Caret,
+ CheckBox,
+ ComboBox,
+ DateTimePicker,
+ Edit,
+ Form,
+ FormProxy,
+ ListBox,
+ MonthCalendar,
+ PictureBox,
+ PushButton,
+ ScrollBar,
+ SpinButton,
+ ToolTip
+};
+
+class CFWL_WidgetImp;
class CFX_Graphics;
+class IFWL_App;
class IFWL_DataProvider;
class IFWL_Form;
-class IFWL_NoteThread;
class IFWL_ThemeProvider;
class IFWL_WidgetDelegate;
-class IFWL_Widget : public IFWL_Target {
+class IFWL_Widget {
public:
- FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- FWL_ERR GetGlobalRect(CFX_RectF& rect);
- FWL_ERR SetWidgetRect(const CFX_RectF& rect);
- FWL_ERR GetClientRect(CFX_RectF& rect);
+ IFWL_Widget() : m_pImpl(nullptr) {}
+ virtual ~IFWL_Widget();
+
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ FWL_Error GetGlobalRect(CFX_RectF& rect);
+ FWL_Error SetWidgetRect(const CFX_RectF& rect);
+ FWL_Error GetClientRect(CFX_RectF& rect);
IFWL_Widget* GetParent();
- FWL_ERR SetParent(IFWL_Widget* pParent);
+ FWL_Error SetParent(IFWL_Widget* pParent);
IFWL_Widget* GetOwner();
- FWL_ERR SetOwner(IFWL_Widget* pOwner);
+ FWL_Error SetOwner(IFWL_Widget* pOwner);
IFWL_Widget* GetOuter();
uint32_t GetStyles();
- FWL_ERR ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
+ FWL_Error ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
uint32_t GetStylesEx();
- FWL_ERR ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved);
+ FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
uint32_t GetStates();
- FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
- FWL_ERR SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback);
+ void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
+ FWL_Error SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback);
void* GetPrivateData(void* module_id);
- FWL_ERR Update();
- FWL_ERR LockUpdate();
- FWL_ERR UnlockUpdate();
- uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
- FWL_ERR TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
- FWL_ERR TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
- FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
- FWL_ERR SetMatrix(const CFX_Matrix& matrix);
- FWL_ERR DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = NULL);
+ FWL_Error Update();
+ FWL_Error LockUpdate();
+ FWL_Error UnlockUpdate();
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ FWL_Error TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
+ FWL_Error TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
+ FWL_Error GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
+ FWL_Error SetMatrix(const CFX_Matrix& matrix);
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
IFWL_ThemeProvider* GetThemeProvider();
- FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider);
+ FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
+ FWL_Error SetDataProvider(IFWL_DataProvider* pDataProvider);
IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
- IFWL_NoteThread* GetOwnerThread() const;
+ IFWL_App* GetOwnerApp() const;
CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
-};
-typedef CFX_MapPtrTemplate<uint32_t, uint32_t> CFX_MapAccelerators;
+ // These call into equivalent polymorphic methods of m_pImpl. There
+ // should be no need to override these in subclasses.
+ FWL_Error GetClassName(CFX_WideString& wsClass) const;
+ FWL_Type GetClassID() const;
+ FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
+ FWL_Error Initialize();
+ FWL_Error Finalize();
-FWL_ERR FWL_Accelerator_SetApp(CFX_MapAccelerators* pMapAccel);
-FWL_ERR FWL_Accelerator_SetThread(CFX_MapAccelerators* pMapAccel);
-FWL_ERR FWL_Accelerator_SetForm(IFWL_Form* pFrom,
- CFX_MapAccelerators* pMapAccel);
-FWL_ERR FWL_EnabelWidget(IFWL_Widget* widget, FX_BOOL bEnable);
+ CFWL_WidgetImp* GetImpl() const { return m_pImpl.get(); }
+
+ protected:
+ // Takes ownership of |pImpl|.
+ void SetImpl(CFWL_WidgetImp* pImpl) { m_pImpl.reset(pImpl); }
+
+ private:
+ std::unique_ptr<CFWL_WidgetImp> m_pImpl;
+};
#endif // XFA_FWL_CORE_IFWL_WIDGET_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetdelegate.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetdelegate.h
index 7fb56d3ba13..820fb6b1c4a 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetdelegate.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetdelegate.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_CORE_IFWL_WIDGETDELEGATE_H_
#define XFA_FWL_CORE_IFWL_WIDGETDELEGATE_H_
+#include <stdint.h>
+
#include "xfa/fwl/core/fwl_error.h"
class CFWL_Event;
@@ -17,10 +19,10 @@ class CFX_Matrix;
class IFWL_WidgetDelegate {
public:
virtual ~IFWL_WidgetDelegate() {}
- virtual int32_t OnProcessMessage(CFWL_Message* pMessage) = 0;
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent) = 0;
- virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) = 0;
+ virtual void OnProcessMessage(CFWL_Message* pMessage) = 0;
+ virtual void OnProcessEvent(CFWL_Event* pEvent) = 0;
+ virtual void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) = 0;
};
#endif // XFA_FWL_CORE_IFWL_WIDGETDELEGATE_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgr.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgr.h
index 648206eea9a..6e25b72290a 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgr.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgr.h
@@ -37,15 +37,11 @@ class IFWL_WidgetMgr {
FWL_WGTRELATION eRelation) = 0;
virtual int32_t GetWidgetIndex(IFWL_Widget* pWidget) = 0;
virtual FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) = 0;
- virtual FWL_ERR RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect = NULL) = 0;
+ virtual FWL_Error RepaintWidget(IFWL_Widget* pWidget,
+ const CFX_RectF* pRect = NULL) = 0;
virtual uint32_t GetCapability() = 0;
};
IFWL_WidgetMgr* FWL_GetWidgetMgr();
-FX_BOOL FWL_WidgetIsChild(IFWL_Widget* parent, IFWL_Widget* find);
-FWL_ERR FWL_WidgetMgrSnapshot(IFWL_Widget* pWidget,
- const CFX_WideString* saveFile,
- const CFX_Matrix* pMatrix = NULL);
#endif // XFA_FWL_CORE_IFWL_WIDGETMGR_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgrdelegate.h b/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgrdelegate.h
deleted file mode 100644
index 2435c0bc23e..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/core/ifwl_widgetmgrdelegate.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_WIDGETMGRDELEGATE_H_
-#define XFA_FWL_CORE_IFWL_WIDGETMGRDELEGATE_H_
-
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-#define FWL_WGTMGR_DisableThread 0x00000001
-#define FWL_WGTMGR_DisableForm 0x00000002
-
-class CFWL_Message;
-class CFX_Graphics;
-class CFX_Matrix;
-class IFWL_Widget;
-
-class IFWL_WidgetMgrDelegate {
- public:
- virtual ~IFWL_WidgetMgrDelegate() {}
-
- virtual FWL_ERR OnSetCapability(
- uint32_t dwCapability = FWL_WGTMGR_DisableThread) = 0;
- virtual int32_t OnProcessMessageToForm(CFWL_Message* pMessage) = 0;
- virtual FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) = 0;
-};
-
-#endif // XFA_FWL_CORE_IFWL_WIDGETMGRDELEGATE_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/include/fwl_widgethit.h b/chromium/third_party/pdfium/xfa/fwl/core/include/fwl_widgethit.h
new file mode 100644
index 00000000000..102024a5109
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fwl/core/include/fwl_widgethit.h
@@ -0,0 +1,35 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_INCLUDE_FWL_WIDGETHIT_H_
+#define XFA_FWL_CORE_INCLUDE_FWL_WIDGETHIT_H_
+
+enum class FWL_WidgetHit {
+ Unknown = 0,
+ Client,
+ Left,
+ Top,
+ Right,
+ Bottom,
+ LeftTop,
+ RightTop,
+ LeftBottom,
+ RightBottom,
+ Titlebar,
+ MinBox,
+ MaxBox,
+ CloseBox,
+ HScrollBar,
+ VScrollBar,
+ Border,
+ Edge,
+ Edit,
+ HyperLink,
+ UpButton,
+ DownButton
+};
+
+#endif // XFA_FWL_CORE_INCLUDE_FWL_WIDGETHIT_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/core/include/ifwl_adaptertimermgr.h b/chromium/third_party/pdfium/xfa/fwl/core/include/ifwl_adaptertimermgr.h
index 64fc260ce54..7859e31fd8d 100644
--- a/chromium/third_party/pdfium/xfa/fwl/core/include/ifwl_adaptertimermgr.h
+++ b/chromium/third_party/pdfium/xfa/fwl/core/include/ifwl_adaptertimermgr.h
@@ -15,11 +15,11 @@ class IFWL_Timer;
class IFWL_AdapterTimerMgr {
public:
virtual ~IFWL_AdapterTimerMgr() {}
- virtual FWL_ERR Start(IFWL_Timer* pTimer,
- uint32_t dwElapse,
- FWL_HTIMER& hTimer,
- FX_BOOL bImmediately = TRUE) = 0;
- virtual FWL_ERR Stop(FWL_HTIMER hTimer) = 0;
+ virtual FWL_Error Start(IFWL_Timer* pTimer,
+ uint32_t dwElapse,
+ FWL_HTIMER& hTimer,
+ FX_BOOL bImmediately = TRUE) = 0;
+ virtual FWL_Error Stop(FWL_HTIMER hTimer) = 0;
};
#endif // XFA_FWL_CORE_INCLUDE_IFWL_ADAPTERTIMERMGR_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_app.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_app.cpp
deleted file mode 100644
index c09e5c0a262..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_app.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/lightwidget/cfwl_app.h"
-
-#include "core/fxcrt/include/fx_coordinates.h"
-#include "xfa/fwl/core/fwl_error.h"
-#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/lightwidget/cfwl_theme.h"
-
-CFWL_App::CFWL_App() : m_pIface(IFWL_App::Create(nullptr)), m_pTheme(nullptr) {}
-
-CFWL_App::~CFWL_App() {
- if (m_pTheme) {
- m_pTheme->Finalize();
- delete m_pTheme;
- }
- m_pIface->Release();
-}
-
-FWL_ERR CFWL_App::Initialize() {
- m_pTheme = new CFWL_Theme;
- m_pTheme->Initialize();
- m_pIface->SetThemeProvider(m_pTheme);
- return m_pIface->Initialize();
-}
-
-FWL_ERR CFWL_App::Exit(int32_t iExitCode) {
- if (!m_pIface)
- return FWL_ERR_Indefinite;
- return m_pIface->Exit(iExitCode);
-}
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_app.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_app.h
deleted file mode 100644
index 24cbd5abb44..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_app.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_LIGHTWIDGET_CFWL_APP_H_
-#define XFA_FWL_LIGHTWIDGET_CFWL_APP_H_
-
-#include "xfa/fwl/core/fwl_error.h"
-
-class CFWL_Theme;
-class IFWL_App;
-
-class CFWL_App {
- public:
- CFWL_App();
- virtual ~CFWL_App();
-
- FWL_ERR Initialize();
- FWL_ERR Exit(int32_t iExitCode);
-
- CFWL_Theme* GetTheme() const { return m_pTheme; }
- IFWL_App* GetInterface() const { return m_pIface; }
-
- private:
- IFWL_App* m_pIface;
- CFWL_Theme* m_pTheme;
-};
-
-#endif // XFA_FWL_LIGHTWIDGET_CFWL_APP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.cpp
index 4ac358ce54a..4b998d04d70 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.cpp
@@ -12,21 +12,21 @@ CFWL_Barcode* CFWL_Barcode::Create() {
return new CFWL_Barcode;
}
-FWL_ERR CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_Barcode> pBarcode(IFWL_Barcode::Create(
m_pProperties->MakeWidgetImpProperties(&m_barcodeData)));
- FWL_ERR ret = pBarcode->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pBarcode->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pBarcode.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFWL_Barcode::CFWL_Barcode() {}
@@ -44,7 +44,7 @@ FX_BOOL CFWL_Barcode::IsProtectedType() {
return 0;
return static_cast<IFWL_Barcode*>(m_pIface)->IsProtectedType();
}
-FWL_ERR CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) {
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_Error::Succeeded;
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.h
index e1e7e658d58..565ebb884e9 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_barcode.h
@@ -17,7 +17,7 @@ class CFWL_WidgetProperties;
class CFWL_Barcode : public CFWL_Edit {
public:
static CFWL_Barcode* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
void SetType(BC_TYPE type);
FX_BOOL IsProtectedType();
@@ -74,7 +74,9 @@ class CFWL_Barcode : public CFWL_Edit {
m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_TRUNCATED;
m_barcodeData.m_bTruncated = truncated;
}
- void ResetBarcodeAttributes() { m_barcodeData.m_dwAttributeMask = 0; }
+ void ResetBarcodeAttributes() {
+ m_barcodeData.m_dwAttributeMask = FWL_BCDATTRIBUTE_NONE;
+ }
protected:
CFWL_Barcode();
@@ -82,38 +84,39 @@ class CFWL_Barcode : public CFWL_Edit {
class CFWL_BarcodeDP : public IFWL_BarcodeDP {
public:
- virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
+ CFWL_BarcodeDP() : m_dwAttributeMask(FWL_BCDATTRIBUTE_NONE) {}
+
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
+ BC_CHAR_ENCODING GetCharEncoding() override { return m_eCharEncoding; }
+ int32_t GetModuleHeight() override { return m_nModuleHeight; }
+ int32_t GetModuleWidth() override { return m_nModuleWidth; }
+ int32_t GetDataLength() override { return m_nDataLength; }
+ int32_t GetCalChecksum() override { return m_nCalChecksum; }
+ FX_BOOL GetPrintChecksum() override { return m_bPrintChecksum; }
+ BC_TEXT_LOC GetTextLocation() override { return m_eTextLocation; }
+ int32_t GetWideNarrowRatio() override { return m_nWideNarrowRatio; }
+ FX_CHAR GetStartChar() override { return m_cStartChar; }
+ FX_CHAR GetEndChar() override { return m_cEndChar; }
+ int32_t GetVersion() override { return m_nVersion; }
+ int32_t GetErrorCorrectionLevel() override { return m_nECLevel; }
+ FX_BOOL GetTruncated() override { return m_bTruncated; }
+ uint32_t GetBarcodeAttributeMask() override { return m_dwAttributeMask; }
+
BC_CHAR_ENCODING m_eCharEncoding;
- virtual BC_CHAR_ENCODING GetCharEncoding() { return m_eCharEncoding; }
int32_t m_nModuleHeight, m_nModuleWidth;
- virtual int32_t GetModuleHeight() { return m_nModuleHeight; }
- virtual int32_t GetModuleWidth() { return m_nModuleWidth; }
int32_t m_nDataLength;
- virtual int32_t GetDataLength() { return m_nDataLength; }
int32_t m_nCalChecksum;
- virtual int32_t GetCalChecksum() { return m_nCalChecksum; }
FX_BOOL m_bPrintChecksum;
- virtual FX_BOOL GetPrintChecksum() { return m_bPrintChecksum; }
-
BC_TEXT_LOC m_eTextLocation;
- virtual BC_TEXT_LOC GetTextLocation() { return m_eTextLocation; }
int32_t m_nWideNarrowRatio;
- virtual int32_t GetWideNarrowRatio() { return m_nWideNarrowRatio; }
FX_CHAR m_cStartChar, m_cEndChar;
- virtual FX_CHAR GetStartChar() { return m_cStartChar; }
- virtual FX_CHAR GetEndChar() { return m_cEndChar; }
int32_t m_nVersion;
- virtual int32_t GetVersion() { return m_nVersion; }
int32_t m_nECLevel;
- virtual int32_t GetErrorCorrectionLevel() { return m_nECLevel; }
FX_BOOL m_bTruncated;
- virtual FX_BOOL GetTruncated() { return m_bTruncated; }
uint32_t m_dwAttributeMask;
- virtual uint32_t GetBarcodeAttributeMask() { return m_dwAttributeMask; }
-
- public:
- CFWL_BarcodeDP() : m_dwAttributeMask(0) {}
};
+
CFWL_BarcodeDP m_barcodeData;
};
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_caret.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_caret.cpp
deleted file mode 100644
index 7fea4f9e774..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_caret.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/lightwidget/cfwl_caret.h"
-
-#include <memory>
-
-#include "xfa/fwl/basewidget/ifwl_caret.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fxgraphics/cfx_color.h"
-#include "xfa/fwl/lightwidget/cfwl_edit.h"
-
-CFWL_Caret* CFWL_Caret::Create() {
- return new CFWL_Caret;
-}
-
-FWL_ERR CFWL_Caret::Initialize(const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_ERR_Indefinite;
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_Caret> pCaret(IFWL_Caret::Create(
- m_pProperties->MakeWidgetImpProperties(nullptr), nullptr));
- FWL_ERR ret = pCaret->Initialize();
- if (ret != FWL_ERR_Succeeded) {
- return ret;
- }
- m_pIface = pCaret.release();
- CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
-}
-
-FWL_ERR CFWL_Caret::ShowCaret(FX_BOOL bFlag) {
- return static_cast<IFWL_Caret*>(m_pIface)->ShowCaret(bFlag);
-}
-
-FWL_ERR CFWL_Caret::GetFrequency(uint32_t& elapse) {
- return static_cast<IFWL_Caret*>(m_pIface)->GetFrequency(elapse);
-}
-
-FWL_ERR CFWL_Caret::SetFrequency(uint32_t elapse) {
- return static_cast<IFWL_Caret*>(m_pIface)->SetFrequency(elapse);
-}
-
-FWL_ERR CFWL_Caret::SetColor(CFX_Color crFill) {
- return static_cast<IFWL_Caret*>(m_pIface)->SetColor(crFill);
-}
-
-CFWL_Caret::CFWL_Caret() {}
-
-CFWL_Caret::~CFWL_Caret() {}
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_caret.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_caret.h
deleted file mode 100644
index c806f2eb738..00000000000
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_caret.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_LIGHTWIDGET_CFWL_CARET_H_
-#define XFA_FWL_LIGHTWIDGET_CFWL_CARET_H_
-
-#include "xfa/fwl/core/fwl_error.h"
-#include "xfa/fxgraphics/cfx_color.h"
-#include "xfa/fwl/lightwidget/cfwl_widget.h"
-
-class CFWL_Caret : public CFWL_Widget {
- public:
- static CFWL_Caret* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
- FWL_ERR ShowCaret(FX_BOOL bFlag = TRUE);
- FWL_ERR GetFrequency(uint32_t& elapse);
- FWL_ERR SetFrequency(uint32_t elapse);
- FWL_ERR SetColor(CFX_Color crFill);
-
- protected:
- CFWL_Caret();
- virtual ~CFWL_Caret();
-};
-
-#endif // XFA_FWL_LIGHTWIDGET_CFWL_CARET_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.cpp
index b5e2a87d67a..a93bc4674aa 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.cpp
@@ -14,38 +14,38 @@ CFWL_CheckBox* CFWL_CheckBox::Create() {
return new CFWL_CheckBox;
}
-FWL_ERR CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_CheckBox> pCheckBox(IFWL_CheckBox::Create(
m_pProperties->MakeWidgetImpProperties(&m_checkboxData), nullptr));
- FWL_ERR ret = pCheckBox->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pCheckBox->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pCheckBox.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption) {
+FWL_Error CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption) {
m_checkboxData.m_wsCaption = wsCaption;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) {
+FWL_Error CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) {
m_checkboxData.m_fBoxHeight = fHeight;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_CheckBox::GetCheckState() {
return static_cast<IFWL_CheckBox*>(m_pIface)->GetCheckState();
}
-FWL_ERR CFWL_CheckBox::SetCheckState(int32_t iCheck) {
+FWL_Error CFWL_CheckBox::SetCheckState(int32_t iCheck) {
return static_cast<IFWL_CheckBox*>(m_pIface)->SetCheckState(iCheck);
}
@@ -56,10 +56,11 @@ CFWL_CheckBox::~CFWL_CheckBox() {}
CFWL_CheckBox::CFWL_CheckBoxDP::CFWL_CheckBoxDP()
: m_fBoxHeight(16.0f), m_wsCaption(L"Check box") {}
-FWL_ERR CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) {
+FWL_Error CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption(
+ IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget* pWidget) {
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.h
index 7b7e4004bdb..061e46f777c 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_checkbox.h
@@ -14,12 +14,12 @@ class CFWL_CheckBox : public CFWL_Widget {
public:
static CFWL_CheckBox* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
- FWL_ERR GetCaption(CFX_WideString& wsCaption);
- FWL_ERR SetCaption(const CFX_WideStringC& wsCaption);
- FWL_ERR SetBoxSize(FX_FLOAT fHeight);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error GetCaption(CFX_WideString& wsCaption);
+ FWL_Error SetCaption(const CFX_WideStringC& wsCaption);
+ FWL_Error SetBoxSize(FX_FLOAT fHeight);
int32_t GetCheckState();
- FWL_ERR SetCheckState(int32_t iCheck);
+ FWL_Error SetCheckState(int32_t iCheck);
CFWL_CheckBox();
virtual ~CFWL_CheckBox();
@@ -27,7 +27,8 @@ class CFWL_CheckBox : public CFWL_Widget {
class CFWL_CheckBoxDP : public IFWL_CheckBoxDP {
public:
CFWL_CheckBoxDP();
- virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
+ virtual FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption);
virtual FX_FLOAT GetBoxSize(IFWL_Widget* pWidget);
FX_FLOAT m_fBoxHeight;
CFX_WideString m_wsCaption;
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.cpp
index bdcc36fa303..ca88a234293 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.cpp
@@ -15,21 +15,21 @@ CFWL_ComboBox* CFWL_ComboBox::Create() {
return new CFWL_ComboBox;
}
-FWL_ERR CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_ComboBox> pComboBox(IFWL_ComboBox::Create(
m_pProperties->MakeWidgetImpProperties(&m_comboBoxData)));
- FWL_ERR ret = pComboBox->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pComboBox->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pComboBox.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) {
@@ -67,13 +67,14 @@ int32_t CFWL_ComboBox::CountItems() {
return m_comboBoxData.CountItems(GetWidget());
}
-FWL_ERR CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString& wsText) {
+FWL_Error CFWL_ComboBox::GetTextByIndex(int32_t iIndex,
+ CFX_WideString& wsText) {
CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(
m_comboBoxData.GetItem(m_pIface, iIndex));
if (!pItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
wsText = pItem->m_wsText;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_ComboBox::GetCurSel() {
@@ -82,15 +83,15 @@ int32_t CFWL_ComboBox::GetCurSel() {
return static_cast<IFWL_ComboBox*>(m_pIface)->GetCurSel();
}
-FWL_ERR CFWL_ComboBox::SetCurSel(int32_t iSel) {
+FWL_Error CFWL_ComboBox::SetCurSel(int32_t iSel) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ComboBox*>(m_pIface)->SetCurSel(iSel);
}
-FWL_ERR CFWL_ComboBox::SetEditText(const CFX_WideStringC& wsText) {
+FWL_Error CFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ComboBox*>(m_pIface)->SetEditText(wsText);
}
@@ -100,18 +101,18 @@ int32_t CFWL_ComboBox::GetEditTextLength() const {
return static_cast<IFWL_ComboBox*>(m_pIface)->GetEditTextLength();
}
-FWL_ERR CFWL_ComboBox::GetEditText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+FWL_Error CFWL_ComboBox::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ComboBox*>(m_pIface)
->GetEditText(wsText, nStart, nCount);
}
-FWL_ERR CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
+FWL_Error CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ComboBox*>(m_pIface)->SetEditSelRange(nStart, nCount);
}
@@ -127,15 +128,15 @@ int32_t CFWL_ComboBox::GetEditLimit() {
return static_cast<IFWL_ComboBox*>(m_pIface)->GetEditLimit();
}
-FWL_ERR CFWL_ComboBox::SetEditLimit(int32_t nLimit) {
+FWL_Error CFWL_ComboBox::SetEditLimit(int32_t nLimit) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ComboBox*>(m_pIface)->SetEditLimit(nLimit);
}
-FWL_ERR CFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
+FWL_Error CFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ComboBox*>(m_pIface)->EditDoClipboard(iCmd);
}
@@ -151,18 +152,18 @@ FX_BOOL CFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) {
return static_cast<IFWL_ComboBox*>(m_pIface)->EditUndo(bsRecord);
}
-FWL_ERR CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) {
+FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) {
m_comboBoxData.m_fMaxListHeight = fMaxHeight;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) {
+FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) {
CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(
m_comboBoxData.GetItem(m_pIface, iIndex));
if (!pItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
pItem->m_pData = pData;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void* CFWL_ComboBox::GetItemData(int32_t iIndex) {
@@ -173,7 +174,7 @@ void* CFWL_ComboBox::GetItemData(int32_t iIndex) {
return pItem->m_pData;
}
-FWL_ERR CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) {
+FWL_Error CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) {
return static_cast<IFWL_ComboBox*>(m_pIface)->GetListBoxt()->SetThemeProvider(
pTheme);
}
@@ -182,7 +183,7 @@ FX_BOOL CFWL_ComboBox::AfterFocusShowDropList() {
return static_cast<IFWL_ComboBox*>(m_pIface)->AfterFocusShowDropList();
}
-FWL_ERR CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
+FWL_Error CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
return static_cast<IFWL_ComboBox*>(m_pIface)->OpenDropDownList(bActivate);
}
@@ -264,16 +265,16 @@ FX_BOOL CFWL_ComboBox::EditDeSelect() {
return static_cast<IFWL_ComboBox*>(m_pIface)->EditDeSelect();
}
-FWL_ERR CFWL_ComboBox::GetBBox(CFX_RectF& rect) {
+FWL_Error CFWL_ComboBox::GetBBox(CFX_RectF& rect) {
if (!m_pIface)
- return FALSE;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ComboBox*>(m_pIface)->GetBBox(rect);
}
-FWL_ERR CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
if (!m_pIface)
- return FALSE;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ComboBox*>(m_pIface)
->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
@@ -328,24 +329,24 @@ uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget,
return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles;
}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_WideString& wsText) {
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
wsText = reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtItem) {
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtItem) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width,
pItem->m_rtItem.height);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget,
@@ -356,31 +357,31 @@ void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget,
return pItem->m_pData;
}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- uint32_t dwStyle) {
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwStyle) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles = dwStyle;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const FX_WCHAR* pszText) {
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const FX_WCHAR* pszText) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText = pszText;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const CFX_RectF& rtItem) {
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtItem) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_rtItem = rtItem;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) {
@@ -394,21 +395,21 @@ CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget* pWidget,
return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_pDIB;
}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtCheck) {
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtCheck) {
CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
rtCheck = pItem->m_rtCheckBox;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect(
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect(
IFWL_Widget* pWidget,
FWL_HLISTITEM hItem,
const CFX_RectF& rtCheck) {
CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
pItem->m_rtCheckBox = rtCheck;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState(
@@ -418,13 +419,13 @@ uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState(
return pItem->m_dwCheckState;
}
-FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState(
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState(
IFWL_Widget* pWidget,
FWL_HLISTITEM hItem,
uint32_t dwCheckState) {
CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
pItem->m_dwCheckState = dwCheckState;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) {
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.h
index 59b542c453d..5a639e33d9c 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_combobox.h
@@ -21,33 +21,33 @@ class CFWL_ComboBoxItem;
class CFWL_ComboBox : public CFWL_Widget {
public:
static CFWL_ComboBox* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
int32_t AddString(const CFX_WideStringC& wsText);
int32_t AddString(const CFX_WideStringC& wsText, CFX_DIBitmap* pIcon);
bool RemoveAt(int32_t iIndex); // Returns false iff |iIndex| out of range.
void RemoveAll();
int32_t CountItems();
- FWL_ERR GetTextByIndex(int32_t iIndex, CFX_WideString& wsText);
+ FWL_Error GetTextByIndex(int32_t iIndex, CFX_WideString& wsText);
int32_t GetCurSel();
- FWL_ERR SetCurSel(int32_t iSel);
- FWL_ERR SetEditText(const CFX_WideStringC& wsText);
+ FWL_Error SetCurSel(int32_t iSel);
+ FWL_Error SetEditText(const CFX_WideString& wsText);
int32_t GetEditTextLength() const;
- FWL_ERR GetEditText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
- FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1);
+ FWL_Error GetEditText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ FWL_Error SetEditSelRange(int32_t nStart, int32_t nCount = -1);
int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
int32_t GetEditLimit();
- FWL_ERR SetEditLimit(int32_t nLimit);
- FWL_ERR EditDoClipboard(int32_t iCmd);
+ FWL_Error SetEditLimit(int32_t nLimit);
+ FWL_Error EditDoClipboard(int32_t iCmd);
FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord);
FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord);
- FWL_ERR SetMaxListHeight(FX_FLOAT fMaxHeight);
- FWL_ERR SetItemData(int32_t iIndex, void* pData);
+ FWL_Error SetMaxListHeight(FX_FLOAT fMaxHeight);
+ FWL_Error SetItemData(int32_t iIndex, void* pData);
void* GetItemData(int32_t iIndex);
- FWL_ERR SetListTheme(IFWL_ThemeProvider* pTheme);
+ FWL_Error SetListTheme(IFWL_ThemeProvider* pTheme);
FX_BOOL AfterFocusShowDropList();
- FWL_ERR OpenDropDownList(FX_BOOL bActivate);
+ FWL_Error OpenDropDownList(FX_BOOL bActivate);
FX_BOOL EditCanUndo();
FX_BOOL EditCanRedo();
@@ -62,9 +62,9 @@ class CFWL_ComboBox : public CFWL_Widget {
FX_BOOL EditSelectAll();
FX_BOOL EditDelete();
FX_BOOL EditDeSelect();
- FWL_ERR GetBBox(CFX_RectF& rect);
- FWL_ERR EditModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
+ FWL_Error GetBBox(CFX_RectF& rect);
+ FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
CFWL_ComboBox();
virtual ~CFWL_ComboBox();
@@ -73,9 +73,9 @@ class CFWL_ComboBox : public CFWL_Widget {
public:
CFWL_ComboBoxDP();
~CFWL_ComboBoxDP();
- virtual FWL_ERR GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) {
- return FWL_ERR_Succeeded;
+ virtual FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_Error::Succeeded;
}
virtual int32_t CountItems(IFWL_Widget* pWidget);
@@ -86,36 +86,36 @@ class CFWL_ComboBox : public CFWL_Widget {
int32_t nIndex);
virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem);
- virtual FWL_ERR GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_WideString& wsText);
- virtual FWL_ERR GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtItem);
+ virtual FWL_Error GetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_WideString& wsText);
+ virtual FWL_Error GetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtItem);
virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem);
- virtual FWL_ERR SetItemStyles(IFWL_Widget* pWidget,
+ virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwStyle);
+ virtual FWL_Error SetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const FX_WCHAR* pszText);
+ virtual FWL_Error SetItemRect(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem,
- uint32_t dwStyle);
- virtual FWL_ERR SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const FX_WCHAR* pszText);
- virtual FWL_ERR SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const CFX_RectF& rtItem);
+ const CFX_RectF& rtItem);
virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget);
virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem);
- virtual FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtCheck);
- virtual FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const CFX_RectF& rtCheck);
+ virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtCheck);
+ virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtCheck);
virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem);
- virtual FWL_ERR SetItemCheckState(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- uint32_t dwCheckState);
+ virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwCheckState);
virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget);
std::vector<std::unique_ptr<CFWL_ComboBoxItem>> m_ItemArray;
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.cpp
index e470616ed8b..dba1a527b49 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.cpp
@@ -16,10 +16,10 @@ CFWL_DateTimePicker* CFWL_DateTimePicker::Create() {
return new CFWL_DateTimePicker;
}
-FWL_ERR CFWL_DateTimePicker::Initialize(
+FWL_Error CFWL_DateTimePicker::Initialize(
const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
@@ -27,22 +27,22 @@ FWL_ERR CFWL_DateTimePicker::Initialize(
IFWL_DateTimePicker::Create(
m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP),
nullptr));
- FWL_ERR ret = pDateTimePicker->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pDateTimePicker->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pDateTimePicker.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePicker::SetToday(int32_t iYear,
- int32_t iMonth,
- int32_t iDay) {
+FWL_Error CFWL_DateTimePicker::SetToday(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
m_DateTimePickerDP.m_iYear = iYear;
m_DateTimePickerDP.m_iMonth = iMonth;
m_DateTimePickerDP.m_iDay = iDay;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_DateTimePicker::CountSelRanges() {
@@ -54,24 +54,24 @@ int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
->GetSelRange(nIndex, nStart);
}
-FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) {
+FWL_Error CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) {
return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetEditText(wsText);
}
-FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText) {
+FWL_Error CFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditText(wsText);
}
-FWL_ERR CFWL_DateTimePicker::GetCurSel(int32_t& iYear,
- int32_t& iMonth,
- int32_t& iDay) {
+FWL_Error CFWL_DateTimePicker::GetCurSel(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
return static_cast<IFWL_DateTimePicker*>(m_pIface)
->GetCurSel(iYear, iMonth, iDay);
}
-FWL_ERR CFWL_DateTimePicker::SetCurSel(int32_t iYear,
- int32_t iMonth,
- int32_t iDay) {
+FWL_Error CFWL_DateTimePicker::SetCurSel(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
return static_cast<IFWL_DateTimePicker*>(m_pIface)
->SetCurSel(iYear, iMonth, iDay);
}
@@ -86,14 +86,14 @@ CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP() {
m_iDay = 1;
}
-FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption(
+FWL_Error CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption(
IFWL_Widget* pWidget,
CFX_WideString& wsCaption) {
wsCaption = m_wsData;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday(
+FWL_Error CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday(
IFWL_Widget* pWidget,
int32_t& iYear,
int32_t& iMonth,
@@ -101,7 +101,7 @@ FWL_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday(
iYear = m_iYear;
iMonth = m_iMonth;
iDay = m_iDay;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_DateTimePicker::CanUndo() {
@@ -156,16 +156,16 @@ FX_BOOL CFWL_DateTimePicker::DeSelect() {
return static_cast<IFWL_DateTimePicker*>(m_pIface)->DeSelect();
}
-FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
+FWL_Error CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
return static_cast<IFWL_DateTimePicker*>(m_pIface)->GetBBox(rect);
}
-FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
+FWL_Error CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
return static_cast<IFWL_DateTimePicker*>(m_pIface)->SetEditLimit(nLimit);
}
-FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
return static_cast<IFWL_DateTimePicker*>(m_pIface)
->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.h
index a96ac532c15..b4349d0cb04 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_datetimepicker.h
@@ -13,14 +13,14 @@
class CFWL_DateTimePicker : public CFWL_Widget {
public:
static CFWL_DateTimePicker* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
- FWL_ERR SetToday(int32_t iYear, int32_t iMonth, int32_t iDay);
- FWL_ERR GetEditText(CFX_WideString& wsText);
- FWL_ERR SetEditText(const CFX_WideStringC& wsText);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error SetToday(int32_t iYear, int32_t iMonth, int32_t iDay);
+ FWL_Error GetEditText(CFX_WideString& wsText);
+ FWL_Error SetEditText(const CFX_WideString& wsText);
int32_t CountSelRanges();
int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
- FWL_ERR GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
- FWL_ERR SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
+ FWL_Error GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
+ FWL_Error SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
FX_BOOL CanUndo();
FX_BOOL CanRedo();
FX_BOOL Undo();
@@ -34,10 +34,10 @@ class CFWL_DateTimePicker : public CFWL_Widget {
FX_BOOL SelectAll();
FX_BOOL Delete();
FX_BOOL DeSelect();
- FWL_ERR GetBBox(CFX_RectF& rect);
- FWL_ERR SetEditLimit(int32_t nLimit);
- FWL_ERR ModifyEditStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved);
+ FWL_Error GetBBox(CFX_RectF& rect);
+ FWL_Error SetEditLimit(int32_t nLimit);
+ FWL_Error ModifyEditStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
protected:
CFWL_DateTimePicker();
@@ -45,11 +45,12 @@ class CFWL_DateTimePicker : public CFWL_Widget {
class CFWL_DateTimePickerDP : public IFWL_DateTimePickerDP {
public:
CFWL_DateTimePickerDP();
- virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
- virtual FWL_ERR GetToday(IFWL_Widget* pWidget,
- int32_t& iYear,
- int32_t& iMonth,
- int32_t& iDay);
+ virtual FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption);
+ virtual FWL_Error GetToday(IFWL_Widget* pWidget,
+ int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay);
int32_t m_iYear;
int32_t m_iMonth;
int32_t m_iDay;
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.cpp
index ba0ff58f6dc..f151edd7e91 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.cpp
@@ -15,26 +15,26 @@ CFWL_Edit* CFWL_Edit::Create() {
return new CFWL_Edit;
}
-FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_Edit> pEdit(IFWL_Edit::Create(
m_pProperties->MakeWidgetImpProperties(nullptr), nullptr));
- FWL_ERR ret = pEdit->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pEdit->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pEdit.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) {
+FWL_Error CFWL_Edit::SetText(const CFX_WideString& wsText) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->SetText(wsText);
}
@@ -44,17 +44,17 @@ int32_t CFWL_Edit::GetTextLength() const {
return static_cast<IFWL_Edit*>(m_pIface)->GetTextLength();
}
-FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText,
- int32_t nStart,
- int32_t nCount) const {
+FWL_Error CFWL_Edit::GetText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->GetText(wsText, nStart, nCount);
}
-FWL_ERR CFWL_Edit::ClearText() {
+FWL_Error CFWL_Edit::ClearText() {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->ClearText();
}
@@ -70,9 +70,9 @@ int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(nIndex, bBefore);
}
-FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
+int32_t CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return -1;
static_cast<IFWL_Edit*>(m_pIface)->AddSelRange(nStart, nCount);
int32_t pos = 0;
int32_t sum = static_cast<IFWL_Edit*>(m_pIface)->GetTextLength();
@@ -96,9 +96,9 @@ int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) {
return static_cast<IFWL_Edit*>(m_pIface)->GetSelRange(nIndex, nStart);
}
-FWL_ERR CFWL_Edit::ClearSelections() {
+FWL_Error CFWL_Edit::ClearSelections() {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->ClearSelections();
}
@@ -108,55 +108,49 @@ int32_t CFWL_Edit::GetLimit() {
return static_cast<IFWL_Edit*>(m_pIface)->GetLimit();
}
-FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) {
+FWL_Error CFWL_Edit::SetLimit(int32_t nLimit) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->SetLimit(nLimit);
}
-FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
+FWL_Error CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->SetAliasChar(wAlias);
}
-FWL_ERR CFWL_Edit::Insert(int32_t nStart,
- const FX_WCHAR* lpText,
- int32_t nLen) {
+FWL_Error CFWL_Edit::Insert(int32_t nStart,
+ const FX_WCHAR* lpText,
+ int32_t nLen) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->Insert(nStart, lpText, nLen);
}
-FWL_ERR CFWL_Edit::DeleteSelections() {
+FWL_Error CFWL_Edit::DeleteSelections() {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->DeleteSelections();
}
-FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
+FWL_Error CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->DeleteRange(nStart, nCount);
}
-FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) {
- if (!m_pIface)
- return FWL_ERR_Indefinite;
- return static_cast<IFWL_Edit*>(m_pIface)->ReplaceSelections(wsReplace);
-}
-
-FWL_ERR CFWL_Edit::Replace(int32_t nStart,
- int32_t nLen,
- const CFX_WideStringC& wsReplace) {
+FWL_Error CFWL_Edit::Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->Replace(nStart, nLen, wsReplace);
}
-FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) {
+FWL_Error CFWL_Edit::DoClipboard(int32_t iCmd) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->DoClipboard(iCmd);
}
@@ -172,29 +166,29 @@ FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) {
return static_cast<IFWL_Edit*>(m_pIface)->Undo(bsRecord);
}
-FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
+FWL_Error CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)
->SetTabWidth(fTabWidth, bEquidistant);
}
-FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
+FWL_Error CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
if (iMin > iMax) {
- return FWL_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
}
return static_cast<IFWL_Edit*>(m_pIface)->SetNumberRange(iMin, iMax);
}
-FWL_ERR CFWL_Edit::SetBackColor(uint32_t dwColor) {
+FWL_Error CFWL_Edit::SetBackColor(uint32_t dwColor) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->SetBackColor(dwColor);
}
-FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
+FWL_Error CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_Edit*>(m_pIface)->SetFont(wsFont, fSize);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.h
index 153c7560441..c7001a31660 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_edit.h
@@ -16,37 +16,36 @@ class CFWL_WidgetProperties;
class CFWL_Edit : public CFWL_Widget {
public:
static CFWL_Edit* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
- FWL_ERR SetText(const CFX_WideString& wsText);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error SetText(const CFX_WideString& wsText);
int32_t GetTextLength() const;
- FWL_ERR GetText(CFX_WideString& wsText,
- int32_t nStart = 0,
- int32_t nCount = -1) const;
- FWL_ERR ClearText();
+ FWL_Error GetText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ FWL_Error ClearText();
int32_t GetCaretPos() const;
int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE);
- FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1);
+ int32_t AddSelRange(int32_t nStart, int32_t nCount = -1);
int32_t CountSelRanges();
int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
- FWL_ERR ClearSelections();
+ FWL_Error ClearSelections();
int32_t GetLimit();
- FWL_ERR SetLimit(int32_t nLimit);
- FWL_ERR SetAliasChar(FX_WCHAR wAlias);
- FWL_ERR SetFormatString(const CFX_WideString& wsFormat);
- FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
- FWL_ERR DeleteSelections();
- FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1);
- FWL_ERR ReplaceSelections(const CFX_WideStringC& wsReplace);
- FWL_ERR Replace(int32_t nStart,
- int32_t nLen,
- const CFX_WideStringC& wsReplace);
- FWL_ERR DoClipboard(int32_t iCmd);
+ FWL_Error SetLimit(int32_t nLimit);
+ FWL_Error SetAliasChar(FX_WCHAR wAlias);
+ FWL_Error SetFormatString(const CFX_WideString& wsFormat);
+ FWL_Error Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
+ FWL_Error DeleteSelections();
+ FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1);
+ FWL_Error Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace);
+ FWL_Error DoClipboard(int32_t iCmd);
FX_BOOL Redo(const CFX_ByteStringC& bsRecord);
FX_BOOL Undo(const CFX_ByteStringC& bsRecord);
- FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
- FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax);
- FWL_ERR SetBackColor(uint32_t dwColor);
- FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
+ FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
+ FWL_Error SetNumberRange(int32_t iMin, int32_t iMax);
+ FWL_Error SetBackColor(uint32_t dwColor);
+ FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
FX_BOOL CanUndo();
FX_BOOL CanRedo();
FX_BOOL Undo();
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.cpp
index 2102d2d3ee6..46433a31983 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.cpp
@@ -14,26 +14,26 @@ CFWL_ListBox* CFWL_ListBox::Create() {
return new CFWL_ListBox;
}
-FWL_ERR CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_ListBox> pListBox(IFWL_ListBox::Create(
m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), nullptr));
- FWL_ERR ret = pListBox->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pListBox->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pListBox.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem) {
+FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem) {
reinterpret_cast<CFWL_ListItem*>(hItem)->m_pDIB = pDIB;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FWL_HLISTITEM CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd,
@@ -91,27 +91,28 @@ int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) {
return static_cast<IFWL_ListBox*>(m_pIface)->GetSelIndex(nIndex);
}
-FWL_ERR CFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
+FWL_Error CFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ListBox*>(m_pIface)->SetSelItem(hItem, bSelect);
}
-FWL_ERR CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) {
+FWL_Error CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ListBox*>(m_pIface)->GetItemText(hItem, wsText);
}
-FWL_ERR CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
+FWL_Error CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ListBox*>(m_pIface)->GetScrollPos(fPos, bVert);
}
-FWL_ERR CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) {
+FWL_Error CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) {
m_ListBoxDP.m_fItemHeight = fItemHeight;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FWL_HLISTITEM CFWL_ListBox::GetFocusItem() {
@@ -122,14 +123,10 @@ FWL_HLISTITEM CFWL_ListBox::GetFocusItem() {
return nullptr;
}
-FWL_ERR CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem) {
+FWL_Error CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem) {
int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem);
m_ListBoxDP.m_ItemArray[nIndex]->m_dwStates |= FWL_ITEMSTATE_LTB_Focused;
- return FWL_ERR_Succeeded;
-}
-
-FWL_ERR* CFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) {
- return static_cast<IFWL_ListBox*>(m_pIface)->Sort(pCom);
+ return FWL_Error::Succeeded;
}
int32_t CFWL_ListBox::CountItems() {
@@ -143,27 +140,27 @@ FWL_HLISTITEM CFWL_ListBox::GetItem(int32_t nIndex) {
return (FWL_HLISTITEM)m_ListBoxDP.m_ItemArray[nIndex].get();
}
-FWL_ERR CFWL_ListBox::SetItemString(FWL_HLISTITEM hItem,
- const CFX_WideStringC& wsText) {
+FWL_Error CFWL_ListBox::SetItemString(FWL_HLISTITEM hItem,
+ const CFX_WideStringC& wsText) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText = wsText;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBox::GetItemString(FWL_HLISTITEM hItem,
- CFX_WideString& wsText) {
+FWL_Error CFWL_ListBox::GetItemString(FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
wsText = reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBox::SetItemData(FWL_HLISTITEM hItem, void* pData) {
+FWL_Error CFWL_ListBox::SetItemData(FWL_HLISTITEM hItem, void* pData) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
reinterpret_cast<CFWL_ListItem*>(hItem)->m_pData = pData;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void* CFWL_ListBox::GetItemData(FWL_HLISTITEM hItem) {
@@ -212,10 +209,10 @@ CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP() {}
CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP() {}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) {
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
wsCaption = m_wsData;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_ListBox::CFWL_ListBoxDP::CountItems(IFWL_Widget* pWidget) {
@@ -256,23 +253,23 @@ uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget,
return reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwStates;
}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_WideString& wsText) {
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
wsText = reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtItem) {
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtItem) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem);
rtItem = pItem->m_rtItem;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget,
@@ -283,31 +280,31 @@ void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget,
return pItem->m_pData;
}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- uint32_t dwStyle) {
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwStyle) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwStates = dwStyle;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const FX_WCHAR* pszText) {
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const FX_WCHAR* pszText) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText = pszText;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const CFX_RectF& rtItem) {
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtItem) {
if (!hItem)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtItem = rtItem;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) {
@@ -319,19 +316,19 @@ CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget* pWidget,
return reinterpret_cast<CFWL_ListItem*>(hItem)->m_pDIB;
}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtCheck) {
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtCheck) {
rtCheck = reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtCheckBox;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect(
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect(
IFWL_Widget* pWidget,
FWL_HLISTITEM hItem,
const CFX_RectF& rtCheck) {
reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtCheckBox = rtCheck;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget* pWidget,
@@ -339,9 +336,10 @@ uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget* pWidget,
return reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwCheckState;
}
-FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- uint32_t dwCheckState) {
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState(
+ IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwCheckState) {
reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwCheckState = dwCheckState;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.h
index 28fb42af691..a40d0f975c3 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_listbox.h
@@ -20,8 +20,8 @@ class CFWL_ListItem;
class CFWL_ListBox : public CFWL_Widget {
public:
static CFWL_ListBox* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
- FWL_ERR AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem);
FWL_HLISTITEM AddString(const CFX_WideStringC& wsAdd,
FX_BOOL bSelect = FALSE);
FX_BOOL DeleteString(FWL_HLISTITEM hItem);
@@ -29,18 +29,17 @@ class CFWL_ListBox : public CFWL_Widget {
int32_t CountSelItems();
FWL_HLISTITEM GetSelItem(int32_t nIndexSel);
int32_t GetSelIndex(int32_t nIndex);
- FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
- FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText);
- FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
- FWL_ERR SetItemHeight(FX_FLOAT fItemHeight);
+ FWL_Error SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
+ FWL_Error GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText);
+ FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
+ FWL_Error SetItemHeight(FX_FLOAT fItemHeight);
FWL_HLISTITEM GetFocusItem();
- FWL_ERR SetFocusItem(FWL_HLISTITEM hItem);
- FWL_ERR* Sort(IFWL_ListBoxCompare* pCom);
+ FWL_Error SetFocusItem(FWL_HLISTITEM hItem);
int32_t CountItems();
FWL_HLISTITEM GetItem(int32_t nIndex);
- FWL_ERR SetItemString(FWL_HLISTITEM hItem, const CFX_WideStringC& wsText);
- FWL_ERR GetItemString(FWL_HLISTITEM hItem, CFX_WideString& wsText);
- FWL_ERR SetItemData(FWL_HLISTITEM hItem, void* pData);
+ FWL_Error SetItemString(FWL_HLISTITEM hItem, const CFX_WideStringC& wsText);
+ FWL_Error GetItemString(FWL_HLISTITEM hItem, CFX_WideString& wsText);
+ FWL_Error SetItemData(FWL_HLISTITEM hItem, void* pData);
void* GetItemData(FWL_HLISTITEM hItem);
FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
uint32_t GetItemStates(FWL_HLISTITEM hItem);
@@ -54,8 +53,8 @@ class CFWL_ListBox : public CFWL_Widget {
~CFWL_ListBoxDP();
// IFWL_DataProvider:
- FWL_ERR GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) override;
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
// IFWL_ListBoxDP:
int32_t CountItems(IFWL_Widget* pWidget) override;
@@ -65,36 +64,36 @@ class CFWL_ListBox : public CFWL_Widget {
FWL_HLISTITEM hItem,
int32_t nIndex) override;
uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override;
- FWL_ERR GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_WideString& wsText) override;
- FWL_ERR GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtItem) override;
+ FWL_Error GetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_WideString& wsText) override;
+ FWL_Error GetItemRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtItem) override;
void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override;
- FWL_ERR SetItemStyles(IFWL_Widget* pWidget,
+ FWL_Error SetItemStyles(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwStyle) override;
+ FWL_Error SetItemText(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const FX_WCHAR* pszText) override;
+ FWL_Error SetItemRect(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem,
- uint32_t dwStyle) override;
- FWL_ERR SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const FX_WCHAR* pszText) override;
- FWL_ERR SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const CFX_RectF& rtItem) override;
+ const CFX_RectF& rtItem) override;
FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) override;
CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem) override;
- FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- CFX_RectF& rtCheck) override;
- FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- const CFX_RectF& rtCheck) override;
+ FWL_Error GetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ CFX_RectF& rtCheck) override;
+ FWL_Error SetItemCheckRect(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ const CFX_RectF& rtCheck) override;
uint32_t GetItemCheckState(IFWL_Widget* pWidget,
FWL_HLISTITEM hItem) override;
- FWL_ERR SetItemCheckState(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
- uint32_t dwCheckState) override;
+ FWL_Error SetItemCheckState(IFWL_Widget* pWidget,
+ FWL_HLISTITEM hItem,
+ uint32_t dwCheckState) override;
std::vector<std::unique_ptr<CFWL_ListItem>> m_ItemArray;
CFX_WideString m_wsData;
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.cpp
index b0bd3c9931b..f3f52ab993b 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.cpp
@@ -12,94 +12,95 @@ CFWL_PictureBox* CFWL_PictureBox::Create() {
return new CFWL_PictureBox;
}
-FWL_ERR CFWL_PictureBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_PictureBox::Initialize(
+ const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_PictureBox> pPictureBox(IFWL_PictureBox::Create(
m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP), nullptr));
- FWL_ERR ret = pPictureBox->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pPictureBox->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pPictureBox.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFX_DIBitmap* CFWL_PictureBox::GetPicture() {
return m_PictureBoxDP.m_pBitmap;
}
-FWL_ERR CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) {
+FWL_Error CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) {
m_PictureBoxDP.m_pBitmap = pBitmap;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_FLOAT CFWL_PictureBox::GetRotation() {
return m_PictureBoxDP.m_fRotation;
}
-FWL_ERR CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) {
+FWL_Error CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) {
m_PictureBoxDP.m_fRotation = fRotation;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_PictureBox::GetFlipMode() {
return m_PictureBoxDP.GetFlipMode(m_pIface);
}
-FWL_ERR CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) {
+FWL_Error CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) {
m_PictureBoxDP.m_iFlipMode = iFlipMode;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_PictureBox::GetOpacity() {
return m_PictureBoxDP.GetOpacity(m_pIface);
}
-FWL_ERR CFWL_PictureBox::SetOpacity(int32_t iOpacity) {
+FWL_Error CFWL_PictureBox::SetOpacity(int32_t iOpacity) {
m_PictureBoxDP.m_iOpacity = iOpacity;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) {
+FWL_Error CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) {
CFX_Matrix matrix;
m_PictureBoxDP.GetMatrix(m_pIface, matrix);
matrix.Scale(fScaleX, fScaleY);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) {
+FWL_Error CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) {
m_PictureBoxDP.m_fScaleX = fScaleX;
m_PictureBoxDP.m_fScaleY = fScaleY;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) {
+FWL_Error CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) {
CFX_Matrix matrix;
m_PictureBoxDP.GetMatrix(m_pIface, matrix);
fx = matrix.e;
fy = matrix.f;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_Error CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) {
m_PictureBoxDP.m_fOffSetX = fx;
m_PictureBoxDP.m_fOffSetY = fy;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFWL_PictureBox::CFWL_PictureBox() {}
CFWL_PictureBox::~CFWL_PictureBox() {}
-FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption(
+FWL_Error CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption(
IFWL_Widget* pWidget,
CFX_WideString& wsCaption) {
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetPicture(
@@ -121,8 +122,8 @@ int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetOpacity(IFWL_Widget* pWidget) {
return m_iOpacity;
}
-FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget* pWidget,
- CFX_Matrix& matrix) {
+FWL_Error CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget* pWidget,
+ CFX_Matrix& matrix) {
CFX_RectF rect;
pWidget->GetClientRect(rect);
FX_FLOAT fLen = rect.width / 2;
@@ -133,7 +134,7 @@ FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget* pWidget,
matrix.Translate(fLen, fWid);
matrix.Scale(m_fScaleX, m_fScaleY);
matrix.Translate(m_fOffSetX, m_fOffSetY);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) {
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.h
index 8fa985acd89..8b0b13de24c 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_picturebox.h
@@ -14,19 +14,19 @@
class CFWL_PictureBox : public CFWL_Widget {
public:
static CFWL_PictureBox* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
CFX_DIBitmap* GetPicture();
- FWL_ERR SetPicture(CFX_DIBitmap* pBitmap);
+ FWL_Error SetPicture(CFX_DIBitmap* pBitmap);
FX_FLOAT GetRotation();
- FWL_ERR SetRotation(FX_FLOAT fRotation);
+ FWL_Error SetRotation(FX_FLOAT fRotation);
int32_t GetFlipMode();
- FWL_ERR SetFlipMode(int32_t iFlipMode);
+ FWL_Error SetFlipMode(int32_t iFlipMode);
int32_t GetOpacity();
- FWL_ERR SetOpacity(int32_t iOpacity);
- FWL_ERR GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY);
- FWL_ERR SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY);
- FWL_ERR GetOffset(FX_FLOAT& fx, FX_FLOAT& fy);
- FWL_ERR SetOffset(FX_FLOAT fx, FX_FLOAT fy);
+ FWL_Error SetOpacity(int32_t iOpacity);
+ FWL_Error GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY);
+ FWL_Error SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY);
+ FWL_Error GetOffset(FX_FLOAT& fx, FX_FLOAT& fy);
+ FWL_Error SetOffset(FX_FLOAT fx, FX_FLOAT fy);
CFWL_PictureBox();
virtual ~CFWL_PictureBox();
@@ -41,13 +41,14 @@ class CFWL_PictureBox : public CFWL_Widget {
m_fOffSetY = 0.0f;
m_pBitmap = NULL;
}
- virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
+ virtual FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption);
virtual CFX_DIBitmap* GetPicture(IFWL_Widget* pWidget);
virtual CFX_DIBitmap* GetErrorPicture(IFWL_Widget* pWidget);
virtual CFX_DIBitmap* GetInitialPicture(IFWL_Widget* pWidget);
virtual int32_t GetOpacity(IFWL_Widget* pWidget);
virtual int32_t GetFlipMode(IFWL_Widget* pWidget);
- virtual FWL_ERR GetMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix);
+ virtual FWL_Error GetMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix);
CFX_DIBitmap* m_pBitmap;
int32_t m_iOpacity;
int32_t m_iFlipMode;
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.cpp
index 52747bdebed..7c8a9fa64db 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.cpp
@@ -12,51 +12,52 @@ CFWL_PushButton* CFWL_PushButton::Create() {
return new CFWL_PushButton;
}
-FWL_ERR CFWL_PushButton::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_PushButton::Initialize(
+ const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_PushButton> pPushButton(IFWL_PushButton::Create(
m_pProperties->MakeWidgetImpProperties(&m_buttonData), nullptr));
- FWL_ERR ret = pPushButton->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pPushButton->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pPushButton.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PushButton::GetCaption(CFX_WideString& wsCaption) {
+FWL_Error CFWL_PushButton::GetCaption(CFX_WideString& wsCaption) {
wsCaption = m_buttonData.m_wsCaption;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption) {
+FWL_Error CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption) {
m_buttonData.m_wsCaption = wsCaption;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFX_DIBitmap* CFWL_PushButton::GetPicture() {
return m_buttonData.m_pBitmap;
}
-FWL_ERR CFWL_PushButton::SetPicture(CFX_DIBitmap* pBitmap) {
+FWL_Error CFWL_PushButton::SetPicture(CFX_DIBitmap* pBitmap) {
m_buttonData.m_pBitmap = pBitmap;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFWL_PushButton::CFWL_PushButton() {}
CFWL_PushButton::~CFWL_PushButton() {}
-FWL_ERR CFWL_PushButton::CFWL_PushButtonDP::GetCaption(
+FWL_Error CFWL_PushButton::CFWL_PushButtonDP::GetCaption(
IFWL_Widget* pWidget,
CFX_WideString& wsCaption) {
wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture(
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.h
index 99b067d2cf9..5ca3dded376 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_pushbutton.h
@@ -13,11 +13,11 @@
class CFWL_PushButton : public CFWL_Widget {
public:
static CFWL_PushButton* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
- FWL_ERR GetCaption(CFX_WideString& wsCaption);
- FWL_ERR SetCaption(const CFX_WideStringC& wsCaption);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error GetCaption(CFX_WideString& wsCaption);
+ FWL_Error SetCaption(const CFX_WideStringC& wsCaption);
CFX_DIBitmap* GetPicture();
- FWL_ERR SetPicture(CFX_DIBitmap* pBitmap);
+ FWL_Error SetPicture(CFX_DIBitmap* pBitmap);
CFWL_PushButton();
virtual ~CFWL_PushButton();
@@ -25,7 +25,7 @@ class CFWL_PushButton : public CFWL_Widget {
class CFWL_PushButtonDP : public IFWL_PushButtonDP {
public:
CFWL_PushButtonDP() : m_pBitmap(NULL) {}
- FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
+ FWL_Error GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
virtual CFX_DIBitmap* GetPicture(IFWL_Widget* pWidget);
CFX_WideString m_wsCaption;
CFX_DIBitmap* m_pBitmap;
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.cpp
index 0c023147330..eb4276c2d19 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.cpp
@@ -18,21 +18,21 @@ CFWL_ScrollBar::CFWL_ScrollBar() {}
CFWL_ScrollBar::~CFWL_ScrollBar() {}
-FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_ScrollBar> pScrollBar(IFWL_ScrollBar::Create(
m_pProperties->MakeWidgetImpProperties(nullptr), nullptr));
- FWL_ERR ret = pScrollBar->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pScrollBar->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pScrollBar.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_ScrollBar::IsVertical() {
@@ -41,15 +41,15 @@ FX_BOOL CFWL_ScrollBar::IsVertical() {
return static_cast<IFWL_ScrollBar*>(m_pIface)->IsVertical();
}
-FWL_ERR CFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
+FWL_Error CFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ScrollBar*>(m_pIface)->GetRange(fMin, fMax);
}
-FWL_ERR CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
+FWL_Error CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ScrollBar*>(m_pIface)->SetRange(fMin, fMax);
}
@@ -59,9 +59,9 @@ FX_FLOAT CFWL_ScrollBar::GetPageSize() {
return static_cast<IFWL_ScrollBar*>(m_pIface)->GetPageSize();
}
-FWL_ERR CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) {
+FWL_Error CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ScrollBar*>(m_pIface)->SetPageSize(fPageSize);
}
@@ -71,9 +71,9 @@ FX_FLOAT CFWL_ScrollBar::GetStepSize() {
return static_cast<IFWL_ScrollBar*>(m_pIface)->GetStepSize();
}
-FWL_ERR CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) {
+FWL_Error CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ScrollBar*>(m_pIface)->SetStepSize(fStepSize);
}
@@ -83,9 +83,9 @@ FX_FLOAT CFWL_ScrollBar::GetPos() {
return static_cast<IFWL_ScrollBar*>(m_pIface)->GetPos();
}
-FWL_ERR CFWL_ScrollBar::SetPos(FX_FLOAT fPos) {
+FWL_Error CFWL_ScrollBar::SetPos(FX_FLOAT fPos) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ScrollBar*>(m_pIface)->SetPos(fPos);
}
@@ -95,9 +95,9 @@ FX_FLOAT CFWL_ScrollBar::GetTrackPos() {
return static_cast<IFWL_ScrollBar*>(m_pIface)->GetTrackPos();
}
-FWL_ERR CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) {
+FWL_Error CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return static_cast<IFWL_ScrollBar*>(m_pIface)->SetTrackPos(fTrackPos);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.h
index 89c0fe44e47..fd80e8b8abc 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_scrollbar.h
@@ -12,18 +12,18 @@
class CFWL_ScrollBar : public CFWL_Widget {
public:
static CFWL_ScrollBar* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
FX_BOOL IsVertical();
- FWL_ERR GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
- FWL_ERR SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
+ FWL_Error GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
+ FWL_Error SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
FX_FLOAT GetPageSize();
- FWL_ERR SetPageSize(FX_FLOAT fPageSize);
+ FWL_Error SetPageSize(FX_FLOAT fPageSize);
FX_FLOAT GetStepSize();
- FWL_ERR SetStepSize(FX_FLOAT fStepSize);
+ FWL_Error SetStepSize(FX_FLOAT fStepSize);
FX_FLOAT GetPos();
- FWL_ERR SetPos(FX_FLOAT fPos);
+ FWL_Error SetPos(FX_FLOAT fPos);
FX_FLOAT GetTrackPos();
- FWL_ERR SetTrackPos(FX_FLOAT fTrackPos);
+ FWL_Error SetTrackPos(FX_FLOAT fTrackPos);
FX_BOOL DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f);
CFWL_ScrollBar();
virtual ~CFWL_ScrollBar();
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.cpp
index fdb0a89997e..a070e046c15 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.cpp
@@ -45,7 +45,7 @@ CFWL_Theme::CFWL_Theme() {
CFWL_Theme::~CFWL_Theme() {}
-FX_BOOL CFWL_Theme::IsValidWidget(IFWL_Widget* pWidget) {
+bool CFWL_Theme::IsValidWidget(IFWL_Widget* pWidget) {
return !!GetTheme(pWidget);
}
@@ -64,13 +64,13 @@ uint32_t CFWL_Theme::SetThemeID(IFWL_Widget* pWidget,
return dwID;
}
-FWL_ERR CFWL_Theme::GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) {
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_Theme::GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) {
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_Theme::SetThemeMatrix(IFWL_Widget* pWidget,
- const CFX_Matrix& matrix) {
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_Theme::SetThemeMatrix(IFWL_Widget* pWidget,
+ const CFX_Matrix& matrix) {
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_Theme::DrawBackground(CFWL_ThemeBackground* pParams) {
@@ -81,7 +81,8 @@ FX_BOOL CFWL_Theme::DrawText(CFWL_ThemeText* pParams) {
return GetTheme(pParams->m_pWidget)->DrawText(pParams);
}
-void* CFWL_Theme::GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity) {
+void* CFWL_Theme::GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity) {
return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity);
}
@@ -89,7 +90,8 @@ FX_BOOL CFWL_Theme::IsCustomizedLayout(IFWL_Widget* pWidget) {
return GetTheme(pWidget)->IsCustomizedLayout(pWidget);
}
-FWL_ERR CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) {
+FWL_Error CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart,
+ CFX_RectF& rtPart) {
return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rtPart);
}
@@ -103,30 +105,30 @@ FX_BOOL CFWL_Theme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
return GetTheme(pParams->m_pWidget)->CalcTextRect(pParams, rect);
}
-FWL_ERR CFWL_Theme::Initialize() {
+FWL_Error CFWL_Theme::Initialize() {
for (const auto& pTheme : m_ThemesArray)
pTheme->Initialize();
FWLTHEME_Init();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_Theme::Finalize() {
+FWL_Error CFWL_Theme::Finalize() {
for (const auto& pTheme : m_ThemesArray)
pTheme->Finalize();
FWLTHEME_Release();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_Theme::SetFont(IFWL_Widget* pWidget,
- const FX_WCHAR* strFont,
- FX_FLOAT fFontSize,
- FX_ARGB rgbFont) {
+FWL_Error CFWL_Theme::SetFont(IFWL_Widget* pWidget,
+ const FX_WCHAR* strFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont) {
for (const auto& pTheme : m_ThemesArray)
pTheme->SetFont(pWidget, strFont, fFontSize, rgbFont);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFWL_WidgetTP* CFWL_Theme::GetTheme(IFWL_Widget* pWidget) {
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.h
index fa62e092fb5..1de1fb607ca 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_theme.h
@@ -12,7 +12,7 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
class CFWL_WidgetTP;
@@ -26,30 +26,31 @@ class CFWL_Theme : public IFWL_ThemeProvider {
~CFWL_Theme() override;
// IFWL_ThemeProvider:
- FX_BOOL IsValidWidget(IFWL_Widget* pWidget) override;
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
uint32_t GetThemeID(IFWL_Widget* pWidget) override;
uint32_t SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren = TRUE) override;
- FWL_ERR GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) override;
- FWL_ERR SetThemeMatrix(IFWL_Widget* pWidget,
- const CFX_Matrix& matrix) override;
+ FWL_Error GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) override;
+ FWL_Error SetThemeMatrix(IFWL_Widget* pWidget,
+ const CFX_Matrix& matrix) override;
FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
FX_BOOL DrawText(CFWL_ThemeText* pParams) override;
- void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity) override;
+ void* GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity) override;
FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget) override;
- FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) override;
+ FWL_Error GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) override;
FX_BOOL IsInPart(CFWL_ThemePart* pThemePart,
FX_FLOAT fx,
FX_FLOAT fy) override;
FX_BOOL CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) override;
- FWL_ERR Initialize();
- FWL_ERR Finalize();
- FWL_ERR SetFont(IFWL_Widget* pWidget,
- const FX_WCHAR* strFont,
- FX_FLOAT fFontSize,
- FX_ARGB rgbFont);
+ FWL_Error Initialize();
+ FWL_Error Finalize();
+ FWL_Error SetFont(IFWL_Widget* pWidget,
+ const FX_WCHAR* strFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont);
CFWL_WidgetTP* GetTheme(IFWL_Widget* pWidget);
protected:
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.cpp
index abdf48997c2..7a9a26cf9ed 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.cpp
@@ -10,88 +10,79 @@
#include "xfa/fwl/core/fwl_formimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_panelimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
CFWL_ToolTip* CFWL_ToolTip::Create() {
return new CFWL_ToolTip;
}
-FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) {
if (m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
if (pProperties) {
*m_pProperties = *pProperties;
}
std::unique_ptr<IFWL_ToolTip> pToolTip(IFWL_ToolTip::Create(
m_pProperties->MakeWidgetImpProperties(&m_tooltipData), nullptr));
- FWL_ERR ret = pToolTip->Initialize();
- if (ret != FWL_ERR_Succeeded) {
+ FWL_Error ret = pToolTip->Initialize();
+ if (ret != FWL_Error::Succeeded) {
return ret;
}
m_pIface = pToolTip.release();
CFWL_Widget::Initialize();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) {
+void CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) {
wsCaption = m_tooltipData.m_wsCaption;
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) {
+void CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) {
m_tooltipData.m_wsCaption = wsCaption;
- return FWL_ERR_Succeeded;
}
int32_t CFWL_ToolTip::GetInitialDelay() {
return m_tooltipData.m_nInitDelayTime;
}
-int32_t CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) {
+void CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) {
m_tooltipData.m_nInitDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
}
int32_t CFWL_ToolTip::GetAutoPopDelay() {
return m_tooltipData.m_nAutoPopDelayTime;
}
-int32_t CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) {
+void CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) {
m_tooltipData.m_nAutoPopDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
}
CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon() {
return m_tooltipData.m_pBitmap;
}
-FWL_ERR CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) {
+void CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) {
m_tooltipData.m_pBitmap = pBitmap;
- return FWL_ERR_Succeeded;
}
CFX_SizeF CFWL_ToolTip::GetToolTipIconSize() {
return m_tooltipData.m_fIconSize;
}
-FWL_ERR CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) {
+void CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) {
m_tooltipData.m_fIconSize = fSize;
- return FWL_ERR_Succeeded;
}
-FWL_ERR CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) {
- return static_cast<IFWL_ToolTip*>(m_pIface)->SetAnchor(rtAnchor);
+void CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) {
+ static_cast<IFWL_ToolTip*>(m_pIface)->SetAnchor(rtAnchor);
}
-FWL_ERR CFWL_ToolTip::Show() {
- return static_cast<IFWL_ToolTip*>(m_pIface)->Show();
+void CFWL_ToolTip::Show() {
+ static_cast<IFWL_ToolTip*>(m_pIface)->Show();
}
-FWL_ERR CFWL_ToolTip::Hide() {
- return static_cast<IFWL_ToolTip*>(m_pIface)->Hide();
+void CFWL_ToolTip::Hide() {
+ static_cast<IFWL_ToolTip*>(m_pIface)->Hide();
}
CFWL_ToolTip::CFWL_ToolTip() {}
@@ -105,10 +96,10 @@ CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) {
m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
}
-FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) {
+FWL_Error CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.h
index 817362a41c7..74f702849c0 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_tooltip.h
@@ -13,28 +13,35 @@
class CFWL_ToolTip : public CFWL_Widget {
public:
static CFWL_ToolTip* Create();
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
- FWL_ERR GetCaption(CFX_WideString& wsCaption);
- FWL_ERR SetCaption(const CFX_WideStringC& wsCaption);
+
+ CFWL_ToolTip();
+ virtual ~CFWL_ToolTip();
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+
+ void GetCaption(CFX_WideString& wsCaption);
+ void SetCaption(const CFX_WideStringC& wsCaption);
+
int32_t GetInitialDelay();
- int32_t SetInitialDelay(int32_t nDelayTime);
+ void SetInitialDelay(int32_t nDelayTime);
+
int32_t GetAutoPopDelay();
- int32_t SetAutoPopDelay(int32_t nDelayTime);
+ void SetAutoPopDelay(int32_t nDelayTime);
+
CFX_DIBitmap* GetToolTipIcon();
- FWL_ERR SetToolTipIcon(CFX_DIBitmap* pBitmap);
+ void SetToolTipIcon(CFX_DIBitmap* pBitmap);
CFX_SizeF GetToolTipIconSize();
- FWL_ERR SetToolTipIconSize(CFX_SizeF fSize);
- FWL_ERR SetAnchor(const CFX_RectF& rtAnchor);
- FWL_ERR Show();
- FWL_ERR Hide();
- CFWL_ToolTip();
- virtual ~CFWL_ToolTip();
+ void SetToolTipIconSize(CFX_SizeF fSize);
+
+ void SetAnchor(const CFX_RectF& rtAnchor);
+ void Show();
+ void Hide();
protected:
class CFWL_ToolTipDP : public IFWL_ToolTipDP {
public:
CFWL_ToolTipDP();
- FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
+ FWL_Error GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
int32_t GetInitialDelay(IFWL_Widget* pWidget);
int32_t GetAutoPopDelay(IFWL_Widget* pWidget);
CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget);
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.cpp
index 1f4512e3813..8d3237605f8 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.cpp
@@ -10,25 +10,28 @@
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
-#include "xfa/fwl/core/ifwl_notethread.h"
+#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
+#define FWL_WGT_CalcHeight 2048
+#define FWL_WGT_CalcWidth 2048
+#define FWL_WGT_CalcMultiLineDefWidth 120.0f
+
IFWL_Widget* CFWL_Widget::GetWidget() {
return m_pIface;
}
-FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
+FWL_Error CFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->GetClassName(wsClass);
}
-uint32_t CFWL_Widget::GetClassID() const {
+FWL_Type CFWL_Widget::GetClassID() const {
if (!m_pIface)
- return 0;
+ return FWL_Type::Unknown;
return m_pIface->GetClassID();
}
@@ -40,62 +43,60 @@ FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't');
-FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
+FWL_Error CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
- return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL);
+ return FWL_Error::Indefinite;
+ return m_pIface->SetPrivateData(gs_pFWLWidget, this, nullptr);
}
-FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+FWL_Error CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->GetWidgetRect(rect, bAutoSize);
}
-FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
+FWL_Error CFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->GetGlobalRect(rect);
}
-FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
+FWL_Error CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->SetWidgetRect(rect);
}
-FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) {
+FWL_Error CFWL_Widget::GetClientRect(CFX_RectF& rect) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->GetClientRect(rect);
}
CFWL_Widget* CFWL_Widget::GetParent() {
if (!m_pIface)
- return NULL;
+ return nullptr;
+
IFWL_Widget* parent = m_pIface->GetParent();
- if (parent) {
+ if (parent)
return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget));
- }
- return NULL;
+ return nullptr;
}
-FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) {
+FWL_Error CFWL_Widget::SetParent(CFWL_Widget* pParent) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
- return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL);
+ return FWL_Error::Indefinite;
+ return m_pIface->SetParent(pParent ? pParent->GetWidget() : nullptr);
}
CFWL_Widget* CFWL_Widget::GetOwner() {
- if (!m_pIface)
- return NULL;
- return NULL;
+ return nullptr;
}
-FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) {
+FWL_Error CFWL_Widget::SetOwner(CFWL_Widget* pOwner) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+ return FWL_Error::Succeeded;
}
uint32_t CFWL_Widget::GetStyles() {
@@ -104,118 +105,120 @@ uint32_t CFWL_Widget::GetStyles() {
return m_pIface->GetStyles();
}
-FWL_ERR CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
- uint32_t dwStylesRemoved) {
+FWL_Error CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
+ uint32_t dwStylesRemoved) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved);
}
+
uint32_t CFWL_Widget::GetStylesEx() {
if (!m_pIface)
return 0;
return m_pIface->GetStylesEx();
}
-FWL_ERR CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
- uint32_t dwStylesExRemoved) {
+FWL_Error CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
}
uint32_t CFWL_Widget::GetStates() {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return 0;
return m_pIface->GetStates();
}
-FWL_ERR CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
- if (!m_pIface)
- return FWL_ERR_Indefinite;
- return m_pIface->SetStates(dwStates, bSet);
+void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
+ if (m_pIface)
+ m_pIface->SetStates(dwStates, bSet);
}
-FWL_ERR CFWL_Widget::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
+FWL_Error CFWL_Widget::SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->SetPrivateData(module_id, pData, callback);
}
void* CFWL_Widget::GetPrivateData(void* module_id) {
if (!m_pIface)
- return NULL;
+ return nullptr;
return m_pIface->GetPrivateData(module_id);
}
-FWL_ERR CFWL_Widget::Update() {
+FWL_Error CFWL_Widget::Update() {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->Update();
}
-FWL_ERR CFWL_Widget::LockUpdate() {
+FWL_Error CFWL_Widget::LockUpdate() {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->LockUpdate();
}
-FWL_ERR CFWL_Widget::UnlockUpdate() {
+FWL_Error CFWL_Widget::UnlockUpdate() {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->UnlockUpdate();
}
-uint32_t CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
if (!m_pIface)
- return 0;
+ return FWL_WidgetHit::Unknown;
return m_pIface->HitTest(fx, fy);
}
-FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
- FX_FLOAT& fx,
- FX_FLOAT& fy) {
+FWL_Error CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
+ FX_FLOAT& fx,
+ FX_FLOAT& fy) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
- return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy);
+ return FWL_Error::Indefinite;
+ return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, fx,
+ fy);
}
-FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) {
+FWL_Error CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
- return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt);
+ return FWL_Error::Indefinite;
+ return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, rt);
}
-FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
+FWL_Error CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->GetMatrix(matrix, bGlobal);
}
-FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
+FWL_Error CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->SetMatrix(matrix);
}
-FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+FWL_Error CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
return m_pIface->DrawWidget(pGraphics, pMatrix);
}
IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
if (!m_pIface)
- return NULL;
+ return nullptr;
+
m_pDelegate = m_pIface->SetDelegate(pDelegate);
return m_pDelegate;
}
CFWL_Widget::CFWL_Widget()
- : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) {
+ : m_pIface(nullptr), m_pDelegate(nullptr), m_pProperties(nullptr) {
m_pProperties = new CFWL_WidgetProperties;
m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- FXSYS_assert(m_pWidgetMgr != NULL);
+ ASSERT(m_pWidgetMgr);
}
CFWL_Widget::~CFWL_Widget() {
@@ -226,9 +229,10 @@ CFWL_Widget::~CFWL_Widget() {
}
}
-FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) {
+FWL_Error CFWL_Widget::Repaint(const CFX_RectF* pRect) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
CFX_RectF rect;
if (pRect) {
rect = *pRect;
@@ -239,77 +243,85 @@ FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) {
return m_pWidgetMgr->RepaintWidget(m_pIface, &rect);
}
-FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) {
+FWL_Error CFWL_Widget::SetFocus(FX_BOOL bFocus) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
- IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
- if (!pThread)
- return FWL_ERR_Indefinite;
- IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+ return FWL_Error::Indefinite;
+
+ IFWL_App* pApp = m_pIface->GetOwnerApp();
+ if (!pApp)
+ return FWL_Error::Indefinite;
+
+ CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
if (!pDriver)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
if (bFocus) {
pDriver->SetFocus(m_pIface);
} else {
if (pDriver->GetFocus() == m_pIface) {
- pDriver->SetFocus(NULL);
+ pDriver->SetFocus(nullptr);
}
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) {
+FWL_Error CFWL_Widget::SetGrab(FX_BOOL bSet) {
if (!m_pIface)
- return FWL_ERR_Indefinite;
- IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
- if (!pThread)
- return FWL_ERR_Indefinite;
- IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+ return FWL_Error::Indefinite;
+
+ IFWL_App* pApp = m_pIface->GetOwnerApp();
+ if (!pApp)
+ return FWL_Error::Indefinite;
+
+ CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
if (!pDriver)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
pDriver->SetGrab(m_pIface, bSet);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource,
uint32_t dwFilter) {
if (!m_pIface)
return;
- IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
- if (!pThread)
+
+ IFWL_App* pApp = m_pIface->GetOwnerApp();
+ if (!pApp)
return;
- IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+
+ CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
if (!pNoteDriver)
return;
+
IFWL_Widget* pEventSourceImp =
- !pEventSource ? NULL : pEventSource->GetWidget();
+ !pEventSource ? nullptr : pEventSource->GetWidget();
pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter);
}
void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
if (!m_pIface)
return;
- if (m_pIface->GetOuter()) {
+ if (m_pIface->GetOuter())
return;
- }
- IFWL_NoteThread* pThread = m_pIface->GetOwnerThread();
- if (!pThread)
+
+ IFWL_App* pApp = m_pIface->GetOwnerApp();
+ if (!pApp)
return;
- IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+
+ CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
if (!pNoteDriver)
return;
- pNoteDriver->SendNote(pEvent);
-}
-#define FWL_WGT_CalcHeight 2048
-#define FWL_WGT_CalcWidth 2048
-#define FWL_WGT_CalcMultiLineDefWidth 120.0f
+ pNoteDriver->SendEvent(pEvent);
+}
CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText,
FX_BOOL bMultiLine,
int32_t iLineWidth) {
if (!m_pIface)
return CFX_SizeF();
+
IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider();
if (!pTheme)
return CFX_SizeF();
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.h
index f1b67158112..1c29b1f58e2 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widget.h
@@ -20,42 +20,45 @@ class CFWL_WidgetMgr;
class CFWL_Widget {
public:
virtual ~CFWL_Widget();
+
IFWL_Widget* GetWidget();
- FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- uint32_t GetClassID() const;
+ FWL_Error GetClassName(CFX_WideString& wsClass) const;
+ FWL_Type GetClassID() const;
virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- FWL_ERR GetGlobalRect(CFX_RectF& rect);
- FWL_ERR SetWidgetRect(const CFX_RectF& rect);
- FWL_ERR GetClientRect(CFX_RectF& rtClient);
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ FWL_Error GetGlobalRect(CFX_RectF& rect);
+ FWL_Error SetWidgetRect(const CFX_RectF& rect);
+ FWL_Error GetClientRect(CFX_RectF& rtClient);
CFWL_Widget* GetParent();
- FWL_ERR SetParent(CFWL_Widget* pParent);
+ FWL_Error SetParent(CFWL_Widget* pParent);
CFWL_Widget* GetOwner();
- FWL_ERR SetOwner(CFWL_Widget* pOwner);
+ FWL_Error SetOwner(CFWL_Widget* pOwner);
uint32_t GetStyles();
- FWL_ERR ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
+ FWL_Error ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
uint32_t GetStylesEx();
- FWL_ERR ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved);
+ FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
uint32_t GetStates();
- FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
- FWL_ERR SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback);
+ void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
+ FWL_Error SetPrivateData(void* module_id,
+ void* pData,
+ PD_CALLBACK_FREEDATA callback);
void* GetPrivateData(void* module_id);
- FWL_ERR Update();
- FWL_ERR LockUpdate();
- FWL_ERR UnlockUpdate();
- uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
- FWL_ERR TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
- FWL_ERR TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt);
- FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
- FWL_ERR SetMatrix(const CFX_Matrix& matrix);
- FWL_ERR DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = NULL);
+ FWL_Error Update();
+ FWL_Error LockUpdate();
+ FWL_Error UnlockUpdate();
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ FWL_Error TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
+ FWL_Error TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt);
+ FWL_Error GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
+ FWL_Error SetMatrix(const CFX_Matrix& matrix);
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
- FWL_ERR Repaint(const CFX_RectF* pRect = NULL);
- FWL_ERR SetFocus(FX_BOOL bFocus);
- FWL_ERR SetGrab(FX_BOOL bSet);
+ FWL_Error Repaint(const CFX_RectF* pRect = NULL);
+ FWL_Error SetFocus(FX_BOOL bFocus);
+ FWL_Error SetGrab(FX_BOOL bSet);
CFWL_Widget();
void RegisterEventTarget(CFWL_Widget* pEventSource = NULL,
@@ -70,7 +73,7 @@ class CFWL_Widget {
CFWL_WidgetProperties* m_pProperties;
protected:
- FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL);
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
};
#endif // XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp
index 1596aba48a4..fcb72326220 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp
@@ -13,15 +13,9 @@ CFWL_WidgetDelegate::CFWL_WidgetDelegate() {}
CFWL_WidgetDelegate::~CFWL_WidgetDelegate() {}
-int32_t CFWL_WidgetDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- return 1;
-}
-
-FWL_ERR CFWL_WidgetDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- return FWL_ERR_Succeeded;
-}
-
-FWL_ERR CFWL_WidgetDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return FWL_ERR_Succeeded;
-}
+void CFWL_WidgetDelegate::OnProcessMessage(CFWL_Message* pMessage) {}
+
+void CFWL_WidgetDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
+
+void CFWL_WidgetDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {}
diff --git a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.h b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.h
index 42f6f9329f0..1f5cdab8f4f 100644
--- a/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.h
+++ b/chromium/third_party/pdfium/xfa/fwl/lightwidget/cfwl_widgetdelegate.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_LIGHTWIDGET_CFWL_WIDGETDELEGATE_H_
#define XFA_FWL_LIGHTWIDGET_CFWL_WIDGETDELEGATE_H_
+#include <stdint.h>
+
#include "xfa/fwl/core/fwl_error.h"
#include "xfa/fwl/core/ifwl_widgetdelegate.h"
@@ -20,10 +22,10 @@ class CFWL_WidgetDelegate : public IFWL_WidgetDelegate {
CFWL_WidgetDelegate();
virtual ~CFWL_WidgetDelegate();
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
};
#endif // XFA_FWL_LIGHTWIDGET_CFWL_WIDGETDELEGATE_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.cpp
index 0edc29b7757..609add6c0e4 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.cpp
@@ -14,26 +14,24 @@ CFWL_BarcodeTP::CFWL_BarcodeTP() {}
CFWL_BarcodeTP::~CFWL_BarcodeTP() {}
-FX_BOOL CFWL_BarcodeTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_Barcode;
+bool CFWL_BarcodeTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::Barcode;
}
FX_BOOL CFWL_BarcodeTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
switch (pParams->m_iPart) {
- case FWL_PART_BCD_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_BCD_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_BCD_Background: {
+ case CFWL_Part::Background: {
FillBackground(pParams->m_pGraphics, &pParams->m_rtPart,
&pParams->m_matrix);
break;
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.h
index 0a03f498051..6db7f156230 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_barcodetp.h
@@ -13,9 +13,11 @@
class CFWL_BarcodeTP : public CFWL_WidgetTP {
public:
CFWL_BarcodeTP();
- virtual ~CFWL_BarcodeTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
+ ~CFWL_BarcodeTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
};
#endif // XFA_FWL_THEME_CFWL_BARCODETP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.cpp
index 0ebc519642a..eb732313170 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.cpp
@@ -15,17 +15,16 @@
CFWL_CaretTP::CFWL_CaretTP() {}
CFWL_CaretTP::~CFWL_CaretTP() {}
-FX_BOOL CFWL_CaretTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_Caret;
+bool CFWL_CaretTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::Caret;
}
+
FX_BOOL CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
switch (pParams->m_iPart) {
- case FWL_PART_CAT_Background: {
- if (!(pParams->m_dwStates & FWL_PARTSTATE_CAT_HightLight)) {
+ case CFWL_Part::Background: {
+ if (!(pParams->m_dwStates & CFWL_PartState_HightLight)) {
return TRUE;
}
DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates,
@@ -33,6 +32,8 @@ FX_BOOL CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) {
&(pParams->m_matrix));
break;
}
+ default:
+ break;
}
return TRUE;
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.h
index 8c56d38aa9b..03b376a61e5 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_carettp.h
@@ -12,9 +12,11 @@
class CFWL_CaretTP : public CFWL_WidgetTP {
public:
CFWL_CaretTP();
- virtual ~CFWL_CaretTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
+ ~CFWL_CaretTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
protected:
void DrawCaretBK(CFX_Graphics* pGraphics,
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.cpp
index 94f69a43894..9a10c60a3df 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.cpp
@@ -14,33 +14,36 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define CHECKBOX_SIZE_SIGNMARGIN 3
-#define CHECKBOX_SIZE_SIGNBORDER 2
-#define CHECKBOX_SIZE_SIGNPATH 100
+namespace {
+
+const int kSignMargin = 3;
+const int kSignBorder = 2;
+const int kSignPath = 100;
+
+} // namespace
+
#define CHECKBOX_COLOR_BOXLT1 (ArgbEncode(255, 172, 168, 153))
#define CHECKBOX_COLOR_BOXLT2 (ArgbEncode(255, 113, 111, 100))
#define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226))
#define CHECKBOX_COLOR_BOXRB2 (ArgbEncode(255, 255, 255, 255))
-#define CHECKBOX_FXGE_CoordinatesAdjust
-CFWL_CheckBoxTP::CFWL_CheckBoxTP() : m_pCheckPath(NULL) {
- m_pThemeData = new CKBThemeData;
+CFWL_CheckBoxTP::CFWL_CheckBoxTP()
+ : m_pThemeData(new CKBThemeData), m_pCheckPath(nullptr) {
SetThemeData(0);
}
+
CFWL_CheckBoxTP::~CFWL_CheckBoxTP() {
- if (m_pThemeData) {
- delete m_pThemeData;
- m_pThemeData = NULL;
- }
+ delete m_pThemeData;
if (m_pCheckPath) {
m_pCheckPath->Clear();
delete m_pCheckPath;
- m_pCheckPath = NULL;
}
}
-FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
- return pWidget && pWidget->GetClassID() == FWL_CLASSHASH_CheckBox;
+
+bool CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::CheckBox;
}
+
uint32_t CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren) {
@@ -52,8 +55,7 @@ uint32_t CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget,
FX_BOOL CFWL_CheckBoxTP::DrawText(CFWL_ThemeText* pParams) {
if (!m_pTextOut)
return FALSE;
- m_pTextOut->SetTextColor((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) ==
- FWL_PARTSTATE_CKB_Disabled
+ m_pTextOut->SetTextColor(pParams->m_dwStates & CFWL_PartState_Disabled
? FWLTHEME_CAPACITY_TextDisColor
: FWLTHEME_CAPACITY_TextColor);
return CFWL_WidgetTP::DrawText(pParams);
@@ -62,49 +64,46 @@ FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
switch (pParams->m_iPart) {
- case FWL_PART_CKB_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_CKB_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_CKB_Background: {
+ case CFWL_Part::Background: {
FillBackground(pParams->m_pGraphics, &pParams->m_rtPart,
&pParams->m_matrix);
- if (pParams->m_dwStates & FWL_PARTSTATE_CKB_Focused) {
+ if (pParams->m_dwStates & CFWL_PartState_Focused) {
pParams->m_rtPart = *(CFX_RectF*)pParams->m_pData;
DrawFocus(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
}
break;
}
- case FWL_PART_CKB_CheckBox: {
+ case CFWL_Part::CheckBox: {
DrawBoxBk(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart,
pParams->m_dwStates, &pParams->m_matrix);
- if (((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) ==
- FWL_PARTSTATE_CKB_Checked) |
- ((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) ==
- FWL_PARTSTATE_CKB_Neutral)) {
+ if ((pParams->m_dwStates & CFWL_PartState_Checked) |
+ (pParams->m_dwStates & CFWL_PartState_Neutral)) {
DrawSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart,
pParams->m_dwStates, &pParams->m_matrix);
}
- FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) ==
- FWL_PARTSTATE_CKB_Disabled;
- DrawSignBorder(pParams->m_pWidget, pParams->m_pGraphics,
- &pParams->m_rtPart, bDisable, &pParams->m_matrix);
+ DrawSignBorder(
+ pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart,
+ pParams->m_dwStates & CFWL_PartState_Disabled, &pParams->m_matrix);
break;
}
default: { return FALSE; }
}
return TRUE;
}
-FWL_ERR CFWL_CheckBoxTP::Initialize() {
+FWL_Error CFWL_CheckBoxTP::Initialize() {
InitTTO();
return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_CheckBoxTP::Finalize() {
+FWL_Error CFWL_CheckBoxTP::Finalize() {
FinalizeTTO();
return CFWL_WidgetTP::Finalize();
}
@@ -121,52 +120,38 @@ void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget,
path.Create();
FX_FLOAT fRight = pRect->right();
FX_FLOAT fBottom = pRect->bottom();
- FX_BOOL bClipSign =
- (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered;
+ bool bClipSign = !!(dwStates & CFWL_PartState_Hovered);
if ((dwStyleEx == FWL_STYLEEXT_CKB_ShapeSolidSquare) ||
(dwStyleEx == FWL_STYLEEXT_CKB_ShapeSunkenSquare)) {
path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
if (bClipSign) {
fillMode = FXFILL_ALTERNATE;
- path.AddRectangle(pRect->left + CHECKBOX_SIZE_SIGNMARGIN,
- pRect->top + CHECKBOX_SIZE_SIGNMARGIN,
- pRect->width - CHECKBOX_SIZE_SIGNMARGIN * 2,
- pRect->height - CHECKBOX_SIZE_SIGNMARGIN * 2);
+ path.AddRectangle(pRect->left + kSignMargin, pRect->top + kSignMargin,
+ pRect->width - kSignMargin * 2,
+ pRect->height - kSignMargin * 2);
}
} else {
-#ifdef CHECKBOX_FXGE_CoordinatesAdjust
CFX_RectF rect(*pRect);
rect.Deflate(0, 0, 1, 1);
path.AddEllipse(rect);
-#else
- path.AddEllipse(*pRect);
-#endif
if (bClipSign) {
fillMode = FXFILL_ALTERNATE;
-#ifdef CHECKBOX_FXGE_CoordinatesAdjust
CFX_RectF rtClip(rect);
-#else
- CFX_RectF rtClip(*pRect);
-#endif
- rtClip.Deflate(CHECKBOX_SIZE_SIGNMARGIN - 1,
- CHECKBOX_SIZE_SIGNMARGIN - 1);
+ rtClip.Deflate(kSignMargin - 1, kSignMargin - 1);
path.AddEllipse(rtClip);
}
}
int32_t iTheme = 1;
- if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) {
+ if (dwStates & CFWL_PartState_Hovered) {
iTheme = 2;
- } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) ==
- FWL_PARTSTATE_CKB_Pressed) {
+ } else if (dwStates & CFWL_PartState_Pressed) {
iTheme = 3;
- } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) ==
- FWL_PARTSTATE_CKB_Disabled) {
+ } else if (dwStates & CFWL_PartState_Disabled) {
iTheme = 4;
}
- if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) {
+ if (dwStates & CFWL_PartState_Checked) {
iTheme += 4;
- } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) ==
- FWL_PARTSTATE_CKB_Neutral) {
+ } else if (dwStates & CFWL_PartState_Neutral) {
iTheme += 8;
}
DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight, fBottom,
@@ -179,33 +164,23 @@ void CFWL_CheckBoxTP::DrawSign(IFWL_Widget* pWidget,
uint32_t dwStates,
CFX_Matrix* pMatrix) {
CFX_RectF rtSign(*pRtBox);
- rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN);
+ rtSign.Deflate(kSignMargin, kSignMargin);
uint32_t dwColor = m_pThemeData->clrSignCheck;
FX_BOOL bCheck = TRUE;
- if (((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) &&
- ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked)) {
+ if ((dwStates & CFWL_PartState_Disabled) &&
+ (dwStates & CFWL_PartState_Checked)) {
dwColor = m_pThemeData->clrSignBorderDisable;
- } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) ==
- FWL_PARTSTATE_CKB_Neutral) {
- switch (dwStates & FWL_PARTSTATE_CKB_Mask1) {
- case FWL_PARTSTATE_CKB_Normal: {
- bCheck = FALSE;
- dwColor = m_pThemeData->clrSignNeutralNormal;
- break;
- }
- case FWL_PARTSTATE_CKB_Hovered: {
- bCheck = FALSE;
- dwColor = m_pThemeData->clrSignNeutralHover;
- break;
- }
- case FWL_PARTSTATE_CKB_Pressed: {
- bCheck = FALSE, dwColor = m_pThemeData->clrSignNeutralPressed;
- break;
- }
- case FWL_PARTSTATE_CKB_Disabled: {
- bCheck = FALSE, dwColor = m_pThemeData->clrSignBorderDisable;
- break;
- }
+ } else if (dwStates & CFWL_PartState_Neutral) {
+ if (dwStates & CFWL_PartState_Normal) {
+ bCheck = FALSE;
+ dwColor = m_pThemeData->clrSignNeutralNormal;
+ } else if (dwStates & CFWL_PartState_Hovered) {
+ bCheck = FALSE;
+ dwColor = m_pThemeData->clrSignNeutralHover;
+ } else if (dwStates & CFWL_PartState_Pressed) {
+ bCheck = FALSE, dwColor = m_pThemeData->clrSignNeutralPressed;
+ } else if (dwStates & CFWL_PartState_Disabled) {
+ bCheck = FALSE, dwColor = m_pThemeData->clrSignBorderDisable;
}
}
if (bCheck) {
@@ -374,8 +349,8 @@ void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget,
break;
}
case FWL_STYLEEXT_CKB_ShapeSunkenSquare: {
- Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER,
- pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
+ Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, kSignBorder, pRtBox,
+ CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix);
break;
}
@@ -386,8 +361,8 @@ void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget,
break;
}
case FWL_STYLEEXT_CKB_ShapeSunkenCircle: {
- Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER,
- pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
+ Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, kSignBorder, pRtBox,
+ CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2,
CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix);
break;
}
@@ -465,9 +440,9 @@ void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen) {
if (!m_pCheckPath) {
m_pCheckPath = new CFX_Path;
m_pCheckPath->Create();
- FX_FLOAT fWidth = CHECKBOX_SIZE_SIGNPATH;
- FX_FLOAT fHeight = -CHECKBOX_SIZE_SIGNPATH;
- FX_FLOAT fBottom = CHECKBOX_SIZE_SIGNPATH;
+ FX_FLOAT fWidth = kSignPath;
+ FX_FLOAT fHeight = -kSignPath;
+ FX_FLOAT fBottom = kSignPath;
CFX_PointF pt1(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f);
CFX_PointF pt2(fWidth / 4.5f, fBottom + fHeight / 16.0f);
CFX_PointF pt3(fWidth / 3.0f, fBottom);
@@ -490,43 +465,38 @@ void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen) {
FX_FLOAT py1 = pt12.y - pt1.y;
FX_FLOAT px2 = pt21.x - pt2.x;
FX_FLOAT py2 = pt21.y - pt2.y;
- m_pCheckPath->BezierTo(pt1.x + px1 * FWLTHEME_BEZIER,
- pt1.y + py1 * FWLTHEME_BEZIER,
- pt2.x + px2 * FWLTHEME_BEZIER,
- pt2.y + py2 * FWLTHEME_BEZIER, pt2.x, pt2.y);
+ m_pCheckPath->BezierTo(pt1.x + px1 * FX_BEZIER, pt1.y + py1 * FX_BEZIER,
+ pt2.x + px2 * FX_BEZIER, pt2.y + py2 * FX_BEZIER,
+ pt2.x, pt2.y);
px1 = pt23.x - pt2.x;
py1 = pt23.y - pt2.y;
px2 = pt32.x - pt3.x;
py2 = pt32.y - pt3.y;
- m_pCheckPath->BezierTo(pt2.x + px1 * FWLTHEME_BEZIER,
- pt2.y + py1 * FWLTHEME_BEZIER,
- pt3.x + px2 * FWLTHEME_BEZIER,
- pt3.y + py2 * FWLTHEME_BEZIER, pt3.x, pt3.y);
+ m_pCheckPath->BezierTo(pt2.x + px1 * FX_BEZIER, pt2.y + py1 * FX_BEZIER,
+ pt3.x + px2 * FX_BEZIER, pt3.y + py2 * FX_BEZIER,
+ pt3.x, pt3.y);
px1 = pt34.x - pt3.x;
py1 = pt34.y - pt3.y;
px2 = pt43.x - pt4.x;
py2 = pt43.y - pt4.y;
- m_pCheckPath->BezierTo(pt3.x + px1 * FWLTHEME_BEZIER,
- pt3.y + py1 * FWLTHEME_BEZIER,
- pt4.x + px2 * FWLTHEME_BEZIER,
- pt4.y + py2 * FWLTHEME_BEZIER, pt4.x, pt4.y);
+ m_pCheckPath->BezierTo(pt3.x + px1 * FX_BEZIER, pt3.y + py1 * FX_BEZIER,
+ pt4.x + px2 * FX_BEZIER, pt4.y + py2 * FX_BEZIER,
+ pt4.x, pt4.y);
px1 = pt45.x - pt4.x;
py1 = pt45.y - pt4.y;
px2 = pt54.x - pt5.x;
py2 = pt54.y - pt5.y;
- m_pCheckPath->BezierTo(pt4.x + px1 * FWLTHEME_BEZIER,
- pt4.y + py1 * FWLTHEME_BEZIER,
- pt5.x + px2 * FWLTHEME_BEZIER,
- pt5.y + py2 * FWLTHEME_BEZIER, pt5.x, pt5.y);
+ m_pCheckPath->BezierTo(pt4.x + px1 * FX_BEZIER, pt4.y + py1 * FX_BEZIER,
+ pt5.x + px2 * FX_BEZIER, pt5.y + py2 * FX_BEZIER,
+ pt5.x, pt5.y);
px1 = pt51.x - pt5.x;
py1 = pt51.y - pt5.y;
px2 = pt15.x - pt1.x;
py2 = pt15.y - pt1.y;
- m_pCheckPath->BezierTo(pt5.x + px1 * FWLTHEME_BEZIER,
- pt5.y + py1 * FWLTHEME_BEZIER,
- pt1.x + px2 * FWLTHEME_BEZIER,
- pt1.y + py2 * FWLTHEME_BEZIER, pt1.x, pt1.y);
- FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH;
+ m_pCheckPath->BezierTo(pt5.x + px1 * FX_BEZIER, pt5.y + py1 * FX_BEZIER,
+ pt1.x + px2 * FX_BEZIER, pt1.y + py2 * FX_BEZIER,
+ pt1.x, pt1.y);
+ FX_FLOAT fScale = fCheckLen / kSignPath;
CFX_Matrix mt;
mt.Set(1, 0, 0, 1, 0, 0);
mt.Scale(fScale, fScale);
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.h
index bb2f14dec36..a502b929265 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_checkboxtp.h
@@ -13,15 +13,17 @@
class CFWL_CheckBoxTP : public CFWL_WidgetTP {
public:
CFWL_CheckBoxTP();
- virtual ~CFWL_CheckBoxTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
- uint32_t dwThemeID,
- FX_BOOL bChildren = TRUE);
- virtual FX_BOOL DrawText(CFWL_ThemeText* pParams);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ ~CFWL_CheckBoxTP() override;
+
+ // CFWL_WidgeTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ uint32_t SetThemeID(IFWL_Widget* pWidget,
+ uint32_t dwThemeID,
+ FX_BOOL bChildren = TRUE) override;
+ FX_BOOL DrawText(CFWL_ThemeText* pParams) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
protected:
void DrawBoxBk(IFWL_Widget* pWidget,
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.cpp
index 2c5a1c4ff4a..92f22961057 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.cpp
@@ -13,41 +13,46 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define FWLTHEME_CAPACITY_ComboFormHandler 8.0f
+namespace {
+
+const float kComboFormHandler = 8.0f;
+
+} // namespace
CFWL_ComboBoxTP::CFWL_ComboBoxTP() {
m_dwThemeID = 0;
}
+
CFWL_ComboBoxTP::~CFWL_ComboBoxTP() {}
-FX_BOOL CFWL_ComboBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_ComboBox;
+
+bool CFWL_ComboBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::ComboBox;
}
+
FX_BOOL CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
switch (pParams->m_iPart) {
- case FWL_PART_CMB_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_CMB_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_CMB_Background: {
+ case CFWL_Part::Background: {
CFX_Path path;
path.Create();
CFX_RectF& rect = pParams->m_rtPart;
path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
CFX_Color cr;
switch (pParams->m_dwStates) {
- case FWL_PARTSTATE_CMB_Selected:
+ case CFWL_PartState_Selected:
cr = FWLTHEME_COLOR_BKSelected;
break;
- case FWL_PARTSTATE_CMB_Disabled:
+ case CFWL_PartState_Disabled:
cr = FWLTHEME_COLOR_EDGERB1;
break;
default:
@@ -59,11 +64,11 @@ FX_BOOL CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
pParams->m_pGraphics->RestoreGraphState();
break;
}
- case FWL_PART_CMB_DropDownButton: {
+ case CFWL_Part::DropDownButton: {
DrawDropDownButton(pParams, pParams->m_dwStates, &pParams->m_matrix);
break;
}
- case FWL_PART_CMB_StretcgHandler: {
+ case CFWL_Part::StretchHandler: {
DrawStrethHandler(pParams, 0, &pParams->m_matrix);
break;
}
@@ -83,32 +88,32 @@ void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground* pParams,
pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
}
void* CFWL_ComboBoxTP::GetCapacity(CFWL_ThemePart* pThemePart,
- uint32_t dwCapacity) {
- if (dwCapacity == FWL_WGTCAPACITY_CMB_ComboFormHandler) {
- m_fValue = FWLTHEME_CAPACITY_ComboFormHandler;
+ CFWL_WidgetCapacity dwCapacity) {
+ if (dwCapacity == CFWL_WidgetCapacity::ComboFormHandler) {
+ m_fValue = kComboFormHandler;
return &m_fValue;
}
return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-#ifdef THEME_XPSimilar
+
void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
uint32_t dwStates,
CFX_Matrix* pMatrix) {
FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
switch (dwStates) {
- case FWL_PARTSTATE_CMB_Normal: {
+ case CFWL_PartState_Normal: {
eState = FWLTHEME_STATE_Normal;
break;
}
- case FWL_PARTSTATE_CMB_Hovered: {
+ case CFWL_PartState_Hovered: {
eState = FWLTHEME_STATE_Hover;
break;
}
- case FWL_PARTSTATE_CMB_Pressed: {
+ case CFWL_PartState_Pressed: {
eState = FWLTHEME_STATE_Pressed;
break;
}
- case FWL_PARTSTATE_CMB_Disabled: {
+ case CFWL_PartState_Disabled: {
eState = FWLTHEME_STATE_Disabale;
break;
}
@@ -117,44 +122,3 @@ void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart,
FWLTHEME_DIRECTION_Down, eState, &pParams->m_matrix);
}
-#else
-void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
- uint32_t dwStates,
- CFX_Matrix* pMatrix) {
- FX_BOOL bPressed = ((pParams->m_dwStates & FWL_CMBPARTSTATE_Pressed) ==
- FWL_CMBPARTSTATE_Pressed);
- FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f;
- FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised;
- Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart,
- FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2,
- FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pParams->m_rtPart.left + fWidth,
- pParams->m_rtPart.top + fWidth,
- pParams->m_rtPart.width - 2 * fWidth,
- pParams->m_rtPart.height - 2 * fWidth);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color crFill(FWLTHEME_COLOR_Background);
- pParams->m_pGraphics->SetFillColor(&crFill);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix);
- pParams->m_pGraphics->RestoreGraphState();
- FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133);
- switch (pParams->m_dwStates & 0x03) {
- case FWL_CMBPARTSTATE_Normal: {
- }
- case FWL_CMBPARTSTATE_Hovered: {
- }
- case FWL_CMBPARTSTATE_Pressed: {
- argbFill = 0xFF000000;
- break;
- }
- case FWL_CMBPARTSTATE_Disabled: {
- argbFill = 0xFFF0F0F0;
- break;
- }
- }
- DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down,
- argbFill, bPressed, &pParams->m_matrix);
-}
-#endif
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.h
index fd65fa5fab1..0480e60c303 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_comboboxtp.h
@@ -12,10 +12,13 @@
class CFWL_ComboBoxTP : public CFWL_WidgetTP {
public:
CFWL_ComboBoxTP();
- virtual ~CFWL_ComboBoxTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
- virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity);
+ ~CFWL_ComboBoxTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
+ void* GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity) override;
protected:
void DrawDropDownButton(CFWL_ThemeBackground* pParams,
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickedtp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickedtp.cpp
index 4e1d39a15af..a303a4ea1f7 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickedtp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickedtp.cpp
@@ -13,28 +13,29 @@ CFWL_DateTimePickerTP::CFWL_DateTimePickerTP() {
m_pThemeData = new DTPThemeData;
initThemeData();
}
+
CFWL_DateTimePickerTP::~CFWL_DateTimePickerTP() {
delete m_pThemeData;
}
-FX_BOOL CFWL_DateTimePickerTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_DateTimePicker;
+
+bool CFWL_DateTimePickerTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::DateTimePicker;
}
+
FX_BOOL CFWL_DateTimePickerTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
switch (pParams->m_iPart) {
- case FWL_PART_DTP_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_DTP_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_DTP_DropDownButton: {
+ case CFWL_Part::DropDownButton: {
DrawDropDownButton(pParams, &pParams->m_matrix);
break;
}
@@ -42,26 +43,26 @@ FX_BOOL CFWL_DateTimePickerTP::DrawBackground(CFWL_ThemeBackground* pParams) {
}
return TRUE;
}
-#ifdef THEME_XPSimilar
+
void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
uint32_t dwStates = pParams->m_dwStates;
dwStates &= 0x03;
FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
switch (eState & dwStates) {
- case FWL_PARTSTATE_DTP_Normal: {
+ case CFWL_PartState_Normal: {
eState = FWLTHEME_STATE_Normal;
break;
}
- case FWL_PARTSTATE_DTP_Hovered: {
+ case CFWL_PartState_Hovered: {
eState = FWLTHEME_STATE_Hover;
break;
}
- case FWL_PARTSTATE_DTP_Pressed: {
+ case CFWL_PartState_Pressed: {
eState = FWLTHEME_STATE_Pressed;
break;
}
- case FWL_PARTSTATE_DTP_Disabled: {
+ case CFWL_PartState_Disabled: {
eState = FWLTHEME_STATE_Disabale;
break;
}
@@ -70,46 +71,7 @@ void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart,
FWLTHEME_DIRECTION_Down, eState, pMatrix);
}
-#else
-void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams,
- CFX_Matrix* pMatrix) {
- FX_BOOL bPressed = ((pParams->m_dwStates & FWL_PARTSTATE_DTP_Pressed) ==
- FWL_PARTSTATE_DTP_Pressed);
- FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f;
- FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised;
- Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart,
- FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2,
- FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pParams->m_rtPart.left + fWidth,
- pParams->m_rtPart.top + fWidth,
- pParams->m_rtPart.width - 2 * fWidth,
- pParams->m_rtPart.height - 2 * fWidth);
- pParams->m_pGraphics->SaveGraphState();
- CFX_Color crFill(FWLTHEME_COLOR_Background);
- pParams->m_pGraphics->SetFillColor(&crFill);
- pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pParams->m_pGraphics->RestoreGraphState();
- FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133);
- switch (pParams->m_dwStates & 0x03) {
- case FWL_PARTSTATE_DTP_Normal: {
- }
- case FWL_PARTSTATE_DTP_Hovered: {
- }
- case FWL_PARTSTATE_DTP_Pressed: {
- argbFill = 0xFF000000;
- break;
- }
- case FWL_PARTSTATE_DTP_Disabled: {
- argbFill = 0xFFF0F0F0;
- break;
- }
- }
- DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down,
- argbFill, bPressed, pMatrix);
-}
-#endif
+
void CFWL_DateTimePickerTP::initThemeData() {
uint32_t* pData = (uint32_t*)&m_pThemeData->BoxBkColor;
*pData++ = 0;
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickertp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickertp.h
index 199551ea1fa..1b8899b73ec 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickertp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_datetimepickertp.h
@@ -12,13 +12,16 @@
class CFWL_DateTimePickerTP : public CFWL_WidgetTP {
public:
CFWL_DateTimePickerTP();
- virtual ~CFWL_DateTimePickerTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
+ ~CFWL_DateTimePickerTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
protected:
void DrawDropDownButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix);
void initThemeData();
+
struct DTPThemeData {
FX_ARGB BoxBkColor[13][2];
} * m_pThemeData;
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.cpp
index 92f32dcaa99..8e59a4d1f2e 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.cpp
@@ -15,23 +15,22 @@
CFWL_EditTP::CFWL_EditTP() {}
CFWL_EditTP::~CFWL_EditTP() {}
-FX_BOOL CFWL_EditTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_Edit;
+bool CFWL_EditTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::Edit;
}
+
FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
switch (pParams->m_iPart) {
- case FWL_PART_EDT_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_EDT_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_EDT_Background: {
+ case CFWL_Part::Background: {
if (pParams->m_pPath) {
CFX_Graphics* pGraphics = pParams->m_pGraphics;
pGraphics->SaveGraphState();
@@ -43,23 +42,18 @@ FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
&pParams->m_matrix);
pGraphics->RestoreGraphState();
} else {
- FX_BOOL bStatic =
- pParams->m_dwData == FWL_PARTDATA_EDT_StaticBackground;
CFX_Path path;
path.Create();
path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top,
pParams->m_rtPart.width, pParams->m_rtPart.height);
CFX_Color cr(FWLTHEME_COLOR_Background);
- if (!bStatic) {
- if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_Disable) ==
- FWL_PARTSTATE_EDT_Disable) {
+ if (!pParams->m_bStaticBackground) {
+ if (pParams->m_dwStates & CFWL_PartState_Disabled)
cr.Set(FWLTHEME_COLOR_EDGERB1);
- } else if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_ReadOnly) ==
- FWL_PARTSTATE_EDT_ReadOnly) {
+ else if (pParams->m_dwStates & CFWL_PartState_ReadOnly)
cr.Set(ArgbEncode(255, 236, 233, 216));
- } else {
+ else
cr.Set(0xFFFFFFFF);
- }
}
pParams->m_pGraphics->SaveGraphState();
pParams->m_pGraphics->SetFillColor(&cr);
@@ -69,7 +63,7 @@ FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
}
break;
}
- case FWL_PART_EDT_CombTextLine: {
+ case CFWL_Part::CombTextLine: {
FX_ARGB cr = 0xFF000000;
FX_FLOAT fWidth = 1.0f;
CFX_Color crLine(cr);
@@ -82,11 +76,11 @@ FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
}
return TRUE;
}
-FWL_ERR CFWL_EditTP::Initialize() {
+FWL_Error CFWL_EditTP::Initialize() {
InitTTO();
return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_EditTP::Finalize() {
+FWL_Error CFWL_EditTP::Finalize() {
FinalizeTTO();
return CFWL_WidgetTP::Finalize();
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.h
index 73c99dafb78..22cbe778a32 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_edittp.h
@@ -12,11 +12,13 @@
class CFWL_EditTP : public CFWL_WidgetTP {
public:
CFWL_EditTP();
- virtual ~CFWL_EditTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ ~CFWL_EditTP() override;
+
+ // CFWL_WidgeTTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
};
#endif // XFA_FWL_THEME_CFWL_EDITTP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.cpp
index e7cc1221d05..75244373d49 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.cpp
@@ -16,16 +16,20 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define FWLTHEME_CAPACITY_CXFormBorder 3
-#define FWLTHEME_CAPACITY_CYFormBorder 3
-#define FWLTHEME_CAPACITY_CYNarrowCaption 18
-#define FWLTHEME_CAPACITY_CYCaption 29
-#define FWLTHEME_CAPACITY_BigIconSize 32
-#define FWLTHEME_CAPACITY_SmallIconSize 16
-#define FWLTHEME_CAPACITY_FormTextColor 0xFFFFFFFF
-#define FWLTHEME_FORMBTN_Margin 5
-#define FWLTHEME_FORMBTN_Span 2
-#define FWLTHEME_FORMBTN_Size 21
+namespace {
+
+const int kCXFormBorder = 3;
+const int kCYFormBorder = 3;
+const int kCYCaption = 29;
+const int kFormBigIconSize = 32;
+const int kFormSmallIconSize = 16;
+const uint32_t kFormTextColor = 0xFFFFFFFF;
+
+const int kButtonSize = 21;
+const int kButtonMargin = 5;
+const int kButtonSpan = 2;
+
+} // namespace
CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) {
m_pThemeData = new SBThemeData;
@@ -35,36 +39,31 @@ CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) {
m_rtDisBBorder.Reset();
m_rtDisCaption.Reset();
}
+
CFWL_FormTP::~CFWL_FormTP() {
- if (m_pThemeData) {
- delete m_pThemeData;
- m_pThemeData = NULL;
- }
+ delete m_pThemeData;
}
-FWL_ERR CFWL_FormTP::Initialize() {
+
+FWL_Error CFWL_FormTP::Initialize() {
InitTTO();
InitCaption(TRUE);
InitCaption(FALSE);
return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_FormTP::Finalize() {
+
+FWL_Error CFWL_FormTP::Finalize() {
FinalizeTTO();
- if (m_pActiveBitmap) {
- delete m_pActiveBitmap;
- m_pActiveBitmap = NULL;
- }
- if (m_pDeactivebitmap) {
- delete m_pDeactivebitmap;
- m_pDeactivebitmap = NULL;
- }
+ delete m_pActiveBitmap;
+ m_pActiveBitmap = nullptr;
+ delete m_pDeactivebitmap;
+ m_pDeactivebitmap = nullptr;
return CFWL_WidgetTP::Finalize();
}
-FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- uint32_t dwHash = pWidget->GetClassID();
- return dwHash == FWL_CLASSHASH_Form;
+
+bool CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::Form;
}
+
uint32_t CFWL_FormTP::SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren) {
@@ -79,67 +78,67 @@ FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
int32_t iActive = 0;
- if (pParams->m_dwStates & FWL_PARTSTATE_FRM_Inactive) {
+ if (pParams->m_dwStates & CFWL_PartState_Inactive) {
iActive = 1;
}
FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
switch (pParams->m_dwStates & 0x03) {
- case FWL_PARTSTATE_FRM_Hover: {
+ case CFWL_PartState_Hovered: {
eState = FWLTHEME_STATE_Hover;
break;
}
- case FWL_PARTSTATE_FRM_Pressed: {
+ case CFWL_PartState_Pressed: {
eState = FWLTHEME_STATE_Pressed;
break;
}
- case FWL_PARTSTATE_FRM_Disabled: {
+ case CFWL_PartState_Disabled: {
eState = FWLTHEME_STATE_Disabale;
break;
}
default: {}
}
switch (pParams->m_iPart) {
- case FWL_PART_FRM_Border: {
+ case CFWL_Part::Border: {
DrawFormBorder(pParams->m_pGraphics, &pParams->m_rtPart, eState,
&pParams->m_matrix, iActive);
break;
}
- case FWL_PART_FRM_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_FRM_Background: {
+ case CFWL_Part::Background: {
FillBackground(pParams->m_pGraphics, &pParams->m_rtPart,
&pParams->m_matrix);
break;
}
- case FWL_PART_FRM_Caption: {
+ case CFWL_Part::Caption: {
DrawCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState,
&pParams->m_matrix, iActive);
break;
}
- case FWL_PART_FRM_NarrowCaption: {
+ case CFWL_Part::NarrowCaption: {
DrawNarrowCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState,
&pParams->m_matrix, iActive);
break;
}
- case FWL_PART_FRM_CloseBox: {
+ case CFWL_Part::CloseBox: {
DrawCloseBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
&pParams->m_matrix, iActive);
break;
}
- case FWL_PART_FRM_MinimizeBox: {
+ case CFWL_Part::MinimizeBox: {
DrawMinimizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
&pParams->m_matrix, iActive);
break;
}
- case FWL_PART_FRM_MaximizeBox: {
+ case CFWL_Part::MaximizeBox: {
DrawMaximizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
- pParams->m_dwData, &pParams->m_matrix, iActive);
+ pParams->m_bMaximize, &pParams->m_matrix, iActive);
break;
}
- case FWL_PART_FRM_Icon: {
+ case CFWL_Part::Icon: {
DrawIconImage(pParams->m_pGraphics, pParams->m_pImage, &pParams->m_rtPart,
eState, &pParams->m_matrix, iActive);
break;
@@ -151,7 +150,7 @@ FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground* pParams) {
FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText* pParams) {
if (!m_pTextOut)
return FALSE;
- if (pParams->m_iPart == FWL_PART_FRM_Caption) {
+ if (pParams->m_iPart == CFWL_Part::Caption) {
m_pTextOut->SetTextColor(0xFFFFFFFF);
} else {
m_pTextOut->SetTextColor(0xFF000000);
@@ -159,37 +158,37 @@ FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText* pParams) {
return CFWL_WidgetTP::DrawText(pParams);
}
void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart,
- uint32_t dwCapacity) {
+ CFWL_WidgetCapacity dwCapacity) {
FX_BOOL bDefPro = FALSE;
FX_BOOL bDwordVal = FALSE;
switch (dwCapacity) {
- case FWL_WGTCAPACITY_CXBorder: {
- m_fValue = FWLTHEME_CAPACITY_CXFormBorder;
+ case CFWL_WidgetCapacity::CXBorder: {
+ m_fValue = kCXFormBorder;
break;
}
- case FWL_WGTCAPACITY_CYBorder: {
- m_fValue = FWLTHEME_CAPACITY_CYFormBorder;
+ case CFWL_WidgetCapacity::CYBorder: {
+ m_fValue = kCYFormBorder;
break;
}
- case FWL_WGTCAPACITY_FRM_CYCaption: {
- m_fValue = FWLTHEME_CAPACITY_CYCaption;
+ case CFWL_WidgetCapacity::CYCaption: {
+ m_fValue = kCYCaption;
break;
}
- case FWL_WGTCAPACITY_FRM_CYNarrowCaption: {
- m_fValue = FWLTHEME_CAPACITY_CYCaption;
+ case CFWL_WidgetCapacity::CYNarrowCaption: {
+ m_fValue = kCYCaption;
break;
}
- case FWL_WGTCAPACITY_TextColor: {
+ case CFWL_WidgetCapacity::TextColor: {
bDwordVal = TRUE;
- m_dwValue = FWLTHEME_CAPACITY_FormTextColor;
+ m_dwValue = kFormTextColor;
break;
}
- case FWL_WGTCAPACITY_FRM_BigIcon: {
- m_fValue = FWLTHEME_CAPACITY_BigIconSize;
+ case CFWL_WidgetCapacity::BigIcon: {
+ m_fValue = kFormBigIconSize;
break;
}
- case FWL_WGTCAPACITY_FRM_SmallIcon: {
- m_fValue = FWLTHEME_CAPACITY_SmallIconSize;
+ case CFWL_WidgetCapacity::SmallIcon: {
+ m_fValue = kFormSmallIconSize;
break;
}
default: { bDefPro = TRUE; }
@@ -202,32 +201,32 @@ void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart,
}
return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-FWL_ERR CFWL_FormTP::GetPartRect(CFWL_ThemePart* pThemePart,
- CFX_RectF& rtPart) {
+FWL_Error CFWL_FormTP::GetPartRect(CFWL_ThemePart* pThemePart,
+ CFX_RectF& rtPart) {
switch (pThemePart->m_iPart) {
- case FWL_PART_FRM_CloseBox: {
+ case CFWL_Part::CloseBox: {
CalCloseBox(pThemePart->m_pWidget, rtPart);
break;
}
- case FWL_PART_FRM_MaximizeBox: {
+ case CFWL_Part::MaximizeBox: {
CalMaxBox(pThemePart->m_pWidget, rtPart);
break;
}
- case FWL_PART_FRM_MinimizeBox: {
+ case CFWL_Part::MinimizeBox: {
CalMinBox(pThemePart->m_pWidget, rtPart);
break;
}
- case FWL_PART_FRM_HeadText: {
+ case CFWL_Part::HeadText: {
CalCaption(pThemePart->m_pWidget, rtPart);
break;
}
- case FWL_PART_FRM_Icon: {
+ case CFWL_Part::Icon: {
CalIcon(pThemePart->m_pWidget, rtPart);
break;
}
default: {}
}
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
uint32_t dwStyles = pWidget->GetStyles();
@@ -235,12 +234,11 @@ void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
pWidget->GetWidgetRect(rtWidget);
rtWidget.Offset(-rtWidget.left, -rtWidget.top);
if (dwStyles & FWL_WGTSTYLE_CloseBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSpan,
+ rtWidget.top + kButtonMargin, kButtonSize, kButtonSize);
} else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSpan,
+ rtWidget.top + kButtonMargin, 0, 0);
}
}
void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
@@ -249,14 +247,11 @@ void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
pWidget->GetWidgetRect(rtWidget);
rtWidget.Offset(-rtWidget.left, -rtWidget.top);
if (dwStyles & FWL_WGTSTYLE_MaximizeBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size +
- FWLTHEME_FORMBTN_Span * 2,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSize + kButtonSpan * 2,
+ rtWidget.top + kButtonMargin, kButtonSize, kButtonSize);
} else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size +
- FWLTHEME_FORMBTN_Span * 2,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSize + kButtonSpan * 2,
+ rtWidget.top + kButtonMargin, 0, 0);
}
}
void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
@@ -265,24 +260,20 @@ void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
pWidget->GetWidgetRect(rtWidget);
rtWidget.Offset(-rtWidget.left, -rtWidget.top);
if (dwStyles & FWL_WGTSTYLE_MinimizeBox) {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin +
- FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
- FWLTHEME_FORMBTN_Size);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSize * 2 + kButtonSpan * 3,
+ rtWidget.top + kButtonMargin, kButtonSize, kButtonSize);
} else {
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin +
- FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
- rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
+ rect.Set(rtWidget.left + kButtonMargin + kButtonSize * 2 + kButtonSpan * 3,
+ rtWidget.top + kButtonMargin, 0, 0);
}
}
void CFWL_FormTP::CalCaption(IFWL_Widget* pWidget, CFX_RectF& rect) {
CFX_RectF rtWidget;
pWidget->GetWidgetRect(rtWidget);
rtWidget.Offset(-rtWidget.left, -rtWidget.top);
- rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin,
- rtWidget.top + FWLTHEME_FORMBTN_Margin - 2,
- rtWidget.width - FWLTHEME_FORMBTN_Margin * 2,
- FWLTHEME_FORMBTN_Size + 2 * FWLTHEME_FORMBTN_Margin + 4);
+ rect.Set(rtWidget.left + kButtonMargin, rtWidget.top + kButtonMargin - 2,
+ rtWidget.width - kButtonMargin * 2,
+ kButtonSize + 2 * kButtonMargin + 4);
}
void CFWL_FormTP::CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect) {}
void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics,
@@ -522,7 +513,7 @@ void CFWL_FormTP::DrawMinimizeBox(CFX_Graphics* pGraphics,
void CFWL_FormTP::DrawMaximizeBox(CFX_Graphics* pGraphics,
const CFX_RectF* pRect,
FWLTHEME_STATE eState,
- FX_BOOL bMax,
+ bool bMax,
CFX_Matrix* pMatrix,
int32_t iActive) {
DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix);
@@ -850,12 +841,9 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
CFX_Graphics gs;
CFX_Path path;
path.Create();
- if (m_pActiveBitmap) {
- delete m_pActiveBitmap;
- m_pActiveBitmap = NULL;
- }
+ delete m_pActiveBitmap;
m_pActiveBitmap = new CFX_DIBitmap;
- m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
+ m_pActiveBitmap->Create(1, kCYCaption, FXDIB_Argb);
dev.Attach(m_pActiveBitmap);
gs.Create(&dev);
path.AddRectangle(0, 0, 1, 5);
@@ -866,21 +854,17 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[0][1],
m_pThemeData->clrHeadBK[0][2], &path);
path.Clear();
- path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19);
- DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption,
- m_pThemeData->clrHeadBK[0][2],
+ path.AddRectangle(0, 20, 1, kCYCaption - 19);
+ DrawAxialShading(&gs, 0, 20, 0, kCYCaption, m_pThemeData->clrHeadBK[0][2],
m_pThemeData->clrHeadBK[0][3], &path);
} else {
CFX_FxgeDevice dev;
CFX_Graphics gs;
CFX_Path path;
path.Create();
- if (m_pDeactivebitmap) {
- delete m_pDeactivebitmap;
- m_pDeactivebitmap = NULL;
- }
+ delete m_pDeactivebitmap;
m_pDeactivebitmap = new CFX_DIBitmap;
- m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
+ m_pDeactivebitmap->Create(1, kCYCaption, FXDIB_Argb);
dev.Attach(m_pDeactivebitmap);
gs.Create(&dev);
path.AddRectangle(0, 0, 1, 5);
@@ -891,9 +875,8 @@ void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[1][1],
m_pThemeData->clrHeadBK[1][2], &path);
path.Clear();
- path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19);
- DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption,
- m_pThemeData->clrHeadBK[1][2],
+ path.AddRectangle(0, 20, 1, kCYCaption - 19);
+ DrawAxialShading(&gs, 0, 20, 0, kCYCaption, m_pThemeData->clrHeadBK[1][2],
m_pThemeData->clrHeadBK[1][3], &path);
}
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.h
index 838f19858aa..ccbc71b2c2c 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_formtp.h
@@ -13,18 +13,20 @@
class CFWL_FormTP : public CFWL_WidgetTP {
public:
CFWL_FormTP();
- virtual ~CFWL_FormTP();
+ ~CFWL_FormTP() override;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
- uint32_t dwThemeID,
- FX_BOOL bChildren = TRUE);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
- virtual FX_BOOL DrawText(CFWL_ThemeText* pParams);
- virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity);
- virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart);
+ // CFWL_WidgetTP
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ uint32_t SetThemeID(IFWL_Widget* pWidget,
+ uint32_t dwThemeID,
+ FX_BOOL bChildren = TRUE) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
+ FX_BOOL DrawText(CFWL_ThemeText* pParams) override;
+ void* GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity) override;
+ FWL_Error GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) override;
protected:
void CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect);
@@ -66,7 +68,7 @@ class CFWL_FormTP : public CFWL_WidgetTP {
void DrawMaximizeBox(CFX_Graphics* pGraphics,
const CFX_RectF* pRect,
FWLTHEME_STATE eState,
- FX_BOOL bMax,
+ bool bMax,
CFX_Matrix* pMatrix,
int32_t iActive = 0);
void DrawIconImage(CFX_Graphics* pGraphics,
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.cpp
index 210949aa415..1d381a42804 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.cpp
@@ -13,27 +13,27 @@
#include "xfa/fxgraphics/cfx_path.h"
CFWL_ListBoxTP::CFWL_ListBoxTP() {}
+
CFWL_ListBoxTP::~CFWL_ListBoxTP() {}
-FX_BOOL CFWL_ListBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_ListBox;
+bool CFWL_ListBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::ListBox;
}
+
FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
switch (pParams->m_iPart) {
- case FWL_PART_LTB_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_LTB_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_LTB_Background: {
+ case CFWL_Part::Background: {
FillSoildRect(pParams->m_pGraphics, ArgbEncode(255, 255, 255, 255),
&pParams->m_rtPart, &pParams->m_matrix);
if (pParams->m_pData) {
@@ -42,21 +42,21 @@ FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
}
break;
}
- case FWL_PART_LTB_ListItem: {
+ case CFWL_Part::ListItem: {
DrawListBoxItem(pParams->m_pGraphics, pParams->m_dwStates,
&pParams->m_rtPart, pParams->m_pData, &pParams->m_matrix);
break;
}
- case FWL_PART_LTB_Icon: {
+ case CFWL_Part::Icon: {
pParams->m_pGraphics->StretchImage(pParams->m_pImage, pParams->m_rtPart,
&pParams->m_matrix);
break;
}
- case FWL_PART_LTB_Check: {
+ case CFWL_Part::Check: {
uint32_t color = 0xFF000000;
- if (pParams->m_dwStates == FWL_PARTSTATE_LTB_Checked) {
+ if (pParams->m_dwStates == CFWL_PartState_Checked) {
color = 0xFFFF0000;
- } else if (pParams->m_dwStates == FWL_PARTSTATE_LTB_UnChecked) {
+ } else if (pParams->m_dwStates == CFWL_PartState_Normal) {
color = 0xFF0000FF;
}
FillSoildRect(pParams->m_pGraphics, color, &pParams->m_rtPart,
@@ -66,11 +66,11 @@ FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
}
return TRUE;
}
-FWL_ERR CFWL_ListBoxTP::Initialize() {
+FWL_Error CFWL_ListBoxTP::Initialize() {
InitTTO();
return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_ListBoxTP::Finalize() {
+FWL_Error CFWL_ListBoxTP::Finalize() {
FinalizeTTO();
return CFWL_WidgetTP::Finalize();
}
@@ -79,7 +79,7 @@ void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics,
const CFX_RectF* prtItem,
void* pData,
CFX_Matrix* pMatrix) {
- if (dwStates & FWL_PARTSTATE_LTB_Selected) {
+ if (dwStates & CFWL_PartState_Selected) {
pGraphics->SaveGraphState();
CFX_Color crFill(FWL_GetThemeColor(m_dwThemeID) == 0
? FWLTHEME_COLOR_BKSelected
@@ -96,7 +96,7 @@ void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics,
pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
pGraphics->RestoreGraphState();
}
- if (dwStates & FWL_PARTSTATE_LTB_Focused) {
+ if (dwStates & CFWL_PartState_Focused) {
if (pData) {
DrawFocus(pGraphics, (CFX_RectF*)pData, pMatrix);
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.h
index d4bd7eff94a..a13df08845c 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_listboxtp.h
@@ -12,11 +12,13 @@
class CFWL_ListBoxTP : public CFWL_WidgetTP {
public:
CFWL_ListBoxTP();
- virtual ~CFWL_ListBoxTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ ~CFWL_ListBoxTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
protected:
void DrawListBoxItem(CFX_Graphics* pGraphics,
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.cpp
index 2d53080b373..d04ebb16d20 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.cpp
@@ -15,61 +15,51 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define FWL_THEMECAPACITY_MC_HEADER_WIDTH 200
-#define FWL_THEMECAPACITY_MC_HEADER_HEIGHT 30
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH 18
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT 16
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN 5
-#define FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN \
- (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \
- FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT) / \
- 2
-#define FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT 100
-#define FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT 20
-#define FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN \
- (FWL_THEMECAPACITY_MC_HEADER_WIDTH - \
- FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT) / \
- 2
-#define FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN \
- (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \
- FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT) / \
- 2
-#define FWL_THEMECAPACITY_MC_HSEP_WIDTH (FWL_THEMECAPACITY_MC_WEEK_WIDTH - 10)
-#define FWL_THEMECAPACITY_MC_HSEP_HEIGHT 1
-#define FWL_THEMECAPACITY_MC_VSEP_WIDTH 1
-#define FWL_THEMECAPACITY_MC_VSEP_HEIGHT FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT
-#define FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH 26
-#define FWL_THEMECAPACITY_MC_SEP_DOFFSET -4
-#define FWL_THEMECAPACITY_MC_SEP_X 3
-#define FWL_THEMECAPACITY_MC_SEP_Y \
- (FWL_THEMECAPACITY_MC_HEADER_HEIGHT + FWL_THEMECAPACITY_MC_WEEK_HEIGHT + \
- FWL_THEMECAPACITY_MC_SEP_DOFFSET)
-#define FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT \
- (6 * FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT)
-#define FWL_THEMECAPACITY_MC_WEEK_WIDTH \
- (FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH * 7)
-#define FWL_THEMECAPACITY_MC_WEEK_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT
-#define FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH \
- (FWL_THEMECAPACITY_MC_HEADER_WIDTH / 7)
-#define FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT 16
-#define FWL_THEMECAPACITY_MC_TODAY_WIDHT FWL_THEMECAPACITY_MC_HEADER_WIDTH
-#define FWL_THEMECAPACITY_MC_TODAY_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT
-#define FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT \
- FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH
-#define FWL_MC_WIDTH 200
-#define FWL_MC_HEIGHT 160
+namespace {
+
+const int kWidth = 200;
+const int kHeight = 160;
+
+const int kHeaderWidth = 200;
+const int kHeaderHeight = 30;
+
+const int kButtonWidth = 18;
+const int kButtonHeight = 16;
+const int kButtonHorizontalMargin = 5;
+const int kButtonVerticalMargin = (kHeaderHeight - kButtonHeight) / 2;
+
+const int kHeaderTextWidth = 100;
+const int kHeaderTextHeight = 20;
+const int kHeaderTextHorizontalMargin = (kHeaderWidth - kHeaderTextWidth) / 2;
+const int kHeaderTextVerticalMargin = (kHeaderHeight - kHeaderTextHeight) / 2;
+
+const int kDatesCellWidth = (kHeaderWidth / 7);
+const int kDatesCellHeight = 16;
+const int kWeekWidth = kDatesCellWidth * 7;
+const int kWeekNumWidth = 26;
+const int kWeekNumHeight = (6 * kDatesCellHeight);
+
+const int kHorizontalSeparatorWidth = kWeekWidth - 10;
+const int kHorizontalSeparatorHeight = 1;
+const int kVerticalSeparatorWidth = 1;
+const int kVerticalSeparatorHeight = kWeekNumHeight;
+const int kSeparatorDOffset = -4;
+const int kSeparatorX = 3;
+const int kSeparatorY = kHeaderHeight + kDatesCellHeight + kSeparatorDOffset;
+
+} // namespace
CFWL_MonthCalendarTP::CFWL_MonthCalendarTP() {
m_pThemeData = new MCThemeData;
SetThemeData(0);
}
+
CFWL_MonthCalendarTP::~CFWL_MonthCalendarTP() {
delete m_pThemeData;
}
-FX_BOOL CFWL_MonthCalendarTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar;
+
+bool CFWL_MonthCalendarTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::MonthCalendar;
}
uint32_t CFWL_MonthCalendarTP::SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
@@ -83,60 +73,52 @@ FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
switch (pParams->m_iPart) {
- case FWL_PART_MCD_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_MCD_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_MCD_Background: {
+ case CFWL_Part::Background: {
DrawTotalBK(pParams, &pParams->m_matrix);
break;
}
- case FWL_PART_MCD_Header: {
+ case CFWL_Part::Header: {
DrawHeadBk(pParams, &pParams->m_matrix);
break;
}
- case FWL_PART_MCD_LBtn: {
-#ifdef THEME_XPSimilar
+ case CFWL_Part::LBtn: {
FWLTHEME_STATE eState = GetState(pParams->m_dwStates);
DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart,
FWLTHEME_DIRECTION_Left, eState, &pParams->m_matrix);
-#else
- DrawLButton(pParams, &pParams->m_matrix);
-#endif
break;
}
- case FWL_PART_MCD_RBtn: {
-#ifdef THEME_XPSimilar
+ case CFWL_Part::RBtn: {
FWLTHEME_STATE eState = GetState(pParams->m_dwStates);
DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart,
FWLTHEME_DIRECTION_Right, eState, &pParams->m_matrix);
-#else
- DrawRButton(pParams, &pParams->m_matrix);
-#endif
break;
}
- case FWL_PART_MCD_HSeparator: {
+ case CFWL_Part::HSeparator: {
DrawHSeperator(pParams, &pParams->m_matrix);
break;
}
- case FWL_PART_MCD_DatesIn: {
+ case CFWL_Part::DatesIn: {
DrawDatesInBK(pParams, &pParams->m_matrix);
break;
}
- case FWL_PART_MCD_TodayCircle: {
+ case CFWL_Part::TodayCircle: {
DrawTodayCircle(pParams, &pParams->m_matrix);
break;
}
- case FWL_PART_MCD_DateInCircle: {
+ case CFWL_Part::DateInCircle: {
DrawDatesInCircle(pParams, &pParams->m_matrix);
break;
}
- case FWL_PART_MCD_WeekNumSep: {
+ case CFWL_Part::WeekNumSep: {
DrawWeekNumSep(pParams, &pParams->m_matrix);
break;
}
@@ -147,12 +129,12 @@ FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) {
FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) {
if (!m_pTextOut)
return FALSE;
- if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) &&
+ if ((pParams->m_iPart == CFWL_Part::DatesIn) &&
!(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) &&
(pParams->m_dwStates &
- (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) {
+ (CFWL_PartState_Hovered | CFWL_PartState_Selected))) {
m_pTextOut->SetTextColor(0xFFFFFFFF);
- } else if (pParams->m_iPart == FWL_PART_MCD_Caption) {
+ } else if (pParams->m_iPart == CFWL_Part::Caption) {
m_pTextOut->SetTextColor(m_pThemeData->clrCaption);
} else {
m_pTextOut->SetTextColor(0xFF000000);
@@ -160,200 +142,200 @@ FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) {
return CFWL_WidgetTP::DrawText(pParams);
}
void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart,
- uint32_t dwCapacity) {
+ CFWL_WidgetCapacity dwCapacity) {
FX_BOOL bDefPro = FALSE;
FX_BOOL bDwordVal = FALSE;
switch (dwCapacity) {
- case FWL_WGTCAPACITY_MC_HEADER_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH;
+ case CFWL_WidgetCapacity::HeaderWidth: {
+ m_fValue = kHeaderWidth;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_Height: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT;
+ case CFWL_WidgetCapacity::HeaderHeight: {
+ m_fValue = kHeaderHeight;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH;
+ case CFWL_WidgetCapacity::HeaderBtnWidth: {
+ m_fValue = kButtonWidth;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT;
+ case CFWL_WidgetCapacity::HeaderBtnHeight: {
+ m_fValue = kButtonHeight;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN: {
+ case CFWL_WidgetCapacity::HeaderBtnHMargin: {
bDwordVal = TRUE;
- m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN;
+ m_dwValue = kButtonHorizontalMargin;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN;
+ case CFWL_WidgetCapacity::HeaderBtnVMargin: {
+ m_fValue = kButtonVerticalMargin;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT;
+ case CFWL_WidgetCapacity::HeaderTextWidth: {
+ m_fValue = kHeaderTextWidth;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT;
+ case CFWL_WidgetCapacity::HeaderTextHeight: {
+ m_fValue = kHeaderTextHeight;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN;
+ case CFWL_WidgetCapacity::HeaderTextHMargin: {
+ m_fValue = kHeaderTextHorizontalMargin;
break;
}
- case FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN: {
- m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN;
+ case CFWL_WidgetCapacity::HeaderTextVMargin: {
+ m_fValue = kHeaderTextVerticalMargin;
break;
}
- case FWL_WGTCAPACITY_MC_HSEP_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH;
+ case CFWL_WidgetCapacity::HSepWidth: {
+ m_fValue = kHorizontalSeparatorWidth;
break;
}
- case FWL_WGTCAPACITY_MC_HSEP_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT;
+ case CFWL_WidgetCapacity::HSepHeight: {
+ m_fValue = kHorizontalSeparatorHeight;
break;
}
- case FWL_WGTCAPACITY_MC_VSEP_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH;
+ case CFWL_WidgetCapacity::VSepWidth: {
+ m_fValue = kVerticalSeparatorWidth;
break;
}
- case FWL_WGTCAPACITY_MC_VSEP_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT;
+ case CFWL_WidgetCapacity::VSepHeight: {
+ m_fValue = kVerticalSeparatorHeight;
break;
}
- case FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH;
+ case CFWL_WidgetCapacity::WeekNumWidth: {
+ m_fValue = kWeekNumWidth;
break;
}
- case FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT;
+ case CFWL_WidgetCapacity::WeekNumHeight: {
+ m_fValue = kWeekNumHeight;
break;
}
- case FWL_WGTCAPACITY_MC_WEEK_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH;
+ case CFWL_WidgetCapacity::WeekWidth: {
+ m_fValue = kWeekWidth;
break;
}
- case FWL_WGTCAPACITY_MC_WEEK_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_WEEK_HEIGHT;
+ case CFWL_WidgetCapacity::WeekHeight: {
+ m_fValue = kDatesCellHeight;
break;
}
- case FWL_WGTCAPACITY_MC_SEP_DOFFSET: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET;
+ case CFWL_WidgetCapacity::SepDOffset: {
+ m_fValue = kSeparatorDOffset;
break;
}
- case FWL_WGTCAPACITY_MC_SEP_X: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_X;
+ case CFWL_WidgetCapacity::SepX: {
+ m_fValue = kSeparatorX;
break;
}
- case FWL_WGTCAPACITY_MC_SEP_Y: {
- m_fValue = FWL_THEMECAPACITY_MC_SEP_Y;
+ case CFWL_WidgetCapacity::SepY: {
+ m_fValue = kSeparatorY;
break;
}
- case FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH: {
- m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH;
+ case CFWL_WidgetCapacity::DatesCellWidth: {
+ m_fValue = kDatesCellWidth;
break;
}
- case FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT;
+ case CFWL_WidgetCapacity::DatesCellHeight: {
+ m_fValue = kDatesCellHeight;
break;
}
- case FWL_WGTCAPACITY_MC_TODAY_WIDHT: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT;
+ case CFWL_WidgetCapacity::TodayWidth: {
+ m_fValue = kHeaderWidth;
break;
}
- case FWL_WGTCAPACITY_MC_TODAY_HEIGHT: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT;
+ case CFWL_WidgetCapacity::TodayHeight: {
+ m_fValue = kDatesCellHeight;
break;
}
- case FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT: {
- m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT;
+ case CFWL_WidgetCapacity::TodayFlagWidth: {
+ m_fValue = kDatesCellWidth;
break;
}
- case FWL_WGTCAPACITY_MC_WIDTH: {
- m_fValue = FWL_MC_WIDTH;
+ case CFWL_WidgetCapacity::Width: {
+ m_fValue = kWidth;
break;
}
- case FWL_WGTCAPACITY_MC_HEIGHT: {
- m_fValue = FWL_MC_HEIGHT;
+ case CFWL_WidgetCapacity::Height: {
+ m_fValue = kHeight;
break;
}
- case FWL_MCCAPACITY_Sun: {
+ case CFWL_WidgetCapacity::Sun: {
wsResource = L"Sun";
return &wsResource;
}
- case FWL_MCCAPACITY_Mon: {
+ case CFWL_WidgetCapacity::Mon: {
wsResource = L"Mon";
return &wsResource;
}
- case FWL_MCCAPACITY_Tue: {
+ case CFWL_WidgetCapacity::Tue: {
wsResource = L"Tue";
return &wsResource;
}
- case FWL_MCCAPACITY_Wed: {
+ case CFWL_WidgetCapacity::Wed: {
wsResource = L"Wed";
return &wsResource;
}
- case FWL_MCCAPACITY_Thu: {
+ case CFWL_WidgetCapacity::Thu: {
wsResource = L"Thu";
return &wsResource;
}
- case FWL_MCCAPACITY_Fri: {
+ case CFWL_WidgetCapacity::Fri: {
wsResource = L"Fri";
return &wsResource;
}
- case FWL_MCCAPACITY_Sat: {
+ case CFWL_WidgetCapacity::Sat: {
wsResource = L"Sat";
return &wsResource;
}
- case FWL_MCCAPACITY_January: {
+ case CFWL_WidgetCapacity::January: {
wsResource = L"January";
return &wsResource;
}
- case FWL_MCCAPACITY_February: {
+ case CFWL_WidgetCapacity::February: {
wsResource = L"February";
return &wsResource;
}
- case FWL_MCCAPACITY_March: {
+ case CFWL_WidgetCapacity::March: {
wsResource = L"March";
return &wsResource;
}
- case FWL_MCCAPACITY_April: {
+ case CFWL_WidgetCapacity::April: {
wsResource = L"April";
return &wsResource;
}
- case FWL_MCCAPACITY_May: {
+ case CFWL_WidgetCapacity::May: {
wsResource = L"May";
return &wsResource;
}
- case FWL_MCCAPACITY_June: {
+ case CFWL_WidgetCapacity::June: {
wsResource = L"June";
return &wsResource;
}
- case FWL_MCCAPACITY_July: {
+ case CFWL_WidgetCapacity::July: {
wsResource = L"July";
return &wsResource;
}
- case FWL_MCCAPACITY_August: {
+ case CFWL_WidgetCapacity::August: {
wsResource = L"August";
return &wsResource;
}
- case FWL_MCCAPACITY_September: {
+ case CFWL_WidgetCapacity::September: {
wsResource = L"September";
return &wsResource;
}
- case FWL_MCCAPACITY_October: {
+ case CFWL_WidgetCapacity::October: {
wsResource = L"October";
return &wsResource;
}
- case FWL_MCCAPACITY_November: {
+ case CFWL_WidgetCapacity::November: {
wsResource = L"November";
return &wsResource;
}
- case FWL_MCCAPACITY_December: {
+ case CFWL_WidgetCapacity::December: {
wsResource = L"December";
return &wsResource;
}
- case FWL_MCCAPACITY_Today: {
+ case CFWL_WidgetCapacity::Today: {
wsResource = L"Today";
return &wsResource;
}
@@ -367,11 +349,11 @@ void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart,
}
return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-FWL_ERR CFWL_MonthCalendarTP::Initialize() {
+FWL_Error CFWL_MonthCalendarTP::Initialize() {
InitTTO();
return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_MonthCalendarTP::Finalize() {
+FWL_Error CFWL_MonthCalendarTP::Finalize() {
FinalizeTTO();
return CFWL_WidgetTP::Finalize();
}
@@ -412,8 +394,7 @@ FX_BOOL CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams,
CFX_Color clrLBtnEdge(ArgbEncode(0xff, 205, 219, 243));
pParams->m_pGraphics->SetStrokeColor(&clrLBtnEdge);
pParams->m_pGraphics->StrokePath(&path, pMatrix);
- if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) ==
- FWL_PARTSTATE_MCD_Pressed) {
+ if (pParams->m_dwStates & CFWL_PartState_Pressed) {
CFX_Color clrLBtnFill(ArgbEncode(0xff, 174, 198, 242));
pParams->m_pGraphics->SetFillColor(&clrLBtnFill);
pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
@@ -445,8 +426,7 @@ FX_BOOL CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams,
CFX_Color clrRBtnEdge(ArgbEncode(0xff, 205, 219, 243));
pParams->m_pGraphics->SetStrokeColor(&clrRBtnEdge);
pParams->m_pGraphics->StrokePath(&path, pMatrix);
- if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) ==
- FWL_PARTSTATE_MCD_Pressed) {
+ if (pParams->m_dwStates & CFWL_PartState_Pressed) {
CFX_Color clrRBtnFill(ArgbEncode(0xff, 174, 198, 242));
pParams->m_pGraphics->SetFillColor(&clrRBtnFill);
pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
@@ -500,7 +480,7 @@ FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams,
FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams,
CFX_Matrix* pMatrix) {
pParams->m_pGraphics->SaveGraphState();
- if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Selected) {
+ if (pParams->m_dwStates & CFWL_PartState_Selected) {
CFX_Path path;
path.Create();
CFX_RectF rtSelDay;
@@ -511,7 +491,7 @@ FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams,
clrSelDayBK = m_pThemeData->clrDatesSelectedBK;
pParams->m_pGraphics->SetFillColor(&clrSelDayBK);
pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- } else if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Hovered) {
+ } else if (pParams->m_dwStates & CFWL_PartState_Hovered) {
CFX_Path path;
path.Create();
CFX_RectF rtSelDay;
@@ -558,14 +538,15 @@ FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams,
pParams->m_pGraphics->RestoreGraphState();
return TRUE;
}
+
FWLTHEME_STATE CFWL_MonthCalendarTP::GetState(uint32_t dwFWLStates) {
- if (dwFWLStates & FWL_PARTSTATE_MCD_Hovered) {
+ if (dwFWLStates & CFWL_PartState_Hovered)
return FWLTHEME_STATE_Hover;
- } else if (dwFWLStates & FWL_PARTSTATE_MCD_Pressed) {
+ if (dwFWLStates & CFWL_PartState_Pressed)
return FWLTHEME_STATE_Pressed;
- }
return FWLTHEME_STATE_Normal;
}
+
void CFWL_MonthCalendarTP::SetThemeData(uint32_t dwThemeID) {
if (dwThemeID == 0) {
m_pThemeData->clrCaption = ArgbEncode(0xff, 0, 153, 255);
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.h
index 3624ee1bfd5..7ecbb90cf2f 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_monthcalendartp.h
@@ -12,16 +12,19 @@
class CFWL_MonthCalendarTP : public CFWL_WidgetTP {
public:
CFWL_MonthCalendarTP();
- virtual ~CFWL_MonthCalendarTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
- uint32_t dwThemeID,
- FX_BOOL bChildren = TRUE);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
- virtual FX_BOOL DrawText(CFWL_ThemeText* pParams);
- virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ ~CFWL_MonthCalendarTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ uint32_t SetThemeID(IFWL_Widget* pWidget,
+ uint32_t dwThemeID,
+ FX_BOOL bChildren = TRUE) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
+ FX_BOOL DrawText(CFWL_ThemeText* pParams) override;
+ void* GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity) override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
protected:
FX_BOOL DrawTotalBK(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix);
@@ -35,6 +38,7 @@ class CFWL_MonthCalendarTP : public CFWL_WidgetTP {
FX_BOOL DrawWeekNumSep(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix);
FWLTHEME_STATE GetState(uint32_t dwFWLStates);
void SetThemeData(uint32_t dwThemeID);
+
class MCThemeData {
public:
FX_ARGB clrCaption;
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.cpp
index ee83a7eb3f0..439082b0524 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.cpp
@@ -14,25 +14,26 @@ CFWL_PictureBoxTP::CFWL_PictureBoxTP() {}
CFWL_PictureBoxTP::~CFWL_PictureBoxTP() {}
-FX_BOOL CFWL_PictureBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_PictureBox;
+bool CFWL_PictureBoxTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::PictureBox;
}
+
FX_BOOL CFWL_PictureBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
if (!pParams)
return FALSE;
+
switch (pParams->m_iPart) {
- case FWL_PART_PTB_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_PTB_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- default: {}
+ default:
+ break;
}
return TRUE;
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.h
index 0216971a941..876e8d20426 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pictureboxtp.h
@@ -12,9 +12,11 @@
class CFWL_PictureBoxTP : public CFWL_WidgetTP {
public:
CFWL_PictureBoxTP();
- virtual ~CFWL_PictureBoxTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
+ ~CFWL_PictureBoxTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
};
#endif // XFA_FWL_THEME_CFWL_PICTUREBOXTP_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.cpp
index 5889f309273..17c02aef44f 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.cpp
@@ -15,17 +15,16 @@
#define PUSHBUTTON_SIZE_Corner 2
-CFWL_PushButtonTP::CFWL_PushButtonTP() {
- m_pThemeData = new PBThemeData;
+CFWL_PushButtonTP::CFWL_PushButtonTP() : m_pThemeData(new PBThemeData) {
SetThemeData(0);
}
+
CFWL_PushButtonTP::~CFWL_PushButtonTP() {
- if (m_pThemeData) {
- delete m_pThemeData;
- }
+ delete m_pThemeData;
}
-FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) {
- return pWidget->GetClassID() == FWL_CLASSHASH_PushButton;
+
+bool CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::PushButton;
}
uint32_t CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
@@ -35,16 +34,16 @@ uint32_t CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget,
}
FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) {
switch (pParams->m_iPart) {
- case FWL_PART_PSB_Border: {
+ case CFWL_Part::Border: {
DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_PSB_Edge: {
+ case CFWL_Part::Edge: {
DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
&pParams->m_rtPart, &pParams->m_matrix);
break;
}
- case FWL_PART_PSB_Background: {
+ case CFWL_Part::Background: {
CFX_RectF& rect = pParams->m_rtPart;
FX_FLOAT fRight = rect.right();
FX_FLOAT fBottom = rect.bottom();
@@ -84,7 +83,7 @@ FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) {
CFX_Color crFill(m_pThemeData->clrFill[iColor]);
pGraphics->SetFillColor(&crFill);
pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix);
- if (pParams->m_dwStates & FWL_PARTSTATE_PSB_Focused) {
+ if (pParams->m_dwStates & CFWL_PartState_Focused) {
rtInner.Inflate(1, 1, 0, 0);
DrawFocus(pGraphics, &rtInner, &pParams->m_matrix);
}
@@ -96,18 +95,18 @@ FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) {
return TRUE;
}
void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart,
- uint32_t dwCapacity) {
- if (dwCapacity == FWL_WGTCAPACITY_PSB_Margin) {
+ CFWL_WidgetCapacity dwCapacity) {
+ if (dwCapacity == CFWL_WidgetCapacity::Margin) {
m_fValue = 0;
return &m_fValue;
}
return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-FWL_ERR CFWL_PushButtonTP::Initialize() {
+FWL_Error CFWL_PushButtonTP::Initialize() {
InitTTO();
return CFWL_WidgetTP::Initialize();
}
-FWL_ERR CFWL_PushButtonTP::Finalize() {
+FWL_Error CFWL_PushButtonTP::Finalize() {
FinalizeTTO();
return CFWL_WidgetTP::Finalize();
}
@@ -157,5 +156,16 @@ void CFWL_PushButtonTP::SetThemeData(uint32_t dwID) {
}
}
int32_t CFWL_PushButtonTP::GetColorID(uint32_t dwStates) {
- return dwStates &= FWL_PARTSTATE_PSB_Mask;
+ int32_t color = 0;
+ if (dwStates & CFWL_PartState_Disabled)
+ color += 4;
+ if (dwStates & CFWL_PartState_Default) {
+ color += 3;
+ } else {
+ if (dwStates & CFWL_PartState_Hovered)
+ color += 2;
+ if (dwStates & CFWL_PartState_Pressed)
+ color += 1;
+ }
+ return color;
}
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.h
index b72ac86126d..6312cd5f290 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_pushbuttontp.h
@@ -12,15 +12,18 @@
class CFWL_PushButtonTP : public CFWL_WidgetTP {
public:
CFWL_PushButtonTP();
- virtual ~CFWL_PushButtonTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
- uint32_t dwThemeID,
- FX_BOOL bChildren = TRUE);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
- virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
+ ~CFWL_PushButtonTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ uint32_t SetThemeID(IFWL_Widget* pWidget,
+ uint32_t dwThemeID,
+ FX_BOOL bChildren = TRUE) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
+ void* GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity) override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
protected:
struct PBThemeData {
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.cpp
index c6a14f8e94e..54dfbe5531c 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.cpp
@@ -13,26 +13,26 @@
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#define FWL_SCROLL_PawLen 12.5f
+namespace {
-CFWL_ScrollBarTP::CFWL_ScrollBarTP() {
- m_pThemeData = new SBThemeData;
+const float kPawLength = 12.5f;
+
+} // namespace
+
+CFWL_ScrollBarTP::CFWL_ScrollBarTP() : m_pThemeData(new SBThemeData) {
SetThemeData(0);
}
+
CFWL_ScrollBarTP::~CFWL_ScrollBarTP() {
- if (m_pThemeData) {
- delete m_pThemeData;
- m_pThemeData = NULL;
- }
+ delete m_pThemeData;
}
-FX_BOOL CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_ScrollBar;
+
+bool CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget && pWidget->GetClassID() == FWL_Type::ScrollBar;
}
void* CFWL_ScrollBarTP::GetCapacity(CFWL_ThemePart* pThemePart,
- uint32_t dwCapacity) {
- if (dwCapacity == FWL_CAPACITY_SCB_Size) {
+ CFWL_WidgetCapacity dwCapacity) {
+ if (dwCapacity == CFWL_WidgetCapacity::Size) {
m_fValue = 5;
return &m_fValue;
}
@@ -52,15 +52,15 @@ FX_BOOL CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) {
IFWL_Widget* pWidget = pParams->m_pWidget;
FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
switch (pParams->m_dwStates & 0x03) {
- case FWL_PARTSTATE_SCB_Hovered: {
+ case CFWL_PartState_Hovered: {
eState = FWLTHEME_STATE_Hover;
break;
}
- case FWL_PARTSTATE_SCB_Pressed: {
+ case CFWL_PartState_Pressed: {
eState = FWLTHEME_STATE_Pressed;
break;
}
- case FWL_PARTSTATE_SCB_Disabled: {
+ case CFWL_PartState_Disabled: {
eState = FWLTHEME_STATE_Disabale;
break;
}
@@ -69,27 +69,27 @@ FX_BOOL CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) {
CFX_RectF* pRect = &pParams->m_rtPart;
FX_BOOL bVert = pWidget->GetStylesEx();
switch (pParams->m_iPart) {
- case FWL_PART_SCB_ForeArrow: {
+ case CFWL_Part::ForeArrow: {
DrawMaxMinBtn(pGraphics, pRect,
bVert ? FWLTHEME_DIRECTION_Up : FWLTHEME_DIRECTION_Left,
eState, &pParams->m_matrix);
break;
}
- case FWL_PART_SCB_BackArrow: {
+ case CFWL_Part::BackArrow: {
DrawMaxMinBtn(pGraphics, pRect,
bVert ? FWLTHEME_DIRECTION_Down : FWLTHEME_DIRECTION_Right,
eState, &pParams->m_matrix);
break;
}
- case FWL_PART_SCB_Thumb: {
+ case CFWL_Part::Thumb: {
DrawThumbBtn(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix);
break;
}
- case FWL_PART_SCB_LowerTrack: {
+ case CFWL_Part::LowerTrack: {
DrawTrack(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix);
break;
}
- case FWL_PART_SCB_UpperTrack: {
+ case CFWL_Part::UpperTrack: {
DrawTrack(pGraphics, pRect, bVert, eState, FALSE, &pParams->m_matrix);
break;
}
@@ -97,7 +97,7 @@ FX_BOOL CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) {
}
return TRUE;
}
-#ifdef THEME_XPSimilar
+
void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics,
const CFX_RectF* pRect,
FX_BOOL bVert,
@@ -152,7 +152,7 @@ void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics,
CFX_Path path;
path.Create();
if (bVert) {
- FX_FLOAT fPawLen = FWL_SCROLL_PawLen;
+ FX_FLOAT fPawLen = kPawLength;
if (pRect->width / 2 <= fPawLen) {
fPawLen = (pRect->width - 6) / 2;
}
@@ -185,7 +185,7 @@ void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics,
pGraphics->SetStrokeColor(&clrDark);
pGraphics->StrokePath(&path, pMatrix);
} else {
- FX_FLOAT fPawLen = FWL_SCROLL_PawLen;
+ FX_FLOAT fPawLen = kPawLength;
if (pRect->height / 2 <= fPawLen) {
fPawLen = (pRect->height - 6) / 2;
}
@@ -266,75 +266,7 @@ void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics,
rtArrowBtn.Deflate(1, 1, 1, 1);
DrawArrowBtn(pGraphics, &rtArrowBtn, eDict, eState, pMatrix);
}
-#else
-void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics,
- const CFX_RectF* pRect,
- FX_BOOL bVert,
- FWLTHEME_STATE eState,
- FX_BOOL bPawButton,
- CFX_Matrix* pMatrix) {
- if (pRect->IsEmpty()) {
- return;
- }
- CFX_RectF rtThumb(*pRect);
- FX_FLOAT fWidth = 2;
- Draw3DRect(pGraphics, FWLTHEME_EDGE_Raised, fWidth, pRect,
- FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2,
- FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth,
- pRect->width - 2 * fWidth, pRect->height - 2 * fWidth);
- pGraphics->SaveGraphState();
- CFX_Color crFill(FWLTHEME_COLOR_Background);
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics,
- const CFX_RectF* pRect,
- FX_BOOL bVert,
- FWLTHEME_STATE eState,
- FX_BOOL bLowerTrack,
- CFX_Matrix* pMatrix) {
- if (pRect->IsEmpty()) {
- return;
- }
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height);
- pGraphics->SaveGraphState();
- CFX_Color clrFill(0xFFF0F0F0);
- pGraphics->SetFillColor(&clrFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
-}
-void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics,
- const CFX_RectF* pRect,
- FWLTHEME_DIRECTION eDict,
- FWLTHEME_STATE eState,
- CFX_Matrix* pMatrix) {
- CFX_RectF rtThumb(*pRect);
- FX_FLOAT fWidth = eState == FWLTHEME_STATE_Pressed ? 1.0f : 2.0f;
- FWLTHEME_EDGE eType = eState == FWLTHEME_STATE_Pressed ? FWLTHEME_EDGE_Flat
- : FWLTHEME_EDGE_Raised;
- Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1,
- FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1,
- FWLTHEME_COLOR_EDGERB2, pMatrix);
- CFX_Path path;
- path.Create();
- path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth,
- pRect->width - 2 * fWidth, pRect->height - 2 * fWidth);
- pGraphics->SaveGraphState();
- CFX_Color crFill(FWLTHEME_COLOR_Background);
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
- pGraphics->RestoreGraphState();
- DrawArrow(pGraphics, pRect, eDict,
- eState == FWLTHEME_STATE_Disabale ? 0xFFA0A0A0 : 0xFF000000,
- eState == FWLTHEME_STATE_Pressed, pMatrix);
-}
-#endif
+
void CFWL_ScrollBarTP::SetThemeData(uint32_t dwID) {
m_pThemeData->clrPawColorLight[3] = ArgbEncode(0xff, 208, 223, 172);
m_pThemeData->clrPawColorDark[3] = ArgbEncode(0xff, 140, 157, 115);
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.h
index 05303930436..84e18193db7 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_scrollbartp.h
@@ -12,13 +12,16 @@
class CFWL_ScrollBarTP : public CFWL_WidgetTP {
public:
CFWL_ScrollBarTP();
- virtual ~CFWL_ScrollBarTP();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
- virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
- uint32_t dwThemeID,
- FX_BOOL bChildren = TRUE);
- virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
- virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity);
+ ~CFWL_ScrollBarTP() override;
+
+ // CFWL_WidgetTP
+ bool IsValidWidget(IFWL_Widget* pWidget) override;
+ uint32_t SetThemeID(IFWL_Widget* pWidget,
+ uint32_t dwThemeID,
+ FX_BOOL bChildren = TRUE) override;
+ FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override;
+ void* GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity) override;
protected:
struct SBThemeData {
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_utils.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_utils.h
index d530b7631b3..cdd768a8789 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_utils.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_utils.h
@@ -9,67 +9,33 @@
#include "core/fxcrt/include/fx_system.h"
-#define THEME_XPSimilar
enum FWLTHEME_EDGE {
FWLTHEME_EDGE_Flat = 0,
FWLTHEME_EDGE_Raised,
FWLTHEME_EDGE_Sunken
};
+
enum FWLTHEME_STATE {
FWLTHEME_STATE_Normal = 1,
FWLTHEME_STATE_Hover,
FWLTHEME_STATE_Pressed,
FWLTHEME_STATE_Disabale
};
+
enum FWLTHEME_DIRECTION {
FWLTHEME_DIRECTION_Up = 0,
FWLTHEME_DIRECTION_Down,
FWLTHEME_DIRECTION_Left,
FWLTHEME_DIRECTION_Right
};
-struct FWLCOLOR {
- union {
- uint32_t color;
- struct {
- uint8_t b;
- uint8_t g;
- uint8_t r;
- uint8_t a;
- };
- };
-
- FWLCOLOR() : color(0) {}
- FWLCOLOR(uint32_t c) : color(c) {}
- FWLCOLOR(const FWLCOLOR& c) : color(c.color) {}
- bool operator==(const FWLCOLOR& frColor) { return color == frColor.color; }
- operator uint32_t() { return color; }
-};
-#define FWLTHEME_BEZIER FX_BEZIER
-#define FWLTHEME_PI FX_PI
-#define FWLTHEME_PI_2_1 (FX_PI / 2.0f)
-#define FWLTHEME_PI_2_3 (3.0f * FX_PI / 2.0f)
-#define FWLTHEME_COLOR_EDGELT1 (ArgbEncode(255, 172, 168, 153))
-#define FWLTHEME_COLOR_EDGELT2 (ArgbEncode(255, 113, 111, 100))
#define FWLTHEME_COLOR_EDGERB1 (ArgbEncode(255, 241, 239, 226))
-#define FWLTHEME_COLOR_EDGERB2 (ArgbEncode(255, 255, 255, 255))
#define FWLTHEME_COLOR_Background (ArgbEncode(255, 236, 233, 216))
#define FWLTHEME_COLOR_BKSelected (ArgbEncode(255, 153, 193, 218))
#define FWLTHEME_COLOR_Green_BKSelected (ArgbEncode(255, 147, 160, 112))
-#ifdef THEME_XPSimilar
-#define FWLTHEME_CAPACITY_EdgeFlat 2.0f
-#else
-#define FWLTHEME_CAPACITY_EdgeFlat 0.0f
-#endif
-#define FWLTHEME_CAPACITY_EdgeRaised 2.0f
-#define FWLTHEME_CAPACITY_EdgeSunken 2.0f
+
#define FWLTHEME_CAPACITY_FontSize 12.0f
-#define FWLTHEME_CAPACITY_LineHeight 12.0f
#define FWLTHEME_CAPACITY_TextColor (ArgbEncode(255, 0, 0, 0))
-#define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218))
#define FWLTHEME_CAPACITY_TextDisColor (ArgbEncode(255, 172, 168, 153))
-#define FWLTHEME_CAPACITY_ScrollBarWidth 17.0f
-#define FWLTHEME_CAPACITY_CXBorder 1.0f
-#define FWLTHEME_CAPACITY_CYBorder 1.0f
#endif // XFA_FWL_THEME_CFWL_UTILS_H_
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.cpp b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.cpp
index eec5337052a..764c86e3141 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -9,15 +9,31 @@
#include <algorithm>
#include "xfa/fde/tto/fde_textout.h"
+#include "xfa/fgas/font/fgas_stdfontmgr.h"
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
+#include "xfa/fwl/core/ifwl_widget.h"
#include "xfa/fwl/core/ifwl_widgetmgr.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
#include "xfa/fxgraphics/cfx_shading.h"
+namespace {
+
+const float kEdgeFlat = 2.0f;
+const float kEdgeRaised = 2.0f;
+const float kEdgeSunken = 2.0f;
+const float kLineHeight = 12.0f;
+const float kScrollBarWidth = 17.0f;
+const float kCXBorder = 1.0f;
+const float kCYBorder = 1.0f;
+
+#define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218))
+
+} // namespace
+
static void FWL_SetChildThemeID(IFWL_Widget* pParent, uint32_t dwThemeID) {
IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr();
IFWL_Widget* pChild =
@@ -31,12 +47,15 @@ static void FWL_SetChildThemeID(IFWL_Widget* pParent, uint32_t dwThemeID) {
pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling);
}
}
-FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) {
+
+bool CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) {
return FALSE;
}
+
uint32_t CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) {
return m_dwThemeID;
}
+
uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren) {
@@ -50,23 +69,23 @@ uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget,
}
return dwOld;
}
-FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget,
- CFX_Matrix& matrix) {
+FWL_Error CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget,
+ CFX_Matrix& matrix) {
matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget,
- const CFX_Matrix& matrix) {
+FWL_Error CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget,
+ const CFX_Matrix& matrix) {
_ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) {
return TRUE;
}
FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) {
- if (!m_pTextOut) {
+ if (!m_pTextOut)
InitTTO();
- }
+
int32_t iLen = pParams->m_wsText.GetLength();
if (iLen <= 0)
return FALSE;
@@ -77,57 +96,57 @@ FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) {
CFX_Matrix* pMatrix = &pParams->m_matrix;
pMatrix->Concat(*pGraphics->GetMatrix());
m_pTextOut->SetMatrix(*pMatrix);
- m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart);
+ m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), iLen, pParams->m_rtPart);
return TRUE;
}
void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart,
- uint32_t dwCapacity) {
+ CFWL_WidgetCapacity dwCapacity) {
switch (dwCapacity) {
- case FWL_WGTCAPACITY_CXBorder: {
- m_fValue = FWLTHEME_CAPACITY_CXBorder;
+ case CFWL_WidgetCapacity::CXBorder: {
+ m_fValue = kCXBorder;
break;
}
- case FWL_WGTCAPACITY_CYBorder: {
- m_fValue = FWLTHEME_CAPACITY_CYBorder;
+ case CFWL_WidgetCapacity::CYBorder: {
+ m_fValue = kCYBorder;
break;
}
- case FWL_WGTCAPACITY_EdgeFlat: {
- m_fValue = FWLTHEME_CAPACITY_EdgeFlat;
+ case CFWL_WidgetCapacity::EdgeFlat: {
+ m_fValue = kEdgeFlat;
break;
}
- case FWL_WGTCAPACITY_EdgeRaised: {
- m_fValue = FWLTHEME_CAPACITY_EdgeRaised;
+ case CFWL_WidgetCapacity::EdgeRaised: {
+ m_fValue = kEdgeRaised;
break;
}
- case FWL_WGTCAPACITY_EdgeSunken: {
- m_fValue = FWLTHEME_CAPACITY_EdgeSunken;
+ case CFWL_WidgetCapacity::EdgeSunken: {
+ m_fValue = kEdgeSunken;
break;
}
- case FWL_WGTCAPACITY_FontSize: {
+ case CFWL_WidgetCapacity::FontSize: {
m_fValue = FWLTHEME_CAPACITY_FontSize;
break;
}
- case FWL_WGTCAPACITY_TextColor: {
+ case CFWL_WidgetCapacity::TextColor: {
m_dwValue = FWLTHEME_CAPACITY_TextColor;
return &m_dwValue;
}
- case FWL_WGTCAPACITY_ScrollBarWidth: {
- m_fValue = FWLTHEME_CAPACITY_ScrollBarWidth;
+ case CFWL_WidgetCapacity::ScrollBarWidth: {
+ m_fValue = kScrollBarWidth;
break;
}
- case FWL_WGTCAPACITY_Font: {
+ case CFWL_WidgetCapacity::Font: {
return m_pFDEFont;
}
- case FWL_WGTCAPACITY_TextSelColor: {
+ case CFWL_WidgetCapacity::TextSelColor: {
m_dwValue = (m_dwThemeID == 0) ? FWLTHEME_CAPACITY_TextSelColor
: FWLTHEME_COLOR_Green_BKSelected;
return &m_dwValue;
}
- case FWL_WGTCAPACITY_LineHeight: {
- m_fValue = FWLTHEME_CAPACITY_LineHeight;
+ case CFWL_WidgetCapacity::LineHeight: {
+ m_fValue = kLineHeight;
break;
}
- case FWL_WGTCAPACITY_UIMargin: {
+ case CFWL_WidgetCapacity::UIMargin: {
m_rtMargin.Set(0, 0, 0, 0);
return &m_rtMargin;
}
@@ -138,9 +157,9 @@ void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart,
FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) {
return FWL_GetThemeLayout(m_dwThemeID);
}
-FWL_ERR CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart,
- CFX_RectF& rect) {
- return FWL_ERR_Succeeded;
+FWL_Error CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart,
+ CFX_RectF& rect) {
+ return FWL_Error::Succeeded;
}
FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart,
FX_FLOAT fx,
@@ -154,73 +173,72 @@ FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
return FALSE;
m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext);
- m_pTextOut->CalcLogicSize(pParams->m_wsText, pParams->m_wsText.GetLength(),
- rect);
+ m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(),
+ pParams->m_wsText.GetLength(), rect);
return TRUE;
}
-FWL_ERR CFWL_WidgetTP::Initialize() {
+FWL_Error CFWL_WidgetTP::Initialize() {
m_dwThemeID = 0;
_ctm.SetIdentity();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CFWL_WidgetTP::Finalize() {
- if (!m_pTextOut) {
+FWL_Error CFWL_WidgetTP::Finalize() {
+ if (!m_pTextOut)
FinalizeTTO();
- }
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFWL_WidgetTP::~CFWL_WidgetTP() {}
-FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
- const FX_WCHAR* strFont,
- FX_FLOAT fFontSize,
- FX_ARGB rgbFont) {
- if (!m_pTextOut) {
- return FWL_ERR_Succeeded;
- }
+FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
+ const FX_WCHAR* strFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont) {
+ if (!m_pTextOut)
+ return FWL_Error::Succeeded;
+
m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0);
m_pTextOut->SetFont(m_pFDEFont);
m_pTextOut->SetFontSize(fFontSize);
m_pTextOut->SetTextColor(rgbFont);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
- IFX_Font* pFont,
- FX_FLOAT fFontSize,
- FX_ARGB rgbFont) {
- if (!m_pTextOut) {
- return FWL_ERR_Succeeded;
- }
+ return FWL_Error::Succeeded;
+}
+FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
+ IFX_Font* pFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont) {
+ if (!m_pTextOut)
+ return FWL_Error::Succeeded;
+
m_pTextOut->SetFont(pFont);
m_pTextOut->SetFontSize(fFontSize);
m_pTextOut->SetTextColor(rgbFont);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) {
return m_pFDEFont;
}
+
CFWL_WidgetTP::CFWL_WidgetTP()
- : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {}
-FX_ERR CFWL_WidgetTP::InitTTO() {
- if (m_pTextOut) {
- return FWL_ERR_Succeeded;
- }
+ : m_dwRefCount(1), m_pFDEFont(nullptr), m_dwThemeID(0) {}
+
+FWL_Error CFWL_WidgetTP::InitTTO() {
+ if (m_pTextOut)
+ return FWL_Error::Succeeded;
+
m_pFDEFont =
CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0);
- m_pTextOut = IFDE_TextOut::Create();
+ m_pTextOut.reset(new CFDE_TextOut);
m_pTextOut->SetFont(m_pFDEFont);
m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
m_pTextOut->SetEllipsisString(L"...");
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFWL_WidgetTP::FinalizeTTO() {
- if (m_pTextOut) {
- m_pTextOut->Release();
- m_pTextOut = NULL;
- }
- return FWL_ERR_Succeeded;
+
+FWL_Error CFWL_WidgetTP::FinalizeTTO() {
+ m_pTextOut.reset();
+ return FWL_Error::Succeeded;
}
-#ifdef THEME_XPSimilar
+
void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics,
uint32_t dwStyles,
const CFX_RectF* pRect,
@@ -247,34 +265,7 @@ void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics,
pGraphics->StrokePath(&path, pMatrix);
pGraphics->RestoreGraphState();
}
-#else
-void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics,
- uint32_t dwStyles,
- const CFX_RectF* pRect,
- CFX_Matrix* pMatrix) {
- if (!pGraphics)
- return;
- if (!pRect)
- return;
- FWLTHEME_EDGE eType;
- FX_FLOAT fWidth;
- switch (dwStyles & FWL_WGTSTYLE_EdgeMask) {
- case FWL_WGTSTYLE_EdgeRaised: {
- eType = FWLTHEME_EDGE_Raised, fWidth = FWLTHEME_CAPACITY_EdgeRaised;
- break;
- }
- case FWL_WGTSTYLE_EdgeSunken: {
- eType = FWLTHEME_EDGE_Sunken, fWidth = FWLTHEME_CAPACITY_EdgeSunken;
- break;
- }
- case FWL_WGTSTYLE_EdgeFlat:
- default: { return; }
- }
- Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1,
- FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1,
- FWLTHEME_COLOR_EDGERB2, pMatrix);
-}
-#endif
+
void CFWL_WidgetTP::Draw3DRect(CFX_Graphics* pGraphics,
FWLTHEME_EDGE eType,
FX_FLOAT fWidth,
@@ -378,7 +369,7 @@ void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics,
CFX_Path path;
path.Create();
path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height,
- FWLTHEME_PI * 3 / 4, FWLTHEME_PI);
+ FX_PI * 3 / 4, FX_PI);
CFX_Color crFill1(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1);
pGraphics->SetStrokeColor(&crFill1);
pGraphics->StrokePath(&path, pMatrix);
@@ -386,18 +377,18 @@ void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics,
rtInner.Deflate(pRect->width / 4, pRect->height / 4);
path.Clear();
path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height,
- FWLTHEME_PI * 3 / 4, FWLTHEME_PI);
+ FX_PI * 3 / 4, FX_PI);
CFX_Color crFill2(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2);
pGraphics->SetStrokeColor(&crFill2);
pGraphics->StrokePath(&path, pMatrix);
path.Clear();
path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height,
- FWLTHEME_PI * 7 / 4, FWLTHEME_PI);
+ FX_PI * 7 / 4, FX_PI);
CFX_Color crFill3(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3);
pGraphics->SetStrokeColor(&crFill3);
pGraphics->StrokePath(&path, pMatrix);
path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height,
- FWLTHEME_PI * 7 / 4, FWLTHEME_PI);
+ FX_PI * 7 / 4, FX_PI);
CFX_Color crFill4(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4);
pGraphics->SetStrokeColor(&crFill4);
pGraphics->StrokePath(&path, pMatrix);
@@ -674,21 +665,6 @@ void CFWL_WidgetTP::DrawArrowBtn(CFX_Graphics* pGraphics,
CFWL_ArrowData::GetInstance()->m_pColorData;
DrawArrow(pGraphics, pRect, eDict, pColorData->clrSign[eState - 1], pMatrix);
}
-FWLCOLOR CFWL_WidgetTP::BlendColor(FWLCOLOR srcColor,
- FWLCOLOR renderColor,
- uint8_t scale) {
- FWLCOLOR dstColor;
- uint8_t n = 255 - scale;
- dstColor.a = (uint8_t)(
- ((uint16_t)srcColor.a * n + (uint16_t)renderColor.a * scale) >> 8);
- dstColor.r = (uint8_t)(
- ((uint16_t)srcColor.r * n + (uint16_t)renderColor.r * scale) >> 8);
- dstColor.g = (uint8_t)(
- ((uint16_t)srcColor.g * n + (uint16_t)renderColor.g * scale) >> 8);
- dstColor.b = (uint8_t)(
- ((uint16_t)srcColor.b * n + (uint16_t)renderColor.b * scale) >> 8);
- return dstColor;
-}
CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(NULL) {
SetColorData(0);
}
@@ -732,11 +708,11 @@ FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily,
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator());
#else
- m_pFontSource = FX_CreateDefaultFontSourceEnum();
+ m_pFontSource = new CFX_FontSourceEnum_File;
m_pFontMgr = IFX_FontMgr::Create(m_pFontSource);
#endif
}
- m_pFont = IFX_Font::LoadFont(wsFontFamily.raw_str(), dwFontStyles, dwCodePage,
+ m_pFont = IFX_Font::LoadFont(wsFontFamily.c_str(), dwFontStyles, dwCodePage,
m_pFontMgr);
return m_pFont != NULL;
}
@@ -779,31 +755,28 @@ uint32_t FWL_GetThemeLayout(uint32_t dwThemeID) {
uint32_t FWL_GetThemeColor(uint32_t dwThemeID) {
return 0x0000ffff & dwThemeID;
}
-uint32_t FWL_MakeThemeID(uint32_t dwLayout, uint32_t dwColor) {
- return (dwLayout << 16) | (0x0000FFFF & dwColor);
-}
+
CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL;
+
CFWL_ArrowData* CFWL_ArrowData::GetInstance() {
- if (!m_pInstance) {
+ if (!m_pInstance)
m_pInstance = new CFWL_ArrowData;
- }
return m_pInstance;
}
+
FX_BOOL CFWL_ArrowData::IsInstance() {
- return (m_pInstance != NULL);
+ return !!m_pInstance;
}
+
void CFWL_ArrowData::DestroyInstance() {
- if (m_pInstance) {
- delete m_pInstance;
- m_pInstance = NULL;
- }
+ delete m_pInstance;
+ m_pInstance = nullptr;
}
+
CFWL_ArrowData::~CFWL_ArrowData() {
- if (m_pColorData) {
- delete m_pColorData;
- m_pColorData = NULL;
- }
+ delete m_pColorData;
}
+
void CFWL_ArrowData::SetColorData(uint32_t dwID) {
if (!m_pColorData) {
m_pColorData = new CColorData;
diff --git a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.h b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.h
index 03d575a1d94..b66e19344e1 100644
--- a/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.h
+++ b/chromium/third_party/pdfium/xfa/fwl/theme/cfwl_widgettp.h
@@ -16,8 +16,83 @@
#include "xfa/fxgraphics/include/cfx_graphics.h"
#include "xfa/fwl/theme/cfwl_utils.h"
+enum class CFWL_WidgetCapacity {
+ None = 0,
+
+ Today,
+ Sun,
+ Mon,
+ Tue,
+ Wed,
+ Thu,
+ Fri,
+ Sat,
+
+ January,
+ February,
+ March,
+ April,
+ May,
+ June,
+ July,
+ August,
+ September,
+ October,
+ November,
+ December,
+
+ BigIcon,
+ ComboFormHandler,
+ CXBorder,
+ CYBorder,
+ CYCaption,
+ CYNarrowCaption,
+ DatesCellHeight,
+ DatesCellWidth,
+ EdgeFlat,
+ EdgeRaised,
+ EdgeSunken,
+ Font,
+ FontSize,
+ HeaderBtnHeight,
+ HeaderBtnHMargin,
+ HeaderBtnVMargin,
+ HeaderBtnWidth,
+ HeaderHeight,
+ HeaderTextHeight,
+ HeaderTextHMargin,
+ HeaderTextVMargin,
+ HeaderTextWidth,
+ HeaderWidth,
+ Height,
+ HSepHeight,
+ HSepWidth,
+ LineHeight,
+ Margin,
+ ScrollBarWidth,
+ SepDOffset,
+ SepX,
+ SepY,
+ Size,
+ SmallIcon,
+ SpaceAboveBelow,
+ TextColor,
+ TextSelColor,
+ TodayFlagWidth,
+ TodayHeight,
+ TodayWidth,
+ UIMargin,
+ VSepHeight,
+ VSepWidth,
+ WeekHeight,
+ WeekNumHeight,
+ WeekNumWidth,
+ WeekWidth,
+ Width
+};
+
class IFWL_Widget;
-class IFDE_TextOut;
+class CFDE_TextOut;
class IFX_Font;
class IFX_FontMgr;
class CFWL_ArrowData;
@@ -26,45 +101,49 @@ class CFWL_ThemePart;
class CFWL_ThemeText;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
-class IFX_FontSourceEnum;
+class CFX_FontSourceEnum_File;
#endif
class CFWL_WidgetTP {
public:
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
+ virtual ~CFWL_WidgetTP();
+
+ virtual FWL_Error Initialize();
+ virtual FWL_Error Finalize();
+
+ virtual bool IsValidWidget(IFWL_Widget* pWidget);
virtual uint32_t GetThemeID(IFWL_Widget* pWidget);
virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren = TRUE);
- virtual FWL_ERR GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix);
- virtual FWL_ERR SetThemeMatrix(IFWL_Widget* pWidget,
- const CFX_Matrix& matrix);
+ virtual FWL_Error GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix);
+ virtual FWL_Error SetThemeMatrix(IFWL_Widget* pWidget,
+ const CFX_Matrix& matrix);
virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
virtual FX_BOOL DrawText(CFWL_ThemeText* pParams);
- virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity);
+ virtual void* GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity);
virtual FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget);
- virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart);
+ virtual FWL_Error GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart);
virtual FX_BOOL IsInPart(CFWL_ThemePart* pThemePart,
FX_FLOAT fx,
FX_FLOAT fy);
virtual FX_BOOL CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect);
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual ~CFWL_WidgetTP();
- FWL_ERR SetFont(IFWL_Widget* pWidget,
- const FX_WCHAR* strFont,
- FX_FLOAT fFontSize,
- FX_ARGB rgbFont);
- FWL_ERR SetFont(IFWL_Widget* pWidget,
- IFX_Font* pFont,
- FX_FLOAT fFontSize,
- FX_ARGB rgbFont);
+
+ FWL_Error SetFont(IFWL_Widget* pWidget,
+ const FX_WCHAR* strFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont);
+ FWL_Error SetFont(IFWL_Widget* pWidget,
+ IFX_Font* pFont,
+ FX_FLOAT fFontSize,
+ FX_ARGB rgbFont);
IFX_Font* GetFont(IFWL_Widget* pWidget);
protected:
CFWL_WidgetTP();
- FX_ERR InitTTO();
- FX_ERR FinalizeTTO();
+ FWL_Error InitTTO();
+ FWL_Error FinalizeTTO();
void DrawEdge(CFX_Graphics* pGraphics,
uint32_t dwStyles,
const CFX_RectF* pRect,
@@ -140,9 +219,8 @@ class CFWL_WidgetTP {
FWLTHEME_DIRECTION eDict,
FWLTHEME_STATE eState,
CFX_Matrix* pMatrix = NULL);
- FWLCOLOR BlendColor(FWLCOLOR srcColor, FWLCOLOR renderColor, uint8_t scale);
uint32_t m_dwRefCount;
- IFDE_TextOut* m_pTextOut;
+ std::unique_ptr<CFDE_TextOut> m_pTextOut;
IFX_Font* m_pFDEFont;
FX_FLOAT m_fValue;
uint32_t m_dwValue;
@@ -154,7 +232,6 @@ FX_BOOL FWLTHEME_Init();
void FWLTHEME_Release();
uint32_t FWL_GetThemeLayout(uint32_t dwThemeID);
uint32_t FWL_GetThemeColor(uint32_t dwThemeID);
-uint32_t FWL_MakeThemeID(uint32_t dwLayout, uint32_t dwColor);
class CFWL_ArrowData {
public:
@@ -196,7 +273,7 @@ class CFWL_FontData {
IFX_Font* m_pFont;
IFX_FontMgr* m_pFontMgr;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- IFX_FontSourceEnum* m_pFontSource;
+ CFX_FontSourceEnum_File* m_pFontSource;
#endif
};
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp
index 86b19c15af8..814f300b2d4 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.cpp
@@ -20,7 +20,10 @@
* limitations under the License.
*/
-#include "core/include/fxcodec/fx_codec.h"
+#include <memory>
+
+#include "core/fxcodec/codec/include/ccodec_progressivedecoder.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h"
#include "xfa/fxbarcode/BC_LuminanceSource.h"
#include "xfa/fxbarcode/utils.h"
@@ -29,62 +32,39 @@ class CBC_Pause : public IFX_Pause {
public:
virtual FX_BOOL NeedToPauseNow() { return TRUE; }
};
+
static CFX_DIBitmap* CreateDIBSource(IFX_FileRead* fileread) {
- CFX_DIBitmap* bitmap = NULL;
- CCodec_ModuleMgr* pCodecMgr = NULL;
- ICodec_ProgressiveDecoder* pImageCodec = NULL;
- pCodecMgr = new CCodec_ModuleMgr();
- pImageCodec = pCodecMgr->CreateProgressiveDecoder();
+ std::unique_ptr<CCodec_ModuleMgr> pCodecMgr(new CCodec_ModuleMgr());
+ std::unique_ptr<CCodec_ProgressiveDecoder> pImageCodec(
+ pCodecMgr->CreateProgressiveDecoder());
FXCODEC_STATUS status = FXCODEC_STATUS_DECODE_FINISH;
status = pImageCodec->LoadImageInfo(fileread, FXCODEC_IMAGE_UNKNOWN, nullptr);
- if (status != FXCODEC_STATUS_FRAME_READY) {
- return NULL;
- }
- bitmap = new CFX_DIBitmap;
+ if (status != FXCODEC_STATUS_FRAME_READY)
+ return nullptr;
+
+ std::unique_ptr<CFX_DIBitmap> bitmap(new CFX_DIBitmap);
bitmap->Create(pImageCodec->GetWidth(), pImageCodec->GetHeight(), FXDIB_Argb);
bitmap->Clear(FXARGB_MAKE(0xFF, 0xFF, 0xFF, 0xFF));
CBC_Pause pause;
int32_t frames;
status = pImageCodec->GetFrames(frames, &pause);
- while (status == FXCODEC_STATUS_FRAME_TOBECONTINUE) {
+ while (status == FXCODEC_STATUS_FRAME_TOBECONTINUE)
status = pImageCodec->GetFrames(frames, &pause);
- }
- if (status != FXCODEC_STATUS_DECODE_READY) {
- goto except;
- }
- status = pImageCodec->StartDecode(bitmap, 0, 0, bitmap->GetWidth(),
+
+ if (status != FXCODEC_STATUS_DECODE_READY)
+ return nullptr;
+
+ status = pImageCodec->StartDecode(bitmap.get(), 0, 0, bitmap->GetWidth(),
bitmap->GetHeight(), 0, FALSE);
- if (status == FXCODEC_STATUS_ERR_PARAMS) {
- goto except;
- }
- if (status != FXCODEC_STATUS_DECODE_TOBECONTINUE) {
- goto except;
- }
- while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE) {
+ if (status != FXCODEC_STATUS_DECODE_TOBECONTINUE)
+ return nullptr;
+
+ while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE)
status = pImageCodec->ContinueDecode(&pause);
- }
- if (status != FXCODEC_STATUS_DECODE_FINISH) {
- goto except;
- }
- if (pImageCodec) {
- delete pImageCodec;
- pImageCodec = NULL;
- }
- delete pCodecMgr;
- pCodecMgr = NULL;
- return bitmap;
-except:
- if (pImageCodec) {
- delete pImageCodec;
- pImageCodec = NULL;
- }
- delete pCodecMgr;
- pCodecMgr = NULL;
- if (bitmap) {
- delete bitmap;
- }
- return NULL;
+
+ return status == FXCODEC_STATUS_DECODE_FINISH ? bitmap.release() : nullptr;
}
+
CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource(
const CFX_WideString& filename)
: CBC_LuminanceSource(0, 0), m_filename(filename) {
@@ -94,10 +74,11 @@ CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource(
m_top = 0;
m_left = 0;
}
+
void CBC_BufferedImageLuminanceSource::Init(int32_t& e) {
- IFX_FileRead* fileread = FX_CreateFileRead(m_filename);
+ IFX_FileRead* fileread = FX_CreateFileRead(m_filename.c_str());
m_pBitmap = CreateDIBSource(fileread);
- if (m_pBitmap == NULL) {
+ if (!m_pBitmap) {
e = BCExceptionLoadFile;
return;
}
@@ -109,6 +90,7 @@ void CBC_BufferedImageLuminanceSource::Init(int32_t& e) {
m_top = 0;
m_left = 0;
}
+
CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource(
CFX_DIBitmap* pBitmap)
: CBC_LuminanceSource(0, 0) {
@@ -121,16 +103,17 @@ CBC_BufferedImageLuminanceSource::CBC_BufferedImageLuminanceSource(
m_top = 0;
m_left = 0;
}
+
CBC_BufferedImageLuminanceSource::~CBC_BufferedImageLuminanceSource() {
delete m_pBitmap;
- m_pBitmap = NULL;
}
+
CFX_ByteArray* CBC_BufferedImageLuminanceSource::GetRow(int32_t y,
CFX_ByteArray& row,
int32_t& e) {
if (y < 0 || y >= m_height) {
e = BCExceptionRequestedRowIsOutSizeTheImage;
- return NULL;
+ return nullptr;
}
int32_t width = m_width;
if (row.GetSize() == 0 || row.GetSize() < width) {
@@ -150,9 +133,10 @@ CFX_ByteArray* CBC_BufferedImageLuminanceSource::GetRow(int32_t y,
}
return &row;
}
+
CFX_ByteArray* CBC_BufferedImageLuminanceSource::GetMatrix() {
- CFX_ByteArray* matirx = new CFX_ByteArray();
- matirx->SetSize(m_bytesPerLine * m_height);
+ CFX_ByteArray* matrix = new CFX_ByteArray();
+ matrix->SetSize(m_bytesPerLine * m_height);
int32_t* rgb = (int32_t*)m_pBitmap->GetBuffer();
int32_t y;
for (y = 0; y < m_height; y++) {
@@ -164,8 +148,8 @@ CFX_ByteArray* CBC_BufferedImageLuminanceSource::GetMatrix() {
(306 * ((pixel >> 16) & 0xFF) + 601 * ((pixel >> 8) & 0xFF) +
117 * (pixel & 0xFF)) >>
10;
- (*matirx)[offset + x] = (uint8_t)luminance;
+ (*matrix)[offset + x] = (uint8_t)luminance;
}
}
- return matirx;
+ return matrix;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.h b/chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.h
index e27dd1df3d1..ca3aafb27d7 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/BC_BufferedImageLuminanceSource.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_string.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/BC_LuminanceSource.h"
class CBC_BufferedImageLuminanceSource : public CBC_LuminanceSource {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/BC_ResultPoint.h b/chromium/third_party/pdfium/xfa/fxbarcode/BC_ResultPoint.h
index 1497b311fc2..e819fa5f6e3 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/BC_ResultPoint.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/BC_ResultPoint.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXBARCODE_BC_RESULTPOINT_H_
#define XFA_FXBARCODE_BC_RESULTPOINT_H_
-#include "core/fxcrt/include/fx_system.h"
+#include "core/fxcrt/include/fx_basic.h"
class CBC_ResultPoint {
public:
@@ -22,4 +22,7 @@ class CBC_ResultPoint {
FX_FLOAT m_y;
};
+using CBC_ResultPointArray = CFX_ArrayTemplate<CBC_ResultPoint*>;
+using CBC_ResultPointArrayArray = CFX_ArrayTemplate<CBC_ResultPointArray*>;
+
#endif // XFA_FXBARCODE_BC_RESULTPOINT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.cpp
index f0065a02b9e..a844bf1c423 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.cpp
@@ -53,6 +53,7 @@ void CBC_TwoDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
}
}
}
+
void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
int32_t& e) {
if (m_bFixedSize) {
@@ -80,12 +81,11 @@ void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
}
if (!m_bFixedSize) {
CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
- if (pOutBitmap) {
- delete pOutBitmap;
- }
+ delete pOutBitmap;
pOutBitmap = pStretchBitmap;
}
}
+
void CBC_TwoDimWriter::RenderResult(uint8_t* code,
int32_t codeWidth,
int32_t codeHeight,
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.h b/chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.h
index f5dcd61ff83..ba94c3269ff 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/BC_TwoDimWriter.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXBARCODE_BC_TWODIMWRITER_H_
#define XFA_FXBARCODE_BC_TWODIMWRITER_H_
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "xfa/fxbarcode/BC_Writer.h"
class CBC_CommonBitMatrix;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/BC_UtilCodingConvert.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/BC_UtilCodingConvert.cpp
index 8421e280f3b..73475751f6e 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/BC_UtilCodingConvert.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/BC_UtilCodingConvert.cpp
@@ -17,13 +17,13 @@ void CBC_UtilCodingConvert::UnicodeToLocale(const CFX_WideString& src,
void CBC_UtilCodingConvert::LocaleToUtf8(const CFX_ByteString& src,
CFX_ByteString& dst) {
- CFX_WideString unicode = CFX_WideString::FromLocal(src);
+ CFX_WideString unicode = CFX_WideString::FromLocal(src.AsStringC());
dst = unicode.UTF8Encode();
}
void CBC_UtilCodingConvert::LocaleToUtf8(const CFX_ByteString& src,
CFX_ByteArray& dst) {
- CFX_WideString unicode = CFX_WideString::FromLocal(src);
+ CFX_WideString unicode = CFX_WideString::FromLocal(src.AsStringC());
CFX_ByteString utf8 = unicode.UTF8Encode();
for (int32_t i = 0; i < utf8.GetLength(); i++) {
dst.Add(utf8[i]);
@@ -36,14 +36,15 @@ void CBC_UtilCodingConvert::Utf8ToLocale(const CFX_ByteArray& src,
for (int32_t i = 0; i < src.GetSize(); i++) {
utf8 += src[i];
}
- CFX_WideString unicode = CFX_WideString::FromUTF8(utf8, utf8.GetLength());
+ CFX_WideString unicode = CFX_WideString::FromUTF8(utf8.AsStringC());
dst = CFX_ByteString::FromUnicode(unicode);
}
void CBC_UtilCodingConvert::Utf8ToLocale(const uint8_t* src,
int32_t count,
CFX_ByteString& dst) {
- CFX_WideString unicode = CFX_WideString::FromUTF8((const char*)src, count);
+ CFX_WideString unicode =
+ CFX_WideString::FromUTF8(CFX_ByteStringC(src, count));
dst = CFX_ByteString::FromUnicode(unicode);
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/BC_Utils.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/BC_Utils.cpp
index 2225f7ce508..ccc620218ac 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/BC_Utils.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/BC_Utils.cpp
@@ -31,18 +31,3 @@ void BC_FX_ByteString_Append(CFX_ByteString& dst, const CFX_ByteArray& ba) {
dst += ba[i];
}
}
-void BC_FX_PtrArray_Sort(CFX_PtrArray& src, BC_PtrArrayCompareCallback fun) {
- int32_t nLength = src.GetSize();
- FX_BOOL changed = true;
- do {
- changed = false;
- for (int32_t i = 0; i < nLength - 1; i++) {
- if (fun(src[i + 1], src[i])) {
- void* temp = src[i];
- src.SetAt(i, src[i + 1]);
- src.SetAt(i + 1, temp);
- changed = true;
- }
- }
- } while (changed);
-}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/BC_Writer.h b/chromium/third_party/pdfium/xfa/fxbarcode/BC_Writer.h
index 0b7719a541c..9b5d037335f 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/BC_Writer.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/BC_Writer.h
@@ -8,7 +8,7 @@
#define XFA_FXBARCODE_BC_WRITER_H_
#include "core/fxcrt/include/fx_string.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/utils.h"
class CBC_Writer {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/DEPS b/chromium/third_party/pdfium/xfa/fxbarcode/DEPS
new file mode 100644
index 00000000000..4d9d2029e0a
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ '+core/fxcodec/include',
+ '+core/fxcodec/codec/include',
+]
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.cpp
index d0389040950..23cd2d1e7e0 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.cpp
@@ -77,21 +77,20 @@ FX_BOOL CBC_Codabar::Encode(const CFX_WideStringC& contents,
->Encode(byteString, format, outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderResult(filtercontents.AsWideStringC(), data, outWidth, isDevice,
- e);
+ ->RenderResult(filtercontents.AsStringC(), data, outWidth, isDevice, e);
FX_Free(data);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_Codabar::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
CFX_WideString renderCon =
((CBC_OnedCodaBarWriter*)m_pBCWriter)
- ->encodedContents(m_renderContents.AsWideStringC());
+ ->encodedContents(m_renderContents.AsStringC());
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderDeviceResult(device, matirx, renderCon.AsWideStringC(), e);
+ ->RenderDeviceResult(device, matrix, renderCon.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
@@ -99,16 +98,16 @@ FX_BOOL CBC_Codabar::RenderDevice(CFX_RenderDevice* device,
FX_BOOL CBC_Codabar::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
CFX_WideString renderCon =
((CBC_OnedCodaBarWriter*)m_pBCWriter)
- ->encodedContents(m_renderContents.AsWideStringC());
+ ->encodedContents(m_renderContents.AsStringC());
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderBitmapResult(pOutBitmap, renderCon.AsWideStringC(), e);
+ ->RenderBitmapResult(pOutBitmap, renderCon.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
CFX_WideString CBC_Codabar::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -119,6 +118,6 @@ CFX_WideString CBC_Codabar::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(str, str.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
+ return CFX_WideString::FromUTF8(str.AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.h
index bab39a84966..9684b584a14 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codabar.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_onecode.h"
class CBC_Codabar : public CBC_OneCode {
@@ -17,15 +17,19 @@ class CBC_Codabar : public CBC_OneCode {
CBC_Codabar();
~CBC_Codabar() override;
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e) override;
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e) override;
+ // CBC_OneCode:
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
-
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) override;
FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
-
BC_TYPE GetType() override { return BC_CODABAR; }
FX_BOOL SetStartChar(FX_CHAR start);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.cpp
index 2f7be931408..85d7afbbe8d 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.cpp
@@ -53,45 +53,44 @@ FX_BOOL CBC_Code128::Encode(const CFX_WideStringC& contents,
BCFORMAT format = BCFORMAT_CODE_128;
int32_t outWidth = 0;
int32_t outHeight = 0;
- CFX_WideString content = contents;
+ CFX_WideString content(contents);
if (contents.GetLength() % 2 &&
((CBC_OnedCode128Writer*)m_pBCWriter)->GetType() == BC_CODE128_C) {
content += '0';
}
CFX_WideString encodeContents = ((CBC_OnedCode128Writer*)m_pBCWriter)
- ->FilterContents(content.AsWideStringC());
+ ->FilterContents(content.AsStringC());
m_renderContents = encodeContents;
CFX_ByteString byteString = encodeContents.UTF8Encode();
uint8_t* data = static_cast<CBC_OnedCode128Writer*>(m_pBCWriter)
->Encode(byteString, format, outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderResult(encodeContents.AsWideStringC(), data, outWidth, isDevice,
- e);
+ ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e);
FX_Free(data);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_Code128::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderDeviceResult(device, matirx, m_renderContents.AsWideStringC(), e);
+ ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_Code128::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderBitmapResult(pOutBitmap, m_renderContents.AsWideStringC(), e);
+ ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
CFX_WideString CBC_Code128::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -102,6 +101,6 @@ CFX_WideString CBC_Code128::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(str, str.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
+ return CFX_WideString::FromUTF8(str.AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.h
index 33005b1dd3b..c5aa8e19b11 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code128.h
@@ -9,23 +9,27 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_onecode.h"
class CBC_Code128 : public CBC_OneCode {
public:
explicit CBC_Code128(BC_TYPE type);
- virtual ~CBC_Code128();
-
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e) override;
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e) override;
+ ~CBC_Code128() override;
+
+ // CBC_OneCode:
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
-
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) override;
FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
-
BC_TYPE GetType() override { return BC_CODE128; }
FX_BOOL SetTextLocation(BC_TEXT_LOC loction);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.cpp
index a590f7e39aa..5d00d772e4e 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.cpp
@@ -68,21 +68,20 @@ FX_BOOL CBC_Code39::Encode(const CFX_WideStringC& contents,
->Encode(byteString, format, outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderResult(renderContents.AsWideStringC(), data, outWidth, isDevice,
- e);
+ ->RenderResult(renderContents.AsStringC(), data, outWidth, isDevice, e);
FX_Free(data);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_Code39::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
CFX_WideString renderCon =
((CBC_OnedCode39Writer*)m_pBCWriter)
- ->encodedContents(m_renderContents.AsWideStringC(), e);
+ ->encodedContents(m_renderContents.AsStringC(), e);
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderDeviceResult(device, matirx, renderCon.AsWideStringC(), e);
+ ->RenderDeviceResult(device, matrix, renderCon.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
@@ -90,16 +89,16 @@ FX_BOOL CBC_Code39::RenderDevice(CFX_RenderDevice* device,
FX_BOOL CBC_Code39::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
CFX_WideString renderCon =
((CBC_OnedCode39Writer*)m_pBCWriter)
- ->encodedContents(m_renderContents.AsWideStringC(), e);
+ ->encodedContents(m_renderContents.AsStringC(), e);
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderBitmapResult(pOutBitmap, renderCon.AsWideStringC(), e);
+ ->RenderBitmapResult(pOutBitmap, renderCon.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
CFX_WideString CBC_Code39::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -110,8 +109,8 @@ CFX_WideString CBC_Code39::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(str, str.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
+ return CFX_WideString::FromUTF8(str.AsStringC());
}
FX_BOOL CBC_Code39::SetTextLocation(BC_TEXT_LOC location) {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.h
index c93b7d7d7c2..d6dad7df31e 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_code39.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_onecode.h"
class CBC_Code39 : public CBC_OneCode {
@@ -17,18 +17,23 @@ class CBC_Code39 : public CBC_OneCode {
CBC_Code39();
explicit CBC_Code39(FX_BOOL usingCheckDigit);
CBC_Code39(FX_BOOL usingCheckDigit, FX_BOOL extendedMode);
- virtual ~CBC_Code39();
-
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e);
- CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e);
-
+ ~CBC_Code39() override;
+
+ // CBC_OneCode:
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
+ CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e);
- FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
+ const CFX_Matrix* matrix,
+ int32_t& e) override;
+ FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
+ BC_TYPE GetType() override { return BC_CODE39; }
- BC_TYPE GetType() { return BC_CODE39; }
FX_BOOL SetTextLocation(BC_TEXT_LOC location);
FX_BOOL SetWideNarrowRatio(int32_t ratio);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codebase.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codebase.h
index 145b929c007..2124f75d788 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codebase.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_codebase.h
@@ -8,7 +8,7 @@
#define XFA_FXBARCODE_CBC_CODEBASE_H_
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/include/BC_Library.h"
class CBC_Writer;
@@ -26,12 +26,12 @@ class CBC_CodeBase {
FX_BOOL isDevice,
int32_t& e) = 0;
virtual FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) = 0;
virtual FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) = 0;
virtual CFX_WideString Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) = 0;
virtual CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) = 0;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.cpp
index d3e1a073a53..7430187f5b4 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.cpp
@@ -43,8 +43,9 @@ FX_BOOL CBC_DataMatrix::Encode(const CFX_WideStringC& contents,
int32_t& e) {
int32_t outWidth = 0;
int32_t outHeight = 0;
- uint8_t* data = ((CBC_DataMatrixWriter*)m_pBCWriter)
- ->Encode(contents, outWidth, outHeight, e);
+ uint8_t* data =
+ ((CBC_DataMatrixWriter*)m_pBCWriter)
+ ->Encode(CFX_WideString(contents), outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e);
FX_Free(data);
@@ -53,9 +54,9 @@ FX_BOOL CBC_DataMatrix::Encode(const CFX_WideStringC& contents,
}
FX_BOOL CBC_DataMatrix::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
- ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx);
+ ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matrix);
return TRUE;
}
@@ -67,7 +68,7 @@ FX_BOOL CBC_DataMatrix::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
CFX_WideString CBC_DataMatrix::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -78,6 +79,6 @@ CFX_WideString CBC_DataMatrix::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString retStr = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(retStr, retStr.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
+ return CFX_WideString::FromUTF8(retStr.AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.h
index ea1e1364775..7cd487567da 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_datamatrix.h
@@ -9,24 +9,28 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_codebase.h"
class CBC_DataMatrix : public CBC_CodeBase {
public:
CBC_DataMatrix();
- virtual ~CBC_DataMatrix();
-
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e);
- CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e);
-
+ ~CBC_DataMatrix() override;
+
+ // CBC_OneCode:
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
+ CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e);
- FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
-
- BC_TYPE GetType() { return BC_DATAMATRIX; }
+ const CFX_Matrix* matrix,
+ int32_t& e) override;
+ FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
+ BC_TYPE GetType() override { return BC_DATAMATRIX; }
};
#endif // XFA_FXBARCODE_CBC_DATAMATRIX_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.cpp
index 149c5a6a63c..ea67c9f64b7 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.cpp
@@ -74,32 +74,31 @@ FX_BOOL CBC_EAN13::Encode(const CFX_WideStringC& contents,
->Encode(byteString, format, outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderResult(encodeContents.AsWideStringC(), data, outWidth, isDevice,
- e);
+ ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e);
FX_Free(data);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_EAN13::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderDeviceResult(device, matirx, m_renderContents.AsWideStringC(), e);
+ ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_EAN13::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderBitmapResult(pOutBitmap, m_renderContents.AsWideStringC(), e);
+ ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
CFX_WideString CBC_EAN13::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -110,6 +109,6 @@ CFX_WideString CBC_EAN13::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(str, str.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
+ return CFX_WideString::FromUTF8(str.AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.h
index eaf95fe8abf..93abab27ff6 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean13.h
@@ -9,24 +9,28 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_onecode.h"
class CBC_EAN13 : public CBC_OneCode {
public:
CBC_EAN13();
- virtual ~CBC_EAN13();
-
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e);
- CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e);
-
+ ~CBC_EAN13() override;
+
+ // CBC_OneCode:
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
+ CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e);
- FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
-
- BC_TYPE GetType() { return BC_EAN13; }
+ const CFX_Matrix* matrix,
+ int32_t& e) override;
+ FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
+ BC_TYPE GetType() override { return BC_EAN13; }
private:
CFX_WideString Preprocess(const CFX_WideStringC& contents);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.cpp
index 12a821385b1..418ef87c1f4 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.cpp
@@ -73,32 +73,31 @@ FX_BOOL CBC_EAN8::Encode(const CFX_WideStringC& contents,
->Encode(byteString, format, outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderResult(encodeContents.AsWideStringC(), data, outWidth, isDevice,
- e);
+ ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e);
FX_Free(data);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_EAN8::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderDeviceResult(device, matirx, m_renderContents.AsWideStringC(), e);
+ ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_EAN8::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderBitmapResult(pOutBitmap, m_renderContents.AsWideStringC(), e);
+ ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
CFX_WideString CBC_EAN8::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -109,6 +108,6 @@ CFX_WideString CBC_EAN8::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(str, str.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
+ return CFX_WideString::FromUTF8(str.AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.h
index fd582deb137..d9cd0574da1 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_ean8.h
@@ -9,24 +9,28 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_onecode.h"
class CBC_EAN8 : public CBC_OneCode {
public:
CBC_EAN8();
- virtual ~CBC_EAN8();
-
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e);
- CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e);
-
+ ~CBC_EAN8() override;
+
+ // CBC_OneCode:
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
+ CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e);
- FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
-
- BC_TYPE GetType() { return BC_EAN8; }
+ const CFX_Matrix* matrix,
+ int32_t& e) override;
+ FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
+ BC_TYPE GetType() override { return BC_EAN8; }
private:
CFX_WideString Preprocess(const CFX_WideStringC& contents);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_onecode.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_onecode.h
index 7c32cf8606e..6e447cc772a 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_onecode.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_onecode.h
@@ -18,24 +18,7 @@ class CFX_RenderDevice;
class CBC_OneCode : public CBC_CodeBase {
public:
CBC_OneCode();
- virtual ~CBC_OneCode();
-
- virtual BC_TYPE GetType() = 0;
-
- virtual FX_BOOL Encode(const CFX_WideStringC& contents,
- FX_BOOL isDevice,
- int32_t& e) = 0;
- virtual CFX_WideString Decode(uint8_t* buf,
- int32_t width,
- int32_t hight,
- int32_t& e) = 0;
- virtual CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) = 0;
-
- virtual FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e) = 0;
- virtual FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) = 0;
-
+ ~CBC_OneCode() override;
virtual FX_BOOL CheckContentValidity(const CFX_WideStringC& contents);
virtual CFX_WideString FilterContents(const CFX_WideStringC& contents);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.cpp
index b27af1cefca..228caed47f8 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.cpp
@@ -51,8 +51,9 @@ FX_BOOL CBC_PDF417I::Encode(const CFX_WideStringC& contents,
int32_t& e) {
int32_t outWidth = 0;
int32_t outHeight = 0;
- uint8_t* data = ((CBC_PDF417Writer*)m_pBCWriter)
- ->Encode(contents, outWidth, outHeight, e);
+ uint8_t* data =
+ ((CBC_PDF417Writer*)m_pBCWriter)
+ ->Encode(CFX_WideString(contents), outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e);
FX_Free(data);
@@ -61,9 +62,9 @@ FX_BOOL CBC_PDF417I::Encode(const CFX_WideStringC& contents,
}
FX_BOOL CBC_PDF417I::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
- ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx);
+ ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matrix);
return TRUE;
}
@@ -75,7 +76,7 @@ FX_BOOL CBC_PDF417I::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
CFX_WideString CBC_PDF417I::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -86,6 +87,6 @@ CFX_WideString CBC_PDF417I::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString bytestring = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(bytestring, bytestring.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
+ return CFX_WideString::FromUTF8(bytestring.AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.h
index 9ad387cada6..0658ff7a53a 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_pdf417i.h
@@ -9,24 +9,28 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_codebase.h"
class CBC_PDF417I : public CBC_CodeBase {
public:
CBC_PDF417I();
- virtual ~CBC_PDF417I();
-
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e);
- CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e);
-
+ ~CBC_PDF417I() override;
+
+ // CBC_CodeBase::
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
+ CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e);
- FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
-
- BC_TYPE GetType() { return BC_PDF417; }
+ const CFX_Matrix* matrix,
+ int32_t& e) override;
+ FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
+ BC_TYPE GetType() override { return BC_PDF417; }
FX_BOOL SetErrorCorrectionLevel(int32_t level);
void SetTruncated(FX_BOOL truncated);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.cpp
index 45185949446..6f93b4415e0 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.cpp
@@ -59,10 +59,11 @@ FX_BOOL CBC_QRCode::Encode(const CFX_WideStringC& contents,
int32_t& e) {
int32_t outWidth = 0;
int32_t outHeight = 0;
- uint8_t* data = ((CBC_QRCodeWriter*)m_pBCWriter)
- ->Encode(contents, ((CBC_QRCodeWriter*)m_pBCWriter)
- ->GetErrorCorrectionLevel(),
- outWidth, outHeight, e);
+ uint8_t* data =
+ ((CBC_QRCodeWriter*)m_pBCWriter)
+ ->Encode(CFX_WideString(contents),
+ ((CBC_QRCodeWriter*)m_pBCWriter)->GetErrorCorrectionLevel(),
+ outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_TwoDimWriter*)m_pBCWriter)->RenderResult(data, outWidth, outHeight, e);
FX_Free(data);
@@ -71,9 +72,9 @@ FX_BOOL CBC_QRCode::Encode(const CFX_WideStringC& contents,
}
FX_BOOL CBC_QRCode::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
- ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matirx);
+ ((CBC_TwoDimWriter*)m_pBCWriter)->RenderDeviceResult(device, matrix);
return TRUE;
}
@@ -85,7 +86,7 @@ FX_BOOL CBC_QRCode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
CFX_WideString CBC_QRCode::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -96,6 +97,6 @@ CFX_WideString CBC_QRCode::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString retStr = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(retStr, retStr.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
+ return CFX_WideString::FromUTF8(retStr.AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.h
index ccf7d13beb9..4038164643a 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_qrcode.h
@@ -9,24 +9,28 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_codebase.h"
class CBC_QRCode : public CBC_CodeBase {
public:
CBC_QRCode();
- virtual ~CBC_QRCode();
-
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e);
- CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e);
-
+ ~CBC_QRCode() override;
+
+ // CBC_CodeBase:
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
+ CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e);
- FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
-
- BC_TYPE GetType() { return BC_QR_CODE; }
+ const CFX_Matrix* matrix,
+ int32_t& e) override;
+ FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
+ BC_TYPE GetType() override { return BC_QR_CODE; }
FX_BOOL SetVersion(int32_t version);
FX_BOOL SetErrorCorrectionLevel(int32_t level);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.cpp
index 79aa922e467..886525ab54b 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.cpp
@@ -76,32 +76,31 @@ FX_BOOL CBC_UPCA::Encode(const CFX_WideStringC& contents,
->Encode(byteString, format, outWidth, outHeight, e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderResult(encodeContents.AsWideStringC(), data, outWidth, isDevice,
- e);
+ ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e);
FX_Free(data);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_UPCA::RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
+ const CFX_Matrix* matrix,
int32_t& e) {
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderDeviceResult(device, matirx, m_renderContents.AsWideStringC(), e);
+ ->RenderDeviceResult(device, matrix, m_renderContents.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
FX_BOOL CBC_UPCA::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
((CBC_OneDimWriter*)m_pBCWriter)
- ->RenderBitmapResult(pOutBitmap, m_renderContents.AsWideStringC(), e);
+ ->RenderBitmapResult(pOutBitmap, m_renderContents.AsStringC(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
return TRUE;
}
CFX_WideString CBC_UPCA::Decode(uint8_t* buf,
int32_t width,
- int32_t hight,
+ int32_t height,
int32_t& e) {
CFX_WideString str;
return str;
@@ -112,6 +111,6 @@ CFX_WideString CBC_UPCA::Decode(CFX_DIBitmap* pBitmap, int32_t& e) {
CBC_GlobalHistogramBinarizer binarizer(&source);
CBC_BinaryBitmap bitmap(&binarizer);
CFX_ByteString str = m_pBCReader->Decode(&bitmap, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
- return CFX_WideString::FromUTF8(str, str.GetLength());
+ BC_EXCEPTION_CHECK_ReturnValue(e, L"");
+ return CFX_WideString::FromUTF8(str.AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.h b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.h
index 1a94cfac0e7..a2e0658f39e 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/cbc_upca.h
@@ -9,21 +9,28 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxbarcode/cbc_onecode.h"
class CBC_UPCA : public CBC_OneCode {
public:
CBC_UPCA();
- virtual ~CBC_UPCA();
- FX_BOOL Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e);
+ ~CBC_UPCA() override;
+
+ // CBC_OneCode:
+ FX_BOOL Encode(const CFX_WideStringC& contents,
+ FX_BOOL isDevice,
+ int32_t& e) override;
FX_BOOL RenderDevice(CFX_RenderDevice* device,
- const CFX_Matrix* matirx,
- int32_t& e);
- FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e);
- CFX_WideString Decode(uint8_t* buf, int32_t width, int32_t hight, int32_t& e);
- CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e);
- BC_TYPE GetType() { return BC_UPCA; }
+ const CFX_Matrix* matrix,
+ int32_t& e) override;
+ FX_BOOL RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) override;
+ CFX_WideString Decode(uint8_t* buf,
+ int32_t width,
+ int32_t height,
+ int32_t& e) override;
+ CFX_WideString Decode(CFX_DIBitmap* pBitmap, int32_t& e) override;
+ BC_TYPE GetType() override { return BC_UPCA; }
private:
CFX_WideString Preprocess(const CFX_WideStringC& contents);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp
index d28a88bfbce..45aff1cae11 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.cpp
@@ -44,7 +44,6 @@ void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes,
}
void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes,
const CFX_ByteString& text,
- const CFX_PtrArray& byteSegments,
const CFX_ByteString& ecLevel,
int32_t& e) {
if (text.IsEmpty()) {
@@ -53,7 +52,6 @@ void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes,
}
m_rawBytes.Copy(rawBytes);
m_text = text;
- m_pdf417byteSegments.Copy(byteSegments);
m_pdf417ecLevel = ecLevel;
m_other = NULL;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.h b/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.h
index 9dc4b66dced..cec74311196 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_CommonDecoderResult.h
@@ -27,7 +27,6 @@ class CBC_CommonDecoderResult {
int32_t& e);
virtual void Init(const CFX_ByteArray& rawBytes,
const CFX_ByteString& text,
- const CFX_PtrArray& byteSegments,
const CFX_ByteString& ecLevel,
int32_t& e);
void setOther(CBC_PDF417ResultMetadata* other);
@@ -36,7 +35,6 @@ class CBC_CommonDecoderResult {
CFX_ByteArray m_rawBytes;
CFX_ByteString m_text;
CFX_Int32Array m_byteSegments;
- CFX_PtrArray m_pdf417byteSegments;
CBC_QRCoderErrorCorrectionLevel* m_ecLevel;
CFX_ByteString m_pdf417ecLevel;
CBC_PDF417ResultMetadata* m_other;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
index 2aeacd13991..f64abb61c08 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.cpp
@@ -59,8 +59,11 @@ CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector(
m_upInit = y - halfsize;
m_downInit = y + halfsize;
}
+
CBC_WhiteRectangleDetector::~CBC_WhiteRectangleDetector() {}
-CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
+
+CFX_ArrayTemplate<CBC_ResultPoint*>* CBC_WhiteRectangleDetector::Detect(
+ int32_t& e) {
int32_t left = m_leftInit;
int32_t right = m_rightInit;
int32_t up = m_upInit;
@@ -131,9 +134,9 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
if (z)
break;
}
- if (z.get() == NULL) {
+ if (!z.get()) {
e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ResultPoint> t;
for (int32_t j = 1; j < maxSize; j++) {
@@ -142,9 +145,9 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
if (t)
break;
}
- if (t.get() == NULL) {
+ if (!t.get()) {
e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ResultPoint> x;
for (int32_t k = 1; k < maxSize; k++) {
@@ -153,9 +156,9 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
if (x)
break;
}
- if (x.get() == NULL) {
+ if (!x.get()) {
e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ResultPoint> y;
for (int32_t m = 1; m < maxSize; m++) {
@@ -164,17 +167,18 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
if (y)
break;
}
- if (y.get() == NULL) {
+ if (!y.get()) {
e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
return CenterEdges(y.get(), z.get(), x.get(), t.get());
- } else {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- return NULL;
+
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ return nullptr;
}
+
int32_t CBC_WhiteRectangleDetector::Round(FX_FLOAT d) {
return (int32_t)(d + 0.5f);
}
@@ -203,10 +207,16 @@ int32_t CBC_WhiteRectangleDetector::DistanceL2(FX_FLOAT aX,
float yDiff = aY - bY;
return Round((float)sqrt(xDiff * xDiff + yDiff * yDiff));
}
-CFX_PtrArray* CBC_WhiteRectangleDetector::CenterEdges(CBC_ResultPoint* y,
- CBC_ResultPoint* z,
- CBC_ResultPoint* x,
- CBC_ResultPoint* t) {
+
+CFX_ArrayTemplate<CBC_ResultPoint*>* CBC_WhiteRectangleDetector::CenterEdges(
+ CBC_ResultPoint* y,
+ CBC_ResultPoint* z,
+ CBC_ResultPoint* x,
+ CBC_ResultPoint* t) const {
+ CFX_ArrayTemplate<CBC_ResultPoint*>* result =
+ new CFX_ArrayTemplate<CBC_ResultPoint*>();
+ result->SetSize(4);
+
float yi = y->GetX();
float yj = y->GetY();
float zi = z->GetX();
@@ -215,24 +225,22 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::CenterEdges(CBC_ResultPoint* y,
float xj = x->GetY();
float ti = t->GetX();
float tj = t->GetY();
+
if (yi < m_width / 2) {
- CFX_PtrArray* result = new CFX_PtrArray;
- result->SetSize(4);
(*result)[0] = new CBC_ResultPoint(ti - CORR, tj + CORR);
(*result)[1] = new CBC_ResultPoint(zi + CORR, zj + CORR);
(*result)[2] = new CBC_ResultPoint(xi - CORR, xj - CORR);
(*result)[3] = new CBC_ResultPoint(yi + CORR, yj - CORR);
return result;
- } else {
- CFX_PtrArray* result = new CFX_PtrArray;
- result->SetSize(4);
- (*result)[0] = new CBC_ResultPoint(ti + CORR, tj + CORR);
- (*result)[1] = new CBC_ResultPoint(zi + CORR, zj - CORR);
- (*result)[2] = new CBC_ResultPoint(xi - CORR, xj + CORR);
- (*result)[3] = new CBC_ResultPoint(yi - CORR, yj - CORR);
- return result;
}
+
+ (*result)[0] = new CBC_ResultPoint(ti + CORR, tj + CORR);
+ (*result)[1] = new CBC_ResultPoint(zi + CORR, zj - CORR);
+ (*result)[2] = new CBC_ResultPoint(xi - CORR, xj + CORR);
+ (*result)[3] = new CBC_ResultPoint(yi - CORR, yj - CORR);
+ return result;
}
+
FX_BOOL CBC_WhiteRectangleDetector::ContainsBlackPoint(int32_t a,
int32_t b,
int32_t fixed,
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h b/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h
index d713d0fa991..f3ac77a9c04 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/BC_WhiteRectangleDetector.h
@@ -20,9 +20,10 @@ class CBC_WhiteRectangleDetector {
int32_t x,
int32_t y);
virtual ~CBC_WhiteRectangleDetector();
- CFX_PtrArray* Detect(int32_t& e);
virtual void Init(int32_t& e);
+ CFX_ArrayTemplate<CBC_ResultPoint*>* Detect(int32_t& e);
+
private:
int32_t Round(float d);
CBC_ResultPoint* GetBlackPointOnSegment(FX_FLOAT aX,
@@ -30,10 +31,11 @@ class CBC_WhiteRectangleDetector {
FX_FLOAT bX,
FX_FLOAT bY);
int32_t DistanceL2(FX_FLOAT aX, FX_FLOAT aY, FX_FLOAT bX, FX_FLOAT bY);
- CFX_PtrArray* CenterEdges(CBC_ResultPoint* y,
- CBC_ResultPoint* z,
- CBC_ResultPoint* x,
- CBC_ResultPoint* t);
+ CFX_ArrayTemplate<CBC_ResultPoint*>* CenterEdges(CBC_ResultPoint* y,
+ CBC_ResultPoint* z,
+ CBC_ResultPoint* x,
+ CBC_ResultPoint* t) const;
+
FX_BOOL ContainsBlackPoint(int32_t a,
int32_t b,
int32_t fixed,
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
index 4d986cca263..40e5fa6625a 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -37,8 +37,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree,
int32_t& e) {
if (degree >= m_cachedGenerators.GetSize()) {
CBC_ReedSolomonGF256Poly* lastGenerator =
- (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators
- [m_cachedGenerators.GetSize() - 1]);
+ m_cachedGenerators[m_cachedGenerators.GetSize() - 1];
for (int32_t d = m_cachedGenerators.GetSize(); d <= degree; d++) {
CFX_Int32Array temp;
temp.Add(1);
@@ -53,7 +52,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree,
lastGenerator = nextGenerator;
}
}
- return (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators[degree]);
+ return m_cachedGenerators[degree];
}
void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
int32_t ecBytes,
@@ -80,10 +79,10 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
std::unique_ptr<CBC_ReedSolomonGF256Poly> infoTemp(
info.MultiplyByMonomial(ecBytes, 1, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- std::unique_ptr<CFX_PtrArray> temp(infoTemp->Divide(generator, e));
+ std::unique_ptr<CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>> temp(
+ infoTemp->Divide(generator, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_ReedSolomonGF256Poly* remainder =
- (CBC_ReedSolomonGF256Poly*)(temp->operator[](1));
+ CBC_ReedSolomonGF256Poly* remainder = (*temp)[1];
CFX_Int32Array* coefficients = remainder->GetCoefficients();
int32_t numZeroCoefficients = ecBytes - coefficients->GetSize();
for (int32_t i = 0; i < numZeroCoefficients; i++) {
@@ -94,11 +93,10 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
coefficients->operator[](y);
}
for (int32_t k = 0; k < temp->GetSize(); k++) {
- delete (CBC_ReedSolomonGF256Poly*)(*temp)[k];
+ delete (*temp)[k];
}
}
CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() {
- for (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++) {
- delete (CBC_ReedSolomonGF256Poly*)m_cachedGenerators[i];
- }
+ for (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++)
+ delete m_cachedGenerators[i];
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
index 0dfa37ddb79..695da46c79e 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
@@ -13,17 +13,18 @@ class CBC_ReedSolomonGF256;
class CBC_ReedSolomonGF256Poly;
class CBC_ReedSolomonEncoder {
- private:
- CBC_ReedSolomonGF256* m_field;
- CFX_PtrArray m_cachedGenerators;
- CBC_ReedSolomonGF256Poly* BuildGenerator(int32_t degree, int32_t& e);
-
public:
CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field);
virtual ~CBC_ReedSolomonEncoder();
void Encode(CFX_Int32Array* toEncode, int32_t ecBytes, int32_t& e);
virtual void Init();
+
+ private:
+ CBC_ReedSolomonGF256Poly* BuildGenerator(int32_t degree, int32_t& e);
+
+ CBC_ReedSolomonGF256* m_field;
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*> m_cachedGenerators;
};
#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
index ff91c9ddc3e..81abd563706 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
@@ -58,13 +58,11 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received,
std::unique_ptr<CBC_ReedSolomonGF256Poly> temp(
m_field->BuildMonomial(twoS, 1, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- std::unique_ptr<CFX_PtrArray> sigmaOmega(
+ std::unique_ptr<CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>> sigmaOmega(
RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(
- (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]);
- std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(
- (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma((*sigmaOmega)[0]);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> omega((*sigmaOmega)[1]);
std::unique_ptr<CFX_Int32Array> errorLocations(
FindErrorLocations(sigma.get(), e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
@@ -83,28 +81,29 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received,
(*received)[position], (*errorMagnitudes)[k]);
}
}
-CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
- CBC_ReedSolomonGF256Poly* a,
- CBC_ReedSolomonGF256Poly* b,
- int32_t R,
- int32_t& e) {
+
+CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>*
+CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a,
+ CBC_ReedSolomonGF256Poly* b,
+ int32_t R,
+ int32_t& e) {
if (a->GetDegree() < b->GetDegree()) {
CBC_ReedSolomonGF256Poly* temp = a;
a = b;
b = temp;
}
std::unique_ptr<CBC_ReedSolomonGF256Poly> rLast(a->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> r(b->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> sLast(m_field->GetOne()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> s(m_field->GetZero()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> tLast(m_field->GetZero()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> t(m_field->GetOne()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
while (r->GetDegree() >= R / 2) {
std::unique_ptr<CBC_ReedSolomonGF256Poly> rLastLast = std::move(rLast);
std::unique_ptr<CBC_ReedSolomonGF256Poly> sLastLast = std::move(sLast);
@@ -114,53 +113,54 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
tLast = std::move(t);
if (rLast->IsZero()) {
e = BCExceptionR_I_1IsZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
r.reset(rLastLast->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> q(m_field->GetZero()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree());
int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
while (r->GetDegree() >= rLast->GetDegree() && !(r->IsZero())) {
int32_t degreeDiff = r->GetDegree() - rLast->GetDegree();
int32_t scale =
m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse);
std::unique_ptr<CBC_ReedSolomonGF256Poly> build(
m_field->BuildMonomial(degreeDiff, scale, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
q.reset(q->AddOrSubtract(build.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> multiply(
rLast->MultiplyByMonomial(degreeDiff, scale, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
r.reset(r->AddOrSubtract(multiply.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ReedSolomonGF256Poly> temp1(
q->Multiply(sLast.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
s.reset(temp1->AddOrSubtract(sLastLast.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> temp5(
q->Multiply(tLast.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
t.reset(temp5->AddOrSubtract(tLastlast.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
int32_t sigmaTildeAtZero = t->GetCoefficients(0);
if (sigmaTildeAtZero == 0) {
e = BCExceptionIsZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(t->Multiply(inverse, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(r->Multiply(inverse, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* temp = new CFX_PtrArray;
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* temp =
+ new CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>();
temp->Add(sigma.release());
temp->Add(omega.release());
return temp;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
index f44f92072e4..d42af6a27af 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
@@ -13,23 +13,25 @@ class CBC_ReedSolomonGF256;
class CBC_ReedSolomonGF256Poly;
class CBC_ReedSolomonDecoder {
- private:
- CBC_ReedSolomonGF256* m_field;
-
public:
CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field);
virtual ~CBC_ReedSolomonDecoder();
+
void Decode(CFX_Int32Array* received, int32_t twoS, int32_t& e);
- CFX_PtrArray* RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a,
- CBC_ReedSolomonGF256Poly* b,
- int32_t R,
- int32_t& e);
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* RunEuclideanAlgorithm(
+ CBC_ReedSolomonGF256Poly* a,
+ CBC_ReedSolomonGF256Poly* b,
+ int32_t R,
+ int32_t& e);
CFX_Int32Array* FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator,
int32_t& e);
CFX_Int32Array* FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator,
CFX_Int32Array* errorLocations,
FX_BOOL dataMatrix,
int32_t& e);
+
+ private:
+ CBC_ReedSolomonGF256* m_field;
};
#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONDECODER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
index 5e9fd33ac40..33771418d45 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -31,16 +31,14 @@ void CBC_ReedSolomonGF256::Initialize() {
DataMatrixField = new CBC_ReedSolomonGF256(0x012D);
DataMatrixField->Init();
}
+
void CBC_ReedSolomonGF256::Finalize() {
- if (QRCodeFild) {
- delete QRCodeFild;
- }
- QRCodeFild = NULL;
- if (DataMatrixField) {
- delete DataMatrixField;
- }
- DataMatrixField = NULL;
+ delete QRCodeFild;
+ QRCodeFild = nullptr;
+ delete DataMatrixField;
+ DataMatrixField = nullptr;
}
+
CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive) {
int32_t x = 1;
for (int32_t j = 0; j < 256; j++) {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index ee22390df65..b3c4326ed6b 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -213,21 +213,23 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
}
-CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other,
- int32_t& e) {
+
+CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide(
+ CBC_ReedSolomonGF256Poly* other,
+ int32_t& e) {
if (other->IsZero()) {
e = BCExceptionDivideByZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient(
m_field->GetZero()->Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree());
int32_t inverseDenominatorLeadingTeam =
m_field->Inverse(denominatorLeadingTerm, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) {
int32_t degreeDifference = remainder->GetDegree() - other->GetDegree();
int32_t scale =
@@ -235,20 +237,22 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other,
inverseDenominatorLeadingTeam);
std::unique_ptr<CBC_ReedSolomonGF256Poly> term(
other->MultiplyByMonomial(degreeDifference, scale, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient(
m_field->BuildMonomial(degreeDifference, scale, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
remainder.reset(remainder->AddOrSubtract(term.get(), e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
- CFX_PtrArray* tempPtrA = new CFX_PtrArray;
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* tempPtrA =
+ new CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>();
tempPtrA->Add(quotient.release());
tempPtrA->Add(remainder.release());
return tempPtrA;
}
+
CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() {
m_coefficients.RemoveAll();
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
index aa549efe60e..03580c23509 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
@@ -11,11 +11,15 @@
class CBC_ReedSolomonGF256;
-class CBC_ReedSolomonGF256Poly {
+class CBC_ReedSolomonGF256Poly final {
public:
CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients);
CBC_ReedSolomonGF256Poly();
- virtual ~CBC_ReedSolomonGF256Poly();
+ ~CBC_ReedSolomonGF256Poly();
+ void Init(CBC_ReedSolomonGF256* field,
+ CFX_Int32Array* coefficients,
+ int32_t& e);
+
int32_t GetCoefficients(int32_t degree);
CFX_Int32Array* GetCoefficients();
int32_t GetDegree();
@@ -29,11 +33,11 @@ class CBC_ReedSolomonGF256Poly {
CBC_ReedSolomonGF256Poly* MultiplyByMonomial(int32_t degree,
int32_t coefficient,
int32_t& e);
- CFX_PtrArray* Divide(CBC_ReedSolomonGF256Poly* other, int32_t& e);
+ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* Divide(
+ CBC_ReedSolomonGF256Poly* other,
+ int32_t& e);
+
CBC_ReedSolomonGF256Poly* Clone(int32_t& e);
- virtual void Init(CBC_ReedSolomonGF256* field,
- CFX_Int32Array* coefficients,
- int32_t& e);
private:
CBC_ReedSolomonGF256* m_field;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
index 89c09c22a88..6b7680d1a8d 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp
@@ -33,18 +33,19 @@ CBC_DataMatrixDataBlock::CBC_DataMatrixDataBlock(int32_t numDataCodewords,
m_codewords.Copy(*codewords);
m_numDataCodewords = numDataCodewords;
}
-CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
- CFX_ByteArray* rawCodewords,
- CBC_DataMatrixVersion* version,
- int32_t& e) {
+CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>*
+CBC_DataMatrixDataBlock::GetDataBlocks(CFX_ByteArray* rawCodewords,
+ CBC_DataMatrixVersion* version,
+ int32_t& e) {
ECBlocks* ecBlocks = version->GetECBlocks();
int32_t totalBlocks = 0;
- const CFX_PtrArray& ecBlockArray = ecBlocks->GetECBlocks();
+ const CFX_ArrayTemplate<ECB*>& ecBlockArray = ecBlocks->GetECBlocks();
int32_t i;
for (i = 0; i < ecBlockArray.GetSize(); i++) {
- totalBlocks += ((ECB*)ecBlockArray[i])->GetCount();
+ totalBlocks += ecBlockArray[i]->GetCount();
}
- std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray());
+ std::unique_ptr<CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>> result(
+ new CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>());
result->SetSize(totalBlocks);
int32_t numResultBlocks = 0;
int32_t j;
@@ -59,8 +60,7 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
codewords.SetSize(0);
}
}
- int32_t longerBlocksTotalCodewords =
- ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->GetSize();
+ int32_t longerBlocksTotalCodewords = (*result)[0]->GetCodewords()->GetSize();
int32_t longerBlocksNumDataCodewords =
longerBlocksTotalCodewords - ecBlocks->GetECCodewords();
int32_t shorterBlocksNumDataCodewords = longerBlocksNumDataCodewords - 1;
@@ -69,10 +69,8 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
int32_t j;
for (j = 0; j < numResultBlocks; j++) {
if (rawCodewordsOffset < rawCodewords->GetSize()) {
- ((CBC_DataMatrixDataBlock*)(*result)[j])
- ->GetCodewords()
- ->
- operator[](i) = (*rawCodewords)[rawCodewordsOffset++];
+ (*result)[j]->GetCodewords()->operator[](i) =
+ (*rawCodewords)[rawCodewordsOffset++];
}
}
}
@@ -80,24 +78,19 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks(
int32_t numLongerBlocks = specialVersion ? 8 : numResultBlocks;
for (j = 0; j < numLongerBlocks; j++) {
if (rawCodewordsOffset < rawCodewords->GetSize()) {
- ((CBC_DataMatrixDataBlock*)(*result)[j])
- ->GetCodewords()
- ->
- operator[](longerBlocksNumDataCodewords - 1) =
+ (*result)[j]->GetCodewords()->operator[](longerBlocksNumDataCodewords -
+ 1) =
(*rawCodewords)[rawCodewordsOffset++];
}
}
- int32_t max =
- ((CBC_DataMatrixDataBlock*)(*result)[0])->GetCodewords()->GetSize();
+ int32_t max = (*result)[0]->GetCodewords()->GetSize();
for (i = longerBlocksNumDataCodewords; i < max; i++) {
int32_t j;
for (j = 0; j < numResultBlocks; j++) {
int32_t iOffset = specialVersion && j > 7 ? i - 1 : i;
if (rawCodewordsOffset < rawCodewords->GetSize()) {
- ((CBC_DataMatrixDataBlock*)(*result)[j])
- ->GetCodewords()
- ->
- operator[](iOffset) = (*rawCodewords)[rawCodewordsOffset++];
+ (*result)[j]->GetCodewords()->operator[](iOffset) =
+ (*rawCodewords)[rawCodewordsOffset++];
}
}
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h
index 039255268fb..782e5ed3190 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h
@@ -11,22 +11,23 @@
class CBC_DataMatrixVersion;
-class CBC_DataMatrixDataBlock {
+class CBC_DataMatrixDataBlock final {
public:
- virtual ~CBC_DataMatrixDataBlock();
+ ~CBC_DataMatrixDataBlock();
int32_t GetNumDataCodewords();
CFX_ByteArray* GetCodewords();
- static CFX_PtrArray* GetDataBlocks(CFX_ByteArray* rawCodewords,
- CBC_DataMatrixVersion* version,
- int32_t& e);
+ static CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>* GetDataBlocks(
+ CFX_ByteArray* rawCodewords,
+ CBC_DataMatrixVersion* version,
+ int32_t& e);
private:
+ CBC_DataMatrixDataBlock(int32_t numDataCodewords, CFX_ByteArray* codewords);
+
int32_t m_numDataCodewords;
CFX_ByteArray m_codewords;
-
- CBC_DataMatrixDataBlock(int32_t numDataCodewords, CFX_ByteArray* codewords);
};
#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDATABLOCK_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp
index 693b6b92097..53c5a846564 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.cpp
@@ -36,9 +36,9 @@ const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::TEXT_BASIC_SET_CHARS[] = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const FX_CHAR CBC_DataMatrixDecodedBitStreamParser::TEXT_SHIFT3_SET_CHARS[] = {
- '\'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
- 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
- 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (FX_CHAR)127};
+ '\'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
+ 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', 127};
const int32_t CBC_DataMatrixDecodedBitStreamParser::PAD_ENCODE = 0;
const int32_t CBC_DataMatrixDecodedBitStreamParser::ASCII_ENCODE = 1;
const int32_t CBC_DataMatrixDecodedBitStreamParser::C40_ENCODE = 2;
@@ -48,6 +48,7 @@ const int32_t CBC_DataMatrixDecodedBitStreamParser::EDIFACT_ENCODE = 5;
const int32_t CBC_DataMatrixDecodedBitStreamParser::BASE256_ENCODE = 6;
CBC_DataMatrixDecodedBitStreamParser::CBC_DataMatrixDecodedBitStreamParser() {}
CBC_DataMatrixDecodedBitStreamParser::~CBC_DataMatrixDecodedBitStreamParser() {}
+
CBC_CommonDecoderResult* CBC_DataMatrixDecodedBitStreamParser::Decode(
CFX_ByteArray& bytes,
int32_t& e) {
@@ -59,32 +60,32 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecodedBitStreamParser::Decode(
do {
if (mode == 1) {
mode = DecodeAsciiSegment(&bits, result, resultTrailer, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
} else {
switch (mode) {
case 2:
DecodeC40Segment(&bits, result, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
break;
case 3:
DecodeTextSegment(&bits, result, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
break;
case 4:
DecodeAnsiX12Segment(&bits, result, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
break;
case 5:
DecodeEdifactSegment(&bits, result, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
break;
case 6:
DecodeBase256Segment(&bits, result, byteSegments, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
break;
default:
e = BCExceptionFormatException;
- return NULL;
+ return nullptr;
}
mode = ASCII_ENCODE;
}
@@ -93,12 +94,11 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecodedBitStreamParser::Decode(
result += resultTrailer;
}
CBC_CommonDecoderResult* tempCp = new CBC_CommonDecoderResult();
- tempCp->Init(bytes, result,
- (byteSegments.GetSize() <= 0) ? CFX_Int32Array() : byteSegments,
- NULL, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ tempCp->Init(bytes, result, byteSegments, nullptr, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return tempCp;
}
+
int32_t CBC_DataMatrixDecodedBitStreamParser::DecodeAsciiSegment(
CBC_CommonBitSource* bits,
CFX_ByteString& result,
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
index 3f765aa8f96..4276066444a 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
@@ -42,40 +42,37 @@ void CBC_DataMatrixDecoder::Init() {
CBC_DataMatrixDecoder::~CBC_DataMatrixDecoder() {
delete m_rsDecoder;
}
+
CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode(
CBC_CommonBitMatrix* bits,
int32_t& e) {
CBC_DataMatrixBitMatrixParser parser;
parser.Init(bits, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
CBC_DataMatrixVersion* version = parser.GetVersion();
std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* dataBlocks =
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>* dataBlocks =
CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
int32_t dataBlocksCount = dataBlocks->GetSize();
int32_t totalBytes = 0;
int32_t i, j;
for (i = 0; i < dataBlocksCount; i++) {
- totalBytes +=
- ((CBC_DataMatrixDataBlock*)(*dataBlocks)[i])->GetNumDataCodewords();
+ totalBytes += (*dataBlocks)[i]->GetNumDataCodewords();
}
CFX_ByteArray resultBytes;
resultBytes.SetSize(totalBytes);
for (j = 0; j < dataBlocksCount; j++) {
- CFX_ByteArray* codewordBytes =
- ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetCodewords();
- int32_t numDataCodewords =
- ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetNumDataCodewords();
+ CFX_ByteArray* codewordBytes = (*dataBlocks)[j]->GetCodewords();
+ int32_t numDataCodewords = (*dataBlocks)[j]->GetNumDataCodewords();
CorrectErrors(*codewordBytes, numDataCodewords, e);
if (e != BCExceptionNO) {
for (int32_t i = 0; i < dataBlocks->GetSize(); i++) {
- delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i];
+ delete (*dataBlocks)[i];
}
delete dataBlocks;
- dataBlocks = NULL;
- return NULL;
+ return nullptr;
}
int32_t i;
for (i = 0; i < numDataCodewords; i++) {
@@ -83,15 +80,15 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode(
}
}
for (i = 0; i < (dataBlocks->GetSize()); i++) {
- delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i];
+ delete (*dataBlocks)[i];
}
delete dataBlocks;
- dataBlocks = NULL;
CBC_CommonDecoderResult* resultR =
CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return resultR;
}
+
void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes,
int32_t numDataCodewords,
int32_t& e) {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp
index fd410097ccc..a4ca4e228c8 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp
@@ -35,7 +35,7 @@
const int32_t CBC_DataMatrixDetector::INTEGERS[5] = {0, 1, 2, 3, 4};
CBC_DataMatrixDetector::CBC_DataMatrixDetector(CBC_CommonBitMatrix* image)
- : m_image(image), m_rectangleDetector(NULL) {}
+ : m_image(image), m_rectangleDetector(nullptr) {}
void CBC_DataMatrixDetector::Init(int32_t& e) {
m_rectangleDetector = new CBC_WhiteRectangleDetector(m_image);
m_rectangleDetector->Init(e);
@@ -44,42 +44,44 @@ void CBC_DataMatrixDetector::Init(int32_t& e) {
CBC_DataMatrixDetector::~CBC_DataMatrixDetector() {
delete m_rectangleDetector;
}
-inline FX_BOOL ResultPointsAndTransitionsComparator(void* a, void* b) {
- return ((CBC_ResultPointsAndTransitions*)b)->GetTransitions() >
- ((CBC_ResultPointsAndTransitions*)a)->GetTransitions();
-}
+
CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) {
- CFX_PtrArray* cornerPoints = m_rectangleDetector->Detect(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_ResultPoint* pointA = (CBC_ResultPoint*)(*cornerPoints)[0];
- CBC_ResultPoint* pointB = (CBC_ResultPoint*)(*cornerPoints)[1];
- CBC_ResultPoint* pointC = (CBC_ResultPoint*)(*cornerPoints)[2];
- CBC_ResultPoint* pointD = (CBC_ResultPoint*)(*cornerPoints)[3];
+ CFX_ArrayTemplate<CBC_ResultPoint*>* cornerPoints =
+ m_rectangleDetector->Detect(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ CBC_ResultPoint* pointA = (*cornerPoints)[0];
+ CBC_ResultPoint* pointB = (*cornerPoints)[1];
+ CBC_ResultPoint* pointC = (*cornerPoints)[2];
+ CBC_ResultPoint* pointD = (*cornerPoints)[3];
delete cornerPoints;
- cornerPoints = NULL;
- CFX_PtrArray transitions;
+
+ CFX_ArrayTemplate<CBC_ResultPointsAndTransitions*> transitions;
transitions.Add(TransitionsBetween(pointA, pointB));
transitions.Add(TransitionsBetween(pointA, pointC));
transitions.Add(TransitionsBetween(pointB, pointD));
transitions.Add(TransitionsBetween(pointC, pointD));
- BC_FX_PtrArray_Sort(transitions, &ResultPointsAndTransitionsComparator);
- delete ((CBC_ResultPointsAndTransitions*)transitions[2]);
- delete ((CBC_ResultPointsAndTransitions*)transitions[3]);
- CBC_ResultPointsAndTransitions* lSideOne =
- (CBC_ResultPointsAndTransitions*)transitions[0];
- CBC_ResultPointsAndTransitions* lSideTwo =
- (CBC_ResultPointsAndTransitions*)transitions[1];
+ std::sort(transitions.GetData(),
+ transitions.GetData() + transitions.GetSize(),
+ [](const CBC_ResultPointsAndTransitions* a,
+ const CBC_ResultPointsAndTransitions* b) {
+ return a->GetTransitions() < b->GetTransitions();
+ });
+ delete transitions[2];
+ delete transitions[3];
+
+ CBC_ResultPointsAndTransitions* lSideOne = transitions[0];
+ CBC_ResultPointsAndTransitions* lSideTwo = transitions[1];
CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t> pointCount;
Increment(pointCount, lSideOne->GetFrom());
Increment(pointCount, lSideOne->GetTo());
Increment(pointCount, lSideTwo->GetFrom());
Increment(pointCount, lSideTwo->GetTo());
- delete ((CBC_ResultPointsAndTransitions*)transitions[1]);
- delete ((CBC_ResultPointsAndTransitions*)transitions[0]);
+ delete transitions[1];
+ delete transitions[0];
transitions.RemoveAll();
- CBC_ResultPoint* maybeTopLeft = NULL;
- CBC_ResultPoint* bottomLeft = NULL;
- CBC_ResultPoint* maybeBottomRight = NULL;
+ CBC_ResultPoint* maybeTopLeft = nullptr;
+ CBC_ResultPoint* bottomLeft = nullptr;
+ CBC_ResultPoint* maybeBottomRight = nullptr;
FX_POSITION itBegin = pointCount.GetStartPosition();
while (itBegin) {
CBC_ResultPoint* key = 0;
@@ -88,31 +90,31 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) {
if (value == 2) {
bottomLeft = key;
} else {
- if (maybeBottomRight == NULL) {
- maybeBottomRight = key;
- } else {
+ if (maybeBottomRight) {
maybeTopLeft = key;
+ } else {
+ maybeBottomRight = key;
}
}
}
- if (maybeTopLeft == NULL || bottomLeft == NULL || maybeBottomRight == NULL) {
+ if (!maybeTopLeft || !bottomLeft || !maybeBottomRight) {
delete pointA;
delete pointB;
delete pointC;
delete pointD;
e = BCExceptionNotFound;
- return NULL;
+ return nullptr;
}
- CFX_PtrArray corners;
+ CFX_ArrayTemplate<CBC_ResultPoint*> corners;
corners.SetSize(3);
corners[0] = maybeTopLeft;
corners[1] = bottomLeft;
corners[2] = maybeBottomRight;
OrderBestPatterns(&corners);
- CBC_ResultPoint* bottomRight = (CBC_ResultPoint*)corners[0];
- bottomLeft = (CBC_ResultPoint*)corners[1];
- CBC_ResultPoint* topLeft = (CBC_ResultPoint*)corners[2];
- CBC_ResultPoint* topRight = NULL;
+ CBC_ResultPoint* bottomRight = corners[0];
+ bottomLeft = corners[1];
+ CBC_ResultPoint* topLeft = corners[2];
+ CBC_ResultPoint* topRight = nullptr;
int32_t value;
if (!pointCount.Lookup(pointA, value)) {
topRight = pointA;
@@ -144,11 +146,11 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) {
correctedTopRight.reset(
CorrectTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight,
dimensionTop, dimensionRight));
- if (correctedTopRight.get() == NULL) {
+ if (!correctedTopRight.get()) {
correctedTopRight.reset(topRight);
} else {
delete topRight;
- topRight = NULL;
+ topRight = nullptr;
}
dimensionTop = std::unique_ptr<CBC_ResultPointsAndTransitions>(
TransitionsBetween(topLeft, correctedTopRight.get()))
@@ -166,16 +168,16 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) {
bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight,
correctedTopRight.get(), dimensionTop, dimensionRight,
e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
} else {
int32_t dimension = std::min(dimensionRight, dimensionTop);
correctedTopRight.reset(
CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension));
- if (correctedTopRight.get() == NULL) {
+ if (!correctedTopRight.get()) {
correctedTopRight.reset(topRight);
} else {
delete topRight;
- topRight = NULL;
+ topRight = nullptr;
}
int32_t dimensionCorrected =
std::max(std::unique_ptr<CBC_ResultPointsAndTransitions>(
@@ -191,9 +193,10 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) {
bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight,
correctedTopRight.get(), dimensionCorrected,
dimensionCorrected, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
- CFX_PtrArray* result = new CFX_PtrArray;
+ CFX_ArrayTemplate<CBC_ResultPoint*>* result =
+ new CFX_ArrayTemplate<CBC_ResultPoint*>();
result->SetSize(4);
result->Add(topLeft);
result->Add(bottomLeft);
@@ -224,7 +227,7 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRightRectangular(
if (IsValid(c2.get())) {
return c2.release();
}
- return NULL;
+ return nullptr;
} else if (!IsValid(c2.get())) {
return c1.release();
}
@@ -271,7 +274,7 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRight(
if (IsValid(c2.get())) {
return c2.release();
}
- return NULL;
+ return nullptr;
} else if (!IsValid(c2.get())) {
return c1.release();
}
@@ -328,7 +331,7 @@ CBC_CommonBitMatrix* CBC_DataMatrixDetector::SampleGrid(
topLeft->GetX(), topLeft->GetY(), topRight->GetX(), topRight->GetY(),
bottomRight->GetX(), bottomRight->GetY(), bottomLeft->GetX(),
bottomLeft->GetY(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return cbm;
}
CBC_ResultPointsAndTransitions* CBC_DataMatrixDetector::TransitionsBetween(
@@ -371,26 +374,24 @@ CBC_ResultPointsAndTransitions* CBC_DataMatrixDetector::TransitionsBetween(
}
return new CBC_ResultPointsAndTransitions(from, to, transitions);
}
-void CBC_DataMatrixDetector::OrderBestPatterns(CFX_PtrArray* patterns) {
- FX_FLOAT abDistance = (FX_FLOAT)Distance((CBC_ResultPoint*)(*patterns)[0],
- (CBC_ResultPoint*)(*patterns)[1]);
- FX_FLOAT bcDistance = (FX_FLOAT)Distance((CBC_ResultPoint*)(*patterns)[1],
- (CBC_ResultPoint*)(*patterns)[2]);
- FX_FLOAT acDistance = (FX_FLOAT)Distance((CBC_ResultPoint*)(*patterns)[0],
- (CBC_ResultPoint*)(*patterns)[2]);
+void CBC_DataMatrixDetector::OrderBestPatterns(
+ CFX_ArrayTemplate<CBC_ResultPoint*>* patterns) {
+ FX_FLOAT abDistance = (FX_FLOAT)Distance((*patterns)[0], (*patterns)[1]);
+ FX_FLOAT bcDistance = (FX_FLOAT)Distance((*patterns)[1], (*patterns)[2]);
+ FX_FLOAT acDistance = (FX_FLOAT)Distance((*patterns)[0], (*patterns)[2]);
CBC_ResultPoint *topLeft, *topRight, *bottomLeft;
if (bcDistance >= abDistance && bcDistance >= acDistance) {
- topLeft = (CBC_ResultPoint*)(*patterns)[0];
- topRight = (CBC_ResultPoint*)(*patterns)[1];
- bottomLeft = (CBC_ResultPoint*)(*patterns)[2];
+ topLeft = (*patterns)[0];
+ topRight = (*patterns)[1];
+ bottomLeft = (*patterns)[2];
} else if (acDistance >= bcDistance && acDistance >= abDistance) {
- topLeft = (CBC_ResultPoint*)(*patterns)[1];
- topRight = (CBC_ResultPoint*)(*patterns)[0];
- bottomLeft = (CBC_ResultPoint*)(*patterns)[2];
+ topLeft = (*patterns)[1];
+ topRight = (*patterns)[0];
+ bottomLeft = (*patterns)[2];
} else {
- topLeft = (CBC_ResultPoint*)(*patterns)[2];
- topRight = (CBC_ResultPoint*)(*patterns)[0];
- bottomLeft = (CBC_ResultPoint*)(*patterns)[1];
+ topLeft = (*patterns)[2];
+ topRight = (*patterns)[0];
+ bottomLeft = (*patterns)[1];
}
if ((bottomLeft->GetY() - topLeft->GetY()) *
(topRight->GetX() - topLeft->GetX()) <
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h
index 589825fc383..8ef053b334e 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixDetector.h
@@ -10,11 +10,11 @@
#include "core/fxcrt/include/fx_basic.h"
class CBC_CommonBitMatrix;
-class CBC_WhiteRectangleDetector;
-class CBC_ResultPoint;
-class CBC_QRDetectorResult;
class CBC_DataMatrixDetector;
-class ResultPointsAndTransitions;
+class CBC_QRDetectorResult;
+class CBC_ResultPoint;
+class CBC_WhiteRectangleDetector;
+
class CBC_ResultPointsAndTransitions {
public:
CBC_ResultPointsAndTransitions(CBC_ResultPoint* from,
@@ -25,15 +25,16 @@ class CBC_ResultPointsAndTransitions {
m_transitions = transitions;
}
~CBC_ResultPointsAndTransitions() {}
- CBC_ResultPoint* GetFrom() { return m_from; }
- CBC_ResultPoint* GetTo() { return m_to; }
- int32_t GetTransitions() { return m_transitions; }
+ CBC_ResultPoint* GetFrom() const { return m_from; }
+ CBC_ResultPoint* GetTo() const { return m_to; }
+ int32_t GetTransitions() const { return m_transitions; }
private:
CBC_ResultPoint* m_from;
CBC_ResultPoint* m_to;
int32_t m_transitions;
};
+
class CBC_DataMatrixDetector {
public:
CBC_DataMatrixDetector(CBC_CommonBitMatrix* image);
@@ -65,7 +66,7 @@ class CBC_DataMatrixDetector {
void Increment(CFX_MapPtrTemplate<CBC_ResultPoint*, int32_t>& table,
CBC_ResultPoint* key);
int32_t Round(FX_FLOAT d);
- void OrderBestPatterns(CFX_PtrArray* patterns);
+ void OrderBestPatterns(CFX_ArrayTemplate<CBC_ResultPoint*>* patterns);
virtual void Init(int32_t& e);
private:
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp
index 50131f3dc25..d1dcc23e7ba 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp
@@ -25,14 +25,15 @@
#include "xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h"
#include "xfa/fxbarcode/utils.h"
-CFX_PtrArray* CBC_DataMatrixVersion::VERSIONS = NULL;
+CFX_ArrayTemplate<CBC_DataMatrixVersion*>* CBC_DataMatrixVersion::VERSIONS =
+ nullptr;
void CBC_DataMatrixVersion::Initialize() {
- VERSIONS = new CFX_PtrArray();
+ VERSIONS = new CFX_ArrayTemplate<CBC_DataMatrixVersion*>();
}
void CBC_DataMatrixVersion::Finalize() {
for (int32_t i = 0; i < VERSIONS->GetSize(); i++) {
- delete ((CBC_DataMatrixVersion*)(VERSIONS->GetAt(i)));
+ delete VERSIONS->GetAt(i);
}
VERSIONS->RemoveAll();
delete VERSIONS;
@@ -51,10 +52,10 @@ CBC_DataMatrixVersion::CBC_DataMatrixVersion(int32_t versionNumber,
m_ecBlocks = ecBlocks;
int32_t total = 0;
int32_t ecCodewords = ecBlocks->GetECCodewords();
- const CFX_PtrArray& ecbArray = ecBlocks->GetECBlocks();
+ const CFX_ArrayTemplate<ECB*>& ecbArray = ecBlocks->GetECBlocks();
for (int32_t i = 0; i < ecbArray.GetSize(); i++) {
- total += ((ECB*)ecbArray[i])->GetCount() *
- (((ECB*)ecbArray[i])->GetDataCodewords() + ecCodewords);
+ total += ecbArray[i]->GetCount() *
+ (ecbArray[i]->GetDataCodewords() + ecCodewords);
}
m_totalCodewords = total;
}
@@ -84,7 +85,7 @@ ECBlocks* CBC_DataMatrixVersion::GetECBlocks() {
}
void CBC_DataMatrixVersion::ReleaseAll() {
for (int32_t i = 0; i < VERSIONS->GetSize(); i++) {
- delete (CBC_DataMatrixVersion*)VERSIONS->GetAt(i);
+ delete VERSIONS->GetAt(i);
}
VERSIONS->RemoveAll();
}
@@ -94,7 +95,7 @@ CBC_DataMatrixVersion* CBC_DataMatrixVersion::GetVersionForDimensions(
int32_t& e) {
if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) {
e = BCExceptionNotFound;
- return NULL;
+ return nullptr;
}
if (VERSIONS->GetSize() == 0) {
VERSIONS->Add(new CBC_DataMatrixVersion(1, 10, 10, 8, 8,
@@ -161,13 +162,11 @@ CBC_DataMatrixVersion* CBC_DataMatrixVersion::GetVersionForDimensions(
}
int32_t numVersions = VERSIONS->GetSize();
for (int32_t i = 0; i < numVersions; ++i) {
- if (((CBC_DataMatrixVersion*)((*VERSIONS)[i]))->m_symbolSizeRows ==
- numRows &&
- ((CBC_DataMatrixVersion*)((*VERSIONS)[i]))->m_symbolSizeColumns ==
- numColumns) {
- return (CBC_DataMatrixVersion*)(*VERSIONS)[i];
+ if ((*VERSIONS)[i]->m_symbolSizeRows == numRows &&
+ (*VERSIONS)[i]->m_symbolSizeColumns == numColumns) {
+ return (*VERSIONS)[i];
}
}
e = BCExceptionNotFound;
- return NULL;
+ return nullptr;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h
index 9e8e801d8ee..b4585d20bc8 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h
@@ -13,14 +13,11 @@ class CBC_DataMatrixVersion;
class ECB {
public:
- ECB(int32_t count, int32_t dataCodewords) {
- m_count = count;
- m_dataCodewords = dataCodewords;
- }
-
- int32_t GetCount() { return m_count; }
+ ECB(int32_t count, int32_t dataCodewords)
+ : m_count(count), m_dataCodewords(dataCodewords) {}
- int32_t GetDataCodewords() { return m_dataCodewords; }
+ int32_t GetCount() const { return m_count; }
+ int32_t GetDataCodewords() const { return m_dataCodewords; }
private:
int32_t m_count;
@@ -29,30 +26,27 @@ class ECB {
class ECBlocks {
public:
- ECBlocks(int32_t ecCodewords, ECB* ecBlocks) {
- m_ecCodewords = ecCodewords;
- m_ecBlocks.Add(ecBlocks);
+ ECBlocks(int32_t ecCodewords, ECB* ecBlocks) : m_ecCodewords(ecCodewords) {
+ m_ecBlocksArray.Add(ecBlocks);
}
- ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2) {
- m_ecCodewords = ecCodewords;
- m_ecBlocks.Add(ecBlocks1);
- m_ecBlocks.Add(ecBlocks2);
+ ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2)
+ : m_ecCodewords(ecCodewords) {
+ m_ecBlocksArray.Add(ecBlocks1);
+ m_ecBlocksArray.Add(ecBlocks2);
}
+
~ECBlocks() {
- for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
- delete (ECB*)m_ecBlocks[i];
- }
- m_ecBlocks.RemoveAll();
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++)
+ delete m_ecBlocksArray[i];
}
int32_t GetECCodewords() { return m_ecCodewords; }
-
- const CFX_PtrArray& GetECBlocks() { return m_ecBlocks; }
+ const CFX_ArrayTemplate<ECB*>& GetECBlocks() { return m_ecBlocksArray; }
private:
int32_t m_ecCodewords;
- CFX_PtrArray m_ecBlocks;
+ CFX_ArrayTemplate<ECB*> m_ecBlocksArray;
};
class CBC_DataMatrixVersion {
@@ -86,7 +80,7 @@ class CBC_DataMatrixVersion {
int32_t m_dataRegionSizeColumns;
ECBlocks* m_ecBlocks;
int32_t m_totalCodewords;
- static CFX_PtrArray* VERSIONS;
+ static CFX_ArrayTemplate<CBC_DataMatrixVersion*>* VERSIONS;
};
#endif // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index 1c20b7c8a1b..8f54353d4ad 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -172,14 +172,12 @@ CFX_WideString CBC_ErrorCorrection::createECCBlock(CFX_WideString codewords,
int32_t len,
int32_t numECWords,
int32_t& e) {
- int32_t table = -1;
- for (int32_t i = 0; i < sizeof(FACTOR_SETS) / sizeof(int32_t); i++) {
- if (FACTOR_SETS[i] == numECWords) {
- table = i;
- break;
- }
- }
- if (table < 0) {
+ static const size_t kFactorTableNum = sizeof(FACTOR_SETS) / sizeof(int32_t);
+ size_t table = 0;
+ while (table < kFactorTableNum && FACTOR_SETS[table] != numECWords)
+ table++;
+
+ if (table >= kFactorTableNum) {
e = BCExceptionIllegalArgument;
return (FX_WCHAR*)"";
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index 1f7c4c3453c..19672c1b715 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -21,6 +21,8 @@
*/
#include <limits>
+#include <memory>
+#include <vector>
#include "xfa/fxbarcode/BC_Dimension.h"
#include "xfa/fxbarcode/BC_UtilCodingConvert.h"
@@ -55,6 +57,7 @@ const wchar_t CBC_HighLevelEncoder::MACRO_TRAILER = 0x0004;
CBC_HighLevelEncoder::CBC_HighLevelEncoder() {}
CBC_HighLevelEncoder::~CBC_HighLevelEncoder() {}
+
CFX_ByteArray& CBC_HighLevelEncoder::getBytesForMessage(CFX_WideString msg) {
CFX_ByteString bytestr;
CBC_UtilCodingConvert::UnicodeToUTF8(msg, bytestr);
@@ -89,23 +92,20 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
context.setSkipAtEnd(2);
context.m_pos += 6;
}
- CFX_PtrArray encoders;
- encoders.Add(new CBC_ASCIIEncoder());
- encoders.Add(new CBC_C40Encoder());
- encoders.Add(new CBC_TextEncoder());
- encoders.Add(new CBC_X12Encoder());
- encoders.Add(new CBC_EdifactEncoder());
- encoders.Add(new CBC_Base256Encoder());
+
+ std::vector<std::unique_ptr<CBC_Encoder>> encoders;
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_ASCIIEncoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_C40Encoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_TextEncoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_X12Encoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_EdifactEncoder()));
+ encoders.push_back(std::unique_ptr<CBC_Encoder>(new CBC_Base256Encoder()));
int32_t encodingMode = ASCII_ENCODATION;
while (context.hasMoreCharacters()) {
- ((CBC_Encoder*)encoders.GetAt(encodingMode))->Encode(context, e);
- if (e != BCExceptionNO) {
- for (int32_t i = 0; i < encoders.GetSize(); i++) {
- delete (CBC_Encoder*)encoders.GetAt(i);
- }
- encoders.RemoveAll();
- return (FX_WCHAR*)"";
- }
+ encoders[encodingMode]->Encode(context, e);
+ if (e != BCExceptionNO)
+ return L"";
+
if (context.m_newEncoding >= 0) {
encodingMode = context.m_newEncoding;
context.resetEncoderSignal();
@@ -113,13 +113,9 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
}
int32_t len = context.m_codewords.GetLength();
context.updateSymbolInfo(e);
- if (e != BCExceptionNO) {
- for (int32_t i = 0; i < encoders.GetSize(); i++) {
- delete (CBC_Encoder*)encoders.GetAt(i);
- }
- encoders.RemoveAll();
- return (FX_WCHAR*)"";
- }
+ if (e != BCExceptionNO)
+ return L"";
+
int32_t capacity = context.m_symbolInfo->m_dataCapacity;
if (len < capacity) {
if (encodingMode != ASCII_ENCODATION &&
@@ -134,10 +130,6 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
while (codewords.GetLength() < capacity) {
codewords += (randomize253State(PAD, codewords.GetLength() + 1));
}
- for (int32_t i = 0; i < encoders.GetSize(); i++) {
- delete (CBC_Encoder*)encoders.GetAt(i);
- }
- encoders.RemoveAll();
return codewords;
}
int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg,
@@ -166,7 +158,7 @@ int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg,
int32_t charsProcessed = 0;
while (TRUE) {
if ((startpos + charsProcessed) == msg.GetLength()) {
- uint32_t min = std::numeric_limits<int32_t>::max();
+ int32_t min = std::numeric_limits<int32_t>::max();
CFX_ByteArray mins;
mins.SetSize(6);
CFX_Int32Array intCharCounts;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
index b95c2be283d..ae1b2379578 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -290,6 +290,7 @@ void CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents,
}
FX_Free(pCharPos);
}
+
void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
const CFX_WideStringC& contents,
int32_t& e) {
@@ -319,11 +320,10 @@ void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
BC_EXCEPTION_CHECK_ReturnVoid(e);
}
CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
- if (pOutBitmap) {
- delete pOutBitmap;
- }
+ delete pOutBitmap;
pOutBitmap = pStretchBitmap;
}
+
void CBC_OneDimWriter::RenderDeviceResult(CFX_RenderDevice* device,
const CFX_Matrix* matrix,
const CFX_WideStringC& contents,
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.h b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.h
index e504f0bacb0..15a1a1a6c74 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OneDimWriter.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_
#define XFA_FXBARCODE_ONED_BC_ONEDIMWRITER_H_
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "xfa/fxbarcode/BC_Writer.h"
#include "xfa/fxbarcode/include/BC_Library.h"
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp
index f767ffa1694..f3c39f2491b 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarReader.cpp
@@ -107,7 +107,7 @@ CFX_ByteString CBC_OnedCodaBarReader::DecodeRow(int32_t rowNumber,
}
if (result.GetLength() < 5) {
int32_t index =
- temp.Find(result.Mid(1, result.GetLength() - 1).AsByteStringC());
+ temp.Find(result.Mid(1, result.GetLength() - 1).AsStringC());
if (index == len - (result.GetLength() - 1)) {
e = BCExceptionNotFound;
return "";
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
index 3fbeb1c3182..2d9c2e5ad87 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
@@ -226,6 +226,6 @@ void CBC_OnedCodaBarWriter::RenderResult(const CFX_WideStringC& contents,
int32_t codeLength,
FX_BOOL isDevice,
int32_t& e) {
- CBC_OneDimWriter::RenderResult(encodedContents(contents).AsWideStringC(),
- code, codeLength, isDevice, e);
+ CBC_OneDimWriter::RenderResult(encodedContents(contents).AsStringC(), code,
+ codeLength, isDevice, e);
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
index ac05e78910f..5806b3d09da 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.cpp
@@ -137,30 +137,31 @@ FX_BOOL CBC_OnedCode128Writer::IsDigits(const CFX_ByteString& contents,
}
return TRUE;
}
+
uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents,
int32_t& outLength,
int32_t& e) {
if (contents.GetLength() < 1 || contents.GetLength() > 80) {
e = BCExceptionContentsLengthShouldBetween1and80;
- return NULL;
+ return nullptr;
}
- CFX_PtrArray patterns;
+ CFX_ArrayTemplate<const int32_t*> patterns;
int32_t checkSum = 0;
if (m_codeFormat == BC_CODE128_B) {
- checkSum = Encode128B(contents, patterns);
+ checkSum = Encode128B(contents, &patterns);
} else if (m_codeFormat == BC_CODE128_C) {
- checkSum = Encode128C(contents, patterns);
+ checkSum = Encode128C(contents, &patterns);
} else {
e = BCExceptionFormatException;
- return NULL;
+ return nullptr;
}
checkSum %= 103;
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[checkSum]);
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_STOP]);
+ patterns.Add(CBC_OnedCode128Reader::CODE_PATTERNS[checkSum]);
+ patterns.Add(CBC_OnedCode128Reader::CODE_PATTERNS[CODE_STOP]);
m_iContentLen = contents.GetLength() + 3;
int32_t codeWidth = 0;
for (int32_t k = 0; k < patterns.GetSize(); k++) {
- int32_t* pattern = (int32_t*)patterns[k];
+ const int32_t* pattern = patterns[k];
for (int32_t j = 0; j < 7; j++) {
codeWidth += pattern[j];
}
@@ -169,27 +170,29 @@ uint8_t* CBC_OnedCode128Writer::Encode(const CFX_ByteString& contents,
uint8_t* result = FX_Alloc(uint8_t, outLength);
int32_t pos = 0;
for (int32_t j = 0; j < patterns.GetSize(); j++) {
- int32_t* pattern = (int32_t*)patterns[j];
+ const int32_t* pattern = patterns[j];
pos += AppendPattern(result, pos, pattern, 7, 1, e);
if (e != BCExceptionNO) {
FX_Free(result);
- return NULL;
+ return nullptr;
}
}
return result;
}
-int32_t CBC_OnedCode128Writer::Encode128B(const CFX_ByteString& contents,
- CFX_PtrArray& patterns) {
+
+int32_t CBC_OnedCode128Writer::Encode128B(
+ const CFX_ByteString& contents,
+ CFX_ArrayTemplate<const int32_t*>* patterns) {
int32_t checkSum = 0;
int32_t checkWeight = 1;
int32_t position = 0;
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_B]);
+ patterns->Add(CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_B]);
checkSum += CODE_START_B * checkWeight;
while (position < contents.GetLength()) {
int32_t patternIndex = 0;
patternIndex = contents[position] - ' ';
position += 1;
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]);
+ patterns->Add(CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]);
checkSum += patternIndex * checkWeight;
if (position != 0) {
checkWeight++;
@@ -197,12 +200,14 @@ int32_t CBC_OnedCode128Writer::Encode128B(const CFX_ByteString& contents,
}
return checkSum;
}
-int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents,
- CFX_PtrArray& patterns) {
+
+int32_t CBC_OnedCode128Writer::Encode128C(
+ const CFX_ByteString& contents,
+ CFX_ArrayTemplate<const int32_t*>* patterns) {
int32_t checkSum = 0;
int32_t checkWeight = 1;
int32_t position = 0;
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_C]);
+ patterns->Add(CBC_OnedCode128Reader::CODE_PATTERNS[CODE_START_C]);
checkSum += CODE_START_C * checkWeight;
while (position < contents.GetLength()) {
int32_t patternIndex = 0;
@@ -211,7 +216,7 @@ int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents,
patternIndex = (int32_t)ch;
position++;
} else {
- patternIndex = FXSYS_atoi(contents.Mid(position, 2));
+ patternIndex = FXSYS_atoi(contents.Mid(position, 2).c_str());
if (contents.GetAt(position + 1) < '0' ||
contents.GetAt(position + 1) > '9') {
position += 1;
@@ -219,7 +224,7 @@ int32_t CBC_OnedCode128Writer::Encode128C(const CFX_ByteString& contents,
position += 2;
}
}
- patterns.Add((int32_t*)CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]);
+ patterns->Add(CBC_OnedCode128Reader::CODE_PATTERNS[patternIndex]);
checkSum += patternIndex * checkWeight;
if (position != 0) {
checkWeight++;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.h b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.h
index aa6bd90f17a..b2530642af8 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode128Writer.h
@@ -47,8 +47,10 @@ class CBC_OnedCode128Writer : public CBC_OneDimWriter {
FX_BOOL IsDigits(const CFX_ByteString& contents,
int32_t start,
int32_t length);
- int32_t Encode128B(const CFX_ByteString& contents, CFX_PtrArray& patterns);
- int32_t Encode128C(const CFX_ByteString& contents, CFX_PtrArray& patterns);
+ int32_t Encode128B(const CFX_ByteString& contents,
+ CFX_ArrayTemplate<const int32_t*>* patterns);
+ int32_t Encode128C(const CFX_ByteString& contents,
+ CFX_ArrayTemplate<const int32_t*>* patterns);
BC_TYPE m_codeFormat;
};
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp
index 0a69f04a4ff..efebfe547d4 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedCode39Writer.cpp
@@ -341,13 +341,13 @@ uint8_t* CBC_OnedCode39Writer::Encode(const CFX_ByteString& contents,
CFX_WideString CBC_OnedCode39Writer::encodedContents(
const CFX_WideStringC& contents,
int32_t& e) {
- CFX_WideString encodedContents = contents;
+ CFX_WideString encodedContents(contents);
if (m_bCalcChecksum && m_bPrintChecksum) {
CFX_WideString checksumContent = FilterContents(contents);
CFX_ByteString str = checksumContent.UTF8Encode();
FX_CHAR checksum;
checksum = CalcCheckSum(str, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, FX_WSTRC(L""));
+ BC_EXCEPTION_CHECK_ReturnValue(e, CFX_WideString());
str += checksum;
encodedContents += checksum;
}
@@ -360,6 +360,6 @@ void CBC_OnedCode39Writer::RenderResult(const CFX_WideStringC& contents,
int32_t& e) {
CFX_WideString encodedCon = encodedContents(contents, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_OneDimWriter::RenderResult(encodedCon.AsWideStringC(), code, codeLength,
+ CBC_OneDimWriter::RenderResult(encodedCon.AsStringC(), code, codeLength,
isDevice, e);
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index b534602fb3d..bdc5e1f2c72 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -66,9 +66,9 @@ int32_t CBC_OnedEAN13Writer::CalcChecksum(const CFX_ByteString& contents) {
int32_t j = 1;
for (int32_t i = contents.GetLength() - 1; i >= 0; i--) {
if (j % 2) {
- odd += FXSYS_atoi(contents.Mid(i, 1));
+ odd += FXSYS_atoi(contents.Mid(i, 1).c_str());
} else {
- even += FXSYS_atoi(contents.Mid(i, 1));
+ even += FXSYS_atoi(contents.Mid(i, 1).c_str());
}
j++;
}
@@ -107,7 +107,7 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents,
return NULL;
}
m_iDataLenth = 13;
- int32_t firstDigit = FXSYS_atoi(contents.Mid(0, 1));
+ int32_t firstDigit = FXSYS_atoi(contents.Mid(0, 1).c_str());
int32_t parities = CBC_OnedEAN13Reader::FIRST_DIGIT_ENCODINGS[firstDigit];
outLength = m_codeWidth;
uint8_t* result = FX_Alloc(uint8_t, m_codeWidth);
@@ -120,7 +120,7 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents,
}
int32_t i = 0;
for (i = 1; i <= 6; i++) {
- int32_t digit = FXSYS_atoi(contents.Mid(i, 1));
+ int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str());
if ((parities >> (6 - i) & 1) == 1) {
digit += 10;
}
@@ -137,7 +137,7 @@ uint8_t* CBC_OnedEAN13Writer::Encode(const CFX_ByteString& contents,
return NULL;
}
for (i = 7; i <= 12; i++) {
- int32_t digit = FXSYS_atoi(contents.Mid(i, 1));
+ int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str());
pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1,
e);
if (e != BCExceptionNO) {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index 5336867538d..4427cb89700 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -76,9 +76,9 @@ int32_t CBC_OnedEAN8Writer::CalcChecksum(const CFX_ByteString& contents) {
int32_t j = 1;
for (int32_t i = contents.GetLength() - 1; i >= 0; i--) {
if (j % 2) {
- odd += FXSYS_atoi(contents.Mid(i, 1));
+ odd += FXSYS_atoi(contents.Mid(i, 1).c_str());
} else {
- even += FXSYS_atoi(contents.Mid(i, 1));
+ even += FXSYS_atoi(contents.Mid(i, 1).c_str());
}
j++;
}
@@ -128,7 +128,7 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents,
}
int32_t i = 0;
for (i = 0; i <= 3; i++) {
- int32_t digit = FXSYS_atoi(contents.Mid(i, 1));
+ int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str());
pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 0,
e);
if (e != BCExceptionNO) {
@@ -142,7 +142,7 @@ uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents,
return NULL;
}
for (i = 4; i <= 7; i++) {
- int32_t digit = FXSYS_atoi(contents.Mid(i, 1));
+ int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str());
pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1,
e);
if (e != BCExceptionNO) {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAReader.h b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAReader.h
index 1f2ba6222c6..c073930c5b1 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAReader.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAReader.h
@@ -43,7 +43,6 @@ class CBC_OnedUPCAReader : public CBC_OneDimReader {
private:
CBC_OnedEAN13Reader* m_ean13Reader;
-
};
#endif // XFA_FXBARCODE_ONED_BC_ONEDUPCAREADER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 21ccafc20c7..943384d55cb 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -70,9 +70,9 @@ int32_t CBC_OnedUPCAWriter::CalcChecksum(const CFX_ByteString& contents) {
int32_t j = 1;
for (int32_t i = contents.GetLength() - 1; i >= 0; i--) {
if (j % 2) {
- odd += FXSYS_atoi(contents.Mid(i, 1));
+ odd += FXSYS_atoi(contents.Mid(i, 1).c_str());
} else {
- even += FXSYS_atoi(contents.Mid(i, 1));
+ even += FXSYS_atoi(contents.Mid(i, 1).c_str());
}
j++;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417.cpp
index 15b448b37bf..908901c04eb 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417.cpp
@@ -401,11 +401,11 @@ CBC_PDF417::CBC_PDF417(FX_BOOL compact) {
m_minRows = 3;
m_barcodeMatrix = NULL;
}
+
CBC_PDF417::~CBC_PDF417() {
- if (m_barcodeMatrix) {
- delete m_barcodeMatrix;
- }
+ delete m_barcodeMatrix;
}
+
CBC_BarcodeMatrix* CBC_PDF417::getBarcodeMatrix() {
return m_barcodeMatrix;
}
@@ -556,9 +556,7 @@ CFX_Int32Array* CBC_PDF417::determineDimensions(
continue;
}
ratio = newRatio;
- if (dimension) {
- delete dimension;
- }
+ delete dimension;
dimension = new CFX_Int32Array;
dimension->Add(cols);
dimension->Add(rows);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
index 47255fac712..a9d1fedef0a 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
@@ -36,14 +36,13 @@ CBC_BarcodeMatrix::CBC_BarcodeMatrix(int32_t height, int32_t width) {
m_outWidth = 0;
}
CBC_BarcodeMatrix::~CBC_BarcodeMatrix() {
- for (int32_t i = 0; i < m_matrix.GetSize(); i++) {
- delete (CBC_BarcodeRow*)m_matrix.GetAt(i);
- }
- m_matrix.RemoveAll();
+ for (int32_t i = 0; i < m_matrix.GetSize(); i++)
+ delete m_matrix.GetAt(i);
+
m_matrixOut.RemoveAll();
}
void CBC_BarcodeMatrix::set(int32_t x, int32_t y, uint8_t value) {
- ((CBC_BarcodeRow*)m_matrix[y])->set(x, value);
+ m_matrix[y]->set(x, value);
}
void CBC_BarcodeMatrix::setMatrix(int32_t x, int32_t y, FX_BOOL black) {
set(x, y, (uint8_t)(black ? 1 : 0));
@@ -52,7 +51,7 @@ void CBC_BarcodeMatrix::startRow() {
++m_currentRow;
}
CBC_BarcodeRow* CBC_BarcodeMatrix::getCurrentRow() {
- return (CBC_BarcodeRow*)m_matrix[m_currentRow];
+ return m_matrix[m_currentRow];
}
int32_t CBC_BarcodeMatrix::getWidth() {
return m_outWidth;
@@ -70,7 +69,7 @@ CFX_ByteArray& CBC_BarcodeMatrix::getScaledMatrix(int32_t xScale,
int32_t yScale) {
int32_t yMax = m_height * yScale;
CFX_ByteArray bytearray;
- bytearray.Copy(((CBC_BarcodeRow*)m_matrix[0])->getScaledRow(xScale));
+ bytearray.Copy(m_matrix[0]->getScaledRow(xScale));
int32_t xMax = bytearray.GetSize();
m_matrixOut.SetSize(xMax * yMax);
m_outWidth = xMax;
@@ -78,8 +77,7 @@ CFX_ByteArray& CBC_BarcodeMatrix::getScaledMatrix(int32_t xScale,
int32_t k = 0;
for (int32_t i = 0; i < yMax; i++) {
if (i != 0) {
- bytearray.Copy(
- ((CBC_BarcodeRow*)m_matrix[i / yScale])->getScaledRow(xScale));
+ bytearray.Copy(m_matrix[i / yScale]->getScaledRow(xScale));
}
k = i * xMax;
for (int32_t l = 0; l < xMax; l++) {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
index 793bf0acf27..c86f714fbb9 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
@@ -10,6 +10,7 @@
#include "core/fxcrt/include/fx_basic.h"
class CBC_BarcodeRow;
+
class CBC_BarcodeMatrix {
public:
CBC_BarcodeMatrix();
@@ -26,7 +27,7 @@ class CBC_BarcodeMatrix {
int32_t getHeight();
private:
- CFX_PtrArray m_matrix;
+ CFX_ArrayTemplate<CBC_BarcodeRow*> m_matrix;
CFX_ByteArray m_matrixOut;
int32_t m_currentRow;
int32_t m_height;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h
index 29f0a833a95..0be71a1fb2e 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h
@@ -9,10 +9,11 @@
#include "core/fxcrt/include/fx_basic.h"
-class CBC_BarcodeValue {
+class CBC_BarcodeValue final {
public:
CBC_BarcodeValue();
- virtual ~CBC_BarcodeValue();
+ ~CBC_BarcodeValue();
+
void setValue(int32_t value);
CFX_Int32Array* getValue();
int32_t getConfidence(int32_t value);
@@ -22,4 +23,7 @@ class CBC_BarcodeValue {
CFX_Int32Array m_values;
};
+using CBC_BarcodeValueArray = CFX_ArrayTemplate<CBC_BarcodeValue*>;
+using CBC_BarcodeValueArrayArray = CFX_ArrayTemplate<CBC_BarcodeValueArray*>;
+
#endif // XFA_FXBARCODE_PDF417_BC_PDF417BARCODEVALUE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp
index c8328ab1c63..d2ad98e4089 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp
@@ -42,20 +42,14 @@ CBC_BoundingBox::CBC_BoundingBox(CBC_BoundingBox* boundingBox) {
init(boundingBox->m_image, boundingBox->m_topLeft, boundingBox->m_bottomLeft,
boundingBox->m_topRight, boundingBox->m_bottomRight);
}
+
CBC_BoundingBox::~CBC_BoundingBox() {
- if (m_topLeft) {
- delete m_topLeft;
- }
- if (m_bottomLeft) {
- delete m_bottomLeft;
- }
- if (m_topRight) {
- delete m_topRight;
- }
- if (m_bottomRight) {
- delete m_bottomRight;
- }
+ delete m_topLeft;
+ delete m_bottomLeft;
+ delete m_topRight;
+ delete m_bottomRight;
}
+
CBC_BoundingBox* CBC_BoundingBox::merge(CBC_BoundingBox* leftBox,
CBC_BoundingBox* rightBox,
int32_t& e) {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
index 04246bd5d86..92351d0c617 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DecodedBitStreamParser.cpp
@@ -113,9 +113,8 @@ CBC_CommonDecoderResult* CBC_DecodedBitStreamPaser::decode(
return NULL;
}
CFX_ByteArray rawBytes;
- CFX_PtrArray byteSegments;
CBC_CommonDecoderResult* tempCd = new CBC_CommonDecoderResult();
- tempCd->Init(rawBytes, result, byteSegments, ecLevel, e);
+ tempCd->Init(rawBytes, result, ecLevel, e);
if (e != BCExceptionNO) {
delete resultMetadata;
return NULL;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
index fa278bdea93..79754b020e5 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp
@@ -36,21 +36,20 @@ CBC_DetectionResult::CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata,
m_barcodeColumnCount = barcodeMetadata->getColumnCount();
m_boundingBox = boundingBox;
m_detectionResultColumns.SetSize(m_barcodeColumnCount + 2);
- for (int32_t i = 0; i < m_barcodeColumnCount + 2; i++) {
- m_detectionResultColumns[i] = NULL;
- }
+ for (int32_t i = 0; i < m_barcodeColumnCount + 2; i++)
+ m_detectionResultColumns[i] = nullptr;
}
+
CBC_DetectionResult::~CBC_DetectionResult() {
delete m_boundingBox;
delete m_barcodeMetadata;
- m_detectionResultColumns.RemoveAll();
}
-CFX_PtrArray& CBC_DetectionResult::getDetectionResultColumns() {
- adjustIndicatorColumnRowNumbers(
- (CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(0));
+
+CFX_ArrayTemplate<CBC_DetectionResultColumn*>&
+CBC_DetectionResult::getDetectionResultColumns() {
+ adjustIndicatorColumnRowNumbers(m_detectionResultColumns.GetAt(0));
adjustIndicatorColumnRowNumbers(
- (CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(
- m_barcodeColumnCount + 1));
+ m_detectionResultColumns.GetAt(m_barcodeColumnCount + 1));
int32_t unadjustedCodewordCount = CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE;
int32_t previousUnadjustedCount;
do {
@@ -73,15 +72,13 @@ void CBC_DetectionResult::setDetectionResultColumn(
}
CBC_DetectionResultColumn* CBC_DetectionResult::getDetectionResultColumn(
int32_t barcodeColumn) {
- return (CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn];
+ return m_detectionResultColumns[barcodeColumn];
}
CFX_ByteString CBC_DetectionResult::toString() {
- CBC_DetectionResultColumn* rowIndicatorColumn =
- (CBC_DetectionResultColumn*)m_detectionResultColumns[0];
- if (rowIndicatorColumn == NULL) {
- rowIndicatorColumn = (CBC_DetectionResultColumn*)
- m_detectionResultColumns[m_barcodeColumnCount + 1];
- }
+ CBC_DetectionResultColumn* rowIndicatorColumn = m_detectionResultColumns[0];
+ if (!rowIndicatorColumn)
+ rowIndicatorColumn = m_detectionResultColumns[m_barcodeColumnCount + 1];
+
CFX_ByteString result;
for (int32_t codewordsRow = 0;
codewordsRow < rowIndicatorColumn->getCodewords()->GetSize();
@@ -89,16 +86,15 @@ CFX_ByteString CBC_DetectionResult::toString() {
result += (FX_CHAR)codewordsRow;
for (int32_t barcodeColumn = 0; barcodeColumn < m_barcodeColumnCount + 2;
barcodeColumn++) {
- if (m_detectionResultColumns[barcodeColumn] == NULL) {
+ if (!m_detectionResultColumns[barcodeColumn]) {
result += " | ";
continue;
}
CBC_Codeword* codeword =
- (CBC_Codeword*)((CBC_DetectionResultColumn*)
- m_detectionResultColumns[barcodeColumn])
+ (CBC_Codeword*)m_detectionResultColumns[barcodeColumn]
->getCodewords()
->GetAt(codewordsRow);
- if (codeword == NULL) {
+ if (!codeword) {
result += " | ";
continue;
}
@@ -122,16 +118,14 @@ int32_t CBC_DetectionResult::adjustRowNumbers() {
}
for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1;
barcodeColumn++) {
- CFX_PtrArray* codewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn])
- ->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords =
+ m_detectionResultColumns[barcodeColumn]->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
- if (!((CBC_Codeword*)codewords->GetAt(codewordsRow))
- ->hasValidRowNumber()) {
+ if (!codewords->GetAt(codewordsRow)->hasValidRowNumber()) {
adjustRowNumbers(barcodeColumn, codewordsRow, codewords);
}
}
@@ -144,39 +138,33 @@ int32_t CBC_DetectionResult::adjustRowNumbersByRow() {
return unadjustedCount + adjustRowNumbersFromRRI();
}
int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() {
- if (m_detectionResultColumns[0] == NULL ||
- m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) {
+ if (!m_detectionResultColumns[0] ||
+ !m_detectionResultColumns[m_barcodeColumnCount + 1]) {
return 0;
}
- CFX_PtrArray* LRIcodewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns[0])->getCodewords();
- CFX_PtrArray* RRIcodewords =
- ((CBC_DetectionResultColumn*)
- m_detectionResultColumns[m_barcodeColumnCount + 1])
- ->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* LRIcodewords =
+ m_detectionResultColumns[0]->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* RRIcodewords =
+ m_detectionResultColumns[m_barcodeColumnCount + 1]->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < LRIcodewords->GetSize();
codewordsRow++) {
if (LRIcodewords->GetAt(codewordsRow) &&
RRIcodewords->GetAt(codewordsRow) &&
- ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber() ==
- ((CBC_Codeword*)RRIcodewords->GetAt(codewordsRow))
- ->getRowNumber()) {
+ LRIcodewords->GetAt(codewordsRow)->getRowNumber() ==
+ RRIcodewords->GetAt(codewordsRow)->getRowNumber()) {
for (int32_t barcodeColumn = 1; barcodeColumn <= m_barcodeColumnCount;
barcodeColumn++) {
CBC_Codeword* codeword =
- (CBC_Codeword*)((CBC_DetectionResultColumn*)
- m_detectionResultColumns[barcodeColumn])
- ->getCodewords()
- ->GetAt(codewordsRow);
- if (codeword == NULL) {
+ m_detectionResultColumns[barcodeColumn]->getCodewords()->GetAt(
+ codewordsRow);
+ if (!codeword) {
continue;
}
codeword->setRowNumber(
- ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber());
+ LRIcodewords->GetAt(codewordsRow)->getRowNumber());
if (!codeword->hasValidRowNumber()) {
- ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn])
- ->getCodewords()
- ->SetAt(codewordsRow, NULL);
+ m_detectionResultColumns[barcodeColumn]->getCodewords()->SetAt(
+ codewordsRow, nullptr);
}
}
}
@@ -184,30 +172,26 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() {
return 0;
}
int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() {
- if (m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) {
+ if (!m_detectionResultColumns[m_barcodeColumnCount + 1]) {
return 0;
}
int32_t unadjustedCount = 0;
- CFX_PtrArray* codewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(
- m_barcodeColumnCount + 1))
- ->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords =
+ m_detectionResultColumns.GetAt(m_barcodeColumnCount + 1)->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
int32_t rowIndicatorRowNumber =
- ((CBC_Codeword*)codewords->GetAt(codewordsRow))->getRowNumber();
+ codewords->GetAt(codewordsRow)->getRowNumber();
int32_t invalidRowCounts = 0;
for (int32_t barcodeColumn = m_barcodeColumnCount + 1;
barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
barcodeColumn--) {
- CBC_Codeword* codeword =
- (CBC_Codeword*)((CBC_DetectionResultColumn*)
- m_detectionResultColumns.GetAt(barcodeColumn))
- ->getCodewords()
- ->GetAt(codewordsRow);
+ CBC_Codeword* codeword = m_detectionResultColumns.GetAt(barcodeColumn)
+ ->getCodewords()
+ ->GetAt(codewordsRow);
if (codeword) {
invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber,
invalidRowCounts, codeword);
@@ -224,25 +208,22 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() {
return 0;
}
int32_t unadjustedCount = 0;
- CFX_PtrArray* codewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(0))
- ->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords =
+ m_detectionResultColumns.GetAt(0)->getCodewords();
for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize();
codewordsRow++) {
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
int32_t rowIndicatorRowNumber =
- ((CBC_Codeword*)codewords->GetAt(codewordsRow))->getRowNumber();
+ codewords->GetAt(codewordsRow)->getRowNumber();
int32_t invalidRowCounts = 0;
for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1 &&
invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
barcodeColumn++) {
CBC_Codeword* codeword =
- (CBC_Codeword*)((CBC_DetectionResultColumn*)
- m_detectionResultColumns[barcodeColumn])
- ->getCodewords()
- ->GetAt(codewordsRow);
+ m_detectionResultColumns[barcodeColumn]->getCodewords()->GetAt(
+ codewordsRow);
if (codeword) {
invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber,
invalidRowCounts, codeword);
@@ -271,21 +252,20 @@ int32_t CBC_DetectionResult::adjustRowNumberIfValid(
}
return invalidRowCounts;
}
-void CBC_DetectionResult::adjustRowNumbers(int32_t barcodeColumn,
- int32_t codewordsRow,
- CFX_PtrArray* codewords) {
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow);
- CFX_PtrArray* previousColumnCodewords =
- ((CBC_DetectionResultColumn*)m_detectionResultColumns.GetAt(
- barcodeColumn - 1))
- ->getCodewords();
- CFX_PtrArray* nextColumnCodewords = previousColumnCodewords;
+void CBC_DetectionResult::adjustRowNumbers(
+ int32_t barcodeColumn,
+ int32_t codewordsRow,
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords) {
+ CBC_Codeword* codeword = codewords->GetAt(codewordsRow);
+ CFX_ArrayTemplate<CBC_Codeword*>* previousColumnCodewords =
+ m_detectionResultColumns.GetAt(barcodeColumn - 1)->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* nextColumnCodewords =
+ previousColumnCodewords;
if (m_detectionResultColumns[barcodeColumn + 1]) {
- nextColumnCodewords = ((CBC_DetectionResultColumn*)
- m_detectionResultColumns[barcodeColumn + 1])
- ->getCodewords();
+ nextColumnCodewords =
+ m_detectionResultColumns[barcodeColumn + 1]->getCodewords();
}
- CFX_PtrArray otherCodewords;
+ CFX_ArrayTemplate<CBC_Codeword*> otherCodewords;
otherCodewords.SetSize(14);
otherCodewords[2] = previousColumnCodewords->GetAt(codewordsRow);
otherCodewords[3] = nextColumnCodewords->GetAt(codewordsRow);
@@ -310,7 +290,7 @@ void CBC_DetectionResult::adjustRowNumbers(int32_t barcodeColumn,
otherCodewords[13] = nextColumnCodewords->GetAt(codewordsRow + 2);
}
for (int32_t i = 0; i < otherCodewords.GetSize(); i++) {
- CBC_Codeword* otherCodeword = (CBC_Codeword*)otherCodewords.GetAt(i);
+ CBC_Codeword* otherCodeword = otherCodewords.GetAt(i);
if (adjustRowNumber(codeword, otherCodeword)) {
return;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
index 8b7f91bfcd1..1590ce227aa 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResult.h
@@ -16,7 +16,7 @@ class CBC_DetectionResult {
CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata,
CBC_BoundingBox* boundingBox);
virtual ~CBC_DetectionResult();
- CFX_PtrArray& getDetectionResultColumns();
+ CFX_ArrayTemplate<CBC_DetectionResultColumn*>& getDetectionResultColumns();
void setBoundingBox(CBC_BoundingBox* boundingBox);
CBC_BoundingBox* getBoundingBox();
void setDetectionResultColumn(
@@ -32,7 +32,7 @@ class CBC_DetectionResult {
private:
static int32_t ADJUST_ROW_NUMBER_SKIP;
CBC_BarcodeMetadata* m_barcodeMetadata;
- CFX_PtrArray m_detectionResultColumns;
+ CFX_ArrayTemplate<CBC_DetectionResultColumn*> m_detectionResultColumns;
CBC_BoundingBox* m_boundingBox;
int32_t m_barcodeColumnCount;
@@ -49,7 +49,7 @@ class CBC_DetectionResult {
CBC_Codeword* codeword);
void adjustRowNumbers(int32_t barcodeColumn,
int32_t codewordsRow,
- CFX_PtrArray* codewords);
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords);
static FX_BOOL adjustRowNumber(CBC_Codeword* codeword,
CBC_Codeword* otherCodeword);
};
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp
index 24d81070f3c..110a5f375e7 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp
@@ -27,16 +27,16 @@
int32_t CBC_DetectionResultColumn::MAX_NEARBY_DISTANCE = 5;
CBC_DetectionResultColumn::CBC_DetectionResultColumn(
- CBC_BoundingBox* boundingBox) {
- m_boundingBox = boundingBox;
- m_codewords = new CFX_PtrArray;
+ CBC_BoundingBox* boundingBox)
+ : m_boundingBox(boundingBox),
+ m_codewords(new CFX_ArrayTemplate<CBC_Codeword*>()) {
m_codewords->SetSize(boundingBox->getMaxY() - boundingBox->getMinY() + 1);
}
+
CBC_DetectionResultColumn::~CBC_DetectionResultColumn() {
for (int32_t i = 0; i < m_codewords->GetSize(); i++) {
- delete (CBC_Codeword*)m_codewords->GetAt(i);
+ delete m_codewords->GetAt(i);
}
- m_codewords->RemoveAll();
delete m_codewords;
}
CBC_Codeword* CBC_DetectionResultColumn::getCodewordNearby(int32_t imageRow) {
@@ -79,7 +79,8 @@ CBC_Codeword* CBC_DetectionResultColumn::getCodeword(int32_t imageRow) {
CBC_BoundingBox* CBC_DetectionResultColumn::getBoundingBox() {
return m_boundingBox;
}
-CFX_PtrArray* CBC_DetectionResultColumn::getCodewords() {
+CFX_ArrayTemplate<CBC_Codeword*>* CBC_DetectionResultColumn::getCodewords()
+ const {
return m_codewords;
}
CFX_ByteString CBC_DetectionResultColumn::toString() {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h
index ebe01a2a0cb..949f8ac4aa6 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.h
@@ -9,22 +9,23 @@
class CBC_Codeword;
class CBC_BoundingBox;
+
class CBC_DetectionResultColumn {
public:
CBC_DetectionResultColumn(CBC_BoundingBox* boundingBox);
virtual ~CBC_DetectionResultColumn();
+
CBC_Codeword* getCodewordNearby(int32_t imageRow);
int32_t imageRowToCodewordIndex(int32_t imageRow);
int32_t codewordIndexToImageRow(int32_t codewordIndex);
void setCodeword(int32_t imageRow, CBC_Codeword* codeword);
CBC_Codeword* getCodeword(int32_t imageRow);
CBC_BoundingBox* getBoundingBox();
- CFX_PtrArray* getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* getCodewords() const;
CFX_ByteString toString();
- public:
CBC_BoundingBox* m_boundingBox;
- CFX_PtrArray* m_codewords;
+ CFX_ArrayTemplate<CBC_Codeword*>* m_codewords;
private:
static int32_t MAX_NEARBY_DISTANCE;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp
index bdcd91052c8..8783e87f1bf 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp
@@ -50,7 +50,7 @@ void CBC_DetectionResultRowIndicatorColumn::setRowNumbers() {
int32_t
CBC_DetectionResultRowIndicatorColumn::adjustCompleteIndicatorColumnRowNumbers(
CBC_BarcodeMetadata barcodeMetadata) {
- CFX_PtrArray* codewords = getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords = getCodewords();
setRowNumbers();
removeIncorrectCodewords(codewords, barcodeMetadata);
CBC_BoundingBox* boundingBox = getBoundingBox();
@@ -70,7 +70,7 @@ CBC_DetectionResultRowIndicatorColumn::adjustCompleteIndicatorColumnRowNumbers(
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow);
+ CBC_Codeword* codeword = codewords->GetAt(codewordsRow);
int32_t rowDifference = codeword->getRowNumber() - barcodeRow;
if (rowDifference == 0) {
currentRowHeight++;
@@ -138,7 +138,7 @@ int32_t CBC_DetectionResultRowIndicatorColumn::
int32_t lastRow = imageRowToCodewordIndex((int32_t)bottom->GetY());
FX_FLOAT averageRowHeight =
(lastRow - firstRow) / (FX_FLOAT)barcodeMetadata.getRowCount();
- CFX_PtrArray* codewords = getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords = getCodewords();
int32_t barcodeRow = -1;
int32_t maxRowHeight = 1;
int32_t currentRowHeight = 0;
@@ -147,7 +147,7 @@ int32_t CBC_DetectionResultRowIndicatorColumn::
if (codewords->GetAt(codewordsRow) == NULL) {
continue;
}
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow);
+ CBC_Codeword* codeword = codewords->GetAt(codewordsRow);
codeword->setRowNumberAsRowIndicatorColumn();
int32_t rowDifference = codeword->getRowNumber() - barcodeRow;
if (rowDifference == 0) {
@@ -168,13 +168,13 @@ int32_t CBC_DetectionResultRowIndicatorColumn::
}
CBC_BarcodeMetadata*
CBC_DetectionResultRowIndicatorColumn::getBarcodeMetadata() {
- CFX_PtrArray* codewords = getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords = getCodewords();
CBC_BarcodeValue barcodeColumnCount;
CBC_BarcodeValue barcodeRowCountUpperPart;
CBC_BarcodeValue barcodeRowCountLowerPart;
CBC_BarcodeValue barcodeECLevel;
for (int32_t i = 0; i < codewords->GetSize(); i++) {
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(i);
+ CBC_Codeword* codeword = codewords->GetAt(i);
if (codeword == NULL) {
continue;
}
@@ -222,15 +222,15 @@ FX_BOOL CBC_DetectionResultRowIndicatorColumn::isLeft() {
return m_isLeft;
}
CFX_ByteString CBC_DetectionResultRowIndicatorColumn::toString() {
- return (CFX_ByteString) "IsLeft: " + (CFX_ByteString)m_isLeft + '\n' +
+ return CFX_ByteString("IsLeft: ") + m_isLeft + '\n' +
CBC_DetectionResultColumn::toString();
}
void CBC_DetectionResultRowIndicatorColumn::removeIncorrectCodewords(
- CFX_PtrArray* codewords,
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords,
CBC_BarcodeMetadata barcodeMetadata) {
for (int32_t codewordRow = 0; codewordRow < codewords->GetSize();
codewordRow++) {
- CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordRow);
+ CBC_Codeword* codeword = codewords->GetAt(codewordRow);
if (codeword == NULL) {
continue;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h
index dfe6a069d64..f914354124b 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.h
@@ -9,7 +9,7 @@
class CBC_BarcodeMetadata;
class CBC_BoundingBox;
-class CBC_DetectionResultRowIndicatorColumn;
+
class CBC_DetectionResultRowIndicatorColumn : public CBC_DetectionResultColumn {
public:
CBC_DetectionResultRowIndicatorColumn(CBC_BoundingBox* boundingBox,
@@ -26,9 +26,10 @@ class CBC_DetectionResultRowIndicatorColumn : public CBC_DetectionResultColumn {
CFX_ByteString toString();
private:
- FX_BOOL m_isLeft;
- void removeIncorrectCodewords(CFX_PtrArray* codewords,
+ void removeIncorrectCodewords(CFX_ArrayTemplate<CBC_Codeword*>* codewords,
CBC_BarcodeMetadata barcodeMetadata);
+
+ FX_BOOL m_isLeft;
};
#endif // XFA_FXBARCODE_PDF417_BC_PDF417DETECTIONRESULTROWINDICATORCOLUMN_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp
index cfd52e56dc5..6c217621b23 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.cpp
@@ -20,6 +20,8 @@
* limitations under the License.
*/
+#include <memory>
+
#include "xfa/fxbarcode/BC_BinaryBitmap.h"
#include "xfa/fxbarcode/BC_ResultPoint.h"
#include "xfa/fxbarcode/common/BC_CommonBitArray.h"
@@ -49,13 +51,14 @@ int32_t CBC_Detector::BARCODE_MIN_HEIGHT = 10;
CBC_Detector::CBC_Detector() {}
CBC_Detector::~CBC_Detector() {}
+
CBC_PDF417DetectorResult* CBC_Detector::detect(CBC_BinaryBitmap* image,
int32_t hints,
FX_BOOL multiple,
int32_t& e) {
CBC_CommonBitMatrix* bitMatrix = image->GetBlackMatrix(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* barcodeCoordinates = detect(multiple, bitMatrix);
+ CBC_ResultPointArrayArray* barcodeCoordinates = detect(multiple, bitMatrix);
if (barcodeCoordinates->GetSize() == 0) {
rotate180(bitMatrix);
barcodeCoordinates = detect(multiple, bitMatrix);
@@ -64,9 +67,7 @@ CBC_PDF417DetectorResult* CBC_Detector::detect(CBC_BinaryBitmap* image,
e = BCExceptionUnSupportedBarcode;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- CBC_PDF417DetectorResult* detectorResult =
- new CBC_PDF417DetectorResult(bitMatrix, barcodeCoordinates);
- return detectorResult;
+ return new CBC_PDF417DetectorResult(bitMatrix, barcodeCoordinates);
}
void CBC_Detector::rotate180(CBC_CommonBitMatrix* bitMatrix) {
int32_t width = bitMatrix->GetWidth();
@@ -104,37 +105,34 @@ CBC_CommonBitArray* CBC_Detector::mirror(CBC_CommonBitArray* input,
}
return array;
}
-CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple,
- CBC_CommonBitMatrix* bitMatrix) {
- CFX_PtrArray* barcodeCoordinates = new CFX_PtrArray;
+
+CBC_ResultPointArrayArray* CBC_Detector::detect(
+ FX_BOOL multiple,
+ CBC_CommonBitMatrix* bitMatrix) {
+ CBC_ResultPointArrayArray* barcodeCoordinates = new CBC_ResultPointArrayArray;
int32_t row = 0;
int32_t column = 0;
FX_BOOL foundBarcodeInRow = FALSE;
while (row < bitMatrix->GetHeight()) {
- CFX_PtrArray* vertices = findVertices(bitMatrix, row, column);
+ CBC_ResultPointArray* vertices = findVertices(bitMatrix, row, column);
if (vertices->GetAt(0) == NULL && vertices->GetAt(3) == NULL) {
if (!foundBarcodeInRow) {
- if (vertices) {
- delete (vertices);
- }
+ delete vertices;
break;
}
foundBarcodeInRow = FALSE;
column = 0;
for (int32_t i = 0; i < barcodeCoordinates->GetSize(); i++) {
- CFX_PtrArray* barcodeCoordinate =
- (CFX_PtrArray*)barcodeCoordinates->GetAt(i);
+ CBC_ResultPointArray* barcodeCoordinate = barcodeCoordinates->GetAt(i);
if (barcodeCoordinate->GetAt(1)) {
- row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(1))->GetY();
+ row = row > barcodeCoordinate->GetAt(1)->GetY();
}
if (barcodeCoordinate->GetAt(3)) {
- row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(3))->GetY();
+ row = row > barcodeCoordinate->GetAt(3)->GetY();
}
}
row += ROW_STEP;
- if (vertices) {
- delete (vertices);
- }
+ delete vertices;
continue;
}
foundBarcodeInRow = TRUE;
@@ -143,59 +141,58 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple,
break;
}
if (vertices->GetAt(2)) {
- column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetX();
- row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetY();
+ column = (int32_t)vertices->GetAt(2)->GetX();
+ row = (int32_t)vertices->GetAt(2)->GetY();
} else {
- column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(4))->GetX();
- row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(4))->GetY();
+ column = (int32_t)vertices->GetAt(4)->GetX();
+ row = (int32_t)vertices->GetAt(4)->GetY();
}
}
return barcodeCoordinates;
}
-CFX_PtrArray* CBC_Detector::findVertices(CBC_CommonBitMatrix* matrix,
- int32_t startRow,
- int32_t startColumn) {
+
+CBC_ResultPointArray* CBC_Detector::findVertices(CBC_CommonBitMatrix* matrix,
+ int32_t startRow,
+ int32_t startColumn) {
int32_t height = matrix->GetHeight();
int32_t width = matrix->GetWidth();
- CFX_PtrArray* result = new CFX_PtrArray;
+ CBC_ResultPointArray* result = new CBC_ResultPointArray;
result->SetSize(8);
- CFX_PtrArray* startptr = findRowsWithPattern(
- matrix, height, width, startRow, startColumn, START_PATTERN,
- sizeof(START_PATTERN) / sizeof(START_PATTERN[0]));
- copyToResult(
- result, startptr, INDEXES_START_PATTERN,
- sizeof(INDEXES_START_PATTERN) / sizeof(INDEXES_START_PATTERN[0]));
- startptr->RemoveAll();
- delete startptr;
+ std::unique_ptr<CBC_ResultPointArray> startptr(
+ findRowsWithPattern(matrix, height, width, startRow, startColumn,
+ START_PATTERN, FX_ArraySize(START_PATTERN)));
+ copyToResult(result, startptr.get(), INDEXES_START_PATTERN,
+ FX_ArraySize(INDEXES_START_PATTERN));
if (result->GetAt(4)) {
- startColumn = (int32_t)((CBC_ResultPoint*)result->GetAt(4))->GetX();
- startRow = (int32_t)((CBC_ResultPoint*)result->GetAt(4))->GetY();
+ startColumn = (int32_t)result->GetAt(4)->GetX();
+ startRow = (int32_t)result->GetAt(4)->GetY();
}
- CFX_PtrArray* stopptr = findRowsWithPattern(
- matrix, height, width, startRow, startColumn, STOP_PATTERN,
- sizeof(STOP_PATTERN) / sizeof(STOP_PATTERN[0]));
- copyToResult(result, stopptr, INDEXES_STOP_PATTERN,
- sizeof(INDEXES_STOP_PATTERN) / sizeof(INDEXES_STOP_PATTERN[0]));
- stopptr->RemoveAll();
- delete stopptr;
+ std::unique_ptr<CBC_ResultPointArray> stopptr(
+ findRowsWithPattern(matrix, height, width, startRow, startColumn,
+ STOP_PATTERN, FX_ArraySize(STOP_PATTERN)));
+ copyToResult(result, stopptr.get(), INDEXES_STOP_PATTERN,
+ FX_ArraySize(INDEXES_STOP_PATTERN));
return result;
}
-void CBC_Detector::copyToResult(CFX_PtrArray* result,
- CFX_PtrArray* tmpResult,
+
+void CBC_Detector::copyToResult(CBC_ResultPointArray* result,
+ CBC_ResultPointArray* tmpResult,
int32_t* destinationIndexes,
int32_t destinationLength) {
for (int32_t i = 0; i < destinationLength; i++) {
result->SetAt(destinationIndexes[i], tmpResult->GetAt(i));
}
}
-CFX_PtrArray* CBC_Detector::findRowsWithPattern(CBC_CommonBitMatrix* matrix,
- int32_t height,
- int32_t width,
- int32_t startRow,
- int32_t startColumn,
- int32_t* pattern,
- int32_t patternLength) {
- CFX_PtrArray* result = new CFX_PtrArray;
+
+CBC_ResultPointArray* CBC_Detector::findRowsWithPattern(
+ CBC_CommonBitMatrix* matrix,
+ int32_t height,
+ int32_t width,
+ int32_t startRow,
+ int32_t startColumn,
+ int32_t* pattern,
+ int32_t patternLength) {
+ CBC_ResultPointArray* result = new CBC_ResultPointArray;
result->SetSize(4);
FX_BOOL found = FALSE;
CFX_Int32Array counters;
@@ -230,8 +227,8 @@ CFX_PtrArray* CBC_Detector::findRowsWithPattern(CBC_CommonBitMatrix* matrix,
if (found) {
int32_t skippedRowCount = 0;
CFX_Int32Array previousRowLoc;
- previousRowLoc.Add((int32_t)((CBC_ResultPoint*)result->GetAt(0))->GetX());
- previousRowLoc.Add((int32_t)((CBC_ResultPoint*)result->GetAt(1))->GetX());
+ previousRowLoc.Add((int32_t)result->GetAt(0)->GetX());
+ previousRowLoc.Add((int32_t)result->GetAt(1)->GetX());
for (; stopRow < height; stopRow++) {
CFX_Int32Array* loc =
findGuardPattern(matrix, previousRowLoc[0], stopRow, width, FALSE,
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.h
index dda039d6d54..c6fa6f6e7e9 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Detector.h
@@ -7,7 +7,8 @@
#ifndef XFA_FXBARCODE_PDF417_BC_PDF417DETECTOR_H_
#define XFA_FXBARCODE_PDF417_BC_PDF417DETECTOR_H_
-class CBC_PDF417DetectorResult;
+#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h"
+
class CBC_BinaryBitmap;
class CBC_CommonBitMatrix;
class CBC_CommonBitArray;
@@ -38,21 +39,22 @@ class CBC_Detector {
static int32_t SKIPPED_ROW_COUNT_MAX;
static int32_t ROW_STEP;
static int32_t BARCODE_MIN_HEIGHT;
- static CFX_PtrArray* detect(FX_BOOL multiple, CBC_CommonBitMatrix* bitMatrix);
- static CFX_PtrArray* findVertices(CBC_CommonBitMatrix* matrix,
- int32_t startRow,
- int32_t startColumn);
- static void copyToResult(CFX_PtrArray* result,
- CFX_PtrArray* tmpResult,
+ static CBC_ResultPointArrayArray* detect(FX_BOOL multiple,
+ CBC_CommonBitMatrix* bitMatrix);
+ static CBC_ResultPointArray* findVertices(CBC_CommonBitMatrix* matrix,
+ int32_t startRow,
+ int32_t startColumn);
+ static void copyToResult(CBC_ResultPointArray* result,
+ CBC_ResultPointArray* tmpResult,
int32_t* destinationIndexes,
int32_t destinationLength);
- static CFX_PtrArray* findRowsWithPattern(CBC_CommonBitMatrix* matrix,
- int32_t height,
- int32_t width,
- int32_t startRow,
- int32_t startColumn,
- int32_t* pattern,
- int32_t patternLength);
+ static CBC_ResultPointArray* findRowsWithPattern(CBC_CommonBitMatrix* matrix,
+ int32_t height,
+ int32_t width,
+ int32_t startRow,
+ int32_t startColumn,
+ int32_t* pattern,
+ int32_t patternLength);
static CFX_Int32Array* findGuardPattern(CBC_CommonBitMatrix* matrix,
int32_t column,
int32_t row,
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp
index 557d50d9518..4b68bdf6788 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.cpp
@@ -24,27 +24,25 @@
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h"
-CBC_PDF417DetectorResult::CBC_PDF417DetectorResult(CBC_CommonBitMatrix* bits,
- CFX_PtrArray* points) {
- m_bits = bits;
- m_points = points;
-}
+CBC_PDF417DetectorResult::CBC_PDF417DetectorResult(
+ CBC_CommonBitMatrix* bits,
+ CBC_ResultPointArrayArray* points)
+ : m_bits(bits), m_points(points) {}
+
CBC_PDF417DetectorResult::~CBC_PDF417DetectorResult() {
for (int32_t i = 0; i < m_points->GetSize(); i++) {
- CFX_PtrArray* temp = (CFX_PtrArray*)m_points->GetAt(i);
- for (int32_t j = 0; j < temp->GetSize(); j++) {
- delete (CBC_ResultPoint*)temp->GetAt(j);
- }
- temp->RemoveAll();
+ CBC_ResultPointArray* temp = m_points->GetAt(i);
+ for (int32_t j = 0; j < temp->GetSize(); j++)
+ delete temp->GetAt(j);
+
delete temp;
}
- m_points->RemoveAll();
- delete m_points;
}
-CBC_CommonBitMatrix* CBC_PDF417DetectorResult::getBits() {
+
+CBC_CommonBitMatrix* CBC_PDF417DetectorResult::getBits() const {
return m_bits;
}
-CFX_PtrArray* CBC_PDF417DetectorResult::getPoints() {
- return m_points;
+CBC_ResultPointArrayArray* CBC_PDF417DetectorResult::getPoints() const {
+ return m_points.get();
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h
index 558111a28a9..afb200a4eac 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417DetectorResult.h
@@ -8,19 +8,23 @@
#define XFA_FXBARCODE_PDF417_BC_PDF417DETECTORRESULT_H_
#include "core/fxcrt/include/fx_basic.h"
+#include "xfa/fxbarcode/BC_ResultPoint.h"
class CBC_CommonBitMatrix;
-class CBC_PDF417DetectorResult {
+class CBC_PDF417DetectorResult final {
public:
- CBC_PDF417DetectorResult(CBC_CommonBitMatrix* bits, CFX_PtrArray* points);
- virtual ~CBC_PDF417DetectorResult();
- CBC_CommonBitMatrix* getBits();
- CFX_PtrArray* getPoints();
+ // Takes ownership of |points|.
+ CBC_PDF417DetectorResult(CBC_CommonBitMatrix* bits,
+ CBC_ResultPointArrayArray* points);
+ ~CBC_PDF417DetectorResult();
+
+ CBC_CommonBitMatrix* getBits() const;
+ CBC_ResultPointArrayArray* getPoints() const;
private:
CBC_CommonBitMatrix* m_bits;
- CFX_PtrArray* m_points;
+ std::unique_ptr<CBC_ResultPointArrayArray> m_points;
};
#endif // XFA_FXBARCODE_PDF417_BC_PDF417DETECTORRESULT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp
index 830b65e1997..6a1f46fd022 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.cpp
@@ -65,7 +65,7 @@ int32_t CBC_PDF417ECErrorCorrection::decode(CFX_Int32Array& received,
delete syndrome;
return -1;
}
- CFX_PtrArray* sigmaOmega =
+ CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* sigmaOmega =
runEuclideanAlgorithm(buildmonomial, syndrome, numECCodewords, e);
delete buildmonomial;
delete syndrome;
@@ -123,11 +123,11 @@ int32_t CBC_PDF417ECErrorCorrection::decode(CFX_Int32Array& received,
delete sigmaOmega;
return result;
}
-CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
- CBC_PDF417ECModulusPoly* a,
- CBC_PDF417ECModulusPoly* b,
- int32_t R,
- int32_t& e) {
+CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>*
+CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(CBC_PDF417ECModulusPoly* a,
+ CBC_PDF417ECModulusPoly* b,
+ int32_t R,
+ int32_t& e) {
if (a->getDegree() < b->getDegree()) {
CBC_PDF417ECModulusPoly* temp = a;
a = b;
@@ -153,32 +153,20 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
n = j;
if (rLast->isZero()) {
e = BCExceptionChecksumException;
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
r = rLastLast;
CBC_PDF417ECModulusPoly* q = m_field->getZero();
int32_t denominatorLeadingTerm = rLast->getCoefficient(rLast->getDegree());
int32_t dltInverse = m_field->inverse(denominatorLeadingTerm, e);
if (e != BCExceptionNO) {
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
while (r->getDegree() >= rLast->getDegree() && !r->isZero()) {
int32_t degreeDiff = r->getDegree() - rLast->getDegree();
@@ -187,81 +175,51 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
CBC_PDF417ECModulusPoly* buildmonomial =
m_field->buildMonomial(degreeDiff, scale, e);
if (e != BCExceptionNO) {
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
q = q->add(buildmonomial, e);
delete buildmonomial;
- if (qtemp) {
- delete qtemp;
- }
+ delete qtemp;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
qtemp = q;
CBC_PDF417ECModulusPoly* multiply =
rLast->multiplyByMonomial(degreeDiff, scale, e);
if (e != BCExceptionNO) {
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
CBC_PDF417ECModulusPoly* temp = r;
r = temp->subtract(multiply, e);
delete multiply;
if (m > 1 && i > m) {
delete temp;
- temp = NULL;
+ temp = nullptr;
}
if (e != BCExceptionNO) {
- if (qtemp) {
- delete qtemp;
- }
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete qtemp;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
rtemp = r;
i = m + 1;
}
ttemp = q->multiply(tLast, e);
- if (qtemp) {
- delete qtemp;
- qtemp = NULL;
- }
+ delete qtemp;
+ qtemp = nullptr;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
t = ttemp->subtract(tLastLast, e);
if (n > 1 && j > n) {
@@ -269,19 +227,15 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
}
delete ttemp;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- return NULL;
+ delete rtemp;
+ return nullptr;
}
ttemp = t;
t = ttemp->negative(e);
delete ttemp;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- return NULL;
+ delete rtemp;
+ return nullptr;
}
ttemp = t;
j++;
@@ -289,40 +243,27 @@ CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(
int32_t sigmaTildeAtZero = t->getCoefficient(0);
if (sigmaTildeAtZero == 0) {
e = BCExceptionChecksumException;
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
+ delete rtemp;
+ delete ttemp;
+ return nullptr;
}
int32_t inverse = m_field->inverse(sigmaTildeAtZero, e);
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- if (ttemp) {
- delete ttemp;
- }
- return NULL;
- }
- CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e);
- if (ttemp) {
+ delete rtemp;
delete ttemp;
+ return nullptr;
}
+ CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e);
+ delete ttemp;
if (e != BCExceptionNO) {
- if (rtemp) {
- delete rtemp;
- }
- return NULL;
- }
- CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e);
- if (rtemp) {
delete rtemp;
+ return nullptr;
}
+ CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e);
+ delete rtemp;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* modulusPoly = new CFX_PtrArray;
+ CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* modulusPoly =
+ new CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>();
modulusPoly->Add(sigma);
modulusPoly->Add(omega);
return modulusPoly;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h
index d7b56defe93..95e691a60a1 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECErrorCorrection.h
@@ -22,10 +22,11 @@ class CBC_PDF417ECErrorCorrection {
private:
static CBC_PDF417ECModulusGF* m_field;
- static CFX_PtrArray* runEuclideanAlgorithm(CBC_PDF417ECModulusPoly* a,
- CBC_PDF417ECModulusPoly* b,
- int32_t R,
- int32_t& e);
+ static CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* runEuclideanAlgorithm(
+ CBC_PDF417ECModulusPoly* a,
+ CBC_PDF417ECModulusPoly* b,
+ int32_t R,
+ int32_t& e);
static CFX_Int32Array* findErrorLocations(
CBC_PDF417ECModulusPoly* errorLocator,
int32_t& e);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp
index d0bbe5ab0a0..47fbcce5d04 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp
@@ -20,6 +20,8 @@
* limitations under the License.
*/
+#include <memory>
+
#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h"
#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusGF.h"
#include "xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h"
@@ -212,19 +214,20 @@ CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply(int32_t scalar,
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return modulusPoly;
}
+
CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiplyByMonomial(
int32_t degree,
int32_t coefficient,
int32_t& e) {
if (degree < 0) {
e = BCExceptionIllegalArgument;
- return NULL;
+ return nullptr;
}
- CBC_PDF417ECModulusPoly* modulusPoly = NULL;
+ CBC_PDF417ECModulusPoly* modulusPoly = nullptr;
if (coefficient == 0) {
modulusPoly = new CBC_PDF417ECModulusPoly(
m_field->getZero()->m_field, m_field->getZero()->m_coefficients, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return modulusPoly;
}
int32_t size = m_coefficients.GetSize();
@@ -234,74 +237,62 @@ CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiplyByMonomial(
product[i] = m_field->multiply(m_coefficients[i], coefficient);
}
modulusPoly = new CBC_PDF417ECModulusPoly(m_field, product, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return modulusPoly;
}
-CFX_PtrArray* CBC_PDF417ECModulusPoly::divide(CBC_PDF417ECModulusPoly* other,
- int32_t& e) {
+
+CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* CBC_PDF417ECModulusPoly::divide(
+ CBC_PDF417ECModulusPoly* other,
+ int32_t& e) {
if (other->isZero()) {
e = BCExceptionDivideByZero;
- return NULL;
- }
- CBC_PDF417ECModulusPoly* quotient = new CBC_PDF417ECModulusPoly(
- m_field->getZero()->m_field, m_field->getZero()->m_coefficients, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_PDF417ECModulusPoly* remainder =
- new CBC_PDF417ECModulusPoly(m_field, m_coefficients, e);
- if (e != BCExceptionNO) {
- delete quotient;
- return NULL;
+ return nullptr;
}
+ std::unique_ptr<CBC_PDF417ECModulusPoly> quotient(new CBC_PDF417ECModulusPoly(
+ m_field->getZero()->m_field, m_field->getZero()->m_coefficients, e));
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
+ std::unique_ptr<CBC_PDF417ECModulusPoly> remainder(
+ new CBC_PDF417ECModulusPoly(m_field, m_coefficients, e));
+ if (e != BCExceptionNO)
+ return nullptr;
+
int32_t denominatorLeadingTerm = other->getCoefficient(other->getDegree());
int32_t inverseDenominatorLeadingTerm =
m_field->inverse(denominatorLeadingTerm, e);
- if (e != BCExceptionNO) {
- delete quotient;
- delete remainder;
- return NULL;
- }
+ if (e != BCExceptionNO)
+ return nullptr;
+
while (remainder->getDegree() >= other->getDegree() && !remainder->isZero()) {
int32_t degreeDifference = remainder->getDegree() - other->getDegree();
int32_t scale =
m_field->multiply(remainder->getCoefficient(remainder->getDegree()),
inverseDenominatorLeadingTerm);
- CBC_PDF417ECModulusPoly* term =
- other->multiplyByMonomial(degreeDifference, scale, e);
- if (e != BCExceptionNO) {
- delete quotient;
- delete remainder;
- return NULL;
- }
- CBC_PDF417ECModulusPoly* iterationQuotient =
- m_field->buildMonomial(degreeDifference, scale, e);
- if (e != BCExceptionNO) {
- delete quotient;
- delete remainder;
- delete term;
- return NULL;
- }
- CBC_PDF417ECModulusPoly* temp = quotient;
- quotient = temp->add(iterationQuotient, e);
- delete iterationQuotient;
- delete temp;
- if (e != BCExceptionNO) {
- delete remainder;
- return NULL;
- }
- temp = remainder;
- remainder = temp->subtract(term, e);
- delete term;
- delete temp;
- if (e != BCExceptionNO) {
- delete quotient;
- return NULL;
- }
+ std::unique_ptr<CBC_PDF417ECModulusPoly> term(
+ other->multiplyByMonomial(degreeDifference, scale, e));
+ if (e != BCExceptionNO)
+ return nullptr;
+
+ std::unique_ptr<CBC_PDF417ECModulusPoly> iterationQuotient(
+ m_field->buildMonomial(degreeDifference, scale, e));
+ if (e != BCExceptionNO)
+ return nullptr;
+
+ quotient.reset(quotient->add(iterationQuotient.get(), e));
+ if (e != BCExceptionNO)
+ return nullptr;
+
+ remainder.reset(remainder->subtract(term.get(), e));
+ if (e != BCExceptionNO)
+ return nullptr;
}
- CFX_PtrArray* modulusPoly = new CFX_PtrArray;
- modulusPoly->Add(quotient);
- modulusPoly->Add(remainder);
+
+ CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* modulusPoly =
+ new CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>();
+ modulusPoly->Add(quotient.release());
+ modulusPoly->Add(remainder.release());
return modulusPoly;
}
+
CFX_ByteString CBC_PDF417ECModulusPoly::toString() {
CFX_ByteString result;
for (int32_t degree = getDegree(); degree >= 0; degree--) {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h
index 2eff3ef1ce2..173972be6e5 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h
@@ -8,12 +8,13 @@
#define XFA_FXBARCODE_PDF417_BC_PDF417ECMODULUSPOLY_H_
class CBC_PDF417ECModulusGF;
-class CBC_PDF417ECModulusPoly {
+class CBC_PDF417ECModulusPoly final {
public:
CBC_PDF417ECModulusPoly(CBC_PDF417ECModulusGF* field,
CFX_Int32Array& coefficients,
int32_t& e);
- virtual ~CBC_PDF417ECModulusPoly();
+ ~CBC_PDF417ECModulusPoly();
+
CFX_Int32Array& getCoefficients();
CBC_PDF417ECModulusGF* getField();
int32_t getDegree();
@@ -28,7 +29,9 @@ class CBC_PDF417ECModulusPoly {
CBC_PDF417ECModulusPoly* multiplyByMonomial(int32_t degree,
int32_t coefficient,
int32_t& e);
- CFX_PtrArray* divide(CBC_PDF417ECModulusPoly* other, int32_t& e);
+ CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* divide(
+ CBC_PDF417ECModulusPoly* other,
+ int32_t& e);
CFX_ByteString toString();
private:
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp
index 4d953e006ab..e68969ef306 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.cpp
@@ -20,7 +20,9 @@
* limitations under the License.
*/
+#include <algorithm>
#include <limits>
+#include <memory>
#include "xfa/fxbarcode/BC_BinaryBitmap.h"
#include "xfa/fxbarcode/BC_BinaryBitmap.h"
@@ -64,27 +66,25 @@ CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image,
int32_t hints,
int32_t& e) {
CFX_ByteString results;
- CBC_PDF417DetectorResult* detectorResult =
- CBC_Detector::detect(image, hints, multiple, e);
+ std::unique_ptr<CBC_PDF417DetectorResult> detectorResult(
+ CBC_Detector::detect(image, hints, multiple, e));
BC_EXCEPTION_CHECK_ReturnValue(e, "");
for (int32_t i = 0; i < detectorResult->getPoints()->GetSize(); i++) {
- CFX_PtrArray* points = (CFX_PtrArray*)detectorResult->getPoints()->GetAt(i);
- CBC_CommonDecoderResult* ResultTemp = CBC_PDF417ScanningDecoder::decode(
- detectorResult->getBits(), (CBC_ResultPoint*)points->GetAt(4),
- (CBC_ResultPoint*)points->GetAt(5), (CBC_ResultPoint*)points->GetAt(6),
- (CBC_ResultPoint*)points->GetAt(7), getMinCodewordWidth(*points),
- getMaxCodewordWidth(*points), e);
- if (ResultTemp == NULL) {
- delete detectorResult;
+ CBC_ResultPointArray* points = detectorResult->getPoints()->GetAt(i);
+ std::unique_ptr<CBC_CommonDecoderResult> ResultTemp(
+ CBC_PDF417ScanningDecoder::decode(
+ detectorResult->getBits(), points->GetAt(4), points->GetAt(5),
+ points->GetAt(6), points->GetAt(7), getMinCodewordWidth(*points),
+ getMaxCodewordWidth(*points), e));
+ if (!ResultTemp) {
e = BCExceptiontNotFoundInstance;
- return "";
+ return CFX_ByteString();
}
results += ResultTemp->GetText();
- delete ResultTemp;
}
- delete detectorResult;
return results;
}
+
CFX_ByteString CBC_PDF417Reader::Decode(CBC_BinaryBitmap* image,
int32_t hints,
int32_t& e) {
@@ -105,45 +105,29 @@ int32_t CBC_PDF417Reader::getMinWidth(CBC_ResultPoint* p1,
return std::numeric_limits<int32_t>::max();
return (int32_t)FXSYS_fabs(p1->GetX() - p2->GetX());
}
-int32_t CBC_PDF417Reader::getMaxCodewordWidth(CFX_PtrArray& p) {
- int32_t a =
- getMaxWidth((CBC_ResultPoint*)p.GetAt(6), (CBC_ResultPoint*)p.GetAt(2)) *
- CBC_PDF417Common::MODULES_IN_CODEWORD /
- CBC_PDF417Common::MODULES_IN_STOP_PATTERN;
- int32_t b =
- getMaxWidth((CBC_ResultPoint*)p.GetAt(7), (CBC_ResultPoint*)p.GetAt(3)) *
- CBC_PDF417Common::MODULES_IN_CODEWORD /
- CBC_PDF417Common::MODULES_IN_STOP_PATTERN;
- int32_t c = getMaxWidth((CBC_ResultPoint*)p.GetAt(0),
- (CBC_ResultPoint*)p.GetAt(4)) < a
- ? getMaxWidth((CBC_ResultPoint*)p.GetAt(0),
- (CBC_ResultPoint*)p.GetAt(4))
- : a;
- int32_t d = getMaxWidth((CBC_ResultPoint*)p.GetAt(1),
- (CBC_ResultPoint*)p.GetAt(5)) < b
- ? getMaxWidth((CBC_ResultPoint*)p.GetAt(1),
- (CBC_ResultPoint*)p.GetAt(5))
- : b;
- return c < d ? c : d;
+
+int32_t CBC_PDF417Reader::getMaxCodewordWidth(
+ const CFX_ArrayTemplate<CBC_ResultPoint*>& p) {
+ int32_t a = getMaxWidth(p.GetAt(6), p.GetAt(2)) *
+ CBC_PDF417Common::MODULES_IN_CODEWORD /
+ CBC_PDF417Common::MODULES_IN_STOP_PATTERN;
+ int32_t b = getMaxWidth(p.GetAt(7), p.GetAt(3)) *
+ CBC_PDF417Common::MODULES_IN_CODEWORD /
+ CBC_PDF417Common::MODULES_IN_STOP_PATTERN;
+ int32_t c = std::min(a, getMaxWidth(p.GetAt(0), p.GetAt(4)));
+ int32_t d = std::min(b, getMaxWidth(p.GetAt(1), p.GetAt(5)));
+ return std::min(c, d);
}
-int32_t CBC_PDF417Reader::getMinCodewordWidth(CFX_PtrArray& p) {
- int32_t a =
- getMinWidth((CBC_ResultPoint*)p.GetAt(6), (CBC_ResultPoint*)p.GetAt(2)) *
- CBC_PDF417Common::MODULES_IN_CODEWORD /
- CBC_PDF417Common::MODULES_IN_STOP_PATTERN;
- int32_t b =
- getMinWidth((CBC_ResultPoint*)p.GetAt(7), (CBC_ResultPoint*)p.GetAt(3)) *
- CBC_PDF417Common::MODULES_IN_CODEWORD /
- CBC_PDF417Common::MODULES_IN_STOP_PATTERN;
- int32_t c = getMinWidth((CBC_ResultPoint*)p.GetAt(0),
- (CBC_ResultPoint*)p.GetAt(4)) < a
- ? getMinWidth((CBC_ResultPoint*)p.GetAt(0),
- (CBC_ResultPoint*)p.GetAt(4))
- : a;
- int32_t d = getMinWidth((CBC_ResultPoint*)p.GetAt(1),
- (CBC_ResultPoint*)p.GetAt(5)) < b
- ? getMinWidth((CBC_ResultPoint*)p.GetAt(1),
- (CBC_ResultPoint*)p.GetAt(5))
- : b;
- return c < d ? c : d;
+
+int32_t CBC_PDF417Reader::getMinCodewordWidth(
+ const CFX_ArrayTemplate<CBC_ResultPoint*>& p) {
+ int32_t a = getMinWidth(p.GetAt(6), p.GetAt(2)) *
+ CBC_PDF417Common::MODULES_IN_CODEWORD /
+ CBC_PDF417Common::MODULES_IN_STOP_PATTERN;
+ int32_t b = getMinWidth(p.GetAt(7), p.GetAt(3)) *
+ CBC_PDF417Common::MODULES_IN_CODEWORD /
+ CBC_PDF417Common::MODULES_IN_STOP_PATTERN;
+ int32_t c = std::min(a, getMinWidth(p.GetAt(0), p.GetAt(4)));
+ int32_t d = std::min(b, getMinWidth(p.GetAt(1), p.GetAt(5)));
+ return std::min(c, d);
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.h
index 808de290147..73499b9cdf3 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417Reader.h
@@ -28,8 +28,10 @@ class CBC_PDF417Reader : public CBC_Reader {
private:
static int32_t getMaxWidth(CBC_ResultPoint* p1, CBC_ResultPoint* p2);
static int32_t getMinWidth(CBC_ResultPoint* p1, CBC_ResultPoint* p2);
- static int32_t getMaxCodewordWidth(CFX_PtrArray& p);
- static int32_t getMinCodewordWidth(CFX_PtrArray& p);
+ static int32_t getMaxCodewordWidth(
+ const CFX_ArrayTemplate<CBC_ResultPoint*>& p);
+ static int32_t getMinCodewordWidth(
+ const CFX_ArrayTemplate<CBC_ResultPoint*>& p);
};
#endif // XFA_FXBARCODE_PDF417_BC_PDF417READER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp
index 6ae68d72f36..4c3d4dbdf22 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp
@@ -20,6 +20,8 @@
* limitations under the License.
*/
+#include <memory>
+
#include "xfa/fxbarcode/BC_DecoderResult.h"
#include "xfa/fxbarcode/BC_ResultPoint.h"
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
@@ -155,16 +157,14 @@ CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::decode(
}
return decoderresult;
}
+
CFX_ByteString CBC_PDF417ScanningDecoder::toString(
- CFX_PtrArray* barcodeMatrix) {
+ CBC_BarcodeValueArrayArray* barcodeMatrix) {
CFX_ByteString result;
for (int32_t row = 0; row < barcodeMatrix->GetSize(); row++) {
result += row;
- int32_t l = 0;
- for (; l < ((CFX_PtrArray*)barcodeMatrix->GetAt(row))->GetSize(); l++) {
- CBC_BarcodeValue* barcodeValue =
- (CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt(row))
- ->GetAt(l);
+ for (int32_t l = 0; l < barcodeMatrix->GetAt(row)->GetSize(); l++) {
+ CBC_BarcodeValue* barcodeValue = barcodeMatrix->GetAt(row)->GetAt(l);
if (barcodeValue->getValue()->GetSize() == 0) {
result += "";
} else {
@@ -176,6 +176,7 @@ CFX_ByteString CBC_PDF417ScanningDecoder::toString(
}
return result;
}
+
CBC_DetectionResult* CBC_PDF417ScanningDecoder::merge(
CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn,
CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn,
@@ -229,7 +230,8 @@ CBC_BoundingBox* CBC_PDF417ScanningDecoder::adjustBoundingBox(
break;
}
}
- CFX_PtrArray* codewords = rowIndicatorColumn->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* codewords =
+ rowIndicatorColumn->getCodewords();
for (int32_t row = 0; missingStartRows > 0 && codewords->GetAt(row) == NULL;
row++) {
missingStartRows--;
@@ -322,13 +324,13 @@ CBC_PDF417ScanningDecoder::getRowIndicatorColumn(CBC_CommonBitMatrix* image,
}
return rowIndicatorColumn;
}
+
void CBC_PDF417ScanningDecoder::adjustCodewordCount(
CBC_DetectionResult* detectionResult,
- CFX_PtrArray* barcodeMatrix,
+ CBC_BarcodeValueArrayArray* barcodeMatrix,
int32_t& e) {
- CFX_Int32Array* numberOfCodewords =
- ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt(0))->GetAt(1))
- ->getValue();
+ std::unique_ptr<CFX_Int32Array> numberOfCodewords(
+ barcodeMatrix->GetAt(0)->GetAt(1)->getValue());
int32_t calculatedNumberOfCodewords =
detectionResult->getBarcodeColumnCount() *
detectionResult->getBarcodeRowCount() -
@@ -338,47 +340,39 @@ void CBC_PDF417ScanningDecoder::adjustCodewordCount(
calculatedNumberOfCodewords >
CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE) {
e = BCExceptiontNotFoundInstance;
- delete numberOfCodewords;
BC_EXCEPTION_CHECK_ReturnVoid(e);
}
- ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt(0))->GetAt(1))
- ->setValue(calculatedNumberOfCodewords);
+ barcodeMatrix->GetAt(0)->GetAt(1)->setValue(calculatedNumberOfCodewords);
} else if (numberOfCodewords->GetAt(0) != calculatedNumberOfCodewords) {
- ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt(0))->GetAt(1))
- ->setValue(calculatedNumberOfCodewords);
+ barcodeMatrix->GetAt(0)->GetAt(1)->setValue(calculatedNumberOfCodewords);
}
- delete numberOfCodewords;
}
+
CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::createDecoderResult(
CBC_DetectionResult* detectionResult,
int32_t& e) {
- CFX_PtrArray* barcodeMatrix = createBarcodeMatrix(detectionResult);
- adjustCodewordCount(detectionResult, barcodeMatrix, e);
+ std::unique_ptr<CBC_BarcodeValueArrayArray> barcodeMatrix(
+ createBarcodeMatrix(detectionResult));
+ adjustCodewordCount(detectionResult, barcodeMatrix.get(), e);
if (e != BCExceptionNO) {
for (int32_t i = 0; i < barcodeMatrix->GetSize(); i++) {
- CFX_PtrArray* temp = (CFX_PtrArray*)barcodeMatrix->GetAt(i);
- for (int32_t j = 0; j < temp->GetSize(); j++) {
- delete (CBC_BarcodeValue*)temp->GetAt(j);
- }
- temp->RemoveAll();
+ CBC_BarcodeValueArray* temp = barcodeMatrix->GetAt(i);
+ for (int32_t j = 0; j < temp->GetSize(); j++)
+ delete temp->GetAt(j);
delete temp;
}
- barcodeMatrix->RemoveAll();
- delete barcodeMatrix;
- return NULL;
+ return nullptr;
}
CFX_Int32Array erasures;
CFX_Int32Array codewords;
codewords.SetSize(detectionResult->getBarcodeRowCount() *
detectionResult->getBarcodeColumnCount());
- CFX_PtrArray ambiguousIndexValuesList;
+ CFX_ArrayTemplate<CFX_Int32Array*> ambiguousIndexValuesList;
CFX_Int32Array ambiguousIndexesList;
for (int32_t row = 0; row < detectionResult->getBarcodeRowCount(); row++) {
for (int32_t l = 0; l < detectionResult->getBarcodeColumnCount(); l++) {
CFX_Int32Array* values =
- ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt(row))
- ->GetAt(l + 1))
- ->getValue();
+ barcodeMatrix->GetAt(row)->GetAt(l + 1)->getValue();
int32_t codewordIndex =
row * detectionResult->getBarcodeColumnCount() + l;
if (values->GetSize() == 0) {
@@ -391,35 +385,33 @@ CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::createDecoderResult(
}
}
}
- CFX_PtrArray ambiguousIndexValues;
+ CFX_ArrayTemplate<CFX_Int32Array*> ambiguousIndexValues;
ambiguousIndexValues.SetSize(ambiguousIndexValuesList.GetSize());
for (int32_t i = 0; i < ambiguousIndexValues.GetSize(); i++) {
ambiguousIndexValues.SetAt(i, ambiguousIndexValuesList.GetAt(i));
}
for (int32_t l = 0; l < barcodeMatrix->GetSize(); l++) {
- CFX_PtrArray* temp = (CFX_PtrArray*)barcodeMatrix->GetAt(l);
- for (int32_t j = 0; j < temp->GetSize(); j++) {
- delete (CBC_BarcodeValue*)temp->GetAt(j);
- }
+ CBC_BarcodeValueArray* temp = barcodeMatrix->GetAt(l);
+ for (int32_t j = 0; j < temp->GetSize(); j++)
+ delete temp->GetAt(j);
temp->RemoveAll();
delete temp;
}
- barcodeMatrix->RemoveAll();
- delete barcodeMatrix;
CBC_CommonDecoderResult* decoderResult =
createDecoderResultFromAmbiguousValues(
detectionResult->getBarcodeECLevel(), codewords, erasures,
ambiguousIndexesList, ambiguousIndexValues, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return decoderResult;
}
+
CBC_CommonDecoderResult*
CBC_PDF417ScanningDecoder::createDecoderResultFromAmbiguousValues(
int32_t ecLevel,
CFX_Int32Array& codewords,
CFX_Int32Array& erasureArray,
CFX_Int32Array& ambiguousIndexes,
- CFX_PtrArray& ambiguousIndexValues,
+ CFX_ArrayTemplate<CFX_Int32Array*>& ambiguousIndexValues,
int32_t& e) {
CFX_Int32Array ambiguousIndexCount;
ambiguousIndexCount.SetSize(ambiguousIndexes.GetSize());
@@ -427,8 +419,7 @@ CBC_PDF417ScanningDecoder::createDecoderResultFromAmbiguousValues(
while (tries-- > 0) {
for (int32_t l = 0; l < ambiguousIndexCount.GetSize(); l++) {
codewords[ambiguousIndexes[l]] =
- ((CFX_Int32Array*)ambiguousIndexValues.GetAt(l))
- ->GetAt(ambiguousIndexCount[l]);
+ ambiguousIndexValues.GetAt(l)->GetAt(ambiguousIndexCount[l]);
}
CBC_CommonDecoderResult* decoderResult =
decodeCodewords(codewords, ecLevel, erasureArray, e);
@@ -444,7 +435,7 @@ CBC_PDF417ScanningDecoder::createDecoderResultFromAmbiguousValues(
}
for (int32_t i = 0; i < ambiguousIndexCount.GetSize(); i++) {
if (ambiguousIndexCount[i] <
- ((CFX_Int32Array*)(ambiguousIndexValues.GetAt(i)))->GetSize() - 1) {
+ ambiguousIndexValues.GetAt(i)->GetSize() - 1) {
ambiguousIndexCount[i]++;
break;
} else {
@@ -459,40 +450,36 @@ CBC_PDF417ScanningDecoder::createDecoderResultFromAmbiguousValues(
e = BCExceptionChecksumInstance;
return NULL;
}
-CFX_PtrArray* CBC_PDF417ScanningDecoder::createBarcodeMatrix(
+CBC_BarcodeValueArrayArray* CBC_PDF417ScanningDecoder::createBarcodeMatrix(
CBC_DetectionResult* detectionResult) {
- CFX_PtrArray* barcodeMatrix = new CFX_PtrArray;
+ CBC_BarcodeValueArrayArray* barcodeMatrix = new CBC_BarcodeValueArrayArray;
barcodeMatrix->SetSize(detectionResult->getBarcodeRowCount());
- CFX_PtrArray* temp = NULL;
- int32_t colume = 0;
for (int32_t row = 0; row < barcodeMatrix->GetSize(); row++) {
- temp = new CFX_PtrArray;
+ CBC_BarcodeValueArray* temp = new CBC_BarcodeValueArray;
temp->SetSize(detectionResult->getBarcodeColumnCount() + 2);
- for (colume = 0; colume < detectionResult->getBarcodeColumnCount() + 2;
- colume++) {
- temp->SetAt(colume, new CBC_BarcodeValue());
+ for (int32_t column = 0;
+ column < detectionResult->getBarcodeColumnCount() + 2; column++) {
+ temp->SetAt(column, new CBC_BarcodeValue());
}
barcodeMatrix->SetAt(row, temp);
}
- colume = -1;
for (int32_t i = 0;
i < detectionResult->getDetectionResultColumns().GetSize(); i++) {
CBC_DetectionResultColumn* detectionResultColumn =
(CBC_DetectionResultColumn*)detectionResult->getDetectionResultColumns()
.GetAt(i);
- colume++;
if (detectionResultColumn == NULL) {
continue;
}
- CFX_PtrArray* temp = detectionResultColumn->getCodewords();
+ CFX_ArrayTemplate<CBC_Codeword*>* temp =
+ detectionResultColumn->getCodewords();
for (int32_t l = 0; l < temp->GetSize(); l++) {
- CBC_Codeword* codeword = (CBC_Codeword*)temp->GetAt(l);
+ CBC_Codeword* codeword = temp->GetAt(l);
if (codeword == NULL || codeword->getRowNumber() == -1) {
continue;
}
- ((CBC_BarcodeValue*)((CFX_PtrArray*)barcodeMatrix->GetAt(
- codeword->getRowNumber()))
- ->GetAt(colume))
+ barcodeMatrix->GetAt(codeword->getRowNumber())
+ ->GetAt(i)
->setValue(codeword->getValue());
}
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h
index 6dbc125c310..aa99d5a0d4d 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/pdf417/BC_PDF417ScanningDecoder.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXBARCODE_PDF417_BC_PDF417SCANNINGDECODER_H_
#define XFA_FXBARCODE_PDF417_BC_PDF417SCANNINGDECODER_H_
+#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeValue.h"
+
class CBC_CommonDecoderResult;
class CBC_CommonBitMatrix;
class CBC_Codeword;
@@ -30,7 +32,7 @@ class CBC_PDF417ScanningDecoder {
int32_t minCodewordWidth,
int32_t maxCodewordWidth,
int32_t& e);
- static CFX_ByteString toString(CFX_PtrArray* barcodeMatrix);
+ static CFX_ByteString toString(CBC_BarcodeValueArrayArray* barcodeMatrix);
private:
static int32_t CODEWORD_SKEW_SIZE;
@@ -56,7 +58,7 @@ class CBC_PDF417ScanningDecoder {
int32_t minCodewordWidth,
int32_t maxCodewordWidth);
static void adjustCodewordCount(CBC_DetectionResult* detectionResult,
- CFX_PtrArray* barcodeMatrix,
+ CBC_BarcodeValueArrayArray* barcodeMatrix,
int32_t& e);
static CBC_CommonDecoderResult* createDecoderResult(
CBC_DetectionResult* detectionResult,
@@ -66,9 +68,9 @@ class CBC_PDF417ScanningDecoder {
CFX_Int32Array& codewords,
CFX_Int32Array& erasureArray,
CFX_Int32Array& ambiguousIndexes,
- CFX_PtrArray& ambiguousIndexValues,
+ CFX_ArrayTemplate<CFX_Int32Array*>& ambiguousIndexValues,
int32_t& e);
- static CFX_PtrArray* createBarcodeMatrix(
+ static CBC_BarcodeValueArrayArray* createBarcodeMatrix(
CBC_DetectionResult* detectionResult);
static FX_BOOL isValidBarcodeColumn(CBC_DetectionResult* detectionResult,
int32_t barcodeColumn);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp
index 25dc28b3f31..63b3ab790dc 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp
@@ -24,18 +24,23 @@
#include "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h"
#include "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h"
-CBC_QRFinderPatternInfo::CBC_QRFinderPatternInfo(CFX_PtrArray* patternCenters) {
- m_bottomLeft = (CBC_QRFinderPattern*)(*patternCenters)[0];
- m_topLeft = (CBC_QRFinderPattern*)(*patternCenters)[1];
- m_topRight = (CBC_QRFinderPattern*)(*patternCenters)[2];
+CBC_QRFinderPatternInfo::CBC_QRFinderPatternInfo(
+ CFX_ArrayTemplate<CBC_QRFinderPattern*>* patternCenters) {
+ m_bottomLeft = (*patternCenters)[0];
+ m_topLeft = (*patternCenters)[1];
+ m_topRight = (*patternCenters)[2];
}
+
CBC_QRFinderPatternInfo::~CBC_QRFinderPatternInfo() {}
-CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetBottomLeft() {
+
+CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetBottomLeft() const {
return m_bottomLeft;
}
-CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopLeft() {
+
+CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopLeft() const {
return m_topLeft;
}
-CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopRight() {
+
+CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopRight() const {
return m_topRight;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h
index 1091d6723d9..6d0cb60f2f5 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h
@@ -12,17 +12,19 @@
class CBC_QRFinderPattern;
class CBC_QRFinderPatternInfo {
+ public:
+ explicit CBC_QRFinderPatternInfo(
+ CFX_ArrayTemplate<CBC_QRFinderPattern*>* patternCenters);
+ ~CBC_QRFinderPatternInfo();
+
+ CBC_QRFinderPattern* GetBottomLeft() const;
+ CBC_QRFinderPattern* GetTopLeft() const;
+ CBC_QRFinderPattern* GetTopRight() const;
+
private:
CBC_QRFinderPattern* m_bottomLeft;
CBC_QRFinderPattern* m_topLeft;
CBC_QRFinderPattern* m_topRight;
-
- public:
- CBC_QRFinderPatternInfo(CFX_PtrArray* patternCenters);
- virtual ~CBC_QRFinderPatternInfo();
- CBC_QRFinderPattern* GetBottomLeft();
- CBC_QRFinderPattern* GetTopLeft();
- CBC_QRFinderPattern* GetTopRight();
};
#endif // XFA_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp
index 8c462bf3284..75565ca6413 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp
@@ -40,12 +40,12 @@ CBC_QRAlignmentPatternFinder::CBC_QRAlignmentPatternFinder(
m_moduleSize(moduleSize) {
m_crossCheckStateCount.SetSize(3);
}
+
CBC_QRAlignmentPatternFinder::~CBC_QRAlignmentPatternFinder() {
- for (int32_t i = 0; i < m_possibleCenters.GetSize(); i++) {
- delete (CBC_QRAlignmentPattern*)m_possibleCenters[i];
- }
- m_possibleCenters.RemoveAll();
+ for (int32_t i = 0; i < m_possibleCenters.GetSize(); i++)
+ delete m_possibleCenters[i];
}
+
CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::Find(int32_t& e) {
int32_t startX = m_startX;
int32_t height = m_height;
@@ -102,7 +102,7 @@ CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::Find(int32_t& e) {
}
}
if (m_possibleCenters.GetSize() != 0) {
- return ((CBC_QRAlignmentPattern*)(m_possibleCenters[0]))->Clone();
+ return m_possibleCenters[0]->Clone();
}
e = BCExceptionRead;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
@@ -186,8 +186,7 @@ CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::HandlePossibleCenter(
(FX_FLOAT)(stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f;
int32_t max = m_possibleCenters.GetSize();
for (int32_t index = 0; index < max; index++) {
- CBC_QRAlignmentPattern* center =
- (CBC_QRAlignmentPattern*)(m_possibleCenters[index]);
+ CBC_QRAlignmentPattern* center = m_possibleCenters[index];
if (center->AboutEquals(estimatedModuleSize, centerI, centerJ)) {
return new CBC_QRAlignmentPattern(centerJ, centerI,
estimatedModuleSize);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h
index d227708fd8f..e524c4bdaf9 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h
@@ -14,16 +14,6 @@ class CBC_CommonBitMatrix;
class CBC_QRAlignmentPattern;
class CBC_QRAlignmentPatternFinder {
- private:
- CBC_CommonBitMatrix* m_image;
- CFX_PtrArray m_possibleCenters;
- int32_t m_startX;
- int32_t m_startY;
- int32_t m_width;
- int32_t m_height;
- FX_FLOAT m_moduleSize;
- CFX_Int32Array m_crossCheckStateCount;
-
public:
CBC_QRAlignmentPatternFinder(CBC_CommonBitMatrix* image,
int32_t startX,
@@ -42,6 +32,16 @@ class CBC_QRAlignmentPatternFinder {
int32_t i,
int32_t j);
static FX_FLOAT CenterFromEnd(const CFX_Int32Array& stateCount, int32_t end);
+
+ private:
+ CBC_CommonBitMatrix* m_image;
+ CFX_ArrayTemplate<CBC_QRAlignmentPattern*> m_possibleCenters;
+ int32_t m_startX;
+ int32_t m_startY;
+ int32_t m_width;
+ int32_t m_height;
+ FX_FLOAT m_moduleSize;
+ CFX_Int32Array m_crossCheckStateCount;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp
index 53803588b57..3fe6783d386 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp
@@ -142,7 +142,7 @@ CFX_ByteArray* CBC_QRBitMatrixParser::ReadCodewords(int32_t& e) {
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
int32_t dimension = m_bitMatrix->GetDimension(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- dataMask->UnmaskBitMatirx(m_bitMatrix, dimension);
+ dataMask->UnmaskBitMatrix(m_bitMatrix, dimension);
std::unique_ptr<CBC_CommonBitMatrix> functionPattern(
version->BuildFunctionPattern(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp
index 716b6c17de7..fc87785d5c6 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp
@@ -93,14 +93,10 @@ CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, int32_t& e) {
return bs;
}
void CBC_QRCodeReader::ReleaseAll() {
- if (CBC_ReedSolomonGF256::QRCodeFild) {
- delete CBC_ReedSolomonGF256::QRCodeFild;
- CBC_ReedSolomonGF256::QRCodeFild = NULL;
- }
- if (CBC_ReedSolomonGF256::DataMatrixField) {
- delete CBC_ReedSolomonGF256::DataMatrixField;
- CBC_ReedSolomonGF256::DataMatrixField = NULL;
- }
+ delete CBC_ReedSolomonGF256::QRCodeFild;
+ CBC_ReedSolomonGF256::QRCodeFild = nullptr;
+ delete CBC_ReedSolomonGF256::DataMatrixField;
+ CBC_ReedSolomonGF256::DataMatrixField = nullptr;
CBC_QRCoderMode::Destroy();
CBC_QRCoderErrorCorrectionLevel::Destroy();
CBC_QRDataMask::Destroy();
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp
index 1966146805e..360a69a0ecf 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp
@@ -74,26 +74,24 @@ CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(CBC_CommonBitMatrix* bits,
CBC_QRCoderErrorCorrectionLevel* ecLevel = temp->GetErrorCorrectionLevel();
std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* dataBlocks =
+ CFX_ArrayTemplate<CBC_QRDataBlock*>* dataBlocks =
CBC_QRDataBlock::GetDataBlocks(codewords.get(), version, ecLevel, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
int32_t totalBytes = 0;
for (int32_t i = 0; i < dataBlocks->GetSize(); i++) {
- totalBytes += ((CBC_QRDataBlock*)((*dataBlocks)[i]))->GetNumDataCodewords();
+ totalBytes += (*dataBlocks)[i]->GetNumDataCodewords();
}
CFX_ByteArray resultBytes;
for (int32_t j = 0; j < dataBlocks->GetSize(); j++) {
- CBC_QRDataBlock* dataBlock = (CBC_QRDataBlock*)((*dataBlocks)[j]);
+ CBC_QRDataBlock* dataBlock = (*dataBlocks)[j];
CFX_ByteArray* codewordBytes = dataBlock->GetCodewords();
int32_t numDataCodewords = dataBlock->GetNumDataCodewords();
CorrectErrors(codewordBytes, numDataCodewords, e);
if (e != BCExceptionNO) {
for (int32_t k = 0; k < dataBlocks->GetSize(); k++) {
- delete (CBC_QRDataBlock*)(*dataBlocks)[k];
+ delete (*dataBlocks)[k];
}
- dataBlocks->RemoveAll();
delete dataBlocks;
- dataBlocks = NULL;
return NULL;
}
for (int32_t i = 0; i < numDataCodewords; i++) {
@@ -101,11 +99,9 @@ CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(CBC_CommonBitMatrix* bits,
}
}
for (int32_t k = 0; k < dataBlocks->GetSize(); k++) {
- delete (CBC_QRDataBlock*)(*dataBlocks)[k];
+ delete (*dataBlocks)[k];
}
- dataBlocks->RemoveAll();
delete dataBlocks;
- dataBlocks = NULL;
CBC_CommonDecoderResult* cdr = CBC_QRDecodedBitStreamParser::Decode(
&resultBytes, version, ecLevel, byteModeDecode, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
index eb6d194b555..507c91878e9 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
@@ -24,36 +24,40 @@
#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h"
CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
- CBC_QRCoderECB* ecBlocks) {
- m_ecCodeWordsPerBlock = ecCodeWordsPerBlock;
- m_ecBlocks.Add(ecBlocks);
+ CBC_QRCoderECB* ecBlocks)
+ : m_ecCodeWordsPerBlock(ecCodeWordsPerBlock) {
+ m_ecBlocksArray.Add(ecBlocks);
}
+
CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
CBC_QRCoderECB* ecBlocks1,
- CBC_QRCoderECB* ecBlocks2) {
- m_ecCodeWordsPerBlock = ecCodeWordsPerBlock;
- m_ecBlocks.Add(ecBlocks1);
- m_ecBlocks.Add(ecBlocks2);
+ CBC_QRCoderECB* ecBlocks2)
+ : m_ecCodeWordsPerBlock(ecCodeWordsPerBlock) {
+ m_ecBlocksArray.Add(ecBlocks1);
+ m_ecBlocksArray.Add(ecBlocks2);
}
+
CBC_QRCoderECBlocks::~CBC_QRCoderECBlocks() {
- for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
- delete ((CBC_QRCoderECB*)(m_ecBlocks[i]));
- }
- m_ecBlocks.RemoveAll();
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++)
+ delete m_ecBlocksArray[i];
}
-int32_t CBC_QRCoderECBlocks::GetECCodeWordsPerBlock() {
+
+int32_t CBC_QRCoderECBlocks::GetECCodeWordsPerBlock() const {
return m_ecCodeWordsPerBlock;
}
-int32_t CBC_QRCoderECBlocks::GetNumBlocks() {
+
+int32_t CBC_QRCoderECBlocks::GetNumBlocks() const {
int32_t total = 0;
- for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
- total += ((CBC_QRCoderECB*)(m_ecBlocks[i]))->GetCount();
- }
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++)
+ total += m_ecBlocksArray[i]->GetCount();
+
return total;
}
-int32_t CBC_QRCoderECBlocks::GetTotalECCodeWords() {
+
+int32_t CBC_QRCoderECBlocks::GetTotalECCodeWords() const {
return m_ecCodeWordsPerBlock * GetNumBlocks();
}
-CFX_PtrArray* CBC_QRCoderECBlocks::GetECBlocks() {
- return &m_ecBlocks;
+
+CFX_ArrayTemplate<CBC_QRCoderECB*>* CBC_QRCoderECBlocks::GetECBlocks() {
+ return &m_ecBlocksArray;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
index 5209a5f8d88..cd1539a7b7d 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
@@ -12,20 +12,21 @@
class CBC_QRCoderECB;
class CBC_QRCoderECBlocks {
- private:
- int32_t m_ecCodeWordsPerBlock;
- CFX_PtrArray m_ecBlocks;
-
public:
CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock, CBC_QRCoderECB* ecBlocks);
CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
CBC_QRCoderECB* ecBlocks1,
CBC_QRCoderECB* ecBlocks2);
- virtual ~CBC_QRCoderECBlocks();
- int32_t GetECCodeWordsPerBlock();
- int32_t GetNumBlocks();
- int32_t GetTotalECCodeWords();
- CFX_PtrArray* GetECBlocks();
+ ~CBC_QRCoderECBlocks();
+
+ int32_t GetECCodeWordsPerBlock() const;
+ int32_t GetNumBlocks() const;
+ int32_t GetTotalECCodeWords() const;
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* GetECBlocks();
+
+ private:
+ int32_t m_ecCodeWordsPerBlock;
+ CFX_ArrayTemplate<CBC_QRCoderECB*> m_ecBlocksArray;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index ded0df694b5..eb7642649d3 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -88,7 +88,7 @@ void CBC_QRCoderEncoder::Encode(const CFX_ByteString& content,
}
void CBC_QRCoderEncoder::AppendECI(CBC_QRCoderBitVector* bits) {}
void CBC_QRCoderEncoder::AppendDataModeLenghInfo(
- CFX_PtrArray& splitResult,
+ const CFX_ArrayTemplate<Make_Pair*>& splitResult,
CBC_QRCoderBitVector& headerAndDataBits,
CBC_QRCoderMode* tempMode,
CBC_QRCoder* qrCode,
@@ -141,7 +141,7 @@ void CBC_QRCoderEncoder::AppendDataModeLenghInfo(
}
}
void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content,
- CFX_PtrArray& result) {
+ CFX_ArrayTemplate<Make_Pair*>* result) {
int32_t index = 0, flag = 0;
while (
(((uint8_t)content[index] >= 0xA1 && (uint8_t)content[index] <= 0xAA) ||
@@ -150,7 +150,7 @@ void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content,
index += 2;
}
if (index != flag) {
- result.Add(
+ result->Add(
new Make_Pair(CBC_QRCoderMode::sGBK, content.Mid(flag, index - flag)));
}
flag = index;
@@ -174,7 +174,7 @@ void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content,
}
}
if (index != flag) {
- result.Add(
+ result->Add(
new Make_Pair(CBC_QRCoderMode::sBYTE, content.Mid(flag, index - flag)));
}
flag = index;
@@ -186,8 +186,8 @@ void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content,
index++;
}
if (index != flag) {
- result.Add(new Make_Pair(CBC_QRCoderMode::sNUMERIC,
- content.Mid(flag, index - flag)));
+ result->Add(new Make_Pair(CBC_QRCoderMode::sNUMERIC,
+ content.Mid(flag, index - flag)));
}
flag = index;
if (index >= content.GetLength()) {
@@ -198,15 +198,14 @@ void CBC_QRCoderEncoder::SplitString(const CFX_ByteString& content,
index++;
}
if (index != flag) {
- result.Add(new Make_Pair(CBC_QRCoderMode::sALPHANUMERIC,
- content.Mid(flag, index - flag)));
+ result->Add(new Make_Pair(CBC_QRCoderMode::sALPHANUMERIC,
+ content.Mid(flag, index - flag)));
}
flag = index;
- if (index >= content.GetLength()) {
- return;
- }
- SplitString(content.Mid(index, content.GetLength() - index), result);
+ if (index < content.GetLength())
+ SplitString(content.Mid(index, content.GetLength() - index), result);
}
+
int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst,
CBC_QRCoderMode* modeSecond,
int32_t versionNum,
@@ -253,16 +252,17 @@ int32_t CBC_QRCoderEncoder::GetSpanByVersion(CBC_QRCoderMode* modeFirst,
}
return -1;
}
-void CBC_QRCoderEncoder::MergeString(CFX_PtrArray& result,
+
+void CBC_QRCoderEncoder::MergeString(CFX_ArrayTemplate<Make_Pair*>* result,
int32_t versionNum,
int32_t& e) {
Make_Pair* first = NULL;
Make_Pair* second = NULL;
size_t mergeNum = 0;
int32_t i;
- for (i = 0; ((i < result.GetSize()) && (i + 1 < result.GetSize())); i++) {
- first = (Make_Pair*)result[i];
- second = (Make_Pair*)result[i + 1];
+ for (i = 0; ((i < result->GetSize()) && (i + 1 < result->GetSize())); i++) {
+ first = (*result)[i];
+ second = (*result)[i + 1];
if (first->m_mode == CBC_QRCoderMode::sALPHANUMERIC) {
int32_t tmp = GetSpanByVersion(CBC_QRCoderMode::sALPHANUMERIC,
CBC_QRCoderMode::sBYTE, versionNum, e);
@@ -272,7 +272,7 @@ void CBC_QRCoderEncoder::MergeString(CFX_PtrArray& result,
CFX_ByteString str = first->m_string + second->m_string;
second->m_string = str;
delete first;
- result.RemoveAt(i);
+ result->RemoveAt(i);
i--;
mergeNum++;
}
@@ -280,7 +280,7 @@ void CBC_QRCoderEncoder::MergeString(CFX_PtrArray& result,
if (second->m_mode == CBC_QRCoderMode::sBYTE) {
first->m_string += second->m_string;
delete second;
- result.RemoveAt(i + 1);
+ result->RemoveAt(i + 1);
i--;
mergeNum++;
}
@@ -293,7 +293,7 @@ void CBC_QRCoderEncoder::MergeString(CFX_PtrArray& result,
CFX_ByteString str = first->m_string + second->m_string;
second->m_string = str;
delete first;
- result.RemoveAt(i);
+ result->RemoveAt(i);
i--;
mergeNum++;
}
@@ -305,7 +305,7 @@ void CBC_QRCoderEncoder::MergeString(CFX_PtrArray& result,
CFX_ByteString str = first->m_string + second->m_string;
second->m_string = str;
delete first;
- result.RemoveAt(i);
+ result->RemoveAt(i);
i--;
mergeNum++;
}
@@ -353,20 +353,18 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
int32_t& e) {
CFX_ByteString encoding = "utf8";
CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE;
- CFX_PtrArray splitResult;
+ CFX_ArrayTemplate<Make_Pair*> splitResult;
CBC_QRCoderBitVector dataBits;
dataBits.Init();
- SplitString(content, splitResult);
- MergeString(splitResult, versionSpecify, e);
+ SplitString(content, &splitResult);
+ MergeString(&splitResult, versionSpecify, e);
BC_EXCEPTION_CHECK_ReturnVoid(e) CBC_QRCoderMode* tempMode = NULL;
for (int32_t i = 0; i < splitResult.GetSize(); i++) {
- AppendBytes(((Make_Pair*)splitResult[i])->m_string,
- ((Make_Pair*)splitResult[i])->m_mode, &dataBits, encoding, e);
+ AppendBytes(splitResult[i]->m_string, splitResult[i]->m_mode, &dataBits,
+ encoding, e);
if (e != BCExceptionNO) {
- for (int32_t y = 0; y < splitResult.GetSize(); y++) {
- delete (Make_Pair*)splitResult[y];
- }
- splitResult.RemoveAll();
+ for (int32_t y = 0; y < splitResult.GetSize(); y++)
+ delete splitResult[y];
return;
}
}
@@ -375,34 +373,25 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion(
headerAndDataBits.Init();
InitQRCode(numInputBytes, versionSpecify, ecLevel, mode, qrCode, e);
if (e != BCExceptionNO) {
- for (int32_t k = 0; k < splitResult.GetSize(); k++) {
- delete (Make_Pair*)splitResult[k];
- }
- splitResult.RemoveAll();
+ for (int32_t k = 0; k < splitResult.GetSize(); k++)
+ delete splitResult[k];
return;
}
AppendDataModeLenghInfo(splitResult, headerAndDataBits, tempMode, qrCode,
encoding, e);
if (e != BCExceptionNO) {
- for (int32_t k = 0; k < splitResult.GetSize(); k++) {
- delete (Make_Pair*)splitResult[k];
- }
- splitResult.RemoveAll();
+ for (int32_t k = 0; k < splitResult.GetSize(); k++)
+ delete splitResult[k];
return;
}
numInputBytes = headerAndDataBits.sizeInBytes();
TerminateBits(qrCode->GetNumDataBytes(), &headerAndDataBits, e);
- if (e != BCExceptionNO) {
- for (int32_t k = 0; k < splitResult.GetSize(); k++) {
- delete (Make_Pair*)splitResult[k];
- }
- splitResult.RemoveAll();
- return;
- }
for (int32_t j = 0; j < splitResult.GetSize(); j++) {
- delete (Make_Pair*)splitResult[j];
+ delete splitResult[j];
}
- splitResult.RemoveAll();
+ if (e != BCExceptionNO)
+ return;
+
CBC_QRCoderBitVector finalBits;
finalBits.Init();
InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(),
@@ -433,21 +422,19 @@ void CBC_QRCoderEncoder::EncodeWithAutoVersion(
int32_t& e) {
CFX_ByteString encoding = "utf8";
CBC_QRCoderMode* mode = CBC_QRCoderMode::sBYTE;
- CFX_PtrArray splitResult;
+ CFX_ArrayTemplate<Make_Pair*> splitResult;
CBC_QRCoderBitVector dataBits;
dataBits.Init();
- SplitString(content, splitResult);
- MergeString(splitResult, 8, e);
+ SplitString(content, &splitResult);
+ MergeString(&splitResult, 8, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
CBC_QRCoderMode* tempMode = NULL;
for (int32_t i = 0; i < splitResult.GetSize(); i++) {
- AppendBytes(((Make_Pair*)splitResult[i])->m_string,
- ((Make_Pair*)splitResult[i])->m_mode, &dataBits, encoding, e);
+ AppendBytes(splitResult[i]->m_string, splitResult[i]->m_mode, &dataBits,
+ encoding, e);
if (e != BCExceptionNO) {
- for (int32_t l = 0; l < splitResult.GetSize(); l++) {
- delete (Make_Pair*)splitResult[l];
- }
- splitResult.RemoveAll();
+ for (int32_t l = 0; l < splitResult.GetSize(); l++)
+ delete splitResult[l];
return;
}
}
@@ -482,17 +469,14 @@ catchException:
e = BCExceptionNO;
goto sign;
} else {
- for (int32_t j = 0; j < splitResult.GetSize(); j++) {
- delete (Make_Pair*)splitResult[j];
- }
- splitResult.RemoveAll();
+ for (int32_t j = 0; j < splitResult.GetSize(); j++)
+ delete splitResult[j];
return;
}
}
- for (int32_t k = 0; k < splitResult.GetSize(); k++) {
- delete (Make_Pair*)splitResult[k];
- }
- splitResult.RemoveAll();
+ for (int32_t k = 0; k < splitResult.GetSize(); k++)
+ delete splitResult[k];
+
CBC_QRCoderBitVector finalBits;
finalBits.Init();
InterleaveWithECBytes(&headerAndDataBits, qrCode->GetNumTotalBytes(),
@@ -863,7 +847,7 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
int32_t dataBytesOffset = 0;
int32_t maxNumDataBytes = 0;
int32_t maxNumEcBytes = 0;
- CFX_PtrArray blocks;
+ CFX_ArrayTemplate<CBC_QRCoderBlockPair*> blocks;
int32_t i;
for (i = 0; i < numRSBlocks; i++) {
int32_t numDataBytesInBlock;
@@ -887,8 +871,7 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
}
for (int32_t x = 0; x < maxNumDataBytes; x++) {
for (int32_t j = 0; j < blocks.GetSize(); j++) {
- CBC_CommonByteArray* dataBytes =
- ((CBC_QRCoderBlockPair*)blocks[j])->GetDataBytes();
+ CBC_CommonByteArray* dataBytes = blocks[j]->GetDataBytes();
if (x < dataBytes->Size()) {
result->AppendBits(dataBytes->At(x), 8, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
@@ -897,8 +880,7 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
}
for (int32_t y = 0; y < maxNumEcBytes; y++) {
for (int32_t l = 0; l < blocks.GetSize(); l++) {
- CBC_CommonByteArray* ecBytes =
- ((CBC_QRCoderBlockPair*)blocks[l])->GetErrorCorrectionBytes();
+ CBC_CommonByteArray* ecBytes = blocks[l]->GetErrorCorrectionBytes();
if (y < ecBytes->Size()) {
result->AppendBits(ecBytes->At(y), 8, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
@@ -906,7 +888,7 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits,
}
}
for (int32_t k = 0; k < blocks.GetSize(); k++) {
- delete (CBC_QRCoderBlockPair*)blocks[k];
+ delete blocks[k];
}
if (numTotalBytes != result->sizeInBytes()) {
e = BCExceptionSizeInBytesDiffer;
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h
index bbdec5bf1ec..be0a76c3377 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h
@@ -16,6 +16,7 @@ class CBC_QRCoderMode;
class CBC_QRCoderBitVector;
class CBC_CommonByteArray;
class CBC_CommonByteMatrix;
+class Make_Pair;
class CBC_QRCoderEncoder {
private:
@@ -120,14 +121,18 @@ class CBC_QRCoderEncoder {
CBC_QRCoderMode* modeSecond,
int32_t versionNum,
int32_t& e);
- static void MergeString(CFX_PtrArray& result, int32_t versionNum, int32_t& e);
- static void SplitString(const CFX_ByteString& content, CFX_PtrArray& result);
- static void AppendDataModeLenghInfo(CFX_PtrArray& splitResult,
- CBC_QRCoderBitVector& headerAndDataBits,
- CBC_QRCoderMode* tempMode,
- CBC_QRCoder* qrCode,
- CFX_ByteString& encoding,
- int32_t& e);
+ static void MergeString(CFX_ArrayTemplate<Make_Pair*>* result,
+ int32_t versionNum,
+ int32_t& e);
+ static void SplitString(const CFX_ByteString& content,
+ CFX_ArrayTemplate<Make_Pair*>* result);
+ static void AppendDataModeLenghInfo(
+ const CFX_ArrayTemplate<Make_Pair*>& splitResult,
+ CBC_QRCoderBitVector& headerAndDataBits,
+ CBC_QRCoderMode* tempMode,
+ CBC_QRCoder* qrCode,
+ CFX_ByteString& encoding,
+ int32_t& e);
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp
index f915e58aaeb..1c85aa16d7f 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp
@@ -20,30 +20,63 @@
* limitations under the License.
*/
-#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h"
+
+#include <limits>
+
+#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
#include "xfa/fxbarcode/utils.h"
-const uint16_t CBC_QRCoderFormatInformation::FORMAT_INFO_MASK_QR = 0X5412;
-const uint16_t CBC_QRCoderFormatInformation::FORMAT_INFO_DECODE_LOOKUP[32][2] =
- {
- {0x5412, 0x00}, {0x5125, 0x01}, {0x5E7C, 0x02}, {0x5B4B, 0x03},
- {0x45F9, 0x04}, {0x40CE, 0x05}, {0x4F97, 0x06}, {0x4AA0, 0x07},
- {0x77C4, 0x08}, {0x72F3, 0x09}, {0x7DAA, 0x0A}, {0x789D, 0x0B},
- {0x662F, 0x0C}, {0x6318, 0x0D}, {0x6C41, 0x0E}, {0x6976, 0x0F},
- {0x1689, 0x10}, {0x13BE, 0x11}, {0x1CE7, 0x12}, {0x19D0, 0x13},
- {0x0762, 0x14}, {0x0255, 0x15}, {0x0D0C, 0x16}, {0x083B, 0x17},
- {0x355F, 0x18}, {0x3068, 0x19}, {0x3F31, 0x1A}, {0x3A06, 0x1B},
- {0x24B4, 0x1C}, {0x2183, 0x1D}, {0x2EDA, 0x1E}, {0x2BED, 0x1F},
+namespace {
+
+const uint16_t FORMAT_INFO_MASK_QR = 0X5412;
+
+struct DecodeInfo {
+ uint16_t target;
+ uint16_t format;
};
-const uint8_t CBC_QRCoderFormatInformation::BITS_SET_IN_HALF_BYTE[] = {
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
+const DecodeInfo FORMAT_INFO_DECODE_LOOKUP[32] = {
+ {0x5412, 0x00}, {0x5125, 0x01}, {0x5E7C, 0x02}, {0x5B4B, 0x03},
+ {0x45F9, 0x04}, {0x40CE, 0x05}, {0x4F97, 0x06}, {0x4AA0, 0x07},
+ {0x77C4, 0x08}, {0x72F3, 0x09}, {0x7DAA, 0x0A}, {0x789D, 0x0B},
+ {0x662F, 0x0C}, {0x6318, 0x0D}, {0x6C41, 0x0E}, {0x6976, 0x0F},
+ {0x1689, 0x10}, {0x13BE, 0x11}, {0x1CE7, 0x12}, {0x19D0, 0x13},
+ {0x0762, 0x14}, {0x0255, 0x15}, {0x0D0C, 0x16}, {0x083B, 0x17},
+ {0x355F, 0x18}, {0x3068, 0x19}, {0x3F31, 0x1A}, {0x3A06, 0x1B},
+ {0x24B4, 0x1C}, {0x2183, 0x1D}, {0x2EDA, 0x1E}, {0x2BED, 0x1F},
+};
+const uint8_t BITS_SET_IN_HALF_BYTE[] = {0, 1, 1, 2, 1, 2, 2, 3,
+ 1, 2, 2, 3, 2, 3, 3, 4};
+
+CBC_QRCoderFormatInformation* DoDecodeFormatInformation(
+ int32_t maskedFormatInfo) {
+ int32_t bestDifference = std::numeric_limits<int32_t>::max();
+ int32_t bestFormatInfo = 0;
+ for (int32_t i = 0; i < 32; ++i) {
+ const DecodeInfo& decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];
+ if (decodeInfo.target == maskedFormatInfo)
+ return new CBC_QRCoderFormatInformation(decodeInfo.format);
+
+ int32_t bitsDifference = CBC_QRCoderFormatInformation::NumBitsDiffering(
+ maskedFormatInfo, decodeInfo.target);
+ if (bitsDifference < bestDifference) {
+ bestFormatInfo = decodeInfo.format;
+ bestDifference = bitsDifference;
+ }
+ }
+ if (bestDifference > 3)
+ return nullptr;
+ return new CBC_QRCoderFormatInformation(bestFormatInfo);
+}
+
+} // namespace
-CBC_QRCoderFormatInformation::CBC_QRCoderFormatInformation(int32_t formatInfo) {
- m_errorCorrectLevl =
+CBC_QRCoderFormatInformation::CBC_QRCoderFormatInformation(int32_t formatInfo)
+ : m_dataMask(static_cast<uint8_t>(formatInfo & 0x07)) {
+ m_errorCorrectLevel =
CBC_QRCoderErrorCorrectionLevel::ForBits((formatInfo >> 3) & 0x03);
- m_dataMask = (uint8_t)(formatInfo & 0x07);
}
+
CBC_QRCoderFormatInformation::~CBC_QRCoderFormatInformation() {}
int32_t CBC_QRCoderFormatInformation::NumBitsDiffering(int32_t a, int32_t b) {
a ^= b;
@@ -56,13 +89,17 @@ int32_t CBC_QRCoderFormatInformation::NumBitsDiffering(int32_t a, int32_t b) {
BITS_SET_IN_HALF_BYTE[(a >> 24) & 0x0F] +
BITS_SET_IN_HALF_BYTE[(a >> 28) & 0x0F];
}
-uint8_t CBC_QRCoderFormatInformation::GetDataMask() {
+uint8_t CBC_QRCoderFormatInformation::GetDataMask() const {
return m_dataMask;
}
+
+// static
CBC_QRCoderErrorCorrectionLevel*
CBC_QRCoderFormatInformation::GetErrorCorrectionLevel() {
- return m_errorCorrectLevl;
+ return m_errorCorrectLevel;
}
+
+// static
CBC_QRCoderFormatInformation*
CBC_QRCoderFormatInformation::DecodeFormatInformation(
int32_t maskedFormatInfo) {
@@ -72,25 +109,3 @@ CBC_QRCoderFormatInformation::DecodeFormatInformation(
return formatInfo;
return DoDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);
}
-CBC_QRCoderFormatInformation*
-CBC_QRCoderFormatInformation::DoDecodeFormatInformation(
- int32_t maskedFormatInfo) {
- int32_t bestDifference = (int32_t)FXSYS_nan();
- int32_t bestFormatInfo = 0;
- for (int32_t i = 0; i < 32; i++) {
- uint16_t const* decodeInfo = &FORMAT_INFO_DECODE_LOOKUP[i][0];
- uint16_t targetInfo = decodeInfo[0];
- if (targetInfo == maskedFormatInfo) {
- return new CBC_QRCoderFormatInformation(decodeInfo[1]);
- }
- int32_t bitsDifference = NumBitsDiffering(maskedFormatInfo, targetInfo);
- if (bitsDifference < bestDifference) {
- bestFormatInfo = decodeInfo[1];
- bestDifference = bitsDifference;
- }
- }
- if (bestDifference <= 3) {
- return new CBC_QRCoderFormatInformation(bestFormatInfo);
- }
- return NULL;
-}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h
index a988d3bd6b9..b069795ce1f 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h
@@ -7,26 +7,24 @@
#ifndef XFA_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_
#define XFA_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_
+#include <stdint.h>
+
class CBC_QRCoderErrorCorrectionLevel;
class CBC_QRCoderFormatInformation {
- private:
- static const uint16_t FORMAT_INFO_MASK_QR;
- static const uint16_t FORMAT_INFO_DECODE_LOOKUP[32][2];
- static const uint8_t BITS_SET_IN_HALF_BYTE[16];
- CBC_QRCoderErrorCorrectionLevel* m_errorCorrectLevl;
- uint8_t m_dataMask;
-
public:
- CBC_QRCoderFormatInformation(int32_t formatInfo);
- virtual ~CBC_QRCoderFormatInformation();
- uint8_t GetDataMask();
+ explicit CBC_QRCoderFormatInformation(int32_t formatInfo);
+ ~CBC_QRCoderFormatInformation();
+
+ uint8_t GetDataMask() const;
CBC_QRCoderErrorCorrectionLevel* GetErrorCorrectionLevel();
static int32_t NumBitsDiffering(int32_t a, int32_t b);
static CBC_QRCoderFormatInformation* DecodeFormatInformation(
int32_t maskedFormatInfo);
- static CBC_QRCoderFormatInformation* DoDecodeFormatInformation(
- int32_t maskedFormatInfo);
+
+ private:
+ CBC_QRCoderErrorCorrectionLevel* m_errorCorrectLevel;
+ const uint8_t m_dataMask;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
index 1ff557ede25..9c3a1cc138c 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
@@ -35,17 +35,18 @@ const int32_t CBC_QRCoderVersion::VERSION_DECODE_INFO[] = {
0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E,
0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA,
0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69};
-CFX_PtrArray* CBC_QRCoderVersion::VERSION = NULL;
+
+CFX_ArrayTemplate<CBC_QRCoderVersion*>* CBC_QRCoderVersion::VERSION = nullptr;
void CBC_QRCoderVersion::Initialize() {
- VERSION = new CFX_PtrArray();
+ VERSION = new CFX_ArrayTemplate<CBC_QRCoderVersion*>();
}
void CBC_QRCoderVersion::Finalize() {
- for (int32_t i = 0; i < VERSION->GetSize(); i++) {
- CBC_QRCoderVersion* v = (CBC_QRCoderVersion*)(VERSION->GetAt(i));
- delete v;
- }
+ for (int32_t i = 0; i < VERSION->GetSize(); i++)
+ delete VERSION->GetAt(i);
+
delete VERSION;
+ VERSION = nullptr;
}
CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber,
CBC_QRCoderECBlocks* ecBlocks1,
@@ -53,15 +54,15 @@ CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber,
CBC_QRCoderECBlocks* ecBlocks3,
CBC_QRCoderECBlocks* ecBlocks4) {
m_versionNumber = versionNumber;
- m_ecBlocks.Add(ecBlocks1);
- m_ecBlocks.Add(ecBlocks2);
- m_ecBlocks.Add(ecBlocks3);
- m_ecBlocks.Add(ecBlocks4);
+ m_ecBlocksArray.Add(ecBlocks1);
+ m_ecBlocksArray.Add(ecBlocks2);
+ m_ecBlocksArray.Add(ecBlocks3);
+ m_ecBlocksArray.Add(ecBlocks4);
int32_t total = 0;
int32_t ecCodeWords = ecBlocks1->GetECCodeWordsPerBlock();
- CFX_PtrArray* ecbArray = ecBlocks1->GetECBlocks();
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* ecbArray = ecBlocks1->GetECBlocks();
for (int32_t i = 0; i < ecbArray->GetSize(); i++) {
- CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)((*ecbArray)[i]);
+ CBC_QRCoderECB* ecBlock = (*ecbArray)[i];
total += ecBlock->GetCount() * (ecBlock->GetDataCodeWords() + ecCodeWords);
}
m_totalCodeWords = total;
@@ -326,16 +327,12 @@ CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber,
break;
}
}
+
CBC_QRCoderVersion::~CBC_QRCoderVersion() {
- if (m_ecBlocks.GetSize() != 0) {
- int32_t itBeg = 0;
- int32_t itEnd = m_ecBlocks.GetSize();
- while (itBeg != itEnd) {
- delete ((CBC_QRCoderECBlocks*)(m_ecBlocks[itBeg]));
- itBeg++;
- }
- }
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); ++i)
+ delete m_ecBlocksArray[i];
}
+
int32_t CBC_QRCoderVersion::GetVersionNumber() {
return m_versionNumber;
}
@@ -350,7 +347,7 @@ int32_t CBC_QRCoderVersion::GetDimensionForVersion() {
}
CBC_QRCoderECBlocks* CBC_QRCoderVersion::GetECBlocksForLevel(
CBC_QRCoderErrorCorrectionLevel* ecLevel) {
- return (CBC_QRCoderECBlocks*)m_ecBlocks[ecLevel->Ordinal()];
+ return m_ecBlocksArray[ecLevel->Ordinal()];
}
CBC_QRCoderVersion* CBC_QRCoderVersion::GetProvisionalVersionForDimension(
int32_t dimension,
@@ -759,11 +756,11 @@ CBC_QRCoderVersion* CBC_QRCoderVersion::GetVersionForNumber(
e = BCExceptionIllegalArgument;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- return (CBC_QRCoderVersion*)(*VERSION)[versionNumber - 1];
+ return (*VERSION)[versionNumber - 1];
}
+
void CBC_QRCoderVersion::Destroy() {
- int32_t i;
- for (i = 0; i < VERSION->GetSize(); i++) {
- delete ((CBC_QRCoderVersion*)(*VERSION)[i]);
- }
+ for (int32_t i = 0; i < VERSION->GetSize(); i++)
+ delete (*VERSION)[i];
+ VERSION->RemoveAll();
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
index 0cbace02514..deae8933e6f 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
@@ -9,26 +9,11 @@
#include "core/fxcrt/include/fx_basic.h"
-class CBC_QRCoderECBlocks;
class CBC_CommonBitMatrix;
+class CBC_QRCoderECBlocks;
class CBC_QRCoderErrorCorrectionLevel;
class CBC_QRCoderVersion {
- private:
- static const int32_t VERSION_DECODE_INFO[34];
- static CFX_PtrArray* VERSION;
- int32_t m_versionNumber;
- int32_t m_totalCodeWords;
- CFX_Int32Array m_alignmentPatternCenters;
- CFX_PtrArray m_ecBlocks;
-
- CBC_QRCoderVersion();
- CBC_QRCoderVersion(int32_t versionNumber,
- CBC_QRCoderECBlocks* ecBlocks1,
- CBC_QRCoderECBlocks* ecBlocks2,
- CBC_QRCoderECBlocks* ecBlocks3,
- CBC_QRCoderECBlocks* ecBlocks4);
-
public:
virtual ~CBC_QRCoderVersion();
static void Initialize();
@@ -49,6 +34,22 @@ class CBC_QRCoderVersion {
static CBC_QRCoderVersion* DecodeVersionInformation(int32_t versionBits,
int32_t& e);
static void Destroy();
+
+ private:
+ CBC_QRCoderVersion();
+ CBC_QRCoderVersion(int32_t versionNumber,
+ CBC_QRCoderECBlocks* ecBlocks1,
+ CBC_QRCoderECBlocks* ecBlocks2,
+ CBC_QRCoderECBlocks* ecBlocks3,
+ CBC_QRCoderECBlocks* ecBlocks4);
+
+ static const int32_t VERSION_DECODE_INFO[34];
+ static CFX_ArrayTemplate<CBC_QRCoderVersion*>* VERSION;
+
+ int32_t m_versionNumber;
+ int32_t m_totalCodeWords;
+ CFX_Int32Array m_alignmentPatternCenters;
+ CFX_ArrayTemplate<CBC_QRCoderECBlocks*> m_ecBlocksArray;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
index 9805ac9af87..31f0b1841d6 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
@@ -41,7 +41,7 @@ int32_t CBC_QRDataBlock::GetNumDataCodewords() {
CFX_ByteArray* CBC_QRDataBlock::GetCodewords() {
return m_codewords;
}
-CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks(
+CFX_ArrayTemplate<CBC_QRDataBlock*>* CBC_QRDataBlock::GetDataBlocks(
CFX_ByteArray* rawCodewords,
CBC_QRCoderVersion* version,
CBC_QRCoderErrorCorrectionLevel* ecLevel,
@@ -52,16 +52,17 @@ CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks(
}
CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel);
int32_t totalBlocks = 0;
- CFX_PtrArray* ecBlockArray = ecBlocks->GetECBlocks();
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* ecBlockArray = ecBlocks->GetECBlocks();
int32_t i = 0;
for (i = 0; i < ecBlockArray->GetSize(); i++) {
- totalBlocks += ((CBC_QRCoderECB*)(*ecBlockArray)[i])->GetCount();
+ totalBlocks += (*ecBlockArray)[i]->GetCount();
}
- std::unique_ptr<CFX_PtrArray> result(new CFX_PtrArray());
+ std::unique_ptr<CFX_ArrayTemplate<CBC_QRDataBlock*>> result(
+ new CFX_ArrayTemplate<CBC_QRDataBlock*>());
result->SetSize(totalBlocks);
int32_t numResultBlocks = 0;
for (int32_t j = 0; j < ecBlockArray->GetSize(); j++) {
- CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)(*ecBlockArray)[j];
+ CBC_QRCoderECB* ecBlock = (*ecBlockArray)[j];
for (int32_t k = 0; k < ecBlock->GetCount(); k++) {
int32_t numDataCodewords = ecBlock->GetDataCodeWords();
int32_t numBlockCodewords =
@@ -72,12 +73,11 @@ CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks(
new CBC_QRDataBlock(numDataCodewords, bytearray);
}
}
- int32_t shorterBlocksTotalCodewords =
- ((CBC_QRDataBlock*)(*result)[0])->m_codewords->GetSize();
+ int32_t shorterBlocksTotalCodewords = (*result)[0]->m_codewords->GetSize();
int32_t longerBlocksStartAt = result->GetSize() - 1;
while (longerBlocksStartAt >= 0) {
- int32_t numCodewords = ((CBC_QRDataBlock*)(*result)[longerBlocksStartAt])
- ->m_codewords->GetSize();
+ int32_t numCodewords =
+ (*result)[longerBlocksStartAt]->m_codewords->GetSize();
if (numCodewords == shorterBlocksTotalCodewords) {
break;
}
@@ -90,20 +90,18 @@ CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks(
int32_t x = 0;
for (int32_t k = 0; k < shorterBlocksNumDataCodewords; k++) {
for (x = 0; x < numResultBlocks; x++) {
- (*(((CBC_QRDataBlock*)(*result)[x])->m_codewords))[k] =
- (*rawCodewords)[rawCodewordsOffset++];
+ (*((*result)[x]->m_codewords))[k] = (*rawCodewords)[rawCodewordsOffset++];
}
}
for (x = longerBlocksStartAt; x < numResultBlocks; x++) {
- (*(((CBC_QRDataBlock*)(*result)[x])
- ->m_codewords))[shorterBlocksNumDataCodewords] =
+ (*((*result)[x]->m_codewords))[shorterBlocksNumDataCodewords] =
(*rawCodewords)[rawCodewordsOffset++];
}
- int32_t max = ((CBC_QRDataBlock*)(*result)[0])->m_codewords->GetSize();
+ int32_t max = (*result)[0]->m_codewords->GetSize();
for (i = shorterBlocksNumDataCodewords; i < max; i++) {
for (int32_t y = 0; y < numResultBlocks; y++) {
int32_t iOffset = y < longerBlocksStartAt ? i : i + 1;
- (*(((CBC_QRDataBlock*)(*result)[y])->m_codewords))[iOffset] =
+ (*((*result)[y]->m_codewords))[iOffset] =
(*rawCodewords)[rawCodewordsOffset++];
}
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.h
index 873904f7c6c..014018dec03 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataBlock.h
@@ -9,22 +9,25 @@
#include "core/fxcrt/include/fx_basic.h"
-class CBC_QRCoderVersion;
class CBC_QRCoderErrorCorrectionLevel;
-class CBC_QRDataBlock {
- private:
- int32_t m_numDataCodewords;
- CFX_ByteArray* m_codewords;
- CBC_QRDataBlock(int32_t numDataCodewords, CFX_ByteArray* codewords);
+class CBC_QRCoderVersion;
+class CBC_QRDataBlock final {
public:
- virtual ~CBC_QRDataBlock();
+ ~CBC_QRDataBlock();
int32_t GetNumDataCodewords();
CFX_ByteArray* GetCodewords();
- static CFX_PtrArray* GetDataBlocks(CFX_ByteArray* rawCodewords,
- CBC_QRCoderVersion* version,
- CBC_QRCoderErrorCorrectionLevel* ecLevel,
- int32_t& e);
+ static CFX_ArrayTemplate<CBC_QRDataBlock*>* GetDataBlocks(
+ CFX_ByteArray* rawCodewords,
+ CBC_QRCoderVersion* version,
+ CBC_QRCoderErrorCorrectionLevel* ecLevel,
+ int32_t& e);
+
+ private:
+ CBC_QRDataBlock(int32_t numDataCodewords, CFX_ByteArray* codewords);
+
+ int32_t m_numDataCodewords;
+ CFX_ByteArray* m_codewords;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp
index 20f94069f43..9b5e3ca0148 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp
@@ -24,43 +24,47 @@
#include "xfa/fxbarcode/qrcode/BC_QRDataMask.h"
#include "xfa/fxbarcode/utils.h"
-static int32_t N_DATA_MASKS = 0;
-CFX_PtrArray* CBC_QRDataMask::DATA_MASKS = NULL;
+namespace {
+
+int32_t N_DATA_MASKS = 0;
+CFX_ArrayTemplate<CBC_QRDataMask*>* DATA_MASKS = nullptr;
+
+} // namespace
void CBC_QRDataMask::Initialize() {
- DATA_MASKS = new CFX_PtrArray();
+ DATA_MASKS = new CFX_ArrayTemplate<CBC_QRDataMask*>();
N_DATA_MASKS = BuildDataMasks();
}
+
void CBC_QRDataMask::Finalize() {
Destroy();
delete DATA_MASKS;
+ DATA_MASKS = nullptr;
}
+
void CBC_QRDataMask::Destroy() {
- int32_t i;
- for (i = 0; i < N_DATA_MASKS; i++) {
- CBC_QRDataMask* p = (CBC_QRDataMask*)(*DATA_MASKS)[i];
- if (p) {
- delete p;
- }
- }
+ for (int32_t i = 0; i < N_DATA_MASKS; ++i)
+ delete (*DATA_MASKS)[i];
}
-void CBC_QRDataMask::UnmaskBitMatirx(CBC_CommonBitMatrix* bits,
+
+void CBC_QRDataMask::UnmaskBitMatrix(CBC_CommonBitMatrix* bits,
int32_t dimension) {
for (int32_t i = 0; i < dimension; i++) {
for (int32_t j = 0; j < dimension; j++) {
- if (IsMasked(i, j)) {
+ if (IsMasked(i, j))
bits->Flip(j, i);
- }
}
}
}
+
CBC_QRDataMask* CBC_QRDataMask::ForReference(int32_t reference, int32_t& e) {
if (reference < 0 || reference > 7) {
e = BCExceptionReferenceMustBeBetween0And7;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
}
- return (CBC_QRDataMask*)(*DATA_MASKS)[reference];
+ return (*DATA_MASKS)[reference];
}
+
class DataMask000 : public CBC_QRDataMask {
public:
FX_BOOL IsMasked(int32_t x, int32_t y) { return ((x + y) % 2) == 0; }
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.h
index 88aa1140ea2..dc8cf498b34 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDataMask.h
@@ -13,16 +13,17 @@ class CBC_CommonBitMatrix;
class CBC_QRDataMask {
public:
- static CFX_PtrArray* DATA_MASKS;
CBC_QRDataMask();
virtual ~CBC_QRDataMask();
+
static void Initialize();
static void Finalize();
- virtual FX_BOOL IsMasked(int32_t i, int32_t j) = 0;
- void UnmaskBitMatirx(CBC_CommonBitMatrix* bits, int32_t dimension);
static CBC_QRDataMask* ForReference(int32_t reference, int32_t& e);
static int32_t BuildDataMasks();
static void Destroy();
+
+ virtual FX_BOOL IsMasked(int32_t i, int32_t j) = 0;
+ void UnmaskBitMatrix(CBC_CommonBitMatrix* bits, int32_t dimension);
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRDATAMASK_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetector.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
index 030ee43c207..15ae3e26f1b 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
@@ -28,6 +28,7 @@
#include "xfa/fxbarcode/BC_ResultPoint.h"
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h"
+#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h"
#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
@@ -90,17 +91,14 @@ CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo(
SampleGrid(m_image, topLeft.get(), topRight.get(), bottomLeft.get(),
(CBC_ResultPoint*)(alignmentPattern), dimension, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* points = new CFX_PtrArray;
- if (alignmentPattern == NULL) {
- points->Add(bottomLeft.release());
- points->Add(topLeft.release());
- points->Add(topRight.release());
- } else {
- points->Add(bottomLeft.release());
- points->Add(topLeft.release());
- points->Add(topRight.release());
+
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points =
+ new CFX_ArrayTemplate<CBC_ResultPoint*>();
+ points->Add(bottomLeft.release());
+ points->Add(topLeft.release());
+ points->Add(topRight.release());
+ if (alignmentPattern)
points->Add(alignmentPattern);
- }
return new CBC_QRDetectorResult(bits, points);
}
CBC_CommonBitMatrix* CBC_QRDetector::SampleGrid(
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
index 18e5d9ad4c7..5ce2e757627 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
@@ -24,20 +24,20 @@
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
-CBC_QRDetectorResult::CBC_QRDetectorResult(CBC_CommonBitMatrix* bits,
- CFX_PtrArray* points)
+CBC_QRDetectorResult::CBC_QRDetectorResult(
+ CBC_CommonBitMatrix* bits,
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points)
: m_bits(bits), m_points(points) {}
+
CBC_QRDetectorResult::~CBC_QRDetectorResult() {
- for (int32_t i = 0; i < m_points->GetSize(); i++) {
- delete (CBC_ResultPoint*)(*m_points)[i];
- }
- m_points->RemoveAll();
- delete m_points;
- delete m_bits;
+ for (int32_t i = 0; i < m_points->GetSize(); i++)
+ delete (*m_points)[i];
}
-CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() {
- return m_bits;
+
+CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() const {
+ return m_bits.get();
}
-CFX_PtrArray* CBC_QRDetectorResult::GetPoints() {
- return m_points;
+
+CFX_ArrayTemplate<CBC_ResultPoint*>* CBC_QRDetectorResult::GetPoints() const {
+ return m_points.get();
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
index 1570777afeb..5948c2a01c9 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
@@ -7,20 +7,26 @@
#ifndef XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
#define XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_basic.h"
class CBC_CommonBitMatrix;
+class CBC_ResultPoint;
-class CBC_QRDetectorResult {
- private:
- CBC_CommonBitMatrix* m_bits;
- CFX_PtrArray* m_points;
-
+class CBC_QRDetectorResult final {
public:
- CBC_QRDetectorResult(CBC_CommonBitMatrix* bits, CFX_PtrArray* points);
- virtual ~CBC_QRDetectorResult();
- CBC_CommonBitMatrix* GetBits();
- CFX_PtrArray* GetPoints();
+ // Takes ownership of |bits| and |points|.
+ CBC_QRDetectorResult(CBC_CommonBitMatrix* bits,
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points);
+ ~CBC_QRDetectorResult();
+
+ CBC_CommonBitMatrix* GetBits() const;
+ CFX_ArrayTemplate<CBC_ResultPoint*>* GetPoints() const;
+
+ private:
+ std::unique_ptr<CBC_CommonBitMatrix> m_bits;
+ std::unique_ptr<CFX_ArrayTemplate<CBC_ResultPoint*>> m_points;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp
index 5039920e327..1bc9648835d 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp
@@ -44,7 +44,7 @@ CBC_QRFinderPattern* CBC_QRFinderPattern::Clone() {
FX_FLOAT CBC_QRFinderPattern::GetEstimatedModuleSize() {
return m_estimatedModuleSize;
}
-int32_t CBC_QRFinderPattern::GetCount() {
+int32_t CBC_QRFinderPattern::GetCount() const {
return m_count;
}
void CBC_QRFinderPattern::IncrementCount() {
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h
index bf3adffea47..0dc2f3cfcb0 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h
@@ -18,7 +18,7 @@ class CBC_QRFinderPattern : public CBC_ResultPoint {
CBC_QRFinderPattern(FX_FLOAT x, FX_FLOAT posY, FX_FLOAT estimatedModuleSize);
virtual ~CBC_QRFinderPattern();
- int32_t GetCount();
+ int32_t GetCount() const;
FX_FLOAT GetX();
FX_FLOAT GetY();
FX_FLOAT GetEstimatedModuleSize();
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp
index ea08f1550d1..dc63131d01d 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp
@@ -42,12 +42,12 @@ CBC_QRFinderPatternFinder::CBC_QRFinderPatternFinder(
m_crossCheckStateCount.SetSize(5);
m_hasSkipped = FALSE;
}
+
CBC_QRFinderPatternFinder::~CBC_QRFinderPatternFinder() {
- for (int32_t i = 0; i < m_possibleCenters.GetSize(); i++) {
- delete (CBC_QRFinderPattern*)m_possibleCenters[i];
- }
- m_possibleCenters.RemoveAll();
+ for (int32_t i = 0; i < m_possibleCenters.GetSize(); i++)
+ delete m_possibleCenters[i];
}
+
class ClosestToAverageComparator {
private:
FX_FLOAT m_averageModuleSize;
@@ -80,9 +80,12 @@ CFX_Int32Array& CBC_QRFinderPatternFinder::GetCrossCheckStateCount() {
m_crossCheckStateCount[4] = 0;
return m_crossCheckStateCount;
}
-CFX_PtrArray* CBC_QRFinderPatternFinder::GetPossibleCenters() {
+
+CFX_ArrayTemplate<CBC_QRFinderPattern*>*
+CBC_QRFinderPatternFinder::GetPossibleCenters() {
return &m_possibleCenters;
}
+
CBC_QRFinderPatternInfo* CBC_QRFinderPatternFinder::Find(int32_t hint,
int32_t& e) {
int32_t maxI = m_image->GetHeight();
@@ -161,31 +164,32 @@ CBC_QRFinderPatternInfo* CBC_QRFinderPatternFinder::Find(int32_t hint,
}
}
}
- std::unique_ptr<CFX_PtrArray> patternInfo(SelectBestpatterns(e));
+ std::unique_ptr<CFX_ArrayTemplate<CBC_QRFinderPattern*>> patternInfo(
+ SelectBestpatterns(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
OrderBestPatterns(patternInfo.get());
return new CBC_QRFinderPatternInfo(patternInfo.get());
}
-void CBC_QRFinderPatternFinder::OrderBestPatterns(CFX_PtrArray* patterns) {
- FX_FLOAT abDistance = Distance((CBC_ResultPoint*)(*patterns)[0],
- (CBC_ResultPoint*)(*patterns)[1]);
- FX_FLOAT bcDistance = Distance((CBC_ResultPoint*)(*patterns)[1],
- (CBC_ResultPoint*)(*patterns)[2]);
- FX_FLOAT acDistance = Distance((CBC_ResultPoint*)(*patterns)[0],
- (CBC_ResultPoint*)(*patterns)[2]);
- CBC_QRFinderPattern *topLeft, *topRight, *bottomLeft;
+void CBC_QRFinderPatternFinder::OrderBestPatterns(
+ CFX_ArrayTemplate<CBC_QRFinderPattern*>* patterns) {
+ FX_FLOAT abDistance = Distance((*patterns)[0], (*patterns)[1]);
+ FX_FLOAT bcDistance = Distance((*patterns)[1], (*patterns)[2]);
+ FX_FLOAT acDistance = Distance((*patterns)[0], (*patterns)[2]);
+ CBC_QRFinderPattern* topLeft;
+ CBC_QRFinderPattern* topRight;
+ CBC_QRFinderPattern* bottomLeft;
if (bcDistance >= abDistance && bcDistance >= acDistance) {
- topLeft = (CBC_QRFinderPattern*)(*patterns)[0];
- topRight = (CBC_QRFinderPattern*)(*patterns)[1];
- bottomLeft = (CBC_QRFinderPattern*)(*patterns)[2];
+ topLeft = (*patterns)[0];
+ topRight = (*patterns)[1];
+ bottomLeft = (*patterns)[2];
} else if (acDistance >= bcDistance && acDistance >= abDistance) {
- topLeft = (CBC_QRFinderPattern*)(*patterns)[1];
- topRight = (CBC_QRFinderPattern*)(*patterns)[0];
- bottomLeft = (CBC_QRFinderPattern*)(*patterns)[2];
+ topLeft = (*patterns)[1];
+ topRight = (*patterns)[0];
+ bottomLeft = (*patterns)[2];
} else {
- topLeft = (CBC_QRFinderPattern*)(*patterns)[2];
- topRight = (CBC_QRFinderPattern*)(*patterns)[0];
- bottomLeft = (CBC_QRFinderPattern*)(*patterns)[1];
+ topLeft = (*patterns)[2];
+ topRight = (*patterns)[0];
+ bottomLeft = (*patterns)[1];
}
if ((bottomLeft->GetY() - topLeft->GetY()) *
(topRight->GetX() - topLeft->GetX()) <
@@ -375,8 +379,7 @@ FX_BOOL CBC_QRFinderPatternFinder::HandlePossibleCenter(
FX_BOOL found = FALSE;
int32_t max = m_possibleCenters.GetSize();
for (int32_t index = 0; index < max; index++) {
- CBC_QRFinderPattern* center =
- (CBC_QRFinderPattern*)(m_possibleCenters[index]);
+ CBC_QRFinderPattern* center = m_possibleCenters[index];
if (center->AboutEquals(estimatedModuleSize, centerI, centerJ)) {
center->IncrementCount();
found = TRUE;
@@ -399,7 +402,7 @@ int32_t CBC_QRFinderPatternFinder::FindRowSkip() {
}
FinderPattern* firstConfirmedCenter = NULL;
for (int32_t i = 0; i < max; i++) {
- CBC_QRFinderPattern* center = (CBC_QRFinderPattern*)m_possibleCenters[i];
+ CBC_QRFinderPattern* center = m_possibleCenters[i];
if (center->GetCount() >= CENTER_QUORUM) {
if (firstConfirmedCenter == NULL) {
firstConfirmedCenter = center;
@@ -419,7 +422,7 @@ FX_BOOL CBC_QRFinderPatternFinder::HaveMultiplyConfirmedCenters() {
int32_t max = m_possibleCenters.GetSize();
int32_t i;
for (i = 0; i < max; i++) {
- CBC_QRFinderPattern* pattern = (CBC_QRFinderPattern*)m_possibleCenters[i];
+ CBC_QRFinderPattern* pattern = m_possibleCenters[i];
if (pattern->GetCount() >= CENTER_QUORUM) {
confirmedCount++;
totalModuleSize += pattern->GetEstimatedModuleSize();
@@ -431,16 +434,14 @@ FX_BOOL CBC_QRFinderPatternFinder::HaveMultiplyConfirmedCenters() {
FX_FLOAT average = totalModuleSize / (FX_FLOAT)max;
FX_FLOAT totalDeviation = 0.0f;
for (i = 0; i < max; i++) {
- CBC_QRFinderPattern* pattern = (CBC_QRFinderPattern*)m_possibleCenters[i];
+ CBC_QRFinderPattern* pattern = m_possibleCenters[i];
totalDeviation += fabs(pattern->GetEstimatedModuleSize() - average);
}
return totalDeviation <= 0.05f * totalModuleSize;
}
-inline FX_BOOL centerComparator(void* a, void* b) {
- return ((CBC_QRFinderPattern*)b)->GetCount() <
- ((CBC_QRFinderPattern*)a)->GetCount();
-}
-CFX_PtrArray* CBC_QRFinderPatternFinder::SelectBestpatterns(int32_t& e) {
+
+CFX_ArrayTemplate<CBC_QRFinderPattern*>*
+CBC_QRFinderPatternFinder::SelectBestpatterns(int32_t& e) {
int32_t startSize = m_possibleCenters.GetSize();
if (m_possibleCenters.GetSize() < 3) {
e = BCExceptionRead;
@@ -449,15 +450,14 @@ CFX_PtrArray* CBC_QRFinderPatternFinder::SelectBestpatterns(int32_t& e) {
FX_FLOAT average = 0.0f;
if (startSize > 3) {
FX_FLOAT totalModuleSize = 0.0f;
- for (int32_t i = 0; i < startSize; i++) {
- totalModuleSize += ((CBC_QRFinderPattern*)m_possibleCenters[i])
- ->GetEstimatedModuleSize();
- }
+ for (int32_t i = 0; i < startSize; i++)
+ totalModuleSize += m_possibleCenters[i]->GetEstimatedModuleSize();
+
average = totalModuleSize / (FX_FLOAT)startSize;
for (int32_t j = 0;
j < m_possibleCenters.GetSize() && m_possibleCenters.GetSize() > 3;
j++) {
- CBC_QRFinderPattern* pattern = (CBC_QRFinderPattern*)m_possibleCenters[j];
+ CBC_QRFinderPattern* pattern = m_possibleCenters[j];
if (fabs(pattern->GetEstimatedModuleSize() - average) > 0.2f * average) {
delete pattern;
m_possibleCenters.RemoveAt(j);
@@ -466,12 +466,17 @@ CFX_PtrArray* CBC_QRFinderPatternFinder::SelectBestpatterns(int32_t& e) {
}
}
if (m_possibleCenters.GetSize() > 3) {
- BC_FX_PtrArray_Sort(m_possibleCenters, centerComparator);
- }
- CFX_PtrArray* vec = new CFX_PtrArray();
+ std::sort(m_possibleCenters.GetData(),
+ m_possibleCenters.GetData() + m_possibleCenters.GetSize(),
+ [](const CBC_QRFinderPattern* a, CBC_QRFinderPattern* b) {
+ return a->GetCount() > b->GetCount(); // e.g. Descending.
+ });
+ }
+ CFX_ArrayTemplate<CBC_QRFinderPattern*>* vec =
+ new CFX_ArrayTemplate<CBC_QRFinderPattern*>();
vec->SetSize(3);
- (*vec)[0] = ((CBC_QRFinderPattern*)m_possibleCenters[0])->Clone();
- (*vec)[1] = ((CBC_QRFinderPattern*)m_possibleCenters[1])->Clone();
- (*vec)[2] = ((CBC_QRFinderPattern*)m_possibleCenters[2])->Clone();
+ (*vec)[0] = m_possibleCenters[0]->Clone();
+ (*vec)[1] = m_possibleCenters[1]->Clone();
+ (*vec)[2] = m_possibleCenters[2]->Clone();
return vec;
}
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h
index ada224787b0..60ec184fe4b 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h
@@ -15,16 +15,6 @@ class CBC_ResultPoint;
class CBC_QRFinderPatternInfo;
class CBC_QRFinderPatternFinder {
- private:
- static const int32_t CENTER_QUORUM;
- static const int32_t MIN_SKIP;
- static const int32_t MAX_MODULES;
- static const int32_t INTEGER_MATH_SHIFT;
- FX_BOOL m_hasSkipped;
- CBC_CommonBitMatrix* m_image;
- CFX_Int32Array m_crossCheckStateCount;
- CFX_PtrArray m_possibleCenters;
-
public:
CBC_QRFinderPatternFinder(CBC_CommonBitMatrix* image);
virtual ~CBC_QRFinderPatternFinder();
@@ -33,8 +23,8 @@ class CBC_QRFinderPatternFinder {
CBC_QRFinderPatternInfo* Find(int32_t hint, int32_t& e);
CFX_Int32Array& GetCrossCheckStateCount();
- CFX_PtrArray* GetPossibleCenters();
- CFX_PtrArray* SelectBestpatterns(int32_t& e);
+ CFX_ArrayTemplate<CBC_QRFinderPattern*>* GetPossibleCenters();
+ CFX_ArrayTemplate<CBC_QRFinderPattern*>* SelectBestpatterns(int32_t& e);
FX_BOOL HandlePossibleCenter(const CFX_Int32Array& stateCount,
int32_t i,
@@ -49,9 +39,21 @@ class CBC_QRFinderPatternFinder {
int32_t CenterI,
int32_t maxCOunt,
int32_t originalStateCountTotal);
- static void OrderBestPatterns(CFX_PtrArray* patterns);
+ static void OrderBestPatterns(
+ CFX_ArrayTemplate<CBC_QRFinderPattern*>* patterns);
static FX_BOOL FoundPatternCross(const CFX_Int32Array& stateCount);
static FX_FLOAT Distance(CBC_ResultPoint* point1, CBC_ResultPoint* point2);
+
+ private:
+ static const int32_t CENTER_QUORUM;
+ static const int32_t MIN_SKIP;
+ static const int32_t MAX_MODULES;
+ static const int32_t INTEGER_MATH_SHIFT;
+
+ FX_BOOL m_hasSkipped;
+ CBC_CommonBitMatrix* m_image;
+ CFX_Int32Array m_crossCheckStateCount;
+ CFX_ArrayTemplate<CBC_QRFinderPattern*> m_possibleCenters;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxbarcode/utils.h b/chromium/third_party/pdfium/xfa/fxbarcode/utils.h
index da10555e2e8..ca2f3214c0d 100644
--- a/chromium/third_party/pdfium/xfa/fxbarcode/utils.h
+++ b/chromium/third_party/pdfium/xfa/fxbarcode/utils.h
@@ -17,8 +17,6 @@ FX_BOOL BC_FX_ByteString_Replace(CFX_ByteString& dst,
FX_CHAR c);
void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, FX_CHAR c);
void BC_FX_ByteString_Append(CFX_ByteString& dst, const CFX_ByteArray& ba);
-typedef FX_BOOL (*BC_PtrArrayCompareCallback)(void* l, void* r);
-void BC_FX_PtrArray_Sort(CFX_PtrArray& src, BC_PtrArrayCompareCallback fun);
#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
#include <limits>
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/DEPS b/chromium/third_party/pdfium/xfa/fxfa/app/DEPS
index a1911963de3..53c19d1aa9a 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/DEPS
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/DEPS
@@ -3,4 +3,7 @@ include_rules = [
'+core/fpdfapi/fpdf_font/include',
'+core/fpdfapi/fpdf_page/include',
'+core/fpdfapi/fpdf_parser/include',
+ '+core/fpdfdoc/include',
+ '+core/fxcodec/include',
+ '+core/fxcodec/codec/include',
]
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_checksum.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_checksum.cpp
index 318541f05a2..195033bfab8 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_checksum.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_checksum.cpp
@@ -4,14 +4,14 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_checksum.h"
+#include "xfa/fxfa/include/xfa_checksum.h"
#include "core/fdrm/crypto/include/fx_crypt.h"
#include "xfa/fgas/crt/fgas_algorithm.h"
CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext)
: m_pContext(pContext) {
- FXSYS_assert(m_pContext);
+ ASSERT(m_pContext);
}
CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {}
void* CXFA_SAXReaderHandler::OnTagEnter(const CFX_ByteStringC& bsTagName,
@@ -73,7 +73,7 @@ void CXFA_SAXReaderHandler::OnTagClose(void* pTag, uint32_t dwEndPos) {
if (pSAXContext->m_eNode == FX_SAXNODE_Instruction) {
textBuf << "?>";
} else if (pSAXContext->m_eNode == FX_SAXNODE_Tag) {
- textBuf << "></" << pSAXContext->m_bsTagName.AsByteStringC() << ">";
+ textBuf << "></" << pSAXContext->m_bsTagName.AsStringC() << ">";
}
UpdateChecksum(FALSE);
}
@@ -126,30 +126,28 @@ void CXFA_SAXReaderHandler::UpdateChecksum(FX_BOOL bCheckSpace) {
}
CXFA_ChecksumContext::CXFA_ChecksumContext()
- : m_pSAXReader(NULL), m_pByteContext(NULL) {}
+ : m_pSAXReader(nullptr), m_pByteContext(nullptr) {}
+
CXFA_ChecksumContext::~CXFA_ChecksumContext() {
FinishChecksum();
}
-FX_BOOL CXFA_ChecksumContext::StartChecksum() {
+
+void CXFA_ChecksumContext::StartChecksum() {
FinishChecksum();
m_pByteContext = FX_Alloc(uint8_t, 128);
CRYPT_SHA1Start(m_pByteContext);
- m_bsChecksum.Empty();
- m_pSAXReader = FX_SAXReader_Create();
- return m_pSAXReader != NULL;
+ m_bsChecksum.clear();
+ m_pSAXReader = new CFX_SAXReader;
}
+
FX_BOOL CXFA_ChecksumContext::UpdateChecksum(IFX_FileRead* pSrcFile,
FX_FILESIZE offset,
size_t size) {
- if (m_pSAXReader == NULL) {
- return FALSE;
- }
- if (pSrcFile == NULL) {
+ if (!m_pSAXReader || !pSrcFile)
return FALSE;
- }
- if (size < 1) {
+ if (size < 1)
size = pSrcFile->GetSize();
- }
+
CXFA_SAXReaderHandler handler(this);
m_pSAXReader->SetHandler(&handler);
if (m_pSAXReader->StartParse(
@@ -161,6 +159,7 @@ FX_BOOL CXFA_ChecksumContext::UpdateChecksum(IFX_FileRead* pSrcFile,
}
return m_pSAXReader->ContinueParse(NULL) > 99;
}
+
void CXFA_ChecksumContext::FinishChecksum() {
if (m_pSAXReader) {
m_pSAXReader->Release();
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffapp.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffapp.cpp
index f629e408c09..7f19b264400 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffapp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffapp.cpp
@@ -4,17 +4,18 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
#include <algorithm>
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
+#include "xfa/fgas/font/fgas_stdfontmgr.h"
+#include "xfa/fwl/core/fwl_widgetmgrimp.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/app/xfa_fwltheme.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdochandler.h"
-#include "xfa/include/fxfa/xfa_ffwidgethandler.h"
-#include "xfa/include/fxfa/xfa_fontmgr.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdochandler.h"
+#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/include/xfa_fontmgr.h"
CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) {
int32_t iCount = streams.GetSize();
@@ -72,8 +73,7 @@ CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider)
#endif
m_pAdapterWidgetMgr(nullptr),
m_pWidgetMgrDelegate(nullptr),
- m_pFDEFontMgr(nullptr),
- m_pAdapterThreadMgr(nullptr) {
+ m_pFDEFontMgr(nullptr) {
m_pFWLApp = IFWL_App::Create(this);
FWL_SetApp(m_pFWLApp);
m_pFWLApp->Initialize();
@@ -89,7 +89,6 @@ CXFA_FFApp::~CXFA_FFApp() {
if (m_pFWLTheme)
m_pFWLTheme->Release();
delete m_pAdapterWidgetMgr;
- delete m_pAdapterThreadMgr;
CXFA_TimeZoneProvider::Destroy();
delete m_pFontMgr;
@@ -146,7 +145,7 @@ IFX_FontMgr* CXFA_FFApp::GetFDEFontMgr() {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
m_pFDEFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator());
#else
- m_pFontSource = FX_CreateDefaultFontSourceEnum();
+ m_pFontSource = new CFX_FontSourceEnum_File;
m_pFDEFontMgr = IFX_FontMgr::Create(m_pFontSource);
#endif
}
@@ -158,8 +157,8 @@ CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() {
}
return m_pFWLTheme;
}
-IFWL_AdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr(
- IFWL_WidgetMgrDelegate* pDelegate) {
+CXFA_FWLAdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr(
+ CFWL_WidgetMgrDelegate* pDelegate) {
if (!m_pAdapterWidgetMgr) {
m_pAdapterWidgetMgr = new CXFA_FWLAdapterWidgetMgr;
pDelegate->OnSetCapability(FWL_WGTMGR_DisableThread |
@@ -168,12 +167,6 @@ IFWL_AdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr(
}
return m_pAdapterWidgetMgr;
}
-IFWL_AdapterThreadMgr* CXFA_FFApp::GetThreadMgr() {
- if (!m_pAdapterThreadMgr) {
- m_pAdapterThreadMgr = new CFWL_SDAdapterThreadMgr;
- }
- return m_pAdapterThreadMgr;
-}
IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() {
return m_pProvider->GetTimerMgr();
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.cpp
index 28dfa860661..a659e13c55d 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.cpp
@@ -7,14 +7,14 @@
#include "xfa/fxfa/app/xfa_ffbarcode.h"
#include "core/fxcrt/include/fx_ext.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
#include "xfa/fwl/lightwidget/cfwl_barcode.h"
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fftextedit.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
namespace {
@@ -94,12 +94,12 @@ const int32_t g_iXFABarcodeTypeCount =
XFA_LPCBARCODETYPEENUMINFO XFA_GetBarcodeTypeByName(
const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.raw_str(), iLength, TRUE);
- int32_t iStart = 0, iEnd = g_iXFABarcodeTypeCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, true);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFABarcodeTypeCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
XFA_LPCBARCODETYPEENUMINFO pInfo = g_XFABarCodeTypeEnumData + iMid;
@@ -128,7 +128,7 @@ FX_BOOL CXFA_FFBarcode::LoadWidget() {
m_pNormalWidget = pFWLBarcode;
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
@@ -167,7 +167,7 @@ void CXFA_FFBarcode::UpdateWidgetProperty() {
CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget;
CFX_WideString wsType = GetDataAcc()->GetBarcodeType();
XFA_LPCBARCODETYPEENUMINFO pBarcodeTypeInfo =
- XFA_GetBarcodeTypeByName(wsType.AsWideStringC());
+ XFA_GetBarcodeTypeByName(wsType.AsStringC());
pBarCodeWidget->SetType(pBarcodeTypeInfo->eBCType);
CXFA_WidgetAcc* pAcc = GetDataAcc();
int32_t intVal;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.h
index 8a32e8df518..ffa7037839b 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffbarcode.h
@@ -9,7 +9,7 @@
#include "xfa/fxbarcode/include/BC_Library.h"
#include "xfa/fxfa/app/xfa_fftextedit.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
class CXFA_FFBarcode : public CXFA_FFTextEdit {
public:
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.cpp
index f741f2598e4..84a60135280 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -7,16 +7,16 @@
#include "xfa/fxfa/app/xfa_ffcheckbutton.h"
#include "xfa/fwl/core/cfwl_message.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
+#include "xfa/fwl/core/fwl_widgetmgrimp.h"
#include "xfa/fwl/lightwidget/cfwl_checkbox.h"
#include "xfa/fxfa/app/xfa_ffexclgroup.h"
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
@@ -30,7 +30,7 @@ FX_BOOL CXFA_FFCheckButton::LoadWidget() {
m_pNormalWidget = pCheckBox;
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
if (m_pDataAcc->IsRadioButton()) {
@@ -250,7 +250,7 @@ FX_BOOL CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags,
}
SetButtonDown(FALSE);
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp;
+ ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -295,14 +295,15 @@ FX_BOOL CXFA_FFCheckButton::UpdateFWLData() {
m_pNormalWidget->Update();
return TRUE;
}
-int32_t CXFA_FFCheckButton::OnProcessMessage(CFWL_Message* pMessage) {
- return m_pOldDelegate->OnProcessMessage(pMessage);
+
+void CXFA_FFCheckButton::OnProcessMessage(CFWL_Message* pMessage) {
+ m_pOldDelegate->OnProcessMessage(pMessage);
}
-FWL_ERR CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) {
+
+void CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) {
CXFA_FFField::OnProcessEvent(pEvent);
- uint32_t dwEventID = pEvent->GetClassID();
- switch (dwEventID) {
- case FWL_EVTHASH_CKB_CheckStateChanged: {
+ switch (pEvent->GetClassID()) {
+ case CFWL_EventType::CheckStateChanged: {
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_Change;
m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw);
@@ -327,11 +328,13 @@ FWL_ERR CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) {
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam);
break;
}
- default: {}
+ default:
+ break;
}
- return m_pOldDelegate->OnProcessEvent(pEvent);
+ m_pOldDelegate->OnProcessEvent(pEvent);
}
-FWL_ERR CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+
+void CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.h
index 2e169041d73..c3323b4035f 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffcheckbutton.h
@@ -8,7 +8,7 @@
#define XFA_FXFA_APP_XFA_FFCHECKBUTTON_H_
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
class CXFA_FFCheckButton : public CXFA_FFField {
public:
@@ -25,10 +25,10 @@ class CXFA_FFCheckButton : public CXFA_FFField {
virtual void UpdateWidgetProperty();
virtual FX_BOOL OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
void SetFWLCheckState(XFA_CHECKSTATE eCheckState);
- virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ virtual void OnProcessMessage(CFWL_Message* pMessage);
+ virtual void OnProcessEvent(CFWL_Event* pEvent);
+ virtual void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
protected:
virtual FX_BOOL CommitData();
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.cpp
index 645b8c88fa4..4676bc93744 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.cpp
@@ -7,16 +7,16 @@
#include "xfa/fxfa/app/xfa_ffchoicelist.h"
#include "xfa/fwl/basewidget/ifwl_edit.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
#include "xfa/fwl/lightwidget/cfwl_combobox.h"
#include "xfa/fwl/lightwidget/cfwl_listbox.h"
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
@@ -24,7 +24,7 @@ CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView,
CXFA_FFListBox::~CXFA_FFListBox() {
if (m_pNormalWidget) {
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->UnregisterEventTarget(pWidget);
}
}
@@ -36,7 +36,7 @@ FX_BOOL CXFA_FFListBox::LoadWidget() {
m_pNormalWidget = (CFWL_Widget*)pListBox;
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
@@ -44,7 +44,7 @@ FX_BOOL CXFA_FFListBox::LoadWidget() {
m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE);
int32_t iItems = wsLabelArray.GetSize();
for (int32_t i = 0; i < iItems; i++) {
- pListBox->AddString(wsLabelArray[i].AsWideStringC());
+ pListBox->AddString(wsLabelArray[i].AsStringC());
}
uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus;
if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
@@ -77,7 +77,7 @@ FX_BOOL CXFA_FFListBox::CommitData() {
for (int32_t i = 0; i < iSels; i++) {
iSelArray.Add(pListBox->GetSelIndex(i));
}
- m_pDataAcc->SetSelectdItems(iSelArray, TRUE);
+ m_pDataAcc->SetSelectedItems(iSelArray, TRUE);
return TRUE;
}
FX_BOOL CXFA_FFListBox::IsDataChanged() {
@@ -166,7 +166,7 @@ void CXFA_FFListBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) {
void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel,
int32_t nIndex) {
CFX_WideString wsTemp(wsLabel);
- ((CFWL_ListBox*)m_pNormalWidget)->AddString(wsTemp.AsWideStringC());
+ ((CFWL_ListBox*)m_pNormalWidget)->AddString(wsTemp.AsStringC());
m_pNormalWidget->Update();
AddInvalidateRect();
}
@@ -180,25 +180,27 @@ void CXFA_FFListBox::DeleteItem(int32_t nIndex) {
m_pNormalWidget->Update();
AddInvalidateRect();
}
-int32_t CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) {
- return m_pOldDelegate->OnProcessMessage(pMessage);
+
+void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) {
+ m_pOldDelegate->OnProcessMessage(pMessage);
}
-FWL_ERR CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) {
+
+void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) {
CXFA_FFField::OnProcessEvent(pEvent);
- uint32_t dwEventID = pEvent->GetClassID();
- switch (dwEventID) {
- case FWL_EVTHASH_LTB_SelChanged: {
+ switch (pEvent->GetClassID()) {
+ case CFWL_EventType::SelectChanged: {
CFX_Int32Array arrSels;
OnSelectChanged(m_pNormalWidget->GetWidget(), arrSels);
break;
}
- default: {}
+ default:
+ break;
}
- return m_pOldDelegate->OnProcessEvent(pEvent);
+ m_pOldDelegate->OnProcessEvent(pEvent);
}
-FWL_ERR CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
}
CXFA_FFComboBox::CXFA_FFComboBox(CXFA_FFPageView* pPageView,
@@ -232,7 +234,7 @@ FX_BOOL CXFA_FFComboBox::LoadWidget() {
m_pNormalWidget = (CFWL_Widget*)pComboBox;
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
@@ -240,7 +242,7 @@ FX_BOOL CXFA_FFComboBox::LoadWidget() {
m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE);
int32_t iItems = wsLabelArray.GetSize();
for (int32_t i = 0; i < iItems; i++) {
- pComboBox->AddString(wsLabelArray[i].AsWideStringC());
+ pComboBox->AddString(wsLabelArray[i].AsStringC());
}
CFX_Int32Array iSelArray;
m_pDataAcc->GetSelectedItems(iSelArray);
@@ -250,7 +252,7 @@ FX_BOOL CXFA_FFComboBox::LoadWidget() {
} else {
CFX_WideString wsText;
m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw);
- pComboBox->SetEditText(wsText.AsWideStringC());
+ pComboBox->SetEditText(wsText);
}
UpdateWidgetProperty();
m_pNormalWidget->UnlockUpdate();
@@ -382,7 +384,7 @@ FX_BOOL CXFA_FFComboBox::UpdateFWLData() {
CFX_WideString wsText;
((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1);
m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw);
- ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText.AsWideStringC());
+ ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText);
}
m_pNormalWidget->Update();
return TRUE;
@@ -495,37 +497,39 @@ void CXFA_FFComboBox::OnPostOpen(IFWL_Widget* pWidget) {
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam);
}
-int32_t CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) {
- return m_pOldDelegate->OnProcessMessage(pMessage);
+void CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) {
+ m_pOldDelegate->OnProcessMessage(pMessage);
}
-FWL_ERR CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) {
+
+void CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) {
CXFA_FFField::OnProcessEvent(pEvent);
- uint32_t dwEventID = pEvent->GetClassID();
- switch (dwEventID) {
- case FWL_EVTHASH_CMB_SelChanged: {
+ switch (pEvent->GetClassID()) {
+ case CFWL_EventType::SelectChanged: {
CFWL_EvtCmbSelChanged* postEvent = (CFWL_EvtCmbSelChanged*)pEvent;
OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->iArraySels,
postEvent->bLButtonUp);
break;
}
- case FWL_EVTHASH_CMB_EditChanged: {
+ case CFWL_EventType::EditChanged: {
CFX_WideString wsChanged;
OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged);
break;
}
- case FWL_EVTHASH_CMB_PreDropDown: {
+ case CFWL_EventType::PreDropDown: {
OnPreOpen(m_pNormalWidget->GetWidget());
break;
}
- case FWL_EVTHASH_CMB_PostDropDown: {
+ case CFWL_EventType::PostDropDown: {
OnPostOpen(m_pNormalWidget->GetWidget());
break;
}
- default: {}
+ default:
+ break;
}
- return m_pOldDelegate->OnProcessEvent(pEvent);
+ m_pOldDelegate->OnProcessEvent(pEvent);
}
-FWL_ERR CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+
+void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.h
index 580bb8f6473..c59ca647aa2 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffchoicelist.h
@@ -8,7 +8,7 @@
#define XFA_FXFA_APP_XFA_FFCHOICELIST_H_
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
class CXFA_FFListBox : public CXFA_FFField {
public:
@@ -28,10 +28,10 @@ class CXFA_FFListBox : public CXFA_FFField {
void SetItemState(int32_t nIndex, FX_BOOL bSelected);
void InsertItem(const CFX_WideStringC& wsLabel, int32_t nIndex = -1);
void DeleteItem(int32_t nIndex);
- virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ virtual void OnProcessMessage(CFWL_Message* pMessage);
+ virtual void OnProcessEvent(CFWL_Event* pEvent);
+ virtual void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
protected:
IFWL_WidgetDelegate* m_pOldDelegate;
@@ -84,10 +84,10 @@ class CXFA_FFComboBox : public CXFA_FFField {
void SetItemState(int32_t nIndex, FX_BOOL bSelected);
void InsertItem(const CFX_WideStringC& wsLabel, int32_t nIndex = -1);
void DeleteItem(int32_t nIndex);
- virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ virtual void OnProcessMessage(CFWL_Message* pMessage);
+ virtual void OnProcessEvent(CFWL_Event* pEvent);
+ virtual void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
protected:
IFWL_WidgetDelegate* m_pOldDelegate;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdoc.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdoc.cpp
index 58cf1a269a2..8297dce9ec7 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdoc.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdoc.cpp
@@ -4,27 +4,29 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+
+#include <algorithm>
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
+#include "core/fpdfdoc/include/fpdf_doc.h"
#include "core/fxcrt/include/fx_ext.h"
#include "core/fxcrt/include/fx_memory.h"
-#include "core/include/fpdfdoc/fpdf_doc.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fgas/crt/fgas_algorithm.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
+#include "xfa/fxfa/include/xfa_checksum.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_fontmgr.h"
+#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_serialize.h"
#include "xfa/fxfa/parser/xfa_parser.h"
#include "xfa/fxfa/parser/xfa_parser_imp.h"
#include "xfa/fxfa/parser/xfa_parser_imp.h"
-#include "xfa/include/fxfa/xfa_checksum.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
-#include "xfa/include/fxfa/xfa_fontmgr.h"
CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider)
: m_pDocProvider(pDocProvider),
@@ -87,10 +89,11 @@ FX_BOOL XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement,
}
CFX_WideString wsPDFContent;
pChunkElement->GetTextData(wsPDFContent);
- iBufferSize = FX_Base64DecodeW(wsPDFContent, wsPDFContent.GetLength(), NULL);
+ iBufferSize =
+ FX_Base64DecodeW(wsPDFContent.c_str(), wsPDFContent.GetLength(), NULL);
pByteBuffer = FX_Alloc(uint8_t, iBufferSize + 1);
pByteBuffer[iBufferSize] = '0'; // FIXME: I bet this is wrong.
- FX_Base64DecodeW(wsPDFContent, wsPDFContent.GetLength(), pByteBuffer);
+ FX_Base64DecodeW(wsPDFContent.c_str(), wsPDFContent.GetLength(), pByteBuffer);
return TRUE;
}
void XFA_XPDPacket_MergeRootNode(CXFA_Node* pOriginRoot, CXFA_Node* pNewRoot) {
@@ -138,7 +141,7 @@ int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) {
}
CPDF_Document* pPDFDocument =
GetDocProvider()->OpenPDF(this, pXFAReader, TRUE);
- FXSYS_assert(!m_pPDFDoc);
+ ASSERT(!m_pPDFDoc);
if (!OpenDoc(pPDFDocument)) {
return XFA_PARSESTATUS_SyntaxErr;
}
@@ -187,37 +190,27 @@ void CXFA_FFDoc::StopLoad() {
m_dwDocType = XFA_DOCTYPE_Dynamic;
}
}
+
CXFA_FFDocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) {
- CXFA_FFDocView* pDocView =
- (CXFA_FFDocView*)m_mapTypeToDocView.GetValueAt((void*)(uintptr_t)dwView);
- if (!pDocView) {
- pDocView = new CXFA_FFDocView(this);
- m_mapTypeToDocView.SetAt((void*)(uintptr_t)dwView, pDocView);
- }
- return pDocView;
+ if (!m_TypeToDocViewMap[dwView])
+ m_TypeToDocViewMap[dwView].reset(new CXFA_FFDocView(this));
+
+ return m_TypeToDocViewMap[dwView].get();
}
+
CXFA_FFDocView* CXFA_FFDoc::GetDocView(CXFA_LayoutProcessor* pLayout) {
- FX_POSITION ps = m_mapTypeToDocView.GetStartPosition();
- while (ps) {
- void* pType;
- CXFA_FFDocView* pDocView;
- m_mapTypeToDocView.GetNextAssoc(ps, pType, (void*&)pDocView);
- if (pDocView->GetXFALayout() == pLayout) {
- return pDocView;
- }
+ for (const auto& pair : m_TypeToDocViewMap) {
+ if (pair.second->GetXFALayout() == pLayout)
+ return pair.second.get();
}
- return NULL;
+ return nullptr;
}
+
CXFA_FFDocView* CXFA_FFDoc::GetDocView() {
- FX_POSITION ps = m_mapTypeToDocView.GetStartPosition();
- if (ps) {
- void* pType;
- CXFA_FFDocView* pDocView;
- m_mapTypeToDocView.GetNextAssoc(ps, pType, (void*&)pDocView);
- return pDocView;
- }
- return NULL;
+ auto it = m_TypeToDocViewMap.begin();
+ return it != m_TypeToDocViewMap.end() ? it->second.get() : nullptr;
}
+
FX_BOOL CXFA_FFDoc::OpenDoc(IFX_FileRead* pStream, FX_BOOL bTakeOverFile) {
m_bOwnStream = bTakeOverFile;
m_pStream = pStream;
@@ -242,8 +235,7 @@ FX_BOOL CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) {
CFX_ArrayTemplate<CPDF_Stream*> xfaStreams;
if (pElementXFA->IsArray()) {
CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA;
- uint32_t count = pXFAArray->GetCount() / 2;
- for (uint32_t i = 0; i < count; i++) {
+ for (size_t i = 0; i < pXFAArray->GetCount() / 2; i++) {
if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1))
xfaStreams.Add(pStream);
}
@@ -264,53 +256,35 @@ FX_BOOL CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) {
return TRUE;
}
FX_BOOL CXFA_FFDoc::CloseDoc() {
- FX_POSITION psClose = m_mapTypeToDocView.GetStartPosition();
- while (psClose) {
- void* pType;
- CXFA_FFDocView* pDocView;
- m_mapTypeToDocView.GetNextAssoc(psClose, pType, (void*&)pDocView);
- pDocView->RunDocClose();
- }
- if (m_pDocument) {
+ for (const auto& pair : m_TypeToDocViewMap)
+ pair.second->RunDocClose();
+
+ if (m_pDocument)
m_pDocument->ClearLayoutData();
- }
- FX_POSITION ps = m_mapTypeToDocView.GetStartPosition();
- while (ps) {
- void* pType;
- CXFA_FFDocView* pDocView;
- m_mapTypeToDocView.GetNextAssoc(ps, pType, (void*&)pDocView);
- delete pDocView;
- }
- m_mapTypeToDocView.RemoveAll();
+
+ m_TypeToDocViewMap.clear();
+
if (m_pDocument) {
- IXFA_Parser* pParser = m_pDocument->GetParser();
- pParser->Release();
- m_pDocument = NULL;
- }
- if (m_pNotify) {
- delete m_pNotify;
- m_pNotify = NULL;
+ m_pDocument->GetParser()->Release();
+ m_pDocument = nullptr;
}
+
+ delete m_pNotify;
+ m_pNotify = nullptr;
+
m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this);
+
if (m_dwDocType != XFA_DOCTYPE_XDP && m_pStream && m_bOwnStream) {
m_pStream->Release();
- m_pStream = NULL;
- }
- ps = m_mapNamedImages.GetStartPosition();
- while (ps) {
- void* pName;
- FX_IMAGEDIB_AND_DPI* pImage = NULL;
- m_mapNamedImages.GetNextAssoc(ps, pName, (void*&)pImage);
- if (pImage) {
- delete pImage->pDibSource;
- pImage->pDibSource = NULL;
- FX_Free(pImage);
- pImage = NULL;
- }
+ m_pStream = nullptr;
}
- m_mapNamedImages.RemoveAll();
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
- pNoteDriver->ClearEventTargets(FALSE);
+
+ for (const auto& pair : m_HashToDibDpiMap)
+ delete pair.second.pDibSource;
+
+ m_HashToDibDpiMap.clear();
+
+ FWL_GetApp()->GetNoteDriver()->ClearEventTargets(FALSE);
return TRUE;
}
void CXFA_FFDoc::SetDocType(uint32_t dwType) {
@@ -326,13 +300,12 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
if (!m_pPDFDoc)
return nullptr;
- uint32_t dwHash =
- FX_HashCode_String_GetW(wsName.raw_str(), wsName.GetLength(), FALSE);
- FX_IMAGEDIB_AND_DPI* imageDIBDpi = nullptr;
- if (m_mapNamedImages.Lookup((void*)(uintptr_t)dwHash, (void*&)imageDIBDpi)) {
- iImageXDpi = imageDIBDpi->iImageXDpi;
- iImageYDpi = imageDIBDpi->iImageYDpi;
- return static_cast<CFX_DIBitmap*>(imageDIBDpi->pDibSource);
+ uint32_t dwHash = FX_HashCode_GetW(wsName, false);
+ auto it = m_HashToDibDpiMap.find(dwHash);
+ if (it != m_HashToDibDpiMap.end()) {
+ iImageXDpi = it->second.iImageXDpi;
+ iImageYDpi = it->second.iImageYDpi;
+ return static_cast<CFX_DIBitmap*>(it->second.pDibSource);
}
CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
@@ -348,11 +321,10 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
return nullptr;
CPDF_NameTree nametree(pXFAImages);
- CFX_ByteString bsName = PDF_EncodeText(wsName.raw_str(), wsName.GetLength());
+ CFX_ByteString bsName = PDF_EncodeText(wsName.c_str(), wsName.GetLength());
CPDF_Object* pObject = nametree.LookupValue(bsName);
if (!pObject) {
- int32_t iCount = nametree.GetCount();
- for (int32_t i = 0; i < iCount; i++) {
+ for (size_t i = 0; i < nametree.GetCount(); i++) {
CFX_ByteString bsTemp;
CPDF_Object* pTempObject = nametree.LookupValue(i, bsTemp);
if (bsTemp == bsName) {
@@ -362,31 +334,25 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
}
}
- if (!pObject || !pObject->IsStream())
+ CPDF_Stream* pStream = ToStream(pObject);
+ if (!pStream)
return nullptr;
- if (!imageDIBDpi) {
- imageDIBDpi = FX_Alloc(FX_IMAGEDIB_AND_DPI, 1);
- imageDIBDpi->pDibSource = nullptr;
- imageDIBDpi->iImageXDpi = 0;
- imageDIBDpi->iImageYDpi = 0;
- CPDF_StreamAcc streamAcc;
- streamAcc.LoadAllData((CPDF_Stream*)pObject);
- IFX_FileRead* pImageFileRead = FX_CreateMemoryStream(
- (uint8_t*)streamAcc.GetData(), streamAcc.GetSize());
- imageDIBDpi->pDibSource = XFA_LoadImageFromBuffer(
- pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
- imageDIBDpi->iImageXDpi = iImageXDpi;
- imageDIBDpi->iImageYDpi = iImageYDpi;
- pImageFileRead->Release();
- }
- m_mapNamedImages.SetAt((void*)(uintptr_t)dwHash, imageDIBDpi);
- return (CFX_DIBitmap*)imageDIBDpi->pDibSource;
+ CPDF_StreamAcc streamAcc;
+ streamAcc.LoadAllData(pStream);
+
+ IFX_FileRead* pImageFileRead =
+ FX_CreateMemoryStream((uint8_t*)streamAcc.GetData(), streamAcc.GetSize());
+
+ CFX_DIBitmap* pDibSource = XFA_LoadImageFromBuffer(
+ pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
+ m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi};
+ pImageFileRead->Release();
+ return pDibSource;
}
CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) {
- uint32_t packetHash =
- FX_HashCode_String_GetW(wsPackage.raw_str(), wsPackage.GetLength());
+ uint32_t packetHash = FX_HashCode_GetW(wsPackage, false);
CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash));
if (!pNode) {
return NULL;
@@ -396,36 +362,29 @@ CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) {
? static_cast<CFDE_XMLElement*>(pXMLNode)
: NULL;
}
+
FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage,
IFX_FileWrite* pFile,
CXFA_ChecksumContext* pCSContext) {
- CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument);
- uint32_t packetHash =
- FX_HashCode_String_GetW(wsPackage.raw_str(), wsPackage.GetLength());
- CXFA_Node* pNode = NULL;
- if (packetHash == XFA_HASHCODE_Xfa) {
- pNode = m_pDocument->GetRoot();
- } else {
- pNode = ToNode(m_pDocument->GetXFAObject(packetHash));
- }
- FX_BOOL bFlags = FALSE;
- if (pNode) {
- CFX_ByteString bsChecksum;
- if (pCSContext) {
- pCSContext->GetChecksum(bsChecksum);
- }
- bFlags = pExport->Export(pFile, pNode, 0, bsChecksum.GetLength()
- ? (const FX_CHAR*)bsChecksum
- : NULL);
- } else {
- bFlags = pExport->Export(pFile);
- }
- pExport->Release();
- return bFlags;
+ std::unique_ptr<CXFA_DataExporter> pExport(
+ new CXFA_DataExporter(m_pDocument));
+ uint32_t packetHash = FX_HashCode_GetW(wsPackage, false);
+ CXFA_Node* pNode = packetHash == XFA_HASHCODE_Xfa
+ ? m_pDocument->GetRoot()
+ : ToNode(m_pDocument->GetXFAObject(packetHash));
+ if (!pNode)
+ return pExport->Export(pFile);
+
+ CFX_ByteString bsChecksum;
+ if (pCSContext)
+ pCSContext->GetChecksum(bsChecksum);
+
+ return pExport->Export(pFile, pNode, 0,
+ bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr);
}
-FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) {
- std::unique_ptr<CXFA_DataImporter, ReleaseDeleter<CXFA_DataImporter>>
- importer(new CXFA_DataImporter(m_pDocument));
+FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) {
+ std::unique_ptr<CXFA_DataImporter> importer(
+ new CXFA_DataImporter(m_pDocument));
return importer->ImportData(pStream);
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdochandler.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdochandler.cpp
index 6aed551fdb7..389e5ac6da6 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdochandler.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdochandler.cpp
@@ -4,12 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_ffdochandler.h"
+#include "xfa/fxfa/include/xfa_ffdochandler.h"
+#include "xfa/fxfa/include/xfa_checksum.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
#include "xfa/fxfa/parser/xfa_script.h"
#include "xfa/fxfa/parser/xfa_script_imp.h"
-#include "xfa/include/fxfa/xfa_checksum.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
CXFA_FFDocHandler::CXFA_FFDocHandler() {}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdocview.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdocview.cpp
index c82fd53bc2e..faf5c8baff8 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fxfa/app/xfa_ffbarcode.h"
@@ -24,14 +24,15 @@
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/parser/cxfa_binditems.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
#include "xfa/fxfa/parser/xfa_script.h"
#include "xfa/fxfa/parser/xfa_script_imp.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
-#include "xfa/include/fxfa/xfa_ffwidgethandler.h"
extern const XFA_ATTRIBUTEENUM gs_EventActivity[] = {
XFA_ATTRIBUTEENUM_Click, XFA_ATTRIBUTEENUM_Change,
@@ -61,13 +62,12 @@ CXFA_FFDocView::CXFA_FFDocView(CXFA_FFDoc* pDoc)
m_pOldFocusWidget(nullptr),
m_iStatus(XFA_DOCVIEW_LAYOUTSTATUS_None),
m_iLock(0) {}
+
CXFA_FFDocView::~CXFA_FFDocView() {
DestroyDocView();
- if (m_pWidgetHandler) {
- delete m_pWidgetHandler;
- }
- m_pWidgetHandler = NULL;
+ delete m_pWidgetHandler;
}
+
void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) {
RunBindItems();
ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize);
@@ -156,14 +156,13 @@ void CXFA_FFDocView::ShowNullTestMsg() {
pAppProvider->LoadString(XFA_IDS_ValidateLimit, wsLimit);
if (!wsLimit.IsEmpty()) {
CFX_WideString wsTemp;
- wsTemp.Format((const FX_WCHAR*)wsLimit, iRemain);
+ wsTemp.Format(wsLimit.c_str(), iRemain);
wsMsg += FX_WSTRC(L"\n") + wsTemp;
}
}
CFX_WideString wsTitle;
pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
- pAppProvider->MsgBox(wsMsg.AsWideStringC(), wsTitle.AsWideStringC(),
- XFA_MBICON_Status, XFA_MB_OK);
+ pAppProvider->MsgBox(wsMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK);
}
m_arrNullTestMsg.RemoveAll();
}
@@ -174,7 +173,7 @@ void CXFA_FFDocView::UpdateDocView() {
LockUpdate();
int32_t iNewAdds = m_NewAddedNodes.GetSize();
for (int32_t i = 0; i < iNewAdds; i++) {
- CXFA_Node* pNode = reinterpret_cast<CXFA_Node*>(m_NewAddedNodes[i]);
+ CXFA_Node* pNode = m_NewAddedNodes[i];
InitCalculate(pNode);
InitValidate(pNode);
ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE);
@@ -214,16 +213,11 @@ FX_BOOL CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) {
if (eType != XFA_ELEMENT_Field && eType != XFA_ELEMENT_ExclGroup) {
return FALSE;
}
- FX_BOOL bNotify = IsStaticNotify();
pWidgetAcc->ResetData();
pWidgetAcc->UpdateUIDisplay();
- if (bNotify) {
- pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL, NULL,
- NULL);
- }
if (CXFA_Validate validate = pWidgetAcc->GetValidate()) {
AddValidateWidget(pWidgetAcc);
- validate.GetNode()->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE);
+ validate.GetNode()->SetFlag(XFA_NODEFLAG_NeedsInitApp, false);
}
return TRUE;
}
@@ -260,7 +254,7 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
return XFA_EVENTERROR_Error;
}
if (pParam->m_eType == XFA_EVENT_Validate) {
- CFX_WideString wsValidateStr = FX_WSTRC(L"preSubmit");
+ CFX_WideString wsValidateStr(L"preSubmit");
CXFA_Node* pConfigItem =
ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Config));
if (pConfigItem) {
@@ -335,7 +329,7 @@ CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() {
}
void CXFA_FFDocView::KillFocus() {
if (m_pFocusWidget &&
- (m_pFocusWidget->GetStatus() & XFA_WIDGETSTATUS_Focused)) {
+ (m_pFocusWidget->GetStatus() & XFA_WidgetStatus_Focused)) {
(m_pFocusWidget)->OnKillFocus(NULL);
}
m_pFocusAcc = NULL;
@@ -351,10 +345,10 @@ FX_BOOL CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) {
m_pOldFocusWidget = pNewFocus;
if (pOldFocus) {
if (m_pFocusWidget != m_pOldFocusWidget &&
- (pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Focused)) {
+ (pOldFocus->GetStatus() & XFA_WidgetStatus_Focused)) {
m_pFocusWidget = pOldFocus;
pOldFocus->OnKillFocus(pNewFocus);
- } else if ((pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) {
+ } else if ((pOldFocus->GetStatus() & XFA_WidgetStatus_Visible)) {
if (!pOldFocus->IsLoaded()) {
pOldFocus->LoadWidget();
}
@@ -374,7 +368,7 @@ FX_BOOL CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) {
m_pOldFocusWidget = NULL;
return FALSE;
}
- if (pNewFocus && (pNewFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) {
+ if (pNewFocus && (pNewFocus->GetStatus() & XFA_WidgetStatus_Visible)) {
if (!pNewFocus->IsLoaded()) {
pNewFocus->LoadWidget();
}
@@ -490,25 +484,25 @@ int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
iRet |= XFA_ProcessEvent(this, pWidgetAcc, &eParam);
return iRet;
}
-CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(const CFX_WideStringC& wsName,
+
+CXFA_FFWidget* CXFA_FFDocView::GetWidgetByName(const CFX_WideString& wsName,
CXFA_FFWidget* pRefWidget) {
- CXFA_WidgetAcc* pRefAcc = pRefWidget ? pRefWidget->GetDataAcc() : NULL;
- if (CXFA_WidgetAcc* pAcc = GetWidgetAccByName(wsName, pRefAcc)) {
- return pAcc->GetNextWidget(NULL);
- }
- return NULL;
+ CXFA_WidgetAcc* pRefAcc = pRefWidget ? pRefWidget->GetDataAcc() : nullptr;
+ CXFA_WidgetAcc* pAcc = GetWidgetAccByName(wsName, pRefAcc);
+ return pAcc ? pAcc->GetNextWidget(nullptr) : nullptr;
}
+
CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
- const CFX_WideStringC& wsName,
+ const CFX_WideString& wsName,
CXFA_WidgetAcc* pRefWidgetAcc) {
CFX_WideString wsExpression;
uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
CXFA_ScriptContext* pScriptContext = m_pDoc->GetXFADoc()->GetScriptContext();
if (!pScriptContext) {
- return NULL;
+ return nullptr;
}
- CXFA_Node* refNode = NULL;
+ CXFA_Node* refNode = nullptr;
if (pRefWidgetAcc) {
refNode = pRefWidgetAcc->GetNode();
wsExpression = wsName;
@@ -517,9 +511,9 @@ CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
}
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
- refNode, wsExpression.AsWideStringC(), resoveNodeRS, dwStyle);
+ refNode, wsExpression.AsStringC(), resoveNodeRS, dwStyle);
if (iRet < 1) {
- return NULL;
+ return nullptr;
}
if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
CXFA_Node* pNode = resoveNodeRS.nodes[0]->AsNode();
@@ -527,21 +521,15 @@ CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
return (CXFA_WidgetAcc*)pNode->GetWidgetData();
}
}
- return NULL;
+ return nullptr;
}
+
void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender,
- XFA_PAGEEVENT eEvent,
- int32_t iPageIndex) {
+ uint32_t dwEvent) {
CXFA_FFPageView* pFFPageView = static_cast<CXFA_FFPageView*>(pSender);
- if (eEvent == XFA_PAGEEVENT_PageRemoved) {
- m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView,
- XFA_PAGEVIEWEVENT_PostRemoved);
- return;
- }
- m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView,
- XFA_PAGEVIEWEVENT_PostAdded);
- pFFPageView->LoadPageView();
+ m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView, dwEvent);
}
+
void CXFA_FFDocView::LockUpdate() {
m_iLock++;
}
@@ -609,8 +597,7 @@ FX_BOOL CXFA_FFDocView::RunLayout() {
void CXFA_FFDocView::RunSubformIndexChange() {
int32_t iSubforms = m_IndexChangedSubforms.GetSize();
for (int32_t i = 0; i < iSubforms; i++) {
- CXFA_Node* pSubformNode =
- reinterpret_cast<CXFA_Node*>(m_IndexChangedSubforms[i]);
+ CXFA_Node* pSubformNode = m_IndexChangedSubforms[i];
CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData();
if (!pWidgetAcc) {
continue;
@@ -627,7 +614,7 @@ void CXFA_FFDocView::AddNewFormNode(CXFA_Node* pNode) {
InitLayout(pNode);
}
void CXFA_FFDocView::AddIndexChangedSubform(CXFA_Node* pNode) {
- FXSYS_assert(pNode->GetClassID() == XFA_ELEMENT_Subform);
+ ASSERT(pNode->GetClassID() == XFA_ELEMENT_Subform);
m_IndexChangedSubforms.Add(pNode);
}
void CXFA_FFDocView::RunDocClose() {
@@ -643,7 +630,7 @@ void CXFA_FFDocView::DestroyDocView() {
m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None;
m_iLock = 0;
m_ValidateAccs.RemoveAll();
- m_bindItems.RemoveAll();
+ m_BindItems.RemoveAll();
m_CalculateAccs.RemoveAll();
}
FX_BOOL CXFA_FFDocView::IsStaticNotify() {
@@ -652,8 +639,7 @@ FX_BOOL CXFA_FFDocView::IsStaticNotify() {
void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) {
int32_t iAccs = m_CalculateAccs.GetSize();
CXFA_WidgetAcc* pCurrentAcc =
- (iAccs < 1) ? (CXFA_WidgetAcc*)NULL
- : (CXFA_WidgetAcc*)m_CalculateAccs[iAccs - 1];
+ iAccs > 0 ? m_CalculateAccs[iAccs - 1] : nullptr;
if (pCurrentAcc != pWidgetAcc) {
m_CalculateAccs.Add(pWidgetAcc);
}
@@ -663,14 +649,13 @@ void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) {
(CXFA_CalcData*)pNodeChange->GetUserData(XFA_CalcData);
int32_t iCount = pGlobalData ? pGlobalData->m_Globals.GetSize() : 0;
for (int32_t i = 0; i < iCount; i++) {
- CXFA_WidgetAcc* pResultAcc = (CXFA_WidgetAcc*)pGlobalData->m_Globals[i];
+ CXFA_WidgetAcc* pResultAcc = pGlobalData->m_Globals[i];
if (pResultAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) {
continue;
}
int32_t iAccs = m_CalculateAccs.GetSize();
CXFA_WidgetAcc* pCurrentAcc =
- (iAccs < 1) ? (CXFA_WidgetAcc*)NULL
- : (CXFA_WidgetAcc*)m_CalculateAccs[iAccs - 1];
+ iAccs > 0 ? m_CalculateAccs[iAccs - 1] : nullptr;
if (pCurrentAcc != pResultAcc) {
m_CalculateAccs.Add(pResultAcc);
}
@@ -678,7 +663,7 @@ void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) {
}
void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) {
while (iIndex < m_CalculateAccs.GetSize()) {
- CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[iIndex];
+ CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[iIndex];
AddCalculateNodeNotify(pCurAcc->GetNode());
int32_t iRefCount =
(int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount);
@@ -705,16 +690,15 @@ int32_t CXFA_FFDocView::RunCalculateWidgets() {
RunCalculateRecursive(iIndex);
}
for (int32_t i = 0; i < m_CalculateAccs.GetSize(); i++) {
- CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[i];
+ CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[i];
pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0);
}
m_CalculateAccs.RemoveAll();
return XFA_EVENTERROR_Success;
}
void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) {
- if (m_ValidateAccs.Find(pWidget) < 0) {
+ if (m_ValidateAccs.Find(pWidget) < 0)
m_ValidateAccs.Add(pWidget);
- }
}
FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) {
ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate);
@@ -734,7 +718,7 @@ FX_BOOL CXFA_FFDocView::RunValidate() {
}
int32_t iCounts = m_ValidateAccs.GetSize();
for (int32_t i = 0; i < iCounts; i++) {
- CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)m_ValidateAccs[i];
+ CXFA_WidgetAcc* pAcc = m_ValidateAccs[i];
if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) {
continue;
}
@@ -754,19 +738,17 @@ FX_BOOL CXFA_FFDocView::RunEventLayoutReady() {
return TRUE;
}
void CXFA_FFDocView::RunBindItems() {
- int32_t iCount = m_bindItems.GetSize();
+ int32_t iCount = m_BindItems.GetSize();
for (int32_t i = 0; i < iCount; i++) {
- if (reinterpret_cast<CXFA_Node*>(m_bindItems[i])
- ->HasFlag(XFA_NODEFLAG_HasRemoved)) {
+ if (m_BindItems[i]->HasFlag(XFA_NODEFLAG_HasRemoved))
continue;
- }
- CXFA_Node* pWidgetNode = reinterpret_cast<CXFA_Node*>(m_bindItems[i])
- ->GetNodeItem(XFA_NODEITEM_Parent);
+
+ CXFA_Node* pWidgetNode = m_BindItems[i]->GetNodeItem(XFA_NODEITEM_Parent);
CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData();
- if (!pAcc) {
+ if (!pAcc)
continue;
- }
- CXFA_BindItems binditems(reinterpret_cast<CXFA_Node*>(m_bindItems[i]));
+
+ CXFA_BindItems binditems(m_BindItems[i]);
CXFA_ScriptContext* pScriptContext =
pWidgetNode->GetDocument()->GetScriptContext();
CFX_WideStringC wsRef;
@@ -778,9 +760,9 @@ void CXFA_FFDocView::RunBindItems() {
pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle);
int32_t iCount = rs.nodes.GetSize();
pAcc->DeleteItem(-1);
- if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1) {
+ if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1)
continue;
- }
+
CFX_WideStringC wsValueRef, wsLabelRef;
binditems.GetValueRef(wsValueRef);
binditems.GetLabelRef(wsLabelRef);
@@ -789,9 +771,9 @@ void CXFA_FFDocView::RunBindItems() {
wsLabelRef.IsEmpty() || wsLabelRef == FX_WSTRC(L"$");
const bool bValueUseContent =
wsValueRef.IsEmpty() || wsValueRef == FX_WSTRC(L"$");
- CFX_WideString wsValue, wsLabel;
- uint32_t uValueHash = FX_HashCode_String_GetW(CFX_WideString(wsValueRef),
- wsValueRef.GetLength());
+ CFX_WideString wsValue;
+ CFX_WideString wsLabel;
+ uint32_t uValueHash = FX_HashCode_GetW(wsValueRef, false);
for (int32_t i = 0; i < iCount; i++) {
CXFA_Object* refObj = rs.nodes[i];
if (!refObj->IsNode()) {
@@ -822,7 +804,7 @@ void CXFA_FFDocView::RunBindItems() {
pAcc->InsertItem(wsLabel, wsValue);
}
}
- m_bindItems.RemoveAll();
+ m_BindItems.RemoveAll();
}
void CXFA_FFDocView::SetChangeMark() {
if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) {
@@ -862,7 +844,7 @@ CXFA_FFWidget* CXFA_FFDocWidgetIterator::MoveToNext() {
if (CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData()) {
while ((m_pCurWidget = pAcc->GetNextWidget(NULL))) {
if (!m_pCurWidget->IsLoaded() &&
- (m_pCurWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) {
+ (m_pCurWidget->GetStatus() & XFA_WidgetStatus_Visible)) {
m_pCurWidget->LoadWidget();
}
return m_pCurWidget;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.cpp
index 68c1d96f4a5..d433003f5c8 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.cpp
@@ -6,10 +6,10 @@
#include "xfa/fxfa/app/xfa_ffdraw.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
CXFA_FFDraw::CXFA_FFDraw(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc)
: CXFA_FFWidget(pPageView, pDataAcc) {}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.h
index 52ceb2cd0c3..c3c1c14445a 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffdraw.h
@@ -7,8 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FFDRAW_H_
#define XFA_FXFA_APP_XFA_FFDRAW_H_
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
class CXFA_FFDraw : public CXFA_FFWidget {
public:
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.cpp
index 177738d6365..f4a1cfb67bf 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.cpp
@@ -6,10 +6,10 @@
#include "xfa/fxfa/app/xfa_ffexclgroup.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
CXFA_FFExclGroup::CXFA_FFExclGroup(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.h
index 5a1fc945b74..6b59f05384c 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffexclgroup.h
@@ -7,8 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FFEXCLGROUP_H_
#define XFA_FXFA_APP_XFA_FFEXCLGROUP_H_
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
class CXFA_FFExclGroup : public CXFA_FFWidget {
public:
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.cpp
index 229ed437338..5b70caa924b 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.cpp
@@ -8,18 +8,18 @@
#include "xfa/fwl/basewidget/ifwl_edit.h"
#include "xfa/fwl/core/cfwl_message.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
+#include "xfa/fwl/core/fwl_widgetmgrimp.h"
#include "xfa/fwl/lightwidget/cfwl_edit.h"
#include "xfa/fwl/lightwidget/cfwl_picturebox.h"
#include "xfa/fxfa/app/xfa_fwltheme.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc)
: CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(NULL) {
@@ -81,7 +81,7 @@ void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS,
if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
return;
}
- if ((dwStatus & XFA_WIDGETSTATUS_Highlight) &&
+ if ((dwStatus & XFA_WidgetStatus_Highlight) &&
m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open) {
CXFA_FFDoc* pDoc = GetDoc();
CFX_Color crHighlight(pDoc->GetDocProvider()->GetHighlightColor(pDoc));
@@ -97,7 +97,7 @@ void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS,
}
}
void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) {
- if (m_dwStatus & XFA_WIDGETSTATUS_Focused) {
+ if (m_dwStatus & XFA_WidgetStatus_Focused) {
CFX_Color cr(0xFF000000);
pGS->SetStrokeColor(&cr);
FX_FLOAT DashPattern[2] = {1, 1};
@@ -334,10 +334,8 @@ void CXFA_FFField::SetFWLRect() {
return;
}
CFX_RectF rtUi = m_rtUI;
- if (rtUi.width < 1.0) {
- FXSYS_assert(rtUi.width < 1.0);
+ if (rtUi.width < 1.0)
rtUi.width = 1.0;
- }
if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
FX_FLOAT fFontSize = m_pDataAcc->GetFontSize();
if (rtUi.height < fFontSize) {
@@ -351,7 +349,7 @@ FX_BOOL CXFA_FFField::OnMouseEnter() {
return FALSE;
}
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_MouseEnter;
+ ms.m_dwCmd = FWL_MouseCommand::Enter;
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
ms.m_pSrcTarget = NULL;
TranslateFWLMessage(&ms);
@@ -362,7 +360,7 @@ FX_BOOL CXFA_FFField::OnMouseExit() {
return FALSE;
}
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave;
+ ms.m_dwCmd = FWL_MouseCommand::Leave;
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
TranslateFWLMessage(&ms);
return TRUE;
@@ -391,7 +389,7 @@ FX_BOOL CXFA_FFField::OnLButtonDown(uint32_t dwFlags,
}
SetButtonDown(TRUE);
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown;
+ ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -409,7 +407,7 @@ FX_BOOL CXFA_FFField::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
}
SetButtonDown(FALSE);
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonUp;
+ ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -425,7 +423,7 @@ FX_BOOL CXFA_FFField::OnLButtonDblClk(uint32_t dwFlags,
return FALSE;
}
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDblClk;
+ ms.m_dwCmd = FWL_MouseCommand::LeftButtonDblClk;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -439,7 +437,7 @@ FX_BOOL CXFA_FFField::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
return FALSE;
}
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_MouseMove;
+ ms.m_dwCmd = FWL_MouseCommand::Move;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -482,7 +480,7 @@ FX_BOOL CXFA_FFField::OnRButtonDown(uint32_t dwFlags,
}
SetButtonDown(TRUE);
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDown;
+ ms.m_dwCmd = FWL_MouseCommand::RightButtonDown;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -500,7 +498,7 @@ FX_BOOL CXFA_FFField::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
}
SetButtonDown(FALSE);
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonUp;
+ ms.m_dwCmd = FWL_MouseCommand::RightButtonUp;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -516,7 +514,7 @@ FX_BOOL CXFA_FFField::OnRButtonDblClk(uint32_t dwFlags,
return FALSE;
}
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDblClk;
+ ms.m_dwCmd = FWL_MouseCommand::RightButtonDblClk;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -535,7 +533,7 @@ FX_BOOL CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) {
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
ms.m_pSrcTarget = NULL;
TranslateFWLMessage(&ms);
- m_dwStatus |= XFA_WIDGETSTATUS_Focused;
+ m_dwStatus |= XFA_WidgetStatus_Focused;
AddInvalidateRect();
return TRUE;
}
@@ -547,7 +545,7 @@ FX_BOOL CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) {
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
ms.m_pSrcTarget = NULL;
TranslateFWLMessage(&ms);
- m_dwStatus &= ~XFA_WIDGETSTATUS_Focused;
+ m_dwStatus &= ~XFA_WidgetStatus_Focused;
AddInvalidateRect();
CXFA_FFWidget::OnKillFocus(pNewWidget);
return TRUE;
@@ -557,7 +555,7 @@ FX_BOOL CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) {
return FALSE;
}
CFWL_MsgKey ms;
- ms.m_dwCmd = FWL_MSGKEYCMD_KeyDown;
+ ms.m_dwCmd = FWL_KeyCommand::KeyDown;
ms.m_dwFlags = dwFlags;
ms.m_dwKeyCode = dwKeyCode;
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
@@ -570,7 +568,7 @@ FX_BOOL CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) {
return FALSE;
}
CFWL_MsgKey ms;
- ms.m_dwCmd = FWL_MSGKEYCMD_KeyUp;
+ ms.m_dwCmd = FWL_KeyCommand::KeyUp;
ms.m_dwFlags = dwFlags;
ms.m_dwKeyCode = dwKeyCode;
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
@@ -592,7 +590,7 @@ FX_BOOL CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) {
return FALSE;
}
CFWL_MsgKey ms;
- ms.m_dwCmd = FWL_MSGKEYCMD_Char;
+ ms.m_dwCmd = FWL_KeyCommand::Char;
ms.m_dwFlags = dwFlags;
ms.m_dwKeyCode = dwChar;
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
@@ -600,24 +598,20 @@ FX_BOOL CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) {
TranslateFWLMessage(&ms);
return TRUE;
}
-uint32_t CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
if (m_pNormalWidget) {
FX_FLOAT ffx = fx, ffy = fy;
FWLToClient(ffx, ffy);
- uint32_t dwWidgetHit = m_pNormalWidget->HitTest(ffx, ffy);
- if (dwWidgetHit != FWL_WGTHITTEST_Unknown) {
- return FWL_WGTHITTEST_Client;
- }
+ if (m_pNormalWidget->HitTest(ffx, ffy) != FWL_WidgetHit::Unknown)
+ return FWL_WidgetHit::Client;
}
CFX_RectF rtBox;
GetRectWithoutRotate(rtBox);
- if (!rtBox.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Unknown;
- }
- if (m_rtCaption.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Titlebar;
- }
- return FWL_WGTHITTEST_Border;
+ if (!rtBox.Contains(fx, fy))
+ return FWL_WidgetHit::Unknown;
+ if (m_rtCaption.Contains(fx, fy))
+ return FWL_WidgetHit::Titlebar;
+ return FWL_WidgetHit::Border;
}
FX_BOOL CXFA_FFField::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) {
return TRUE;
@@ -731,8 +725,7 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) {
wsMessage += wsWarning;
CFX_WideString wsTitle;
pAppProvider->LoadString(XFA_IDS_CalcOverride, wsTitle);
- pAppProvider->MsgBox(wsMessage.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Warning,
+ pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Warning,
XFA_MB_OK);
}
}
@@ -764,10 +757,9 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) {
wsMessage += wsWarning;
CFX_WideString wsTitle;
pAppProvider->LoadString(XFA_IDS_CalcOverride, wsTitle);
- if (pAppProvider->MsgBox(wsMessage.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Warning,
+ if (pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Warning,
XFA_MB_YesNo) == XFA_IDYes) {
- pAcc->GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE);
+ pAcc->GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, false);
return 1;
}
}
@@ -776,7 +768,7 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) {
case XFA_ATTRIBUTEENUM_Ignore:
return 0;
case XFA_ATTRIBUTEENUM_Disabled:
- pAcc->GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE);
+ pAcc->GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, false);
default:
return 1;
}
@@ -792,30 +784,28 @@ FX_BOOL CXFA_FFField::IsDataChanged() {
void CXFA_FFField::TranslateFWLMessage(CFWL_Message* pMessage) {
GetApp()->GetWidgetMgrDelegate()->OnProcessMessageToForm(pMessage);
}
-int32_t CXFA_FFField::OnProcessMessage(CFWL_Message* pMessage) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) {
- uint32_t dwEventID = pEvent->GetClassID();
- switch (dwEventID) {
- case FWL_EVTHASH_Mouse: {
+void CXFA_FFField::OnProcessMessage(CFWL_Message* pMessage) {}
+
+void CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) {
+ switch (pEvent->GetClassID()) {
+ case CFWL_EventType::Mouse: {
CFWL_EvtMouse* event = (CFWL_EvtMouse*)pEvent;
- if (event->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) {
+ if (event->m_dwCmd == FWL_MouseCommand::Enter) {
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_MouseEnter;
eParam.m_pTarget = m_pDataAcc;
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseEnter, &eParam);
- } else if (event->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave) {
+ } else if (event->m_dwCmd == FWL_MouseCommand::Leave) {
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_MouseExit;
eParam.m_pTarget = m_pDataAcc;
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseExit, &eParam);
- } else if (event->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) {
+ } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonDown) {
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_MouseDown;
eParam.m_pTarget = m_pDataAcc;
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_MouseDown, &eParam);
- } else if (event->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) {
+ } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonUp) {
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_MouseUp;
eParam.m_pTarget = m_pDataAcc;
@@ -823,18 +813,17 @@ FWL_ERR CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) {
}
break;
}
- case FWL_EVTHASH_Click: {
+ case CFWL_EventType::Click: {
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_Click;
eParam.m_pTarget = m_pDataAcc;
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam);
break;
}
- default: {}
+ default:
+ break;
}
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return FWL_ERR_Succeeded;
}
+
+void CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.h
index 44ee9bb4f20..fd6661dea23 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fffield.h
@@ -7,11 +7,10 @@
#ifndef XFA_FXFA_APP_XFA_FFFIELD_H_
#define XFA_FXFA_APP_XFA_FFFIELD_H_
-#include "xfa/fwl/core/fwl_sdadapterimp.h"
#include "xfa/fwl/core/ifwl_widgetdelegate.h"
#include "xfa/fwl/lightwidget/cfwl_widget.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#define XFA_MINUI_HEIGHT 4.32f
#define XFA_DEFAULTUI_HEIGHT 2.0f
@@ -53,7 +52,7 @@ class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate {
virtual FX_BOOL OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags);
virtual FX_BOOL OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags);
virtual FX_BOOL OnChar(uint32_t dwChar, uint32_t dwFlags);
- virtual uint32_t OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy);
protected:
@@ -86,10 +85,10 @@ class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate {
void SetEditScrollOffset();
public:
- virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ virtual void OnProcessMessage(CFWL_Message* pMessage);
+ virtual void OnProcessEvent(CFWL_Event* pEvent);
+ virtual void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
protected:
CFWL_Widget* m_pNormalWidget;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimage.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimage.cpp
index 5c286829787..7e4b0a9c34a 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimage.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimage.cpp
@@ -7,10 +7,10 @@
#include "xfa/fxfa/app/xfa_ffimage.h"
#include "xfa/fxfa/app/xfa_ffdraw.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
CXFA_FFImage::CXFA_FFImage(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc)
: CXFA_FFDraw(pPageView, pDataAcc) {}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.cpp
index d419fbd37d0..2250eef2e40 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.cpp
@@ -7,14 +7,14 @@
#include "xfa/fxfa/app/xfa_ffimageedit.h"
#include "xfa/fwl/core/cfwl_message.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
#include "xfa/fwl/lightwidget/cfwl_picturebox.h"
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
@@ -30,7 +30,7 @@ FX_BOOL CXFA_FFImageEdit::LoadWidget() {
m_pNormalWidget = (CFWL_Widget*)pPictureBox;
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
m_pOldDelegate = pPictureBox->SetDelegate(this);
CXFA_FFField::LoadWidget();
@@ -82,79 +82,28 @@ void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS,
iImageYDpi, iHorzAlign, iVertAlign);
}
}
+
FX_BOOL CXFA_FFImageEdit::OnLButtonDown(uint32_t dwFlags,
FX_FLOAT fx,
FX_FLOAT fy) {
- if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) {
+ if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open)
return FALSE;
- }
- if (!PtInActiveRect(fx, fy)) {
+
+ if (!PtInActiveRect(fx, fy))
return FALSE;
- }
+
SetButtonDown(TRUE);
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown;
+ ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
FWLToClient(ms.m_fx, ms.m_fy);
TranslateFWLMessage(&ms);
- IXFA_AppProvider* pAppProvider = GetAppProvider();
- if (!pAppProvider) {
- return TRUE;
- }
- CFX_WideString wsTitle;
- CFX_WideString wsFilter;
- pAppProvider->LoadString(XFA_IDS_ImageFilter, wsFilter);
- CFX_WideStringArray wsPathArray;
- pAppProvider->ShowFileDialog(wsTitle.AsWideStringC(),
- wsFilter.AsWideStringC(), wsPathArray);
- int32_t iSize = wsPathArray.GetSize();
- if (iSize < 1) {
- return TRUE;
- }
- CFX_WideString wsFilePath = wsPathArray[0];
- FX_STRSIZE nLen = wsFilePath.GetLength();
- FX_STRSIZE nIndex = nLen - 1;
- while (nIndex > 0 && wsFilePath[nIndex] != '.') {
- nIndex--;
- }
- if (nIndex <= 0) {
- return TRUE;
- }
- CFX_WideString wsContentType(L"image/");
- wsContentType += wsFilePath.Right(nLen - nIndex - 1);
- wsContentType.MakeLower();
- FXCODEC_IMAGE_TYPE eImageType = XFA_GetImageType(wsContentType);
- if (eImageType == FXCODEC_IMAGE_UNKNOWN) {
- return TRUE;
- }
- CFX_WideString wsImage;
- IFX_FileRead* pFileRead = FX_CreateFileRead(wsFilePath);
- if (pFileRead) {
- int32_t nDataSize = pFileRead->GetSize();
- if (nDataSize > 0) {
- CFX_ByteString bsBuf;
- FX_CHAR* pImageBuffer = bsBuf.GetBuffer(nDataSize);
- pFileRead->ReadBlock(pImageBuffer, 0, nDataSize);
- bsBuf.ReleaseBuffer();
- if (!bsBuf.IsEmpty()) {
- FX_CHAR* pData = XFA_Base64Encode(bsBuf, nDataSize);
- wsImage = CFX_WideString::FromLocal(pData);
- FX_Free(pData);
- }
- }
- m_pDataAcc->SetImageEditImage(NULL);
- pFileRead->Release();
- }
- m_pDataAcc->SetImageEdit(wsContentType.AsWideStringC(), CFX_WideStringC(),
- wsImage.AsWideStringC());
- m_pDataAcc->LoadImageEditImage();
- AddInvalidateRect();
- m_pDocView->SetChangeMark();
return TRUE;
}
+
void CXFA_FFImageEdit::SetFWLRect() {
if (!m_pNormalWidget) {
return;
@@ -174,14 +123,17 @@ FX_BOOL CXFA_FFImageEdit::UpdateFWLData() {
m_pDataAcc->LoadImageEditImage();
return TRUE;
}
-int32_t CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) {
- return m_pOldDelegate->OnProcessMessage(pMessage);
+
+void CXFA_FFImageEdit::OnProcessMessage(CFWL_Message* pMessage) {
+ m_pOldDelegate->OnProcessMessage(pMessage);
}
-FWL_ERR CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) {
+
+void CXFA_FFImageEdit::OnProcessEvent(CFWL_Event* pEvent) {
CXFA_FFField::OnProcessEvent(pEvent);
- return m_pOldDelegate->OnProcessEvent(pEvent);
+ m_pOldDelegate->OnProcessEvent(pEvent);
}
-FWL_ERR CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+
+void CXFA_FFImageEdit::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.h
index 1acc13c7fab..fb3e21e19f7 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffimageedit.h
@@ -21,10 +21,10 @@ class CXFA_FFImageEdit : public CXFA_FFField {
virtual FX_BOOL LoadWidget();
virtual void UnloadWidget();
virtual FX_BOOL OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
- virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ virtual void OnProcessMessage(CFWL_Message* pMessage);
+ virtual void OnProcessEvent(CFWL_Event* pEvent);
+ virtual void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
protected:
virtual void SetFWLRect();
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.cpp
index 7851819474d..4d7d4799f2f 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.cpp
@@ -23,12 +23,12 @@
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
-#include "xfa/include/fxfa/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
static void XFA_FFDeleteWidgetAcc(void* pData) {
delete static_cast<CXFA_WidgetAcc*>(pData);
@@ -39,224 +39,137 @@ static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = {
CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {}
CXFA_FFNotify::~CXFA_FFNotify() {}
+
void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender,
- XFA_PAGEEVENT eEvent,
- void* pParam) {
+ uint32_t dwEvent) {
CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout());
- if (!pDocView) {
- return;
- }
- pDocView->OnPageEvent(pSender, eEvent, (int32_t)(uintptr_t)pParam);
+ if (pDocView)
+ pDocView->OnPageEvent(pSender, dwEvent);
}
-void CXFA_FFNotify::OnNodeEvent(CXFA_Node* pSender,
- XFA_NODEEVENT eEvent,
- void* pParam,
- void* pParam2,
- void* pParam3,
- void* pParam4) {
- switch (eEvent) {
- case XFA_NODEEVENT_Ready:
- OnNodeReady(pSender);
- break;
- case XFA_NODEEVENT_ValueChanging:
- OnValueChanging(pSender, pParam, pParam2);
- break;
- case XFA_NODEEVENT_ValueChanged:
- OnValueChanged(pSender, pParam, pParam2, pParam3, pParam4);
- break;
- case XFA_NODEEVENT_ChildAdded:
- OnChildAdded(pSender, pParam, pParam2);
- break;
- case XFA_NODEEVENT_ChildRemoved:
- OnChildRemoved(pSender, pParam, pParam2);
- break;
+
+void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender,
+ const FX_WCHAR* pLabel,
+ const FX_WCHAR* pValue,
+ int32_t iIndex) {
+ CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender);
+ if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList)
+ return;
+
+ CXFA_FFWidget* pWidget = nullptr;
+ while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
+ if (pWidget->IsLoaded()) {
+ if (pWidgetAcc->IsListBox()) {
+ static_cast<CXFA_FFListBox*>(pWidget)->InsertItem(pLabel, iIndex);
+ } else {
+ static_cast<CXFA_FFComboBox*>(pWidget)->InsertItem(pLabel, iIndex);
+ }
+ }
}
}
-void CXFA_FFNotify::OnWidgetDataEvent(CXFA_WidgetData* pSender,
- uint32_t dwEvent,
- void* pParam,
- void* pAdditional,
- void* pAdditional2) {
+
+void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender,
+ int32_t iIndex) {
CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender);
- switch (dwEvent) {
- case XFA_WIDGETEVENT_ListItemAdded: {
- if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
- return;
- }
- FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify();
- CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
- if (!pWidget) {
- if (bStaticNotify) {
- pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
- pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam,
- pAdditional);
- }
- return;
- }
- while (pWidget) {
- if (pWidget->IsLoaded()) {
- if (pWidgetAcc->IsListBox()) {
- static_cast<CXFA_FFListBox*>(pWidget)
- ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam,
- (int32_t)(uintptr_t)pAdditional2);
- } else {
- static_cast<CXFA_FFComboBox*>(pWidget)
- ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam,
- (int32_t)(uintptr_t)pAdditional2);
- }
- }
- if (bStaticNotify) {
- pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
- pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam,
- pAdditional);
- }
- pWidget = pWidgetAcc->GetNextWidget(pWidget);
- }
- } break;
- case XFA_WIDGETEVENT_ListItemRemoved: {
- if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) {
- return;
- }
- FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify();
- CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL);
- if (!pWidget) {
- if (bStaticNotify) {
- pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
- pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam,
- pAdditional);
- }
- return;
- }
- while (pWidget) {
- if (pWidget->IsLoaded()) {
- if (pWidgetAcc->IsListBox()) {
- static_cast<CXFA_FFListBox*>(pWidget)
- ->DeleteItem((int32_t)(uintptr_t)pParam);
- } else {
- static_cast<CXFA_FFComboBox*>(pWidget)
- ->DeleteItem((int32_t)(uintptr_t)pParam);
- }
- }
- if (bStaticNotify) {
- pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent(
- pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam,
- pAdditional);
- }
- pWidget = pWidgetAcc->GetNextWidget(pWidget);
+ if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList)
+ return;
+
+ CXFA_FFWidget* pWidget = nullptr;
+ while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
+ if (pWidget->IsLoaded()) {
+ if (pWidgetAcc->IsListBox()) {
+ static_cast<CXFA_FFListBox*>(pWidget)->DeleteItem(iIndex);
+ } else {
+ static_cast<CXFA_FFComboBox*>(pWidget)->DeleteItem(iIndex);
}
- } break;
+ }
}
}
+
CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) {
CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout();
CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
XFA_ELEMENT eType = pNode->GetClassID();
- if (eType == XFA_ELEMENT_PageArea) {
+ if (eType == XFA_ELEMENT_PageArea)
return new CXFA_FFPageView(pDocView, pNode);
- }
- if (eType == XFA_ELEMENT_ContentArea) {
+
+ if (eType == XFA_ELEMENT_ContentArea)
return new CXFA_ContainerLayoutItem(pNode);
- }
+
CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData());
- if (!pAcc) {
+ if (!pAcc)
return new CXFA_ContentLayoutItem(pNode);
- }
- CXFA_FFPageView* pPageView = NULL;
- CXFA_FFWidget* pWidget = NULL;
+
+ CXFA_FFWidget* pWidget;
switch (pAcc->GetUIType()) {
case XFA_ELEMENT_Barcode:
- pWidget = new CXFA_FFBarcode(pPageView, pAcc);
+ pWidget = new CXFA_FFBarcode(nullptr, pAcc);
break;
case XFA_ELEMENT_Button:
- pWidget = new CXFA_FFPushButton(pPageView, pAcc);
+ pWidget = new CXFA_FFPushButton(nullptr, pAcc);
break;
case XFA_ELEMENT_CheckButton:
- pWidget = new CXFA_FFCheckButton(pPageView, pAcc);
+ pWidget = new CXFA_FFCheckButton(nullptr, pAcc);
break;
case XFA_ELEMENT_ChoiceList: {
if (pAcc->IsListBox()) {
- pWidget = new CXFA_FFListBox(pPageView, pAcc);
+ pWidget = new CXFA_FFListBox(nullptr, pAcc);
} else {
- pWidget = new CXFA_FFComboBox(pPageView, pAcc);
+ pWidget = new CXFA_FFComboBox(nullptr, pAcc);
}
} break;
case XFA_ELEMENT_DateTimeEdit:
- pWidget = new CXFA_FFDateTimeEdit(pPageView, pAcc);
+ pWidget = new CXFA_FFDateTimeEdit(nullptr, pAcc);
break;
case XFA_ELEMENT_ImageEdit:
- pWidget = new CXFA_FFImageEdit(pPageView, pAcc);
+ pWidget = new CXFA_FFImageEdit(nullptr, pAcc);
break;
case XFA_ELEMENT_NumericEdit:
- pWidget = new CXFA_FFNumericEdit(pPageView, pAcc);
+ pWidget = new CXFA_FFNumericEdit(nullptr, pAcc);
break;
case XFA_ELEMENT_PasswordEdit:
- pWidget = new CXFA_FFPasswordEdit(pPageView, pAcc);
+ pWidget = new CXFA_FFPasswordEdit(nullptr, pAcc);
break;
case XFA_ELEMENT_Signature:
- pWidget = new CXFA_FFSignature(pPageView, pAcc);
+ pWidget = new CXFA_FFSignature(nullptr, pAcc);
break;
case XFA_ELEMENT_TextEdit:
- pWidget = new CXFA_FFTextEdit(pPageView, pAcc);
+ pWidget = new CXFA_FFTextEdit(nullptr, pAcc);
break;
case XFA_ELEMENT_Arc:
- pWidget = new CXFA_FFArc(pPageView, pAcc);
+ pWidget = new CXFA_FFArc(nullptr, pAcc);
break;
case XFA_ELEMENT_Line:
- pWidget = new CXFA_FFLine(pPageView, pAcc);
+ pWidget = new CXFA_FFLine(nullptr, pAcc);
break;
case XFA_ELEMENT_Rectangle:
- pWidget = new CXFA_FFRectangle(pPageView, pAcc);
+ pWidget = new CXFA_FFRectangle(nullptr, pAcc);
break;
case XFA_ELEMENT_Text:
- pWidget = new CXFA_FFText(pPageView, pAcc);
+ pWidget = new CXFA_FFText(nullptr, pAcc);
break;
case XFA_ELEMENT_Image:
- pWidget = new CXFA_FFImage(pPageView, pAcc);
+ pWidget = new CXFA_FFImage(nullptr, pAcc);
break;
case XFA_ELEMENT_Draw:
- pWidget = new CXFA_FFDraw(pPageView, pAcc);
+ pWidget = new CXFA_FFDraw(nullptr, pAcc);
break;
case XFA_ELEMENT_Subform:
- pWidget = new CXFA_FFSubForm(pPageView, pAcc);
+ pWidget = new CXFA_FFSubForm(nullptr, pAcc);
break;
case XFA_ELEMENT_ExclGroup:
- pWidget = new CXFA_FFExclGroup(pPageView, pAcc);
+ pWidget = new CXFA_FFExclGroup(nullptr, pAcc);
break;
case XFA_ELEMENT_DefaultUi:
default:
- pWidget = NULL;
+ pWidget = nullptr;
break;
}
- if (!pWidget) {
- return NULL;
- }
- pWidget->SetDocView(pDocView);
+
+ if (pWidget)
+ pWidget->SetDocView(pDocView);
return pWidget;
}
-void CXFA_FFNotify::OnLayoutEvent(CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- XFA_LAYOUTEVENT eEvent,
- void* pParam,
- void* pParam2) {
- CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
- if (!pDocView || !XFA_GetWidgetFromLayoutItem(pSender)) {
- return;
- }
- switch (eEvent) {
- case XFA_LAYOUTEVENT_ItemAdded:
- OnLayoutItemAdd(pDocView, pLayout, pSender, pParam, pParam2);
- break;
- case XFA_LAYOUTEVENT_ItemRemoving:
- OnLayoutItemRemoving(pDocView, pLayout, pSender, pParam, pParam2);
- break;
- case XFA_LAYOUTEVENT_RectChanged:
- OnLayoutItemRectChanged(pDocView, pLayout, pSender, pParam, pParam2);
- break;
- case XFA_LAYOUTEVENT_StatusChanged:
- OnLayoutItemStatustChanged(pDocView, pLayout, pSender, pParam, pParam2);
- break;
- }
-}
+
void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem,
FX_FLOAT& fCalcWidth,
FX_FLOAT& fCalcHeight) {
@@ -400,6 +313,7 @@ void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) {
pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr;
pDocView->SetFocusWidgetAcc(pAcc);
}
+
void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) {
CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
if (!pDocView) {
@@ -413,134 +327,113 @@ void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) {
}
switch (iType) {
case XFA_ELEMENT_BindItems:
- pDocView->m_bindItems.Add(pNode);
+ pDocView->m_BindItems.Add(pNode);
break;
case XFA_ELEMENT_Validate: {
- pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, TRUE, FALSE);
+ pNode->SetFlag(XFA_NODEFLAG_NeedsInitApp, false);
} break;
default:
break;
}
}
-void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender,
- void* pParam,
- void* pParam2) {
+
+void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) {
+ if (eAttr != XFA_ATTRIBUTE_Presence)
+ return;
+
+ if (pSender->GetPacketID() & XFA_XDPPACKET_Datasets)
+ return;
+
+ if (!pSender->IsFormContainer())
+ return;
+
CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
- if (!pDocView) {
+ if (!pDocView)
return;
- }
- if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) {
+
+ if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End)
return;
- }
- uint32_t dwPacket = pSender->GetPacketID();
- if (dwPacket & XFA_XDPPACKET_Datasets) {
- } else if (pSender->IsFormContainer()) {
- XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam;
- if (eAttr == XFA_ATTRIBUTE_Presence) {
- CXFA_WidgetAcc* pWidgetAcc =
- static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData());
- if (!pWidgetAcc) {
- return;
- }
- CXFA_FFWidget* pWidget = NULL;
- while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
- if (pWidget->IsLoaded()) {
- pWidget->AddInvalidateRect();
- }
- }
- }
+
+ CXFA_WidgetAcc* pWidgetAcc =
+ static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData());
+ if (!pWidgetAcc)
+ return;
+
+ CXFA_FFWidget* pWidget = nullptr;
+ while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
+ if (pWidget->IsLoaded())
+ pWidget->AddInvalidateRect();
}
}
+
void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender,
- void* pParam,
- void* pParam2,
- void* pParam3,
- void* pParam4) {
+ XFA_ATTRIBUTE eAttr,
+ CXFA_Node* pParentNode,
+ CXFA_Node* pWidgetNode) {
CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
- if (!pDocView) {
+ if (!pDocView)
return;
- }
- uint32_t dwPacket = pSender->GetPacketID();
- XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam;
- if (dwPacket & XFA_XDPPACKET_Form) {
- CXFA_Node* pParentNode = static_cast<CXFA_Node*>(pParam3);
- CXFA_Node* pWidgetNode = static_cast<CXFA_Node*>(pParam4);
- XFA_ELEMENT ePType = pParentNode->GetClassID();
- FX_BOOL bIsContainerNode = pParentNode->IsContainerNode();
- CXFA_WidgetAcc* pWidgetAcc =
- static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData());
- if (!pWidgetAcc) {
- return;
- }
- FX_BOOL bUpdateProperty = FALSE;
- pDocView->SetChangeMark();
- switch (ePType) {
- case XFA_ELEMENT_Caption: {
- CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout();
- if (!pCapOut) {
- return;
- }
- pCapOut->Unload();
- } break;
- case XFA_ELEMENT_Ui:
- case XFA_ELEMENT_Para:
- bUpdateProperty = TRUE;
- break;
- case XFA_ELEMENT_Font:
- case XFA_ELEMENT_Margin:
- case XFA_ELEMENT_Value:
- case XFA_ELEMENT_Items:
- break;
- default:
- break;
- }
- if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) {
- bUpdateProperty = TRUE;
- FX_BOOL bNotify = pDocView->IsStaticNotify();
- if (bNotify) {
- pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_AccessChanged, NULL, pParam2,
- NULL);
- }
- }
- if (eAttr == XFA_ATTRIBUTE_Value) {
+
+ if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) {
+ if (eAttr == XFA_ATTRIBUTE_Value)
pDocView->AddCalculateNodeNotify(pSender);
- if (ePType == XFA_ELEMENT_Value || bIsContainerNode) {
- FX_BOOL bNotify = pDocView->IsStaticNotify();
- if (bIsContainerNode) {
- pWidgetAcc->UpdateUIDisplay();
- pDocView->AddCalculateWidgetAcc(pWidgetAcc);
- pDocView->AddValidateWidget(pWidgetAcc);
- } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent)
- ->GetClassID() == XFA_ELEMENT_ExclGroup) {
- pWidgetAcc->UpdateUIDisplay();
- }
- if (bNotify) {
- pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL,
- NULL, NULL);
- }
+ return;
+ }
+
+ XFA_ELEMENT ePType = pParentNode->GetClassID();
+ FX_BOOL bIsContainerNode = pParentNode->IsContainerNode();
+ CXFA_WidgetAcc* pWidgetAcc =
+ static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData());
+ if (!pWidgetAcc)
+ return;
+
+ bool bUpdateProperty = false;
+ pDocView->SetChangeMark();
+ switch (ePType) {
+ case XFA_ELEMENT_Caption: {
+ CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout();
+ if (!pCapOut)
return;
+
+ pCapOut->Unload();
+ } break;
+ case XFA_ELEMENT_Ui:
+ case XFA_ELEMENT_Para:
+ bUpdateProperty = true;
+ break;
+ default:
+ break;
+ }
+ if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access)
+ bUpdateProperty = true;
+
+ if (eAttr == XFA_ATTRIBUTE_Value) {
+ pDocView->AddCalculateNodeNotify(pSender);
+ if (ePType == XFA_ELEMENT_Value || bIsContainerNode) {
+ if (bIsContainerNode) {
+ pWidgetAcc->UpdateUIDisplay();
+ pDocView->AddCalculateWidgetAcc(pWidgetAcc);
+ pDocView->AddValidateWidget(pWidgetAcc);
+ } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent)->GetClassID() ==
+ XFA_ELEMENT_ExclGroup) {
+ pWidgetAcc->UpdateUIDisplay();
}
- }
- CXFA_FFWidget* pWidget = NULL;
- while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
- if (!pWidget->IsLoaded()) {
- continue;
- }
- if (bUpdateProperty) {
- pWidget->UpdateWidgetProperty();
- }
- pWidget->PerformLayout();
- pWidget->AddInvalidateRect();
- }
- } else {
- if (eAttr == XFA_ATTRIBUTE_Value) {
- pDocView->AddCalculateNodeNotify(pSender);
+ return;
}
}
+ CXFA_FFWidget* pWidget = nullptr;
+ while ((pWidget = pWidgetAcc->GetNextWidget(pWidget))) {
+ if (!pWidget->IsLoaded())
+ continue;
+
+ if (bUpdateProperty)
+ pWidget->UpdateWidgetProperty();
+ pWidget->PerformLayout();
+ pWidget->AddInvalidateRect();
+ }
}
-void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender,
- void* pParam,
- void* pParam2) {
+
+void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) {
if (!pSender->IsFormContainer()) {
return;
}
@@ -551,45 +444,47 @@ void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender,
FX_BOOL bLayoutReady =
!(pDocView->m_bInLayoutStatus) &&
(pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End);
- if (bLayoutReady) {
+ if (bLayoutReady)
m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);
- }
}
-void CXFA_FFNotify::OnChildRemoved(CXFA_Node* pSender,
- void* pParam,
- void* pParam2) {
- if (CXFA_FFDocView* pDocView = m_pDoc->GetDocView()) {
- FX_BOOL bLayoutReady =
- !(pDocView->m_bInLayoutStatus) &&
- (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End);
- if (bLayoutReady) {
- m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);
- }
- }
+
+void CXFA_FFNotify::OnChildRemoved() {
+ CXFA_FFDocView* pDocView = m_pDoc->GetDocView();
+ if (!pDocView)
+ return;
+
+ bool bLayoutReady =
+ !(pDocView->m_bInLayoutStatus) &&
+ (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End);
+ if (bLayoutReady)
+ m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc);
}
-void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView,
- CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- void* pParam,
- void* pParam2) {
- CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender);
- int32_t iPageIdx = (int32_t)(uintptr_t)pParam;
+
+void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout,
+ CXFA_LayoutItem* pSender,
+ int32_t iPageIdx,
+ uint32_t dwStatus) {
+ CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
+ if (!pDocView)
+ return;
+
+ CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender);
+ if (!pWidget)
+ return;
+
CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx);
- uint32_t dwStatus = (uint32_t)(uintptr_t)pParam2;
- uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable |
- XFA_WIDGETSTATUS_Printable;
+ uint32_t dwFilter = XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable |
+ XFA_WidgetStatus_Printable;
pWidget->ModifyStatus(dwStatus, dwFilter);
CXFA_FFPageView* pPrePageView = pWidget->GetPageView();
if (pPrePageView != pNewPageView ||
- (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) ==
- (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) {
+ (dwStatus & (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) ==
+ (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) {
pWidget->SetPageView(pNewPageView);
- m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
- XFA_WIDGETEVENT_PostAdded,
- pNewPageView, pPrePageView);
+ m_pDoc->GetDocProvider()->WidgetPostAdd(pWidget, pWidget->GetDataAcc());
}
if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End ||
- !(dwStatus & XFA_WIDGETSTATUS_Visible)) {
+ !(dwStatus & XFA_WidgetStatus_Visible)) {
return;
}
if (pWidget->IsLoaded()) {
@@ -602,47 +497,18 @@ void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView,
}
pWidget->AddInvalidateRect(nullptr);
}
-void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView,
- CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- void* pParam,
- void* pParam2) {
- CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender);
- pDocView->DeleteLayoutItem(pWidget);
- m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
- XFA_WIDGETEVENT_PreRemoved, nullptr,
- pWidget->GetPageView());
- pWidget->AddInvalidateRect(nullptr);
-}
-void CXFA_FFNotify::OnLayoutItemRectChanged(CXFA_FFDocView* pDocView,
- CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- void* pParam,
- void* pParam2) {}
-void CXFA_FFNotify::OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView,
- CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- void* pParam,
- void* pParam2) {
- CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender);
- if (!pWidget) {
+
+void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout,
+ CXFA_LayoutItem* pSender) {
+ CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout);
+ if (!pDocView)
return;
- }
- uint32_t dwStatus = (uint32_t)(uintptr_t)pParam;
- if (dwStatus == 0) {
- CXFA_LayoutItem* pPreItem = pSender->GetPrev();
- if (pPreItem) {
- CXFA_FFWidget* pPreWidget = static_cast<CXFA_FFWidget*>(pPreItem);
- if (pPreWidget) {
- dwStatus = pPreWidget->GetStatus();
- }
- }
- }
- uint32_t dwOldStatus = pWidget->GetStatus();
- uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable |
- XFA_WIDGETSTATUS_Printable;
- if ((dwOldStatus & dwFilter) == dwStatus) {
+
+ CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender);
+ if (!pWidget)
return;
- }
- pWidget->ModifyStatus(dwStatus, dwFilter);
+
+ pDocView->DeleteLayoutItem(pWidget);
+ m_pDoc->GetDocProvider()->WidgetPreRemove(pWidget, pWidget->GetDataAcc());
+ pWidget->AddInvalidateRect(nullptr);
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.h
index 6bf39ee6d2d..6dd400859b7 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffnotify.h
@@ -16,27 +16,31 @@ class CXFA_FFNotify {
CXFA_FFNotify(CXFA_FFDoc* pDoc);
~CXFA_FFNotify();
- void OnPageEvent(CXFA_ContainerLayoutItem* pSender,
- XFA_PAGEEVENT eEvent,
- void* pParam = NULL);
+ void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent);
+
+ void OnWidgetListItemAdded(CXFA_WidgetData* pSender,
+ const FX_WCHAR* pLabel,
+ const FX_WCHAR* pValue,
+ int32_t iIndex);
+ void OnWidgetListItemRemoved(CXFA_WidgetData* pSender, int32_t iIndex);
+
+ // Node events
+ void OnNodeReady(CXFA_Node* pNode);
+ void OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr);
+ void OnValueChanged(CXFA_Node* pSender,
+ XFA_ATTRIBUTE eAttr,
+ CXFA_Node* pParentNode,
+ CXFA_Node* pWidgetNode);
+ void OnChildAdded(CXFA_Node* pSender);
+ void OnChildRemoved();
- void OnNodeEvent(CXFA_Node* pSender,
- XFA_NODEEVENT eEvent,
- void* pParam = NULL,
- void* pParam2 = NULL,
- void* pParam3 = NULL,
- void* pParam4 = NULL);
- void OnWidgetDataEvent(CXFA_WidgetData* pSender,
- uint32_t dwEvent,
- void* pParam = NULL,
- void* pAdditional = NULL,
- void* pAdditional2 = NULL);
CXFA_LayoutItem* OnCreateLayoutItem(CXFA_Node* pNode);
- void OnLayoutEvent(CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- XFA_LAYOUTEVENT eEvent,
- void* pParam = NULL,
- void* pParam2 = NULL);
+ void OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout,
+ CXFA_LayoutItem* pSender,
+ int32_t iPageIdx,
+ uint32_t dwStatus);
+ void OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout,
+ CXFA_LayoutItem* pSender);
void StartFieldDrawLayout(CXFA_Node* pItem,
FX_FLOAT& fCalcWidth,
@@ -66,36 +70,7 @@ class CXFA_FFNotify {
void SetFocusWidgetNode(CXFA_Node* pNode);
protected:
- void OnNodeReady(CXFA_Node* pNode);
- void OnValueChanging(CXFA_Node* pSender, void* pParam, void* pParam2);
- void OnValueChanged(CXFA_Node* pSender,
- void* pParam,
- void* pParam2,
- void* pParam3,
- void* pParam4);
- void OnChildAdded(CXFA_Node* pSender, void* pParam, void* pParam2);
- void OnChildRemoved(CXFA_Node* pSender, void* pParam, void* pParam2);
- void OnLayoutItemAdd(CXFA_FFDocView* pDocView,
- CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- void* pParam,
- void* pParam2);
- void OnLayoutItemRemoving(CXFA_FFDocView* pDocView,
- CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- void* pParam,
- void* pParam2);
- void OnLayoutItemRectChanged(CXFA_FFDocView* pDocView,
- CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- void* pParam,
- void* pParam2);
- void OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView,
- CXFA_LayoutProcessor* pLayout,
- CXFA_LayoutItem* pSender,
- void* pParam,
- void* pParam2);
- CXFA_FFDoc* m_pDoc;
+ CXFA_FFDoc* const m_pDoc;
};
#endif // XFA_FXFA_APP_XFA_FFNOTIFY_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpageview.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpageview.cpp
index 21eb8554da6..16461eb07c0 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpageview.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpageview.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
#include "xfa/fde/fde_render.h"
#include "xfa/fxfa/app/xfa_ffcheckbutton.h"
@@ -14,77 +14,113 @@
#include "xfa/fxfa/app/xfa_ffpushbutton.h"
#include "xfa/fxfa/app/xfa_fftextedit.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
+
+namespace {
+
+void GetPageMatrix(CFX_Matrix& pageMatrix,
+ const CFX_RectF& docPageRect,
+ const CFX_Rect& devicePageRect,
+ int32_t iRotate,
+ uint32_t dwCoordinatesType) {
+ ASSERT(iRotate >= 0 && iRotate <= 3);
+ FX_BOOL bFlipX = (dwCoordinatesType & 0x01) != 0;
+ FX_BOOL bFlipY = (dwCoordinatesType & 0x02) != 0;
+ CFX_Matrix m;
+ m.Set((bFlipX ? -1.0f : 1.0f), 0, 0, (bFlipY ? -1.0f : 1.0f), 0, 0);
+ if (iRotate == 0 || iRotate == 2) {
+ m.a *= (FX_FLOAT)devicePageRect.width / docPageRect.width;
+ m.d *= (FX_FLOAT)devicePageRect.height / docPageRect.height;
+ } else {
+ m.a *= (FX_FLOAT)devicePageRect.height / docPageRect.width;
+ m.d *= (FX_FLOAT)devicePageRect.width / docPageRect.height;
+ }
+ m.Rotate(iRotate * 1.57079632675f);
+ switch (iRotate) {
+ case 0:
+ m.e = bFlipX ? (FX_FLOAT)devicePageRect.right()
+ : (FX_FLOAT)devicePageRect.left;
+ m.f = bFlipY ? (FX_FLOAT)devicePageRect.bottom()
+ : (FX_FLOAT)devicePageRect.top;
+ break;
+ case 1:
+ m.e = bFlipY ? (FX_FLOAT)devicePageRect.left
+ : (FX_FLOAT)devicePageRect.right();
+ m.f = bFlipX ? (FX_FLOAT)devicePageRect.bottom()
+ : (FX_FLOAT)devicePageRect.top;
+ break;
+ case 2:
+ m.e = bFlipX ? (FX_FLOAT)devicePageRect.left
+ : (FX_FLOAT)devicePageRect.right();
+ m.f = bFlipY ? (FX_FLOAT)devicePageRect.top
+ : (FX_FLOAT)devicePageRect.bottom();
+ break;
+ case 3:
+ m.e = bFlipY ? (FX_FLOAT)devicePageRect.right()
+ : (FX_FLOAT)devicePageRect.left;
+ m.f = bFlipX ? (FX_FLOAT)devicePageRect.top
+ : (FX_FLOAT)devicePageRect.bottom();
+ break;
+ default:
+ break;
+ }
+ pageMatrix = m;
+}
+
+bool PageWidgetFilter(CXFA_FFWidget* pWidget,
+ uint32_t dwFilter,
+ FX_BOOL bTraversal,
+ FX_BOOL bIgnorerelevant) {
+ CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
+
+ if (!!(dwFilter & XFA_WidgetStatus_Focused) &&
+ pWidgetAcc->GetClassID() != XFA_ELEMENT_Field) {
+ return false;
+ }
+
+ uint32_t dwStatus = pWidget->GetStatus();
+ if (bTraversal && (dwStatus & XFA_WidgetStatus_Disabled))
+ return false;
+ if (bIgnorerelevant)
+ return !!(dwStatus & XFA_WidgetStatus_Visible);
+
+ dwFilter &= (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable |
+ XFA_WidgetStatus_Printable);
+ return (dwFilter & dwStatus) == dwFilter;
+}
+
+} // namespace
CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea)
- : CXFA_ContainerLayoutItem(pPageArea),
- m_pDocView(pDocView),
- m_bLoaded(FALSE) {}
+ : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView) {}
+
CXFA_FFPageView::~CXFA_FFPageView() {}
-CXFA_FFDocView* CXFA_FFPageView::GetDocView() {
+
+CXFA_FFDocView* CXFA_FFPageView::GetDocView() const {
return m_pDocView;
}
-int32_t CXFA_FFPageView::GetPageViewIndex() {
+
+int32_t CXFA_FFPageView::GetPageViewIndex() const {
return GetPageIndex();
}
-void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) {
+
+void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) const {
CFX_SizeF sz;
GetPageSize(sz);
rtPage.Set(0, 0, sz);
}
void CXFA_FFPageView::GetDisplayMatrix(CFX_Matrix& mt,
const CFX_Rect& rtDisp,
- int32_t iRotate) {
+ int32_t iRotate) const {
CFX_SizeF sz;
GetPageSize(sz);
CFX_RectF fdePage;
fdePage.Set(0, 0, sz.x, sz.y);
- FDE_GetPageMatrix(mt, fdePage, rtDisp, iRotate, 0);
-}
-int32_t CXFA_FFPageView::LoadPageView(IFX_Pause* pPause) {
- if (m_bLoaded) {
- return 100;
- }
- m_bLoaded = TRUE;
- return 100;
-}
-void CXFA_FFPageView::UnloadPageView() {
- if (!m_bLoaded) {
- return;
- }
-}
-FX_BOOL CXFA_FFPageView::IsPageViewLoaded() {
- return m_bLoaded;
-}
-CXFA_FFWidget* CXFA_FFPageView::GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) {
- if (!m_bLoaded) {
- return nullptr;
- }
- IXFA_WidgetIterator* pIterator = CreateWidgetIterator();
- CXFA_FFWidget* pWidget = nullptr;
- while ((pWidget = static_cast<CXFA_FFWidget*>(pIterator->MoveToNext()))) {
- if (!(pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) {
- continue;
- }
- CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc();
- int32_t type = pAcc->GetClassID();
- if (type != XFA_ELEMENT_Field && type != XFA_ELEMENT_Draw) {
- continue;
- }
- FX_FLOAT fWidgetx = fx;
- FX_FLOAT fWidgety = fy;
- pWidget->Rotate2Normal(fWidgetx, fWidgety);
- uint32_t dwFlag = pWidget->OnHitTest(fWidgetx, fWidgety);
- if ((FWL_WGTHITTEST_Client == dwFlag ||
- FWL_WGTHITTEST_HyperLink == dwFlag)) {
- break;
- }
- }
- pIterator->Release();
- return pWidget;
+ GetPageMatrix(mt, fdePage, rtDisp, iRotate, 0);
}
+
IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator(
uint32_t dwTraverseWay,
uint32_t dwWidgetFilter) {
@@ -94,29 +130,9 @@ IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator(
case XFA_TRAVERSEWAY_Form:
return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter);
}
- return NULL;
-}
-static FX_BOOL XFA_PageWidgetFilter(CXFA_FFWidget* pWidget,
- uint32_t dwFilter,
- FX_BOOL bTraversal,
- FX_BOOL bIgnorerelevant) {
- CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
- uint32_t dwType = dwFilter & XFA_WIDGETFILTER_AllType;
- if ((dwType == XFA_WIDGETFILTER_Field) &&
- (pWidgetAcc->GetClassID() != XFA_ELEMENT_Field)) {
- return FALSE;
- }
- uint32_t dwStatus = pWidget->GetStatus();
- if (bTraversal && (dwStatus & XFA_WIDGETSTATUS_Disabled)) {
- return FALSE;
- }
- if (bIgnorerelevant) {
- return (dwStatus & XFA_WIDGETFILTER_Visible) != 0;
- }
- dwFilter &= (XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_Viewable |
- XFA_WIDGETFILTER_Printable);
- return (dwFilter & dwStatus) == dwFilter;
+ return nullptr;
}
+
CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView,
uint32_t dwFilter) {
m_pPageView = pPageView;
@@ -172,17 +188,18 @@ FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) {
CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget(
CXFA_LayoutItem* pLayoutItem) {
if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) {
- if (!XFA_PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) {
+ if (!PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) {
return NULL;
}
if (!pWidget->IsLoaded() &&
- (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible) != 0) {
+ (pWidget->GetStatus() & XFA_WidgetStatus_Visible) != 0) {
pWidget->LoadWidget();
}
return pWidget;
}
return NULL;
}
+
CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator(
CXFA_FFPageView* pPageView,
uint32_t dwFilter)
@@ -192,10 +209,9 @@ CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator(
->GetCurVersionMode() < XFA_VERSION_205;
Reset();
}
+
CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {}
-void CXFA_FFTabOrderPageWidgetIterator::Release() {
- delete this;
-}
+
void CXFA_FFTabOrderPageWidgetIterator::Reset() {
CreateTabOrderWidgetArray();
m_iCurWidget = -1;
@@ -203,8 +219,8 @@ void CXFA_FFTabOrderPageWidgetIterator::Reset() {
CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() {
if (m_TabOrderWidgetArray.GetSize() > 0) {
for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) {
- if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
- m_bIgnorerelevant)) {
+ if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
+ m_bIgnorerelevant)) {
m_iCurWidget = i;
return m_TabOrderWidgetArray[m_iCurWidget];
}
@@ -215,8 +231,8 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() {
CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() {
if (m_TabOrderWidgetArray.GetSize() > 0) {
for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) {
- if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
- m_bIgnorerelevant)) {
+ if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
+ m_bIgnorerelevant)) {
m_iCurWidget = i;
return m_TabOrderWidgetArray[m_iCurWidget];
}
@@ -226,8 +242,8 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() {
}
CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() {
for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) {
- if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
- m_bIgnorerelevant)) {
+ if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
+ m_bIgnorerelevant)) {
m_iCurWidget = i;
return m_TabOrderWidgetArray[m_iCurWidget];
}
@@ -237,8 +253,8 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() {
}
CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() {
for (int32_t i = m_iCurWidget - 1; i >= 0; i--) {
- if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
- m_bIgnorerelevant)) {
+ if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
+ m_bIgnorerelevant)) {
m_iCurWidget = i;
return m_TabOrderWidgetArray[m_iCurWidget];
}
@@ -270,14 +286,14 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget(
if (pTraverse) {
CFX_WideString wsTraverseWidgetName;
if (pTraverse->GetAttribute(XFA_ATTRIBUTE_Ref, wsTraverseWidgetName)) {
- return FindWidgetByName(wsTraverseWidgetName.AsWideStringC(), pWidget);
+ return FindWidgetByName(wsTraverseWidgetName, pWidget);
}
}
}
return NULL;
}
CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::FindWidgetByName(
- const CFX_WideStringC& wsWidgetName,
+ const CFX_WideString& wsWidgetName,
CXFA_FFWidget* pRefWidget) {
return pRefWidget->GetDocView()->GetWidgetByName(wsWidgetName, pRefWidget);
}
@@ -337,7 +353,7 @@ void CXFA_FFTabOrderPageWidgetIterator::OrderContainer(
FX_BOOL& bCurrentItem,
FX_BOOL& bContentArea,
FX_BOOL bMarsterPage) {
- CFX_PtrArray tabParams;
+ CFX_ArrayTemplate<CXFA_TabParam*> tabParams;
CXFA_LayoutItem* pSearchItem = sIterator->MoveToNext();
while (pSearchItem) {
if (!pSearchItem->IsContentLayoutItem()) {
@@ -379,7 +395,7 @@ void CXFA_FFTabOrderPageWidgetIterator::OrderContainer(
XFA_TabOrderWidgetComparator);
}
for (int32_t iStart = 0; iStart < iChildren; iStart++) {
- CXFA_TabParam* pParam = (CXFA_TabParam*)tabParams[iStart];
+ CXFA_TabParam* pParam = tabParams[iStart];
pContainer->m_Children.Add(pParam->m_pWidget);
if (pParam->m_Children.GetSize() > 0) {
pContainer->m_Children.Append(pParam->m_Children);
@@ -413,7 +429,7 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget(
CXFA_LayoutItem* pLayoutItem) {
if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) {
if (!pWidget->IsLoaded() &&
- (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) {
+ (pWidget->GetStatus() & XFA_WidgetStatus_Visible)) {
pWidget->LoadWidget();
}
return pWidget;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpath.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpath.cpp
index 6f30612942e..2aad39f99ca 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpath.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpath.cpp
@@ -7,12 +7,12 @@
#include "xfa/fxfa/app/xfa_ffpath.h"
#include "xfa/fxfa/app/xfa_ffdraw.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
CXFA_FFLine::CXFA_FFLine(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc)
: CXFA_FFDraw(pPageView, pDataAcc) {}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.cpp
index 4c54868f55a..96b6d77096d 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.cpp
@@ -6,17 +6,17 @@
#include "xfa/fxfa/app/xfa_ffpushbutton.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
+#include "xfa/fwl/core/fwl_widgetmgrimp.h"
#include "xfa/fwl/lightwidget/cfwl_pushbutton.h"
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
CXFA_FFPushButton::CXFA_FFPushButton(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
@@ -52,7 +52,7 @@ void CXFA_FFPushButton::RenderWidget(CFX_Graphics* pGS,
pGS, &mt);
}
FX_BOOL CXFA_FFPushButton::LoadWidget() {
- FXSYS_assert(m_pNormalWidget == NULL);
+ ASSERT(!m_pNormalWidget);
CFWL_PushButton* pPushButton = CFWL_PushButton::Create();
if (pPushButton) {
pPushButton->Initialize();
@@ -61,7 +61,7 @@ FX_BOOL CXFA_FFPushButton::LoadWidget() {
m_pNormalWidget = (CFWL_Widget*)pPushButton;
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
m_pNormalWidget->LockUpdate();
UpdateWidgetProperty();
@@ -86,25 +86,19 @@ void CXFA_FFPushButton::UpdateWidgetProperty() {
}
m_pNormalWidget->ModifyStylesEx(dwStyleEx, 0xFFFFFFFF);
}
+
void CXFA_FFPushButton::UnloadWidget() {
- if (m_pRolloverTextLayout) {
- delete m_pRolloverTextLayout;
- m_pRolloverTextLayout = NULL;
- }
- if (m_pDownTextLayout) {
- delete m_pDownTextLayout;
- m_pDownTextLayout = NULL;
- }
- if (m_pDownProvider) {
- delete m_pDownProvider;
- m_pDownProvider = NULL;
- }
- if (m_pRollProvider) {
- delete m_pRollProvider;
- m_pRollProvider = NULL;
- }
+ delete m_pRolloverTextLayout;
+ m_pRolloverTextLayout = nullptr;
+ delete m_pDownTextLayout;
+ m_pDownTextLayout = nullptr;
+ delete m_pDownProvider;
+ m_pDownProvider = nullptr;
+ delete m_pRollProvider;
+ m_pRollProvider = nullptr;
CXFA_FFField::UnloadWidget();
}
+
FX_BOOL CXFA_FFPushButton::PerformLayout() {
CXFA_FFWidget::PerformLayout();
CFX_RectF rtWidget;
@@ -207,15 +201,18 @@ void CXFA_FFPushButton::RenderHighlightCaption(CFX_Graphics* pGS,
}
}
}
-int32_t CXFA_FFPushButton::OnProcessMessage(CFWL_Message* pMessage) {
- return m_pOldDelegate->OnProcessMessage(pMessage);
+
+void CXFA_FFPushButton::OnProcessMessage(CFWL_Message* pMessage) {
+ m_pOldDelegate->OnProcessMessage(pMessage);
}
-FWL_ERR CXFA_FFPushButton::OnProcessEvent(CFWL_Event* pEvent) {
+
+void CXFA_FFPushButton::OnProcessEvent(CFWL_Event* pEvent) {
m_pOldDelegate->OnProcessEvent(pEvent);
- return CXFA_FFField::OnProcessEvent(pEvent);
+ CXFA_FFField::OnProcessEvent(pEvent);
}
-FWL_ERR CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+
+void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) {
if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) &&
(m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) {
@@ -246,7 +243,5 @@ FWL_ERR CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics,
path.AddRectangle(0, 0, rect.width, rect.height);
pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix);
}
- } else if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HilitePush) {
}
- return FWL_ERR_Succeeded;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.h
index a37670bb300..96cf785eb0f 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffpushbutton.h
@@ -28,10 +28,10 @@ class CXFA_FFPushButton : public CXFA_FFField {
virtual void UnloadWidget();
virtual FX_BOOL PerformLayout();
virtual void UpdateWidgetProperty();
- virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ virtual void OnProcessMessage(CFWL_Message* pMessage);
+ virtual void OnProcessEvent(CFWL_Event* pEvent);
+ virtual void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL);
protected:
void LoadHighlightCaption();
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.cpp
index e5dba349851..4008abf8088 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.cpp
@@ -7,9 +7,9 @@
#include "xfa/fxfa/app/xfa_ffsignature.h"
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
CXFA_FFSignature::CXFA_FFSignature(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
@@ -37,7 +37,7 @@ void CXFA_FFSignature::RenderWidget(CFX_Graphics* pGS,
DrawHighlight(pGS, &mtRotate, dwStatus, FALSE);
CFX_RectF rtWidget = m_rtUI;
IXFA_DocProvider* pDocProvider = m_pDataAcc->GetDoc()->GetDocProvider();
- FXSYS_assert(pDocProvider);
+ ASSERT(pDocProvider);
pDocProvider->RenderCustomWidget(this, pGS, &mtRotate, rtWidget);
}
FX_BOOL CXFA_FFSignature::OnMouseEnter() {
@@ -96,24 +96,20 @@ FX_BOOL CXFA_FFSignature::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) {
FX_BOOL CXFA_FFSignature::OnChar(uint32_t dwChar, uint32_t dwFlags) {
return FALSE;
}
-uint32_t CXFA_FFSignature::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CXFA_FFSignature::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
if (m_pNormalWidget) {
FX_FLOAT ffx = fx, ffy = fy;
FWLToClient(ffx, ffy);
- uint32_t dwWidgetHit = m_pNormalWidget->HitTest(ffx, ffy);
- if (dwWidgetHit != FWL_WGTHITTEST_Unknown) {
- return FWL_WGTHITTEST_Client;
- }
+ if (m_pNormalWidget->HitTest(ffx, ffy) != FWL_WidgetHit::Unknown)
+ return FWL_WidgetHit::Client;
}
CFX_RectF rtBox;
GetRectWithoutRotate(rtBox);
- if (!rtBox.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Unknown;
- }
- if (m_rtCaption.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Titlebar;
- }
- return FWL_WGTHITTEST_Client;
+ if (!rtBox.Contains(fx, fy))
+ return FWL_WidgetHit::Unknown;
+ if (m_rtCaption.Contains(fx, fy))
+ return FWL_WidgetHit::Titlebar;
+ return FWL_WidgetHit::Client;
}
FX_BOOL CXFA_FFSignature::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) {
return FALSE;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.h
index 1b5f33ccc49..01ece76c4fd 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsignature.h
@@ -36,7 +36,7 @@ class CXFA_FFSignature final : public CXFA_FFField {
virtual FX_BOOL OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags);
virtual FX_BOOL OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags);
virtual FX_BOOL OnChar(uint32_t dwChar, uint32_t dwFlags);
- virtual uint32_t OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy);
};
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.cpp
index 0ba4858b722..a2add4f6a48 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.cpp
@@ -6,10 +6,10 @@
#include "xfa/fxfa/app/xfa_ffsubform.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
CXFA_FFSubForm::CXFA_FFSubForm(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.h
index 5a705a6a006..fd3da986705 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffsubform.h
@@ -7,8 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FFSUBFORM_H_
#define XFA_FXFA_APP_XFA_FFSUBFORM_H_
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
class CXFA_FFSubForm : public CXFA_FFWidget {
public:
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.cpp
index d4bce5419f1..1000b91c089 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.cpp
@@ -9,11 +9,11 @@
#include "xfa/fwl/core/fwl_widgetdef.h"
#include "xfa/fxfa/app/xfa_ffdraw.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
CXFA_FFText::CXFA_FFText(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc)
: CXFA_FFDraw(pPageView, pDataAcc) {}
@@ -136,19 +136,17 @@ FX_BOOL CXFA_FFText::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
return FALSE;
}
CXFA_FFDoc* pDoc = GetDoc();
- pDoc->GetDocProvider()->GotoURL(pDoc, CFX_WideStringC(wsURLContent), FALSE);
+ pDoc->GetDocProvider()->GotoURL(pDoc, wsURLContent, FALSE);
return TRUE;
}
-uint32_t CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
CFX_RectF rtBox;
GetRectWithoutRotate(rtBox);
- if (!rtBox.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Unknown;
- }
- if (!GetLinkURLAtPoint(fx, fy)) {
- return FWL_WGTHITTEST_Unknown;
- }
- return FWL_WGTHITTEST_HyperLink;
+ if (!rtBox.Contains(fx, fy))
+ return FWL_WidgetHit::Unknown;
+ if (!GetLinkURLAtPoint(fx, fy))
+ return FWL_WidgetHit::Unknown;
+ return FWL_WidgetHit::HyperLink;
}
const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.h
index 847805b5275..f505ddb30e4 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftext.h
@@ -16,7 +16,7 @@ class CXFA_FFText : public CXFA_FFDraw {
virtual FX_BOOL OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
virtual FX_BOOL OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
virtual FX_BOOL OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
- virtual uint32_t OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
virtual void RenderWidget(CFX_Graphics* pGS,
CFX_Matrix* pMatrix = NULL,
uint32_t dwStatus = 0,
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.cpp
index de93c031b5c..89c9d356bd1 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.cpp
@@ -11,18 +11,18 @@
#include "xfa/fwl/basewidget/ifwl_datetimepicker.h"
#include "xfa/fwl/basewidget/ifwl_edit.h"
#include "xfa/fwl/core/cfwl_message.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/lightwidget/cfwl_datetimepicker.h"
#include "xfa/fwl/lightwidget/cfwl_edit.h"
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxfa/parser/xfa_localevalue.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
@@ -30,7 +30,7 @@ CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView,
CXFA_FFTextEdit::~CXFA_FFTextEdit() {
if (m_pNormalWidget) {
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->UnregisterEventTarget(pWidget);
}
}
@@ -40,7 +40,7 @@ FX_BOOL CXFA_FFTextEdit::LoadWidget() {
m_pNormalWidget = pFWLEdit;
IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
@@ -101,13 +101,13 @@ FX_BOOL CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags,
return FALSE;
}
if (!IsFocused()) {
- m_dwStatus |= XFA_WIDGETSTATUS_Focused;
+ m_dwStatus |= XFA_WidgetStatus_Focused;
UpdateFWLData();
AddInvalidateRect();
}
SetButtonDown(TRUE);
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_LButtonDown;
+ ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -126,13 +126,13 @@ FX_BOOL CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags,
return FALSE;
}
if (!IsFocused()) {
- m_dwStatus |= XFA_WIDGETSTATUS_Focused;
+ m_dwStatus |= XFA_WidgetStatus_Focused;
UpdateFWLData();
AddInvalidateRect();
}
SetButtonDown(TRUE);
CFWL_MsgMouse ms;
- ms.m_dwCmd = FWL_MSGMOUSECMD_RButtonDown;
+ ms.m_dwCmd = FWL_MouseCommand::RightButtonDown;
ms.m_dwFlags = dwFlags;
ms.m_fx = fx;
ms.m_fy = fy;
@@ -150,9 +150,9 @@ FX_BOOL CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags,
return TRUE;
}
FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) {
- m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged;
+ m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged;
if (!IsFocused()) {
- m_dwStatus |= XFA_WIDGETSTATUS_Focused;
+ m_dwStatus |= XFA_WidgetStatus_Focused;
UpdateFWLData();
AddInvalidateRect();
}
@@ -168,13 +168,13 @@ FX_BOOL CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) {
ms.m_pDstTarget = m_pNormalWidget->m_pIface;
ms.m_pSrcTarget = NULL;
TranslateFWLMessage(&ms);
- m_dwStatus &= ~XFA_WIDGETSTATUS_Focused;
+ m_dwStatus &= ~XFA_WidgetStatus_Focused;
SetEditScrollOffset();
ProcessCommittedData();
UpdateFWLData();
AddInvalidateRect();
CXFA_FFWidget::OnKillFocus(pNewWidget);
- m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged;
+ m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged;
return TRUE;
}
FX_BOOL CXFA_FFTextEdit::CommitData() {
@@ -194,20 +194,18 @@ void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) {
if (pAppProvider) {
CFX_WideString wsTitle;
pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
- CFX_WideString wsMessage;
CFX_WideString wsError;
pAppProvider->LoadString(XFA_IDS_ValidateNumberError, wsError);
CFX_WideString wsSomField;
pAcc->GetNode()->GetSOMExpression(wsSomField);
- wsMessage.Format(wsError, (const FX_WCHAR*)wsText,
- (const FX_WCHAR*)wsSomField);
- pAppProvider->MsgBox(wsMessage.AsWideStringC(), wsTitle.AsWideStringC(),
- XFA_MBICON_Error, XFA_MB_OK);
+ CFX_WideString wsMessage;
+ wsMessage.Format(wsError.c_str(), wsText.c_str(), wsSomField.c_str());
+ pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
}
}
}
FX_BOOL CXFA_FFTextEdit::IsDataChanged() {
- return (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) != 0;
+ return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0;
}
uint32_t CXFA_FFTextEdit::GetAlignment() {
uint32_t dwExtendedStyle = 0;
@@ -333,7 +331,8 @@ FX_BOOL CXFA_FFTextEdit::Delete() {
return ((CFWL_Edit*)m_pNormalWidget)->Delete();
}
FX_BOOL CXFA_FFTextEdit::DeSelect() {
- return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections();
+ return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections() ==
+ FWL_Error::Succeeded;
}
FX_BOOL CXFA_FFTextEdit::GetSuggestWords(
CFX_PointF pointf,
@@ -357,7 +356,7 @@ FX_BOOL CXFA_FFTextEdit::ReplaceSpellCheckWord(
void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget,
const CFX_WideString& wsChanged,
const CFX_WideString& wsPrevText) {
- m_dwStatus |= XFA_WIDGETSTATUS_TextEditValueChanged;
+ m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged;
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_Change;
eParam.m_wsChange = wsChanged;
@@ -401,43 +400,47 @@ FX_BOOL CXFA_FFTextEdit::GetSuggestWords(
}
return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest);
}
-int32_t CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) {
- return m_pOldDelegate->OnProcessMessage(pMessage);
+
+void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) {
+ m_pOldDelegate->OnProcessMessage(pMessage);
}
-FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) {
+
+void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) {
CXFA_FFField::OnProcessEvent(pEvent);
- uint32_t dwEventID = pEvent->GetClassID();
- switch (dwEventID) {
- case FWL_EVTHASH_EDT_TextChanged: {
+ switch (pEvent->GetClassID()) {
+ case CFWL_EventType::TextChanged: {
CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent;
CFX_WideString wsChange;
OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText);
break;
}
- case FWL_EVTHASH_EDT_TextFull: {
+ case CFWL_EventType::TextFull: {
OnTextFull(m_pNormalWidget->GetWidget());
break;
}
- case FWL_EVTHASH_EDT_CheckWord: {
+ case CFWL_EventType::CheckWord: {
CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged");
CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent;
- event->bCheckWord = CheckWord(event->bsWord.AsByteStringC());
+ event->bCheckWord = CheckWord(event->bsWord.AsStringC());
break;
}
- case FWL_EVTHASH_EDT_GetSuggestWords: {
+ case CFWL_EventType::GetSuggestedWords: {
CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent;
- event->bSuggestWords = GetSuggestWords(event->bsWord.AsByteStringC(),
+ event->bSuggestWords = GetSuggestWords(event->bsWord.AsStringC(),
event->bsArraySuggestWords);
break;
}
- default: {}
+ default:
+ break;
}
- return m_pOldDelegate->OnProcessEvent(pEvent);
+ m_pOldDelegate->OnProcessEvent(pEvent);
}
-FWL_ERR CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
+
+void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
}
+
CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
: CXFA_FFTextEdit(pPageView, pDataAcc) {}
@@ -448,7 +451,7 @@ FX_BOOL CXFA_FFNumericEdit::LoadWidget() {
m_pNormalWidget = (CFWL_Widget*)pWidget;
IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pIWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
@@ -484,17 +487,17 @@ void CXFA_FFNumericEdit::UpdateWidgetProperty() {
}
m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF);
}
-FWL_ERR CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) {
- uint32_t dwEventID = pEvent->GetClassID();
- if (dwEventID == FWL_EVTHASH_EDT_Validate) {
+
+void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) {
+ if (pEvent->GetClassID() == CFWL_EventType::Validate) {
CFWL_EvtEdtValidate* event = (CFWL_EvtEdtValidate*)pEvent;
CFX_WideString wsChange = event->wsInsert;
event->bValidate = OnValidate(m_pNormalWidget->GetWidget(), wsChange);
- return event->bValidate;
- } else {
- return CXFA_FFTextEdit::OnProcessEvent(pEvent);
+ return;
}
+ CXFA_FFTextEdit::OnProcessEvent(pEvent);
}
+
FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget,
CFX_WideString& wsText) {
CFX_WideString wsPattern;
@@ -522,7 +525,7 @@ FX_BOOL CXFA_FFPasswordEdit::LoadWidget() {
m_pNormalWidget = (CFWL_Widget*)pWidget;
IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pIWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
@@ -588,13 +591,13 @@ FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() {
m_pNormalWidget = (CFWL_Widget*)pWidget;
IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget();
m_pNormalWidget->SetPrivateData(pIWidget, this, NULL);
- IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+ CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
CFX_WideString wsText;
m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display);
- pWidget->SetEditText(wsText.AsWideStringC());
+ pWidget->SetEditText(wsText);
if (CXFA_Value value = m_pDataAcc->GetFormValue()) {
switch (value.GetChildValueClassID()) {
case XFA_ELEMENT_Date: {
@@ -694,7 +697,7 @@ FX_BOOL CXFA_FFDateTimeEdit::UpdateFWLData() {
}
CFX_WideString wsText;
m_pDataAcc->GetValue(wsText, eType);
- ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText.AsWideStringC());
+ ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText);
if (IsFocused() && !wsText.IsEmpty()) {
CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc);
CFX_Unitime date = lcValue.GetDate();
@@ -709,7 +712,7 @@ FX_BOOL CXFA_FFDateTimeEdit::UpdateFWLData() {
return TRUE;
}
FX_BOOL CXFA_FFDateTimeEdit::IsDataChanged() {
- if (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) {
+ if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) {
return TRUE;
}
CFX_WideString wsText;
@@ -777,7 +780,7 @@ void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget,
date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(),
XFA_VALUEPICTURE_Edit);
CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget;
- pDateTime->SetEditText(wsDate.AsWideStringC());
+ pDateTime->SetEditText(wsDate);
pDateTime->Update();
GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL);
CXFA_EventParam eParam;
@@ -786,14 +789,13 @@ void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget,
m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw);
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam);
}
-FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) {
- uint32_t dwEventID = pEvent->GetClassID();
- if (dwEventID == FWL_EVTHASH_DTP_SelectChanged) {
+
+void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) {
+ if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) {
CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent;
OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth,
event->iDay);
- return TRUE;
- } else {
- return CXFA_FFTextEdit::OnProcessEvent(pEvent);
+ return;
}
+ CXFA_FFTextEdit::OnProcessEvent(pEvent);
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.h
index ecdc2da4855..9b73577aab3 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fftextedit.h
@@ -44,10 +44,10 @@ class CXFA_FFTextEdit : public CXFA_FFField {
const CFX_ByteStringC& bsReplace) override;
// IFWL_WidgetDelegate:
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
void OnTextChanged(IFWL_Widget* pWidget,
const CFX_WideString& wsChanged,
@@ -73,7 +73,7 @@ class CXFA_FFNumericEdit : public CXFA_FFTextEdit {
virtual ~CXFA_FFNumericEdit();
virtual FX_BOOL LoadWidget();
virtual void UpdateWidgetProperty();
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual void OnProcessEvent(CFWL_Event* pEvent);
public:
FX_BOOL OnValidate(IFWL_Widget* pWidget, CFX_WideString& wsText);
@@ -132,7 +132,7 @@ class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit {
int32_t iYear,
int32_t iMonth,
int32_t iDay);
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
+ virtual void OnProcessEvent(CFWL_Event* pEvent);
};
#endif // XFA_FXFA_APP_XFA_FFTEXTEDIT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidget.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidget.cpp
index 3a238ad0f3b..3af84a6bbe2 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidget.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidget.cpp
@@ -4,22 +4,25 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include <algorithm>
+#include <memory>
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h"
-#include "core/include/fxcodec/fx_codec.h"
+#include "core/fxcodec/codec/include/ccodec_progressivedecoder.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/parser/cxfa_corner.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
#include "xfa/fxgraphics/cfx_pattern.h"
#include "xfa/fxgraphics/cfx_shading.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
CXFA_FFWidget::CXFA_FFWidget(CXFA_FFPageView* pPageView,
CXFA_WidgetAcc* pDataAcc)
@@ -36,14 +39,14 @@ void CXFA_FFWidget::SetPageView(CXFA_FFPageView* pPageView) {
m_pPageView = pPageView;
}
void CXFA_FFWidget::GetWidgetRect(CFX_RectF& rtWidget) {
- if ((m_dwStatus & XFA_WIDGETSTATUS_RectCached) == 0) {
- m_dwStatus |= XFA_WIDGETSTATUS_RectCached;
+ if ((m_dwStatus & XFA_WidgetStatus_RectCached) == 0) {
+ m_dwStatus |= XFA_WidgetStatus_RectCached;
GetRect(m_rtWidget);
}
rtWidget = m_rtWidget;
}
CFX_RectF CXFA_FFWidget::ReCacheWidgetRect() {
- m_dwStatus |= XFA_WIDGETSTATUS_RectCached;
+ m_dwStatus |= XFA_WidgetStatus_RectCached;
GetRect(m_rtWidget);
return m_rtWidget;
}
@@ -143,7 +146,7 @@ void CXFA_FFWidget::DrawBorder(CFX_Graphics* pGS,
void CXFA_FFWidget::InvalidateWidget(const CFX_RectF* pRect) {
if (!pRect) {
CFX_RectF rtWidget;
- GetBBox(rtWidget, XFA_WIDGETSTATUS_Focused);
+ GetBBox(rtWidget, XFA_WidgetStatus_Focused);
rtWidget.Inflate(2, 2);
GetDoc()->GetDocProvider()->InvalidateRect(m_pPageView, rtWidget,
XFA_INVALIDATE_CurrentPage);
@@ -157,7 +160,7 @@ void CXFA_FFWidget::AddInvalidateRect(const CFX_RectF* pRect) {
if (pRect) {
rtWidget = *pRect;
} else {
- GetBBox(rtWidget, XFA_WIDGETSTATUS_Focused);
+ GetBBox(rtWidget, XFA_WidgetStatus_Focused);
rtWidget.Inflate(2, 2);
}
m_pDocView->AddInvalidateRect(m_pPageView, rtWidget);
@@ -170,9 +173,11 @@ FX_BOOL CXFA_FFWidget::GetCaptionText(CFX_WideString& wsCap) {
pCapTextlayout->GetText(wsCap);
return TRUE;
}
-FX_BOOL CXFA_FFWidget::IsFocused() {
- return m_dwStatus & XFA_WIDGETSTATUS_Focused;
+
+bool CXFA_FFWidget::IsFocused() {
+ return !!(m_dwStatus & XFA_WidgetStatus_Focused);
}
+
FX_BOOL CXFA_FFWidget::OnMouseEnter() {
return FALSE;
}
@@ -220,7 +225,7 @@ FX_BOOL CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) {
if (pParent && !pParent->IsAncestorOf(pOldWidget)) {
pParent->OnSetFocus(pOldWidget);
}
- m_dwStatus |= XFA_WIDGETSTATUS_Focused;
+ m_dwStatus |= XFA_WidgetStatus_Focused;
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_Enter;
eParam.m_pTarget = m_pDataAcc;
@@ -228,7 +233,7 @@ FX_BOOL CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) {
return TRUE;
}
FX_BOOL CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) {
- m_dwStatus &= ~XFA_WIDGETSTATUS_Focused;
+ m_dwStatus &= ~XFA_WidgetStatus_Focused;
EventKillFocus();
if (pNewWidget) {
CXFA_FFWidget* pParent = GetParent();
@@ -247,8 +252,8 @@ FX_BOOL CXFA_FFWidget::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) {
FX_BOOL CXFA_FFWidget::OnChar(uint32_t dwChar, uint32_t dwFlags) {
return FALSE;
}
-uint32_t CXFA_FFWidget::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
- return FALSE;
+FWL_WidgetHit CXFA_FFWidget::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ return FWL_WidgetHit::Unknown;
}
FX_BOOL CXFA_FFWidget::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) {
return FALSE;
@@ -398,12 +403,14 @@ void CXFA_FFWidget::GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight) {
m_pDataAcc->GetMaxHeight(fMaxHeight);
}
}
-FX_BOOL CXFA_FFWidget::IsMatchVisibleStatus(uint32_t dwStatus) {
- return m_dwStatus & XFA_WIDGETSTATUS_Visible;
+
+bool CXFA_FFWidget::IsMatchVisibleStatus(uint32_t dwStatus) {
+ return !!(m_dwStatus & XFA_WidgetStatus_Visible);
}
+
void CXFA_FFWidget::EventKillFocus() {
- if (m_dwStatus & XFA_WIDGETSTATUS_Access) {
- m_dwStatus &= ~XFA_WIDGETSTATUS_Access;
+ if (m_dwStatus & XFA_WidgetStatus_Access) {
+ m_dwStatus &= ~XFA_WidgetStatus_Access;
return;
}
CXFA_EventParam eParam;
@@ -412,11 +419,11 @@ void CXFA_FFWidget::EventKillFocus() {
m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Exit, &eParam);
}
FX_BOOL CXFA_FFWidget::IsButtonDown() {
- return (m_dwStatus & XFA_WIDGETSTATUS_ButtonDown) != 0;
+ return (m_dwStatus & XFA_WidgetStatus_ButtonDown) != 0;
}
void CXFA_FFWidget::SetButtonDown(FX_BOOL bSet) {
- bSet ? m_dwStatus |= XFA_WIDGETSTATUS_ButtonDown
- : m_dwStatus &= ~XFA_WIDGETSTATUS_ButtonDown;
+ bSet ? m_dwStatus |= XFA_WidgetStatus_ButtonDown
+ : m_dwStatus &= ~XFA_WidgetStatus_ButtonDown;
}
int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics,
int32_t iStrokeType,
@@ -474,10 +481,12 @@ CFX_GraphStateData::LineCap XFA_LineCapToFXGE(int32_t iLineCap) {
}
return CFX_GraphStateData::LineCapSquare;
}
+
class CXFA_ImageRenderer {
public:
CXFA_ImageRenderer();
~CXFA_ImageRenderer();
+
FX_BOOL Start(CFX_RenderDevice* pDevice,
CFX_DIBSource* pDIBSource,
FX_ARGB bitmap_argb,
@@ -496,7 +505,7 @@ class CXFA_ImageRenderer {
int m_BitmapAlpha;
FX_ARGB m_FillArgb;
uint32_t m_Flags;
- CFX_ImageTransformer* m_pTransformer;
+ std::unique_ptr<CFX_ImageTransformer> m_pTransformer;
void* m_DeviceHandle;
int32_t m_BlendType;
FX_BOOL m_Result;
@@ -518,23 +527,18 @@ CXFA_ImageRenderer::CXFA_ImageRenderer() {
m_BitmapAlpha = 255;
m_FillArgb = 0;
m_Flags = 0;
- m_pTransformer = NULL;
m_DeviceHandle = NULL;
m_BlendType = FXDIB_BLEND_NORMAL;
m_Result = TRUE;
m_bPrint = FALSE;
}
+
CXFA_ImageRenderer::~CXFA_ImageRenderer() {
- if (m_pCloneConvert) {
- delete m_pCloneConvert;
- }
- if (m_pTransformer) {
- delete m_pTransformer;
- }
- if (m_DeviceHandle) {
+ delete m_pCloneConvert;
+ if (m_DeviceHandle)
m_pDevice->CancelDIBits(m_DeviceHandle);
- }
}
+
FX_BOOL CXFA_ImageRenderer::Start(CFX_RenderDevice* pDevice,
CFX_DIBSource* pDIBSource,
FX_ARGB bitmap_argb,
@@ -585,8 +589,9 @@ FX_BOOL CXFA_ImageRenderer::StartDIBSource() {
FX_RECT clip_box = m_pDevice->GetClipBox();
clip_box.Intersect(image_rect);
m_Status = 2;
- m_pTransformer = new CFX_ImageTransformer;
- m_pTransformer->Start(pDib, &m_ImageMatrix, m_Flags, &clip_box);
+ m_pTransformer.reset(
+ new CFX_ImageTransformer(pDib, &m_ImageMatrix, m_Flags, &clip_box));
+ m_pTransformer->Start();
return TRUE;
}
if (m_ImageMatrix.a < 0) {
@@ -623,45 +628,45 @@ FX_BOOL CXFA_ImageRenderer::StartDIBSource() {
FX_RECT dest_clip(
dest_rect.left - image_rect.left, dest_rect.top - image_rect.top,
dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top);
- CFX_DIBitmap* pStretched =
- m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip);
+ std::unique_ptr<CFX_DIBitmap> pStretched(
+ m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip));
if (pStretched) {
- CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top, m_FillArgb,
- m_BitmapAlpha, m_BlendType, FALSE);
- delete pStretched;
- pStretched = NULL;
+ CompositeDIBitmap(pStretched.get(), dest_rect.left, dest_rect.top,
+ m_FillArgb, m_BitmapAlpha, m_BlendType, FALSE);
}
return FALSE;
}
+
FX_BOOL CXFA_ImageRenderer::Continue(IFX_Pause* pPause) {
if (m_Status == 2) {
- if (m_pTransformer->Continue(pPause)) {
+ if (m_pTransformer->Continue(pPause))
return TRUE;
- }
- CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
- if (pBitmap == NULL) {
+
+ std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap());
+ if (!pBitmap)
return FALSE;
- }
+
if (pBitmap->IsAlphaMask()) {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha);
- }
- m_Result = m_pDevice->SetBitMask(pBitmap, m_pTransformer->m_ResultLeft,
- m_pTransformer->m_ResultTop, m_FillArgb);
+ m_Result =
+ m_pDevice->SetBitMask(pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_FillArgb);
} else {
- if (m_BitmapAlpha != 255) {
+ if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
- }
- m_Result = m_pDevice->SetDIBits(pBitmap, m_pTransformer->m_ResultLeft,
- m_pTransformer->m_ResultTop, m_BlendType);
+ m_Result =
+ m_pDevice->SetDIBits(pBitmap.get(), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_BlendType);
}
- delete pBitmap;
return FALSE;
- } else if (m_Status == 3) {
- return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
}
+ if (m_Status == 3)
+ return m_pDevice->ContinueDIBits(m_DeviceHandle, pPause);
+
return FALSE;
}
+
void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
int left,
int top,
@@ -672,8 +677,8 @@ void CXFA_ImageRenderer::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap,
if (pDIBitmap == NULL) {
return;
}
- FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED;
- FX_BOOL bGroup = Transparency & PDFTRANS_GROUP;
+ bool bIsolated = !!(Transparency & PDFTRANS_ISOLATED);
+ bool bGroup = !!(Transparency & PDFTRANS_GROUP);
if (blend_mode == FXDIB_BLEND_NORMAL) {
if (!pDIBitmap->IsAlphaMask()) {
if (bitmap_alpha < 255) {
@@ -989,21 +994,21 @@ CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc,
CFX_ByteString bsData = wsImage.UTF8Encode();
int32_t iLength = bsData.GetLength();
pImageBuffer = FX_Alloc(uint8_t, iLength);
- int32_t iRead = XFA_Base64Decode((const FX_CHAR*)bsData, pImageBuffer);
+ int32_t iRead = XFA_Base64Decode(bsData.c_str(), pImageBuffer);
if (iRead > 0) {
pImageFileRead = FX_CreateMemoryStream(pImageBuffer, iRead);
}
} else {
bsContent = CFX_ByteString::FromUnicode(wsImage);
pImageFileRead = FX_CreateMemoryStream(
- (uint8_t*)(const uint8_t*)bsContent, bsContent.GetLength());
+ const_cast<uint8_t*>(bsContent.raw_str()), bsContent.GetLength());
}
} else {
CFX_WideString wsURL = wsHref;
if (wsURL.Left(7) != FX_WSTRC(L"http://") &&
wsURL.Left(6) != FX_WSTRC(L"ftp://")) {
CFX_DIBitmap* pBitmap =
- pDoc->GetPDFNamedImage(wsURL.AsWideStringC(), iImageXDpi, iImageYDpi);
+ pDoc->GetPDFNamedImage(wsURL.AsStringC(), iImageXDpi, iImageYDpi);
if (pBitmap) {
bNameImage = TRUE;
return pBitmap;
@@ -1056,7 +1061,7 @@ CFX_DIBitmap* XFA_LoadImageFromBuffer(IFX_FileRead* pImageFileRead,
}
CFX_DIBAttribute dibAttr;
CFX_DIBitmap* pBitmap = NULL;
- ICodec_ProgressiveDecoder* pProgressiveDecoder =
+ CCodec_ProgressiveDecoder* pProgressiveDecoder =
pCodecMgr->CreateProgressiveDecoder();
pProgressiveDecoder->LoadImageInfo(pImageFileRead, type, &dibAttr);
switch (dibAttr.m_wDPIUnit) {
@@ -1151,7 +1156,7 @@ static void XFA_BOX_GetPath(CXFA_Box box,
int32_t nIndex,
FX_BOOL bStart,
FX_BOOL bCorner) {
- FXSYS_assert(nIndex >= 0 && nIndex < 8);
+ ASSERT(nIndex >= 0 && nIndex < 8);
FX_BOOL bInverted, bRound;
FX_FLOAT fRadius1, fRadius2, sx, sy, vx, vy, nx, ny, offsetY, offsetX,
offsetEX, offsetEY;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index fb2b0c3ffd5..64ac9b2d60e 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
#include <algorithm>
+#include <memory>
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fde/xml/fde_xml_imp.h"
@@ -15,16 +16,16 @@
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/app/xfa_textlayout.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
+#include "xfa/fxfa/include/xfa_fontmgr.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
#include "xfa/fxfa/parser/xfa_localevalue.h"
#include "xfa/fxfa/parser/xfa_script.h"
#include "xfa/fxfa/parser/xfa_script_imp.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
-#include "xfa/include/fxfa/xfa_fontmgr.h"
static void XFA_FFDeleteCalcData(void* pData) {
if (pData) {
@@ -101,50 +102,30 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData {
int32_t m_iImageXDpi;
int32_t m_iImageYDpi;
};
+
class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
public:
- CXFA_FieldLayoutData()
- : m_pCapTextLayout(NULL),
- m_pCapTextProvider(NULL),
- m_pTextOut(NULL),
- m_pFieldSplitArray(NULL) {}
- ~CXFA_FieldLayoutData() {
- if (m_pCapTextLayout) {
- delete m_pCapTextLayout;
- }
- m_pCapTextLayout = NULL;
- if (m_pCapTextProvider) {
- delete m_pCapTextProvider;
- }
- m_pCapTextProvider = NULL;
- if (m_pTextOut) {
- m_pTextOut->Release();
- }
- m_pTextOut = NULL;
- if (m_pFieldSplitArray) {
- m_pFieldSplitArray->RemoveAll();
- delete m_pFieldSplitArray;
- m_pFieldSplitArray = NULL;
- }
- }
+ CXFA_FieldLayoutData() {}
+ ~CXFA_FieldLayoutData() {}
+
FX_BOOL LoadCaption(CXFA_WidgetAcc* pAcc) {
- if (m_pCapTextLayout) {
+ if (m_pCapTextLayout)
return TRUE;
- }
CXFA_Caption caption = pAcc->GetCaption();
- if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) {
- m_pCapTextProvider =
- new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption);
- m_pCapTextLayout = new CXFA_TextLayout(m_pCapTextProvider);
- return TRUE;
- }
- return FALSE;
+ if (!caption || caption.GetPresence() == XFA_ATTRIBUTEENUM_Hidden)
+ return FALSE;
+ m_pCapTextProvider.reset(
+ new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption));
+ m_pCapTextLayout.reset(new CXFA_TextLayout(m_pCapTextProvider.get()));
+ return TRUE;
}
- CXFA_TextLayout* m_pCapTextLayout;
- CXFA_TextProvider* m_pCapTextProvider;
- IFDE_TextOut* m_pTextOut;
- CFX_FloatArray* m_pFieldSplitArray;
+
+ std::unique_ptr<CXFA_TextLayout> m_pCapTextLayout;
+ std::unique_ptr<CXFA_TextProvider> m_pCapTextProvider;
+ std::unique_ptr<CFDE_TextOut> m_pTextOut;
+ std::unique_ptr<CFX_FloatArray> m_pFieldSplitArray;
};
+
class CXFA_TextEditData : public CXFA_FieldLayoutData {
public:
};
@@ -200,7 +181,7 @@ FX_BOOL CXFA_WidgetAcc::GetName(CFX_WideString& wsName, int32_t iNameType) {
m_pNode->GetSOMExpression(wsName);
if (iNameType == 2 && wsName.GetLength() >= 15) {
CFX_WideStringC wsPre = FX_WSTRC(L"xfa[0].form[0].");
- if (wsPre == CFX_WideStringC(wsName, wsPre.GetLength())) {
+ if (wsPre == CFX_WideStringC(wsName.c_str(), wsPre.GetLength())) {
wsName.Delete(0, wsPre.GetLength());
}
}
@@ -229,8 +210,7 @@ void CXFA_WidgetAcc::ResetData() {
image.GetContentType(wsContentType);
image.GetHref(wsHref);
}
- SetImageEdit(wsContentType.AsWideStringC(), wsHref.AsWideStringC(),
- wsValue.AsWideStringC());
+ SetImageEdit(wsContentType, wsHref, wsValue);
} break;
case XFA_ELEMENT_ExclGroup: {
CXFA_Node* pNextChild = m_pNode->GetNodeItem(
@@ -271,12 +251,12 @@ void CXFA_WidgetAcc::ResetData() {
break;
}
}
-void CXFA_WidgetAcc::SetImageEdit(const CFX_WideStringC& wsContentType,
- const CFX_WideStringC& wsHref,
- const CFX_WideStringC& wsData) {
+void CXFA_WidgetAcc::SetImageEdit(const CFX_WideString& wsContentType,
+ const CFX_WideString& wsHref,
+ const CFX_WideString& wsData) {
CXFA_Image image = GetFormValue().GetImage();
if (image) {
- image.SetContentType(wsContentType);
+ image.SetContentType(CFX_WideString(wsContentType));
image.SetHref(wsHref);
}
CFX_WideString wsFormatValue(wsData);
@@ -293,9 +273,8 @@ void CXFA_WidgetAcc::SetImageEdit(const CFX_WideStringC& wsContentType,
pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref);
} else {
CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode();
- FXSYS_assert(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element);
- static_cast<CFDE_XMLElement*>(pXMLNode)
- ->SetString(FX_WSTRC(L"href"), wsHref);
+ ASSERT(pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element);
+ static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"href", wsHref);
}
}
@@ -361,6 +340,7 @@ int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event& event,
}
return XFA_EVENTERROR_NotExist;
}
+
int32_t CXFA_WidgetAcc::ProcessCalculate() {
if (GetClassID() == XFA_ELEMENT_Draw) {
return XFA_EVENTERROR_NotExist;
@@ -376,19 +356,16 @@ int32_t CXFA_WidgetAcc::ProcessCalculate() {
EventParam.m_eType = XFA_EVENT_Calculate;
CXFA_Script script = calc.GetScript();
int32_t iRet = ExecuteScript(script, &EventParam);
- if (iRet == XFA_EVENTERROR_Success) {
- if (GetRawValue() != EventParam.m_wsResult) {
- const bool bNotify = GetDoc()->GetDocType() == XFA_DOCTYPE_Static;
- SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw);
- UpdateUIDisplay();
- if (bNotify) {
- NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL, NULL, NULL);
- }
- iRet = XFA_EVENTERROR_Success;
- }
+ if (iRet != XFA_EVENTERROR_Success)
+ return iRet;
+
+ if (GetRawValue() != EventParam.m_wsResult) {
+ SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw);
+ UpdateUIDisplay();
}
- return iRet;
+ return XFA_EVENTERROR_Success;
}
+
void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate,
int32_t iRet,
FXJSE_HVALUE pRetValue,
@@ -412,23 +389,19 @@ void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate validate,
GetValidateMessage(pAppProvider, wsScriptMsg, FALSE, bVersionFlag);
}
if (bVersionFlag) {
- pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Warning,
+ pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
XFA_MB_OK);
return;
}
- if (pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Warning,
+ if (pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Warning,
XFA_MB_YesNo) == XFA_IDYes) {
- GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE);
+ GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, false);
}
} else {
if (wsScriptMsg.IsEmpty()) {
GetValidateMessage(pAppProvider, wsScriptMsg, TRUE, bVersionFlag);
}
- pAppProvider->MsgBox(wsScriptMsg.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Error,
- XFA_MB_OK);
+ pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
}
}
}
@@ -461,9 +434,7 @@ int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate,
if (wsFormatMsg.IsEmpty()) {
GetValidateMessage(pAppProvider, wsFormatMsg, TRUE, bVersionFlag);
}
- pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Error,
- XFA_MB_OK);
+ pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
return XFA_EVENTERROR_Success;
}
if (GetNode()->HasFlag(XFA_NODEFLAG_UserInteractive)) {
@@ -473,15 +444,13 @@ int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate validate,
GetValidateMessage(pAppProvider, wsFormatMsg, FALSE, bVersionFlag);
}
if (bVersionFlag) {
- pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Warning,
+ pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
XFA_MB_OK);
return XFA_EVENTERROR_Success;
}
- if (pAppProvider->MsgBox(wsFormatMsg.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Warning,
+ if (pAppProvider->MsgBox(wsFormatMsg, wsTitle, XFA_MBICON_Warning,
XFA_MB_YesNo) == XFA_IDYes) {
- GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE);
+ GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, false);
}
return XFA_EVENTERROR_Success;
}
@@ -533,10 +502,9 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate,
GetValidateCaptionName(wsCaptionName, bVersionFlag);
CFX_WideString wsError;
pAppProvider->LoadString(XFA_IDS_ValidateNullError, wsError);
- wsNullMsg.Format(wsError, (const FX_WCHAR*)wsCaptionName);
+ wsNullMsg.Format(wsError.c_str(), wsCaptionName.c_str());
}
- pAppProvider->MsgBox(wsNullMsg.AsWideStringC(), wsTitle.AsWideStringC(),
- XFA_MBICON_Status, XFA_MB_OK);
+ pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Status, XFA_MB_OK);
return XFA_EVENTERROR_Error;
}
case XFA_ATTRIBUTEENUM_Warning: {
@@ -547,13 +515,12 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate validate,
GetValidateCaptionName(wsCaptionName, bVersionFlag);
CFX_WideString wsWarning;
pAppProvider->LoadString(XFA_IDS_ValidateNullWarning, wsWarning);
- wsNullMsg.Format(wsWarning, (const FX_WCHAR*)wsCaptionName,
- (const FX_WCHAR*)wsCaptionName);
+ wsNullMsg.Format(wsWarning.c_str(), wsCaptionName.c_str(),
+ wsCaptionName.c_str());
}
- if (pAppProvider->MsgBox(wsNullMsg.AsWideStringC(),
- wsTitle.AsWideStringC(), XFA_MBICON_Warning,
+ if (pAppProvider->MsgBox(wsNullMsg, wsTitle, XFA_MBICON_Warning,
XFA_MB_YesNo) == XFA_IDYes) {
- GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, TRUE, FALSE);
+ GetNode()->SetFlag(XFA_NODEFLAG_UserInteractive, false);
}
return XFA_EVENTERROR_Error;
}
@@ -590,18 +557,18 @@ void CXFA_WidgetAcc::GetValidateMessage(IXFA_AppProvider* pAppProvider,
CFX_WideString wsError;
if (bVersionFlag) {
pAppProvider->LoadString(XFA_IDS_ValidateFailed, wsError);
- wsMessage.Format(wsError, (const FX_WCHAR*)wsCaptionName);
+ wsMessage.Format(wsError.c_str(), wsCaptionName.c_str());
return;
}
if (bError) {
pAppProvider->LoadString(XFA_IDS_ValidateError, wsError);
- wsMessage.Format(wsError, (const FX_WCHAR*)wsCaptionName);
+ wsMessage.Format(wsError.c_str(), wsCaptionName.c_str());
return;
}
CFX_WideString wsWarning;
pAppProvider->LoadString(XFA_IDS_ValidateWarning, wsWarning);
- wsMessage.Format(wsWarning, (const FX_WCHAR*)wsCaptionName,
- (const FX_WCHAR*)wsCaptionName);
+ wsMessage.Format(wsWarning.c_str(), wsCaptionName.c_str(),
+ wsCaptionName.c_str());
}
int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) {
if (GetClassID() == XFA_ELEMENT_Draw) {
@@ -633,7 +600,7 @@ int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) {
bVersionFlag = TRUE;
}
if (bInitDoc) {
- validate.GetNode()->SetFlag(XFA_NODEFLAG_NeedsInitApp, FALSE, FALSE);
+ validate.GetNode()->ClearFlag(XFA_NODEFLAG_NeedsInitApp);
} else {
iFormat = ProcessFormatTestValidate(validate, bVersionFlag);
if (!bVersionFlag) {
@@ -655,7 +622,7 @@ int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
static const uint32_t MAX_RECURSION_DEPTH = 2;
if (m_nRecursionDepth > MAX_RECURSION_DEPTH)
return XFA_EVENTERROR_Success;
- FXSYS_assert(pEventParam);
+ ASSERT(pEventParam);
if (!script) {
return XFA_EVENTERROR_NotExist;
}
@@ -684,7 +651,7 @@ int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
++m_nRecursionDepth;
FX_BOOL bRet =
pContext->RunScript((XFA_SCRIPTLANGTYPE)eScriptType,
- wsExpression.AsWideStringC(), hRetValue, m_pNode);
+ wsExpression.AsStringC(), hRetValue, m_pNode);
--m_nRecursionDepth;
int32_t iRet = XFA_EVENTERROR_Error;
if (bRet) {
@@ -696,7 +663,7 @@ int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
CFX_ByteString bsString;
FXJSE_Value_ToUTF8String(hRetValue, bsString);
pEventParam->m_wsResult =
- CFX_WideString::FromUTF8(bsString, bsString.GetLength());
+ CFX_WideString::FromUTF8(bsString.AsStringC());
}
iRet = XFA_EVENTERROR_Success;
} else {
@@ -757,25 +724,7 @@ void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFWidget* pExcept) {
pWidget->AddInvalidateRect();
}
}
-void CXFA_WidgetAcc::NotifyEvent(uint32_t dwEvent,
- CXFA_FFWidget* pWidget,
- void* pParam,
- void* pAdditional) {
- IXFA_DocProvider* pDocProvider = GetDoc()->GetDocProvider();
- if (pWidget) {
- pDocProvider->WidgetEvent(pWidget, this, dwEvent, pParam, pAdditional);
- } else {
- pWidget = GetNextWidget(pWidget);
- if (pWidget == NULL) {
- pDocProvider->WidgetEvent(NULL, this, dwEvent, pParam, pAdditional);
- return;
- }
- while (pWidget) {
- pDocProvider->WidgetEvent(pWidget, this, dwEvent, pParam, pAdditional);
- pWidget = GetNextWidget(pWidget);
- }
- }
-}
+
void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
CXFA_Caption caption = GetCaption();
if (!caption || caption.GetPresence() != XFA_ATTRIBUTEENUM_Visible) {
@@ -789,7 +738,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
iCapPlacement == XFA_ATTRIBUTEENUM_Bottom;
const bool bReserveExit = fCapReserve > 0.01;
CXFA_TextLayout* pCapTextLayout =
- ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout;
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)->m_pCapTextLayout.get();
if (pCapTextLayout) {
if (!bVert && eUIType != XFA_ELEMENT_Button) {
szCap.x = fCapReserve;
@@ -908,9 +857,12 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) {
if (wsLast == wcEnter) {
wsText = wsText + wcEnter;
}
- if (!((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut) {
- ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut = IFDE_TextOut::Create();
- IFDE_TextOut* pTextOut = ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut;
+
+ CXFA_FieldLayoutData* layoutData =
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData);
+ if (!layoutData->m_pTextOut) {
+ layoutData->m_pTextOut.reset(new CFDE_TextOut);
+ CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get();
pTextOut->SetFont(GetFDEFont());
pTextOut->SetFontSize(fFontSize);
pTextOut->SetLineBreakTolerance(fFontSize * 0.2f);
@@ -921,8 +873,8 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) {
}
pTextOut->SetStyles(dwStyles);
}
- ((CXFA_FieldLayoutData*)m_pLayoutData)
- ->m_pTextOut->CalcLogicSize(wsText, wsText.GetLength(), size);
+ layoutData->m_pTextOut->CalcLogicSize(wsText.c_str(), wsText.GetLength(),
+ size);
}
FX_BOOL CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) {
if (size.x > 0) {
@@ -1287,12 +1239,13 @@ FX_BOOL CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex,
iLinesCount =
((CXFA_FieldLayoutData*)m_pLayoutData)->m_pTextOut->GetTotalLines();
}
- if (!((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray) {
- ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray =
- new CFX_FloatArray;
+ if (!static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)->m_pFieldSplitArray) {
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)
+ ->m_pFieldSplitArray.reset(new CFX_FloatArray);
}
CFX_FloatArray* pFieldArray =
- ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pFieldSplitArray;
+ static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)
+ ->m_pFieldSplitArray.get();
int32_t iFieldSplitCount = pFieldArray->GetSize();
for (int32_t i = 0; i < iBlockIndex * 3; i += 3) {
iLinesCount -= (int32_t)pFieldArray->GetAt(i + 1);
@@ -1509,8 +1462,9 @@ FX_BOOL CXFA_WidgetAcc::LoadCaption() {
}
CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() {
return m_pLayoutData
- ? ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout
- : NULL;
+ ? static_cast<CXFA_FieldLayoutData*>(m_pLayoutData)
+ ->m_pCapTextLayout.get()
+ : nullptr;
}
CXFA_TextLayout* CXFA_WidgetAcc::GetTextLayout() {
return m_pLayoutData ? ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout
@@ -1619,7 +1573,7 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(FX_BOOL& bRichText) {
} else if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) {
CXFA_Node* pBind = m_pWidgetAcc->GetDatasets();
CFDE_XMLNode* pXMLNode = pBind->GetXMLMappingNode();
- FXSYS_assert(pXMLNode);
+ ASSERT(pXMLNode);
for (CFDE_XMLNode* pXMLChild =
pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild);
pXMLChild;
@@ -1712,12 +1666,12 @@ FX_BOOL CXFA_TextProvider::GetEmbbedObj(FX_BOOL bURI,
CXFA_Node* pIDNode = NULL;
CXFA_WidgetAcc* pEmbAcc = NULL;
if (pParent) {
- pIDNode = pDocument->GetNodeByID(pParent, wsAttr.AsWideStringC());
+ pIDNode = pDocument->GetNodeByID(pParent, wsAttr.AsStringC());
}
if (!pIDNode) {
pIDNode = pDocument->GetNodeByID(
ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)),
- wsAttr.AsWideStringC());
+ wsAttr.AsStringC());
}
if (pIDNode) {
pEmbAcc = (CXFA_WidgetAcc*)pIDNode->GetWidgetData();
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.h
index 6d4303d72ad..97514b78db8 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgetacc.h
@@ -22,7 +22,7 @@ class CXFA_TextProvider {
XFA_TEXTPROVIDERTYPE eType,
CXFA_Node* pTextNode = NULL)
: m_pWidgetAcc(pWidgetAcc), m_eType(eType), m_pTextNode(pTextNode) {
- FXSYS_assert(m_pWidgetAcc);
+ ASSERT(m_pWidgetAcc);
}
~CXFA_TextProvider() {}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgethandler.cpp
index b79082965a7..027c3d9fa83 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgethandler.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_ffwidgethandler.cpp
@@ -4,19 +4,19 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_ffwidgethandler.h"
+#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
#include <vector>
#include "xfa/fxfa/app/xfa_ffchoicelist.h"
#include "xfa/fxfa/app/xfa_fffield.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdocview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
#include "xfa/fxfa/parser/xfa_parser.h"
#include "xfa/fxfa/parser/xfa_parser_imp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_ffdocview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
CXFA_FFWidgetHandler::CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView)
: m_pDocView(pDocView) {}
@@ -160,11 +160,11 @@ FX_BOOL CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget,
return bRet;
}
-uint32_t CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- if (!(hWidget->GetStatus() & XFA_WIDGETSTATUS_Visible))
- return FWL_WGTHITTEST_Unknown;
+FWL_WidgetHit CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ if (!(hWidget->GetStatus() & XFA_WidgetStatus_Visible))
+ return FWL_WidgetHit::Unknown;
hWidget->Rotate2Normal(fx, fy);
return hWidget->OnHitTest(fx, fy);
@@ -182,7 +182,7 @@ void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget,
CFX_Matrix* pMatrix,
FX_BOOL bHighlight) {
hWidget->RenderWidget(pGS, pMatrix,
- bHighlight ? XFA_WIDGETSTATUS_Highlight : 0, 0);
+ bHighlight ? XFA_WidgetStatus_Highlight : 0, 0);
}
FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc,
@@ -264,8 +264,8 @@ CXFA_FFWidget* CXFA_FFWidgetHandler::CreateWidget(CXFA_FFWidget* hParent,
if (!pNewFormItem)
return nullptr;
- pNewFormItem->GetTemplateNode()->SetFlag(XFA_NODEFLAG_Initialized);
- pNewFormItem->SetFlag(XFA_NODEFLAG_Initialized);
+ pNewFormItem->GetTemplateNode()->SetFlag(XFA_NODEFLAG_Initialized, true);
+ pNewFormItem->SetFlag(XFA_NODEFLAG_Initialized, true);
m_pDocView->RunLayout();
CXFA_LayoutItem* pLayout =
m_pDocView->GetXFALayout()->GetLayoutItem(pNewFormItem);
@@ -328,7 +328,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent,
CXFA_Node* pCaption = CreateCopyNode(XFA_ELEMENT_Caption, pField);
CXFA_Node* pValue = CreateCopyNode(XFA_ELEMENT_Value, pCaption);
CXFA_Node* pText = CreateCopyNode(XFA_ELEMENT_Text, pValue);
- pText->SetContent(FX_WSTRC(L"Button"), FX_WSTRC(L"Button"), FALSE);
+ pText->SetContent(L"Button", L"Button", FALSE);
CXFA_Node* pPara = CreateCopyNode(XFA_ELEMENT_Para, pCaption);
pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, FALSE);
@@ -343,7 +343,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent,
CXFA_Node* pFill = CreateCopyNode(XFA_ELEMENT_Fill, pBorder);
CXFA_Node* pColor = CreateCopyNode(XFA_ELEMENT_Color, pFill);
- pColor->SetCData(XFA_ATTRIBUTE_Value, FX_WSTRC(L"212, 208, 200"), FALSE);
+ pColor->SetCData(XFA_ATTRIBUTE_Value, L"212, 208, 200", FALSE);
CXFA_Node* pBind = CreateCopyNode(XFA_ELEMENT_Bind, pField);
pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None);
@@ -515,7 +515,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_ELEMENT eElement,
CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const {
CXFA_Node* pFont = CreateCopyNode(XFA_ELEMENT_Font, pParent);
- pFont->SetCData(XFA_ATTRIBUTE_Typeface, FX_WSTRC(L"Myriad Pro"), FALSE);
+ pFont->SetCData(XFA_ATTRIBUTE_Typeface, L"Myriad Pro", FALSE);
return pFont;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fontmgr.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fontmgr.cpp
index 8ffb7ce5784..bf8c1a7326a 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fontmgr.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fontmgr.cpp
@@ -4,15 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_fontmgr.h"
+#include "xfa/fxfa/include/xfa_fontmgr.h"
#include <algorithm>
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
static const XFA_FONTINFO g_XFAFontsMap[] = {
@@ -1694,12 +1694,7 @@ static const XFA_FONTINFO g_XFAFontsMap[] = {
void XFA_LocalFontNameToEnglishName(const CFX_WideStringC& wsLocalName,
CFX_WideString& wsEnglishName) {
wsEnglishName = wsLocalName;
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
- uint32_t dwLocalNameHash = FX_HashCode_String_GetW(
- wsLocalName.raw_str(), wsLocalName.GetLength(), TRUE);
+ uint32_t dwLocalNameHash = FX_HashCode_GetW(wsLocalName, true);
int32_t iStart = 0;
int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1;
int32_t iMid = 0;
@@ -1715,18 +1710,13 @@ void XFA_LocalFontNameToEnglishName(const CFX_WideStringC& wsLocalName,
iEnd = iMid - 1;
}
} while (iEnd >= iStart);
-#endif
}
const XFA_FONTINFO* XFA_GetFontINFOByFontName(
const CFX_WideStringC& wsFontName) {
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
- CFX_WideString wsFontNameTemp = wsFontName;
+ CFX_WideString wsFontNameTemp(wsFontName);
wsFontNameTemp.Remove(L' ');
uint32_t dwCurFontNameHash =
- FX_HashCode_String_GetW(wsFontNameTemp, wsFontNameTemp.GetLength(), TRUE);
+ FX_HashCode_GetW(wsFontNameTemp.AsStringC(), true);
int32_t iStart = 0;
int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1;
int32_t iMid = 0;
@@ -1744,29 +1734,24 @@ const XFA_FONTINFO* XFA_GetFontINFOByFontName(
}
} while (iEnd >= iStart);
return pFontInfo;
-#else
- return NULL;
-#endif
}
CXFA_DefFontMgr::~CXFA_DefFontMgr() {
- int32_t iCounts = m_CacheFonts.GetSize();
- for (int32_t i = 0; i < iCounts; i++) {
- ((IFX_Font*)m_CacheFonts[i])->Release();
- }
- m_CacheFonts.RemoveAll();
+ for (int32_t i = 0; i < m_CacheFonts.GetSize(); i++)
+ m_CacheFonts[i]->Release();
}
IFX_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc,
const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage) {
- CFX_WideString wsFontName = wsFontFamily;
+ CFX_WideString wsFontName(wsFontFamily);
IFX_FontMgr* pFDEFontMgr = hDoc->GetApp()->GetFDEFontMgr();
- IFX_Font* pFont = pFDEFontMgr->LoadFont(wsFontName, dwFontStyles, wCodePage);
+ IFX_Font* pFont =
+ pFDEFontMgr->LoadFont(wsFontName.c_str(), dwFontStyles, wCodePage);
if (!pFont) {
const XFA_FONTINFO* pCurFont =
- XFA_GetFontINFOByFontName(wsFontName.AsWideStringC());
+ XFA_GetFontINFOByFontName(wsFontName.AsStringC());
if (pCurFont && pCurFont->pReplaceFont) {
uint32_t dwStyle = 0;
if (dwFontStyles & FX_FONTSTYLE_Bold) {
@@ -1785,7 +1770,7 @@ IFX_Font* CXFA_DefFontMgr::GetFont(CXFA_FFDoc* hDoc,
}
CFX_WideString wsReplace =
CFX_WideString(pReplace, pNameText - pReplace);
- pFont = pFDEFontMgr->LoadFont(wsReplace, dwStyle, wCodePage);
+ pFont = pFDEFontMgr->LoadFont(wsReplace.c_str(), dwStyle, wCodePage);
if (pFont) {
break;
}
@@ -1811,7 +1796,7 @@ IFX_Font* CXFA_DefFontMgr::GetDefaultFont(CXFA_FFDoc* hDoc,
if (!pFont)
pFont =
pFDEFontMgr->LoadFont((const FX_WCHAR*)NULL, dwFontStyles, wCodePage);
- FXSYS_assert(pFont);
+ ASSERT(pFont);
if (pFont) {
m_CacheFonts.Add(pFont);
}
@@ -1862,7 +1847,7 @@ IFX_Font* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName,
for (const auto& it : *pFontSetDict) {
const CFX_ByteString& key = it.first;
CPDF_Object* pObj = it.second;
- if (!PsNameMatchDRFontName(strPsName.AsByteStringC(), bBold, bItalic, key,
+ if (!PsNameMatchDRFontName(strPsName.AsStringC(), bBold, bItalic, key,
bStrictMatch)) {
continue;
}
@@ -1886,18 +1871,19 @@ IFX_Font* CXFA_PDFFontMgr::FindFont(CFX_ByteString strPsName,
}
return NULL;
}
+
IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
CPDF_Font** pPDFFont,
FX_BOOL bStrictMatch) {
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsFontFamily.raw_str(), wsFontFamily.GetLength());
+ uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false);
CFX_ByteString strKey;
strKey.Format("%u%u", dwHashCode, dwFontStyles);
auto it = m_FontMap.find(strKey);
if (it != m_FontMap.end())
return it->second;
- CFX_ByteString bsPsName = CFX_ByteString::FromUnicode(wsFontFamily);
+ CFX_ByteString bsPsName =
+ CFX_ByteString::FromUnicode(CFX_WideString(wsFontFamily));
FX_BOOL bBold = (dwFontStyles & FX_FONTSTYLE_Bold) == FX_FONTSTYLE_Bold;
FX_BOOL bItalic = (dwFontStyles & FX_FONTSTYLE_Italic) == FX_FONTSTYLE_Italic;
CFX_ByteString strFontName = PsNameToFontName(bsPsName, bBold, bItalic);
@@ -1907,6 +1893,7 @@ IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily,
m_FontMap[strKey] = pFont;
return pFont;
}
+
CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName(
const CFX_ByteString& strPsName,
FX_BOOL bBold,
@@ -1920,6 +1907,7 @@ CFX_ByteString CXFA_PDFFontMgr::PsNameToFontName(
}
return strPsName;
}
+
FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName(
const CFX_ByteStringC& bsPsName,
FX_BOOL bBold,
@@ -2009,16 +1997,18 @@ FX_BOOL CXFA_PDFFontMgr::GetCharWidth(IFX_Font* pFont,
iWidth = pPDFFont->GetCharWidthF(wUnicode);
return TRUE;
}
-CXFA_FontMgr::CXFA_FontMgr() : m_pDefFontMgr(NULL) {}
+
+CXFA_FontMgr::CXFA_FontMgr() : m_pDefFontMgr(nullptr) {}
+
CXFA_FontMgr::~CXFA_FontMgr() {
DelAllMgrMap();
}
+
IFX_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage) {
- uint32_t dwHash = FX_HashCode_String_GetW(wsFontFamily.raw_str(),
- wsFontFamily.GetLength(), FALSE);
+ uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false);
CFX_ByteString bsKey;
bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage);
auto it = m_FontMap.find(bsKey);
@@ -2030,8 +2020,7 @@ IFX_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
CPDF_Font* pPDFFont = NULL;
IFX_Font* pFont = NULL;
if (pMgr) {
- pFont =
- pMgr->GetFont(wsEnglishName.AsWideStringC(), dwFontStyles, &pPDFFont);
+ pFont = pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont);
if (pFont)
return pFont;
}
@@ -2040,8 +2029,8 @@ IFX_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
}
if (!pFont && pMgr) {
pPDFFont = NULL;
- pFont = pMgr->GetFont(wsEnglishName.AsWideStringC(), dwFontStyles,
- &pPDFFont, FALSE);
+ pFont = pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont,
+ FALSE);
if (pFont)
return pFont;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.cpp
index c1732776b2b..4a0828b5ef9 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.cpp
@@ -7,17 +7,23 @@
#include "xfa/fxfa/app/xfa_fwladapter.h"
#include "xfa/fxfa/app/xfa_fffield.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
-FWL_ERR CXFA_FWLAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect) {
+CXFA_FWLAdapterWidgetMgr::CXFA_FWLAdapterWidgetMgr() {}
+
+CXFA_FWLAdapterWidgetMgr::~CXFA_FWLAdapterWidgetMgr() {}
+
+FWL_Error CXFA_FWLAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
+ const CFX_RectF* pRect) {
if (!pWidget)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
CXFA_FFField* pField = (CXFA_FFField*)pWidget->GetPrivateData(pWidget);
if (!pField)
- return FWL_ERR_Indefinite;
+ return FWL_Error::Indefinite;
+
pField->AddInvalidateRect(nullptr);
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CXFA_FWLAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget,
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.h
index c42ae7402b5..00e76db227c 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwladapter.h
@@ -7,16 +7,23 @@
#ifndef XFA_FXFA_APP_XFA_FWLADAPTER_H_
#define XFA_FXFA_APP_XFA_FWLADAPTER_H_
-#include "xfa/fwl/core/fwl_sdadapterimp.h"
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fwl/core/fwl_error.h"
-class CXFA_FWLAdapterWidgetMgr : public CFWL_SDAdapterWidgetMgr {
+class IFWL_Widget;
+
+class CXFA_FWLAdapterWidgetMgr {
public:
- virtual FWL_ERR RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect);
- virtual FX_BOOL GetPopupPos(IFWL_Widget* pWidget,
- FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
+ CXFA_FWLAdapterWidgetMgr();
+ ~CXFA_FWLAdapterWidgetMgr();
+
+ FWL_Error RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect);
+ FX_BOOL GetPopupPos(IFWL_Widget* pWidget,
+ FX_FLOAT fMinHeight,
+ FX_FLOAT fMaxHeight,
+ const CFX_RectF& rtAnchor,
+ CFX_RectF& rtPopup);
};
#endif // XFA_FXFA_APP_XFA_FWLADAPTER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.cpp
index f36c1bcc974..df09fb504a9 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.cpp
@@ -21,9 +21,9 @@
#include "xfa/fwl/basewidget/ifwl_scrollbar.h"
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themetext.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_color.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
namespace {
@@ -44,7 +44,6 @@ CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) {
return NULL;
}
CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) {
- m_pTextOut = NULL;
m_dwCapacity = 0;
m_fCapacity = 0;
m_pCalendarFont = NULL;
@@ -76,8 +75,8 @@ CXFA_FWLTheme::~CXFA_FWLTheme() {
delete m_pCaretTP;
delete m_pBarcodeTP;
}
-FWL_ERR CXFA_FWLTheme::Initialize() {
- m_pTextOut = IFDE_TextOut::Create();
+FWL_Error CXFA_FWLTheme::Initialize() {
+ m_pTextOut.reset(new CFDE_TextOut);
for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts);
++i) {
m_pCalendarFont = IFX_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0,
@@ -93,57 +92,58 @@ FWL_ERR CXFA_FWLTheme::Initialize() {
#endif
}
- FXSYS_assert(NULL != m_pCalendarFont);
+ ASSERT(NULL != m_pCalendarFont);
FWLTHEME_Init();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FWL_ERR CXFA_FWLTheme::Finalize() {
- if (m_pTextOut) {
- m_pTextOut->Release();
- m_pTextOut = NULL;
- }
+FWL_Error CXFA_FWLTheme::Finalize() {
+ m_pTextOut.reset();
if (m_pCalendarFont) {
m_pCalendarFont->Release();
- m_pCalendarFont = NULL;
+ m_pCalendarFont = nullptr;
}
FWLTHEME_Release();
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_BOOL CXFA_FWLTheme::IsValidWidget(IFWL_Widget* pWidget) {
+
+bool CXFA_FWLTheme::IsValidWidget(IFWL_Widget* pWidget) {
return TRUE;
}
+
uint32_t CXFA_FWLTheme::GetThemeID(IFWL_Widget* pWidget) {
return 0;
}
+
uint32_t CXFA_FWLTheme::SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren) {
return 0;
}
+
FX_BOOL CXFA_FWLTheme::DrawBackground(CFWL_ThemeBackground* pParams) {
return GetTheme(pParams->m_pWidget)->DrawBackground(pParams);
}
FX_BOOL CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) {
- if (pParams->m_wsText.IsEmpty()) {
- return FWL_ERR_Indefinite;
- }
- if (pParams->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar) {
+ if (pParams->m_wsText.IsEmpty())
+ return FALSE;
+
+ if (pParams->m_pWidget->GetClassID() == FWL_Type::MonthCalendar) {
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget);
- if (!pWidget) {
- return FWL_ERR_Indefinite;
- }
+ if (!pWidget)
+ return FALSE;
+
m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
m_pTextOut->SetFont(m_pCalendarFont);
m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
- if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) &&
+ if ((pParams->m_iPart == CFWL_Part::DatesIn) &&
!(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) &&
(pParams->m_dwStates &
- (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) {
+ (CFWL_PartState_Hovered | CFWL_PartState_Selected))) {
m_pTextOut->SetTextColor(0xFFFFFFFF);
}
- if (pParams->m_iPart == FWL_PART_MCD_Caption) {
+ if (pParams->m_iPart == CFWL_Part::Caption) {
if (m_pMonthCalendarTP->GetThemeID(pParams->m_pWidget) == 0) {
m_pTextOut->SetTextColor(ArgbEncode(0xff, 0, 153, 255));
} else {
@@ -161,14 +161,14 @@ FX_BOOL CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) {
mtPart.Concat(*pMatrix);
}
m_pTextOut->SetMatrix(mtPart);
- m_pTextOut->DrawLogicText(pParams->m_wsText, pParams->m_wsText.GetLength(),
- pParams->m_rtPart);
+ m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(),
+ pParams->m_wsText.GetLength(), pParams->m_rtPart);
return TRUE;
}
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget);
- if (!pWidget) {
- return FWL_ERR_Indefinite;
- }
+ if (!pWidget)
+ return FALSE;
+
CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc();
CFX_Graphics* pGraphics = pParams->m_pGraphics;
CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice();
@@ -186,45 +186,45 @@ FX_BOOL CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) {
mtPart.Concat(*pMatrix);
}
m_pTextOut->SetMatrix(mtPart);
- m_pTextOut->DrawLogicText(pParams->m_wsText, pParams->m_wsText.GetLength(),
- pParams->m_rtPart);
+ m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(),
+ pParams->m_wsText.GetLength(), pParams->m_rtPart);
return TRUE;
}
void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart,
- uint32_t dwCapacity) {
+ CFWL_WidgetCapacity dwCapacity) {
switch (dwCapacity) {
- case FWL_WGTCAPACITY_Font: {
+ case CFWL_WidgetCapacity::Font: {
if (CXFA_FFWidget* pWidget =
XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
return pWidget->GetDataAcc()->GetFDEFont();
}
} break;
- case FWL_WGTCAPACITY_FontSize: {
+ case CFWL_WidgetCapacity::FontSize: {
if (CXFA_FFWidget* pWidget =
XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
m_fCapacity = pWidget->GetDataAcc()->GetFontSize();
return &m_fCapacity;
}
} break;
- case FWL_WGTCAPACITY_TextColor: {
+ case CFWL_WidgetCapacity::TextColor: {
if (CXFA_FFWidget* pWidget =
XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
m_dwCapacity = pWidget->GetDataAcc()->GetTextColor();
return &m_dwCapacity;
}
} break;
- case FWL_WGTCAPACITY_LineHeight: {
+ case CFWL_WidgetCapacity::LineHeight: {
if (CXFA_FFWidget* pWidget =
XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
m_fCapacity = pWidget->GetDataAcc()->GetLineHeight();
return &m_fCapacity;
}
} break;
- case FWL_WGTCAPACITY_ScrollBarWidth: {
+ case CFWL_WidgetCapacity::ScrollBarWidth: {
m_fCapacity = 9;
return &m_fCapacity;
} break;
- case FWL_WGTCAPACITY_UIMargin: {
+ case CFWL_WidgetCapacity::UIMargin: {
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget);
if (pWidget) {
CXFA_LayoutItem* pItem = pWidget;
@@ -249,7 +249,7 @@ void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart,
}
return &m_Rect;
} break;
- case FWL_WGTCAPACITY_SpaceAboveBelow: {
+ case CFWL_WidgetCapacity::SpaceAboveBelow: {
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget);
if (pWidget) {
CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
@@ -263,18 +263,81 @@ void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart,
default:
break;
}
- if (pThemePart->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar &&
- dwCapacity >= FWL_MCCAPACITY_Sun && dwCapacity <= FWL_MCCAPACITY_Today) {
+
+ int dwCapValue = static_cast<int>(dwCapacity);
+ if (pThemePart->m_pWidget->GetClassID() == FWL_Type::MonthCalendar &&
+ dwCapValue >= static_cast<int>(CFWL_WidgetCapacity::Today) &&
+ dwCapValue <= static_cast<int>(CFWL_WidgetCapacity::December)) {
if (CXFA_FFWidget* pWidget =
XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) {
IXFA_AppProvider* pAppProvider = pWidget->GetAppProvider();
- m_wsResource.Empty();
- pAppProvider->LoadString(
- XFA_IDS_StringWeekDay_Sun + dwCapacity - FWL_WGTCAPACITY_MAX - 5,
- m_wsResource);
- if (!m_wsResource.IsEmpty()) {
- return &m_wsResource;
+ m_wsResource.clear();
+ switch (dwCapacity) {
+ case CFWL_WidgetCapacity::Sun:
+ pAppProvider->LoadString(XFA_IDS_StringWeekDay_Sun, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::Mon:
+ pAppProvider->LoadString(XFA_IDS_StringWeekDay_Mon, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::Tue:
+ pAppProvider->LoadString(XFA_IDS_StringWeekDay_Tue, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::Wed:
+ pAppProvider->LoadString(XFA_IDS_StringWeekDay_Wed, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::Thu:
+ pAppProvider->LoadString(XFA_IDS_StringWeekDay_Thu, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::Fri:
+ pAppProvider->LoadString(XFA_IDS_StringWeekDay_Fri, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::Sat:
+ pAppProvider->LoadString(XFA_IDS_StringWeekDay_Sat, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::January:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_Jan, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::February:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_Feb, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::March:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_March, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::April:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_April, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::May:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_May, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::June:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_June, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::July:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_July, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::August:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_Aug, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::September:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_Sept, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::October:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_Oct, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::November:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_Nov, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::December:
+ pAppProvider->LoadString(XFA_IDS_StringMonth_Dec, m_wsResource);
+ break;
+ case CFWL_WidgetCapacity::Today:
+ pAppProvider->LoadString(XFA_IDS_String_Today, m_wsResource);
+ break;
+ default:
+ break;
}
+ if (!m_wsResource.IsEmpty())
+ return &m_wsResource;
}
}
return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity);
@@ -282,7 +345,7 @@ void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart,
FX_BOOL CXFA_FWLTheme::IsCustomizedLayout(IFWL_Widget* pWidget) {
return GetTheme(pWidget)->IsCustomizedLayout(pWidget);
}
-FWL_ERR CXFA_FWLTheme::GetPartRect(CFWL_ThemePart* pThemePart) {
+FWL_Error CXFA_FWLTheme::GetPartRect(CFWL_ThemePart* pThemePart) {
CFX_RectF rect;
return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rect);
}
@@ -292,11 +355,10 @@ FX_BOOL CXFA_FWLTheme::IsInPart(CFWL_ThemePart* pThemePart,
return GetTheme(pThemePart->m_pWidget)->IsInPart(pThemePart, fx, fy);
}
FX_BOOL CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
- if (pParams->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar) {
+ if (pParams->m_pWidget->GetClassID() == FWL_Type::MonthCalendar) {
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget);
- if (!pWidget) {
- return FWL_ERR_Indefinite;
- }
+ if (!pWidget)
+ return FALSE;
if (!pParams)
return FALSE;
if (!m_pTextOut)
@@ -306,66 +368,61 @@ FX_BOOL CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
- m_pTextOut->CalcLogicSize(pParams->m_wsText, pParams->m_wsText.GetLength(),
- rect);
+ m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(),
+ pParams->m_wsText.GetLength(), rect);
return TRUE;
}
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget);
- if (!pWidget) {
- return FWL_ERR_Indefinite;
- }
+ if (!pWidget)
+ return FALSE;
+
CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc();
m_pTextOut->SetFont(pAcc->GetFDEFont());
m_pTextOut->SetFontSize(pAcc->GetFontSize());
m_pTextOut->SetTextColor(pAcc->GetTextColor());
if (!pParams)
return FALSE;
- if (!m_pTextOut)
- return FALSE;
m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
- m_pTextOut->CalcLogicSize(pParams->m_wsText, pParams->m_wsText.GetLength(),
- rect);
+ m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(),
+ pParams->m_wsText.GetLength(), rect);
return TRUE;
}
CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(IFWL_Widget* pWidget) {
switch (pWidget->GetClassID()) {
- case FWL_CLASSHASH_CheckBox:
+ case FWL_Type::CheckBox:
return m_pCheckBoxTP;
- case FWL_CLASSHASH_ListBox:
+ case FWL_Type::ListBox:
return m_pListBoxTP;
- case FWL_CLASSHASH_PictureBox:
+ case FWL_Type::PictureBox:
return m_pPictureBoxTP;
- case FWL_CLASSHASH_ScrollBar:
+ case FWL_Type::ScrollBar:
return m_pSrollBarTP;
- case FWL_CLASSHASH_Edit:
+ case FWL_Type::Edit:
return m_pEditTP;
- case FWL_CLASSHASH_ComboBox:
+ case FWL_Type::ComboBox:
return m_pComboBoxTP;
- case FWL_CLASSHASH_MonthCalendar:
+ case FWL_Type::MonthCalendar:
return m_pMonthCalendarTP;
- case FWL_CLASSHASH_DateTimePicker:
+ case FWL_Type::DateTimePicker:
return m_pDateTimePickerTP;
- case FWL_CLASSHASH_PushButton:
+ case FWL_Type::PushButton:
return m_pPushButtonTP;
- case FWL_CLASSHASH_Caret:
+ case FWL_Type::Caret:
return m_pCaretTP;
- case FWL_CLASSHASH_Barcode:
+ case FWL_Type::Barcode:
return m_pBarcodeTP;
default:
- break;
+ return nullptr;
}
- return NULL;
}
CXFA_FWLCheckBoxTP::CXFA_FWLCheckBoxTP() {}
FX_BOOL CXFA_FWLCheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) {
- if (pParams->m_iPart != FWL_PART_CKB_CheckBox) {
+ if (pParams->m_iPart != CFWL_Part::CheckBox) {
return TRUE;
}
- if (((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) ==
- FWL_PARTSTATE_CKB_Checked) ||
- ((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) ==
- FWL_PARTSTATE_CKB_Neutral)) {
+ if ((pParams->m_dwStates & CFWL_PartState_Checked) ||
+ (pParams->m_dwStates & CFWL_PartState_Neutral)) {
DrawCheckSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart,
pParams->m_dwStates, &pParams->m_matrix);
}
@@ -378,9 +435,9 @@ void CXFA_FWLCheckBoxTP::DrawCheckSign(IFWL_Widget* pWidget,
CFX_Matrix* pMatrix) {
CFX_RectF rtSign(*pRtBox);
uint32_t dwColor = 0xFF000000;
- if ((iState & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Neutral) {
+ if (iState & CFWL_PartState_Neutral)
dwColor = 0xFFA9A9A9;
- }
+
{
uint32_t dwStyle = pWidget->GetStylesEx();
rtSign.Deflate(rtSign.width / 4, rtSign.height / 4);
@@ -411,7 +468,7 @@ void CXFA_FWLCheckBoxTP::DrawCheckSign(IFWL_Widget* pWidget,
CXFA_FWLEditTP::CXFA_FWLEditTP() {}
CXFA_FWLEditTP::~CXFA_FWLEditTP() {}
FX_BOOL CXFA_FWLEditTP::DrawBackground(CFWL_ThemeBackground* pParams) {
- if (FWL_PART_EDT_CombTextLine == pParams->m_iPart) {
+ if (CFWL_Part::CombTextLine == pParams->m_iPart) {
CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget);
FX_ARGB cr = 0xFF000000;
FX_FLOAT fWidth = 1.0f;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.h
index 72a516b7553..319df8dfa56 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_fwltheme.h
@@ -7,7 +7,8 @@
#ifndef XFA_FXFA_APP_XFA_FWLTHEME_H_
#define XFA_FXFA_APP_XFA_FWLTHEME_H_
-#include "xfa/fwl/core/ifwl_target.h"
+#include <memory>
+
#include "xfa/fwl/core/ifwl_themeprovider.h"
#include "xfa/fwl/theme/cfwl_barcodetp.h"
#include "xfa/fwl/theme/cfwl_carettp.h"
@@ -21,47 +22,48 @@
#include "xfa/fwl/theme/cfwl_pushbuttontp.h"
#include "xfa/fwl/theme/cfwl_scrollbartp.h"
#include "xfa/fwl/theme/cfwl_widgettp.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
class CXFA_FWLTheme : public IFWL_ThemeProvider {
public:
CXFA_FWLTheme(CXFA_FFApp* pApp);
virtual ~CXFA_FWLTheme();
- virtual FWL_ERR Release() {
+ virtual FWL_Error Release() {
delete this;
- return FWL_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- virtual IFWL_Target* Retain() { return NULL; }
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const {
- return FWL_ERR_Succeeded;
+ virtual IFWL_Widget* Retain() { return NULL; }
+ virtual FWL_Error GetClassName(CFX_WideString& wsClass) const {
+ return FWL_Error::Succeeded;
}
virtual uint32_t GetHashCode() const { return 0; }
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget);
+ virtual FWL_Error Initialize();
+ virtual FWL_Error Finalize();
+ virtual bool IsValidWidget(IFWL_Widget* pWidget);
virtual uint32_t GetThemeID(IFWL_Widget* pWidget);
virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
FX_BOOL bChildren = TRUE);
virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams);
virtual FX_BOOL DrawText(CFWL_ThemeText* pParams);
- virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity);
+ virtual void* GetCapacity(CFWL_ThemePart* pThemePart,
+ CFWL_WidgetCapacity dwCapacity);
virtual FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget);
- virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart);
+ virtual FWL_Error GetPartRect(CFWL_ThemePart* pThemePart);
virtual FX_BOOL IsInPart(CFWL_ThemePart* pThemePart,
FX_FLOAT fx,
FX_FLOAT fy);
virtual FX_BOOL CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect);
- virtual FWL_ERR GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) {
- return FWL_ERR_Succeeded;
+ virtual FWL_Error GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) {
+ return FWL_Error::Succeeded;
}
- virtual FWL_ERR SetThemeMatrix(IFWL_Widget* pWidget,
- const CFX_Matrix& matrix) {
- return FWL_ERR_Succeeded;
+ virtual FWL_Error SetThemeMatrix(IFWL_Widget* pWidget,
+ const CFX_Matrix& matrix) {
+ return FWL_Error::Succeeded;
}
- virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) {
- return FWL_ERR_Succeeded;
+ virtual FWL_Error GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) {
+ return FWL_Error::Succeeded;
}
protected:
@@ -77,7 +79,7 @@ class CXFA_FWLTheme : public IFWL_ThemeProvider {
CFWL_PushButtonTP* m_pPushButtonTP;
CFWL_CaretTP* m_pCaretTP;
CFWL_BarcodeTP* m_pBarcodeTP;
- IFDE_TextOut* m_pTextOut;
+ std::unique_ptr<CFDE_TextOut> m_pTextOut;
FX_FLOAT m_fCapacity;
uint32_t m_dwCapacity;
IFX_Font* m_pCalendarFont;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_rendercontext.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_rendercontext.cpp
index 59ed31a21d9..7bfd9630cb0 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_rendercontext.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_rendercontext.cpp
@@ -4,11 +4,11 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/include/fxfa/xfa_rendercontext.h"
+#include "xfa/fxfa/include/xfa_rendercontext.h"
+#include "xfa/fxfa/include/xfa_ffpageview.h"
+#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
-#include "xfa/include/fxfa/xfa_ffpageview.h"
-#include "xfa/include/fxfa/xfa_ffwidget.h"
#define XFA_RENDERCONTEXT_MaxCount 30
@@ -38,10 +38,10 @@ int32_t CXFA_RenderContext::StartRender(CXFA_FFPageView* pPageView,
mtRes.SetReverse(matrix);
m_rtClipRect.Set(rtPage.left, rtPage.top, rtPage.width, rtPage.height);
mtRes.TransformRect(m_rtClipRect);
- m_dwStatus = m_options.m_bHighlight ? XFA_WIDGETSTATUS_Highlight : 0;
- uint32_t dwFilterType = XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_AllType |
- (m_options.m_bPrint ? XFA_WIDGETSTATUS_Printable
- : XFA_WIDGETSTATUS_Viewable);
+ m_dwStatus = m_options.m_bHighlight ? XFA_WidgetStatus_Highlight : 0;
+ uint32_t dwFilterType = XFA_WidgetStatus_Visible |
+ (m_options.m_bPrint ? XFA_WidgetStatus_Printable
+ : XFA_WidgetStatus_Viewable);
m_pWidgetIterator =
m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType);
m_pWidget = m_pWidgetIterator->MoveToNext();
@@ -52,7 +52,7 @@ int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) {
while (m_pWidget) {
CXFA_FFWidget* pWidget = (CXFA_FFWidget*)m_pWidget;
CFX_RectF rtWidgetBox;
- pWidget->GetBBox(rtWidgetBox, XFA_WIDGETSTATUS_Visible);
+ pWidget->GetBBox(rtWidgetBox, XFA_WidgetStatus_Visible);
rtWidgetBox.width += 1;
rtWidgetBox.height += 1;
if (rtWidgetBox.IntersectWith(m_rtClipRect)) {
@@ -68,8 +68,6 @@ int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) {
return XFA_RENDERSTATUS_Done;
}
void CXFA_RenderContext::StopRender() {
- if (m_pWidgetIterator) {
- m_pWidgetIterator->Release();
- m_pWidgetIterator = NULL;
- }
+ delete m_pWidgetIterator;
+ m_pWidgetIterator = nullptr;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.cpp b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.cpp
index cd323633c09..b7dfa3f168c 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.cpp
@@ -9,61 +9,37 @@
#include <algorithm>
#include "core/fxcrt/include/fx_ext.h"
-#include "xfa/fde/fde_pen.h"
+#include "xfa/fde/cfde_path.h"
+#include "xfa/fde/css/fde_csscache.h"
+#include "xfa/fde/css/fde_cssstyleselector.h"
+#include "xfa/fde/fde_gedevice.h"
+#include "xfa/fde/fde_object.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fgas/crt/fgas_algorithm.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fxfa/app/xfa_ffwidgetacc.h"
-#include "xfa/include/fxfa/xfa_ffapp.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
-#include "xfa/include/fxfa/xfa_fontmgr.h"
+#include "xfa/fxfa/include/xfa_ffapp.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_fontmgr.h"
-CXFA_CSSTagProvider::~CXFA_CSSTagProvider() {
- FX_POSITION pos = m_Attributes.GetStartPosition();
- while (pos) {
- CFX_WideString *pName = NULL, *pValue = NULL;
- m_Attributes.GetNextAssoc(pos, (void*&)pName, (void*&)pValue);
- delete pName;
- delete pValue;
- }
-}
-void CXFA_CSSTagProvider::GetNextAttribute(FX_POSITION& pos,
- CFX_WideStringC& wsAttr,
- CFX_WideStringC& wsValue) {
- if (pos == NULL) {
- return;
- }
- CFX_WideString* pName = NULL;
- CFX_WideString* pValue = NULL;
- m_Attributes.GetNextAssoc(pos, (void*&)pName, (void*&)pValue);
- wsAttr = *pName;
- wsValue = *pValue;
-}
-void CXFA_CSSTagProvider::SetAttribute(const CFX_WideString& wsAttr,
- const CFX_WideString& wsValue) {
- CFX_WideString* pName = new CFX_WideString();
- CFX_WideString* pValue = new CFX_WideString();
- *pName = wsAttr;
- *pValue = wsValue;
- m_Attributes.SetAt(pName, pValue);
-}
-void CXFA_TextParseContext::SetDecls(const IFDE_CSSDeclaration** ppDeclArray,
+void CXFA_TextParseContext::SetDecls(const CFDE_CSSDeclaration** ppDeclArray,
int32_t iDeclCount) {
- if (iDeclCount <= 0 || ppDeclArray == NULL) {
+ if (iDeclCount <= 0 || !ppDeclArray)
return;
- }
+
m_dwMatchedDecls = iDeclCount;
- m_ppMatchedDecls = FX_Alloc(IFDE_CSSDeclaration*, iDeclCount);
+ m_ppMatchedDecls = FX_Alloc(CFDE_CSSDeclaration*, iDeclCount);
FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray,
- iDeclCount * sizeof(IFDE_CSSDeclaration*));
+ iDeclCount * sizeof(CFDE_CSSDeclaration*));
}
+
+CXFA_TextParser::CXFA_TextParser() : m_pAllocator(NULL), m_pUASheet(NULL) {}
+
CXFA_TextParser::~CXFA_TextParser() {
if (m_pUASheet)
m_pUASheet->Release();
- if (m_pSelector)
- m_pSelector->Release();
- if (m_pAllocator)
- m_pAllocator->Release();
+
+ delete m_pAllocator;
FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition();
while (ps) {
CFDE_XMLNode* pXMLNode;
@@ -84,20 +60,18 @@ void CXFA_TextParser::Reset() {
FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext);
}
m_mapXMLNodeToParseContext.RemoveAll();
- if (m_pAllocator) {
- m_pAllocator->Release();
- m_pAllocator = NULL;
- }
+ delete m_pAllocator;
+ m_pAllocator = nullptr;
}
void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
- if (pTextProvider == NULL) {
+ if (!pTextProvider)
return;
- }
- if (m_pSelector == NULL) {
+
+ if (!m_pSelector) {
CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
- FXSYS_assert(pFontMgr);
- m_pSelector = IFDE_CSSStyleSelector::Create();
+ ASSERT(pFontMgr);
+ m_pSelector.reset(new CFDE_CSSStyleSelector);
m_pSelector->SetFontMgr(pFontMgr);
FX_FLOAT fFontSize = 10;
CXFA_Font font = pTextProvider->GetFontNode();
@@ -106,7 +80,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
}
m_pSelector->SetDefFontSize(fFontSize);
}
- if (m_pUASheet == NULL) {
+ if (!m_pUASheet) {
m_pUASheet = LoadDefaultSheetStyle();
m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet);
m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL);
@@ -138,22 +112,22 @@ IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle(
FDE_CSSLENGTH indent;
indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent());
pParaStyle->SetTextIndent(indent);
- FDE_CSSTEXTALIGN hAlgin = FDE_CSSTEXTALIGN_Left;
+ FDE_CSSTEXTALIGN hAlign = FDE_CSSTEXTALIGN_Left;
switch (para.GetHorizontalAlign()) {
case XFA_ATTRIBUTEENUM_Center:
- hAlgin = FDE_CSSTEXTALIGN_Center;
+ hAlign = FDE_CSSTEXTALIGN_Center;
break;
case XFA_ATTRIBUTEENUM_Right:
- hAlgin = FDE_CSSTEXTALIGN_Right;
+ hAlign = FDE_CSSTEXTALIGN_Right;
break;
case XFA_ATTRIBUTEENUM_Justify:
- hAlgin = FDE_CSSTEXTALIGN_Justify;
+ hAlign = FDE_CSSTEXTALIGN_Justify;
break;
case XFA_ATTRIBUTEENUM_JustifyAll:
- hAlgin = FDE_CSSTEXTALIGN_JustifyAll;
+ hAlign = FDE_CSSTEXTALIGN_JustifyAll;
break;
}
- pParaStyle->SetTextAlign(hAlgin);
+ pParaStyle->SetTextAlign(hAlign);
FDE_CSSRECT rtMarginWidth;
rtMarginWidth.left.Set(FDE_CSSLENGTHUNIT_Point, para.GetMarginLeft());
rtMarginWidth.top.Set(FDE_CSSLENGTHUNIT_Point, para.GetSpaceAbove());
@@ -191,7 +165,7 @@ IFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle(
IFDE_CSSComputedStyle* pParentStyle) {
IFDE_CSSComputedStyle* pNewStyle =
m_pSelector->CreateComputedStyle(pParentStyle);
- FXSYS_assert(pNewStyle);
+ ASSERT(pNewStyle);
if (pParentStyle) {
IFDE_CSSParagraphStyle* pParaStyle = pParentStyle->GetParagraphStyles();
uint32_t dwDecoration = pParaStyle->GetTextDecoration();
@@ -225,7 +199,7 @@ IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle(
if (tagProvider.m_bContent)
return nullptr;
IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle);
- IFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
+ CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
pCSSAccel->OnEnterTag(&tagProvider);
m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(),
pContext->CountDecls(), pStyle);
@@ -237,8 +211,8 @@ void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer,
if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) {
return;
}
- m_pAllocator =
- FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 32, sizeof(CXFA_CSSTagProvider));
+ m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32,
+ sizeof(CXFA_CSSTagProvider));
InitCSSData(pTextProvider);
IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider);
ParseRichText(pXMLContainer, pRootStyle);
@@ -262,13 +236,13 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline;
if (!tagProvider.m_bContent) {
pNewStyle = CreateStyle(pParentStyle);
- IFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
+ CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
pCSSAccel->OnEnterTag(&tagProvider);
CFDE_CSSDeclarationArray DeclArray;
int32_t iMatchedDecls =
m_pSelector->MatchDeclarations(&tagProvider, DeclArray);
- const IFDE_CSSDeclaration** ppMatchDecls =
- (const IFDE_CSSDeclaration**)DeclArray.GetData();
+ const CFDE_CSSDeclaration** ppMatchDecls =
+ const_cast<const CFDE_CSSDeclaration**>(DeclArray.GetData());
m_pSelector->ComputeStyle(&tagProvider, ppMatchDecls, iMatchedDecls,
pNewStyle);
pCSSAccel->OnLeaveTag(&tagProvider);
@@ -301,16 +275,15 @@ void CXFA_TextParser::ParseTagInfo(CFDE_XMLNode* pXMLNode,
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
pXMLElement->GetLocalTagName(wsName);
tagProvider.SetTagNameObj(wsName);
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsName, wsName.GetLength(), TRUE);
+ uint32_t dwHashCode = FX_HashCode_GetW(wsName.AsStringC(), true);
static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t);
CFX_DSPATemplate<uint32_t> lookup;
tagProvider.m_bTagAviliable =
lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1;
CFX_WideString wsValue;
- pXMLElement->GetString(FX_WSTRC(L"style").raw_str(), wsValue);
+ pXMLElement->GetString(L"style", wsValue);
if (!wsValue.IsEmpty()) {
- tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue);
+ tagProvider.SetAttribute(L"style", wsValue);
}
} else if (pXMLNode->GetType() == FDE_XMLNODE_Text) {
tagProvider.m_bTagAviliable = TRUE;
@@ -318,7 +291,7 @@ void CXFA_TextParser::ParseTagInfo(CFDE_XMLNode* pXMLNode,
}
}
-int32_t CXFA_TextParser::GetVAlgin(CXFA_TextProvider* pTextProvider) const {
+int32_t CXFA_TextParser::GetVAlign(CXFA_TextProvider* pTextProvider) const {
CXFA_Para para = pTextProvider->GetParaNode();
return para ? para.GetVerticalAlign() : XFA_ATTRIBUTEENUM_Top;
}
@@ -326,7 +299,7 @@ int32_t CXFA_TextParser::GetVAlgin(CXFA_TextProvider* pTextProvider) const {
FX_FLOAT CXFA_TextParser::GetTabInterval(IFDE_CSSComputedStyle* pStyle) const {
CFX_WideString wsValue;
if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"tab-interval"), wsValue))
- return CXFA_Measurement(wsValue.AsWideStringC()).ToUnit(XFA_UNIT_Pt);
+ return CXFA_Measurement(wsValue.AsStringC()).ToUnit(XFA_UNIT_Pt);
return 36;
}
@@ -516,7 +489,7 @@ FX_FLOAT CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider,
FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
CFDE_XMLNode* pXMLNode,
CFX_WideString& wsValue) {
- wsValue.Empty();
+ wsValue.clear();
if (pXMLNode == NULL) {
return FALSE;
}
@@ -524,7 +497,7 @@ FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode);
CFX_WideString wsAttr;
- pElement->GetString(FX_WSTRC(L"xfa:embed").raw_str(), wsAttr);
+ pElement->GetString(L"xfa:embed", wsAttr);
if (wsAttr.IsEmpty()) {
return FALSE;
}
@@ -532,7 +505,7 @@ FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
wsAttr.Delete(0);
}
CFX_WideString ws;
- pElement->GetString(FX_WSTRC(L"xfa:embedType").raw_str(), ws);
+ pElement->GetString(L"xfa:embedType", ws);
if (ws.IsEmpty()) {
ws = L"som";
} else {
@@ -542,8 +515,8 @@ FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider,
if (!bURI && ws != FX_WSTRC(L"som")) {
return FALSE;
}
- ws.Empty();
- pElement->GetString(FX_WSTRC(L"xfa:embedMode").raw_str(), ws);
+ ws.clear();
+ pElement->GetString(L"xfa:embedMode", ws);
if (ws.IsEmpty()) {
ws = L"formatted";
} else {
@@ -583,7 +556,7 @@ FX_BOOL CXFA_TextParser::GetTabstops(
return FALSE;
}
int32_t iLength = wsValue.GetLength();
- const FX_WCHAR* pTabStops = wsValue;
+ const FX_WCHAR* pTabStops = wsValue.c_str();
int32_t iCur = 0;
int32_t iLast = 0;
CFX_WideString wsAlign;
@@ -639,12 +612,11 @@ FX_BOOL CXFA_TextParser::GetTabstops(
break;
case XFA_TABSTOPSSTATUS_Location:
if (ch == ' ') {
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE);
+ uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringC(), true);
CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast));
FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt);
pTabstopContext->Append(dwHashCode, fPos);
- wsAlign.Empty();
+ wsAlign.clear();
eStatus = XFA_TABSTOPSSTATUS_None;
}
iCur++;
@@ -654,8 +626,7 @@ FX_BOOL CXFA_TextParser::GetTabstops(
}
}
if (!wsAlign.IsEmpty()) {
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE);
+ uint32_t dwHashCode = FX_HashCode_GetW(wsAlign.AsStringC(), true);
CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast));
FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt);
pTabstopContext->Append(dwHashCode, fPos);
@@ -674,7 +645,7 @@ CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider)
m_fMaxWidth(0),
m_pTabstopContext(nullptr),
m_bBlockContinue(TRUE) {
- FXSYS_assert(m_pTextProvider);
+ ASSERT(m_pTextProvider);
}
CXFA_TextLayout::~CXFA_TextLayout() {
m_textParser.Reset();
@@ -693,10 +664,8 @@ void CXFA_TextLayout::Unload() {
m_pBreak->Release();
m_pBreak = NULL;
}
- if (m_pAllocator) {
- m_pAllocator->Release();
- m_pAllocator = NULL;
- }
+ delete m_pAllocator;
+ m_pAllocator = nullptr;
}
const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() {
return &m_pieceLines;
@@ -735,12 +704,12 @@ CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() {
}
return pXMLContainer;
}
-IFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) {
+CFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) {
uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab;
if (!bDefault) {
dwStyle |= FX_RTFLAYOUTSTYLE_Pagination;
}
- IFX_RTFBreak* pBreak = IFX_RTFBreak::Create(0);
+ CFX_RTFBreak* pBreak = new CFX_RTFBreak(0);
pBreak->SetLayoutStyles(dwStyle);
pBreak->SetLineBreakChar(L'\n');
pBreak->SetLineBreakTolerance(1);
@@ -887,7 +856,7 @@ void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle,
}
int32_t CXFA_TextLayout::GetText(CFX_WideString& wsText) {
GetTextDataNode();
- wsText.Empty();
+ wsText.clear();
if (m_bRichText) {
} else {
wsText = m_pTextDataNode->GetContent();
@@ -960,7 +929,7 @@ FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex,
if (iBlockCount == 0 && fHeight > 0) {
fHeight = fTextHeight - GetLayoutHeight();
if (fHeight > 0) {
- int32_t iAlign = m_textParser.GetVAlgin(m_pTextProvider);
+ int32_t iAlign = m_textParser.GetVAlign(m_pTextProvider);
if (iAlign == XFA_ATTRIBUTEENUM_Middle) {
fHeight /= 2.0f;
} else if (iAlign != XFA_ATTRIBUTEENUM_Bottom) {
@@ -1024,6 +993,7 @@ int32_t CXFA_TextLayout::CountBlocks() const {
int32_t iCount = m_Blocks.GetSize() / 2;
return iCount > 0 ? iCount : 1;
}
+
FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize,
const CFX_SizeF& maxSize,
CFX_SizeF& defaultSize) {
@@ -1042,13 +1012,12 @@ FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize,
if (fLinePos < 0.1f) {
fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL);
}
- if (m_pTabstopContext) {
- delete m_pTabstopContext;
- m_pTabstopContext = NULL;
- }
+ delete m_pTabstopContext;
+ m_pTabstopContext = nullptr;
defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos);
return TRUE;
}
+
FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) {
if (size.x < 1) {
return FALSE;
@@ -1063,15 +1032,13 @@ FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) {
FX_FLOAT fLinePos = 0;
Loader(size, fLinePos, TRUE);
UpdateAlign(size.y, fLinePos);
- if (m_pTabstopContext) {
- delete m_pTabstopContext;
- m_pTabstopContext = NULL;
- }
- if (fHeight) {
+ delete m_pTabstopContext;
+ m_pTabstopContext = nullptr;
+ if (fHeight)
*fHeight = fLinePos;
- }
return TRUE;
}
+
FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) {
if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) {
return FALSE;
@@ -1215,18 +1182,16 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice,
const CFX_Matrix& tmDoc2Device,
const CFX_RectF& rtClip,
int32_t iBlock) {
- IFDE_RenderDevice* pDevice = IFDE_RenderDevice::Create(pFxDevice);
- if (pDevice == NULL) {
+ if (!pFxDevice)
return FALSE;
- }
+
+ std::unique_ptr<CFDE_RenderDevice> pDevice(
+ new CFDE_RenderDevice(pFxDevice, FALSE));
FDE_HDEVICESTATE state = pDevice->SaveState();
pDevice->SetClipRect(rtClip);
- IFDE_SolidBrush* pSolidBrush =
- (IFDE_SolidBrush*)IFDE_Brush::Create(FDE_BRUSHTYPE_Solid);
- IFDE_Pen* pPen = IFDE_Pen::Create();
- FXSYS_assert(pDevice);
- FXSYS_assert(pSolidBrush);
- FXSYS_assert(pPen);
+
+ std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush);
+ std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen);
if (m_pieceLines.GetSize() == 0) {
int32_t iBlockCount = CountBlocks();
for (int32_t i = 0; i < iBlockCount; i++) {
@@ -1263,17 +1228,16 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice,
iCharCount = iChars;
}
FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS));
- RenderString(pDevice, pSolidBrush, pPieceLine, j, pCharPos, tmDoc2Device);
+ RenderString(pDevice.get(), pSolidBrush.get(), pPieceLine, j, pCharPos,
+ tmDoc2Device);
}
for (j = 0; j < iPieces; j++) {
- RenderPath(pDevice, pPen, pPieceLine, j, pCharPos, tmDoc2Device);
+ RenderPath(pDevice.get(), pPen.get(), pPieceLine, j, pCharPos,
+ tmDoc2Device);
}
}
pDevice->RestoreState(state);
FX_Free(pCharPos);
- pSolidBrush->Release();
- pPen->Release();
- pDevice->Release();
return iPieceLines;
}
void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) {
@@ -1281,7 +1245,7 @@ void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) {
if (fHeight < 0.1f) {
return;
}
- switch (m_textParser.GetVAlgin(m_pTextProvider)) {
+ switch (m_textParser.GetVAlign(m_pTextProvider)) {
case XFA_ATTRIBUTEENUM_Middle:
fHeight /= 2.0f;
break;
@@ -1304,9 +1268,9 @@ void CXFA_TextLayout::UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom) {
FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText,
FX_FLOAT& fLinePos,
FX_BOOL bSavePieces) {
- if (m_pAllocator == NULL) {
- m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 256, 0);
- }
+ if (!m_pAllocator)
+ m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0);
+
GetTextDataNode();
if (m_pTextDataNode == NULL) {
return TRUE;
@@ -1421,8 +1385,8 @@ FX_BOOL CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode,
}
if (wsName == FX_WSTRC(L"a")) {
CFX_WideString wsLinkContent;
- FXSYS_assert(pElement);
- pElement->GetString(FX_WSTRC(L"href").raw_str(), wsLinkContent);
+ ASSERT(pElement);
+ pElement->GetString(L"href", wsLinkContent);
if (!wsLinkContent.IsEmpty()) {
pLinkData = FXTARGET_NewWith(m_pAllocator) CXFA_LinkUserData(
m_pAllocator,
@@ -1671,13 +1635,13 @@ void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle,
if (m_pTabstopContext->m_bTabstops) {
XFA_TABSTOPS* pTabstops =
m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex);
- uint32_t dwAlgin = pTabstops->dwAlign;
- if (dwAlgin == FX_HashCode_String_GetW(L"center", 6)) {
+ uint32_t dwAlign = pTabstops->dwAlign;
+ if (dwAlign == FX_HashCode_GetW(L"center", false)) {
fLeft = pPiece->rtPiece.width / 2.0f;
- } else if (dwAlgin == FX_HashCode_String_GetW(L"right", 5) ||
- dwAlgin == FX_HashCode_String_GetW(L"before", 6)) {
+ } else if (dwAlign == FX_HashCode_GetW(L"right", false) ||
+ dwAlign == FX_HashCode_GetW(L"before", false)) {
fLeft = pPiece->rtPiece.width;
- } else if (dwAlgin == FX_HashCode_String_GetW(L"decimal", 7)) {
+ } else if (dwAlign == FX_HashCode_GetW(L"decimal", false)) {
int32_t iChars = pPiece->iChars;
for (int32_t i = 0; i < iChars; i++) {
if (pPiece->pszText[i] == L'.') {
@@ -1839,8 +1803,8 @@ void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus,
}
m_iLines++;
}
-void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice,
- IFDE_SolidBrush* pBrush,
+void CXFA_TextLayout::RenderString(CFDE_RenderDevice* pDevice,
+ CFDE_Brush* pBrush,
CXFA_PieceLine* pPieceLine,
int32_t iPiece,
FXTEXT_CHARPOS* pCharPos,
@@ -1854,8 +1818,9 @@ void CXFA_TextLayout::RenderString(IFDE_RenderDevice* pDevice,
}
pPieceLine->m_charCounts.Add(iCount);
}
-void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice,
- IFDE_Pen* pPen,
+
+void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice,
+ CFDE_Pen* pPen,
CXFA_PieceLine* pPieceLine,
int32_t iPiece,
FXTEXT_CHARPOS* pCharPos,
@@ -1867,7 +1832,7 @@ void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice,
return;
}
pPen->SetColor(pPiece->dwColor);
- IFDE_Path* pPath = IFDE_Path::Create();
+ std::unique_ptr<CFDE_Path> pPath(new CFDE_Path);
int32_t iChars = GetDisplayPos(pPiece, pCharPos);
if (iChars > 0) {
CFX_PointF pt1, pt2;
@@ -1907,7 +1872,7 @@ void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice,
} else {
if (bNoLineThrough &&
(bNoUnderline || pPiece->iPeriod != XFA_ATTRIBUTEENUM_All)) {
- goto XFA_RenderPathRet;
+ return;
}
int32_t iCharsTmp = 0;
int32_t iPiecePrev = iPiece, iPieceNext = iPiece;
@@ -1919,7 +1884,7 @@ void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice,
}
}
if (iCharsTmp == 0) {
- goto XFA_RenderPathRet;
+ return;
}
iCharsTmp = 0;
int32_t iPieces = pPieceLine->m_textPieces.GetSize();
@@ -1931,20 +1896,20 @@ void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice,
}
}
if (iCharsTmp == 0) {
- goto XFA_RenderPathRet;
+ return;
}
FX_FLOAT fOrgX = 0.0f, fEndX = 0.0f;
pPiece = pPieceLine->m_textPieces.GetAt(iPiecePrev);
iChars = GetDisplayPos(pPiece, pCharPos);
if (iChars < 1) {
- goto XFA_RenderPathRet;
+ return;
}
fOrgX = pCharPos[iChars - 1].m_OriginX +
pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f;
pPiece = pPieceLine->m_textPieces.GetAt(iPieceNext);
iChars = GetDisplayPos(pPiece, pCharPos);
if (iChars < 1) {
- goto XFA_RenderPathRet;
+ return;
}
fEndX = pCharPos[0].m_OriginX;
CFX_PointF pt1, pt2;
@@ -1963,10 +1928,9 @@ void CXFA_TextLayout::RenderPath(IFDE_RenderDevice* pDevice,
fEndY += 2.0f;
}
}
- pDevice->DrawPath(pPen, 1, pPath, &tmDoc2Device);
-XFA_RenderPathRet:
- pPath->Release();
+ pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device);
}
+
int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece,
FXTEXT_CHARPOS* pCharPos,
FX_BOOL bCharCode) {
diff --git a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.h b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.h
index d92a2f40586..4d03aee3021 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/app/xfa_textlayout.h
@@ -7,42 +7,48 @@
#ifndef XFA_FXFA_APP_XFA_TEXTLAYOUT_H_
#define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_
+#include <map>
+#include <memory>
+
#include "xfa/fde/css/fde_css.h"
-#include "xfa/fde/fde_brush.h"
-#include "xfa/fde/fde_renderdevice.h"
+#include "xfa/fde/fde_gedevice.h"
#include "xfa/fgas/layout/fgas_rtfbreak.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
#include "xfa/fxfa/parser/xfa_object.h"
-#include "xfa/include/fxfa/xfa_ffdoc.h"
#define XFA_LOADERCNTXTFLG_FILTERSPACE 0x001
+class CFDE_CSSStyleSelector;
class CXFA_Para;
class CXFA_Font;
class CXFA_TextProvider;
class CXFA_TextTabstopsContext;
-class CXFA_CSSTagProvider : public IFDE_CSSTagProvider {
+class CXFA_CSSTagProvider {
public:
CXFA_CSSTagProvider() : m_bTagAviliable(FALSE), m_bContent(FALSE) {}
- virtual ~CXFA_CSSTagProvider();
+ ~CXFA_CSSTagProvider() {}
+
+ CFX_WideString GetTagName() { return m_wsTagName; }
+
+ using AttributeMap = std::map<CFX_WideString, CFX_WideString>;
+ AttributeMap::iterator begin() { return m_Attributes.begin(); }
+ AttributeMap::iterator end() { return m_Attributes.end(); }
+
+ bool empty() const { return m_Attributes.empty(); }
- // Note: |this| must outlive the use of GetTagName()'s result.
- virtual CFX_WideStringC GetTagName() { return m_wsTagName.AsWideStringC(); }
- virtual FX_POSITION GetFirstAttribute() {
- return m_Attributes.GetStartPosition();
- }
- virtual void GetNextAttribute(FX_POSITION& pos,
- CFX_WideStringC& wsAttr,
- CFX_WideStringC& wsValue);
void SetTagNameObj(const CFX_WideString& wsName) { m_wsTagName = wsName; }
void SetAttribute(const CFX_WideString& wsAttr,
- const CFX_WideString& wsValue);
+ const CFX_WideString& wsValue) {
+ m_Attributes.insert({wsAttr, wsValue});
+ }
+
FX_BOOL m_bTagAviliable;
FX_BOOL m_bContent;
protected:
CFX_WideString m_wsTagName;
- CFX_MapPtrToPtr m_Attributes;
+ AttributeMap m_Attributes;
};
class CXFA_TextParseContext : public CFX_Target {
@@ -59,22 +65,22 @@ class CXFA_TextParseContext : public CFX_Target {
}
void SetDisplay(FDE_CSSDISPLAY eDisplay) { m_eDisplay = eDisplay; }
FDE_CSSDISPLAY GetDisplay() const { return m_eDisplay; }
- void SetDecls(const IFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount);
- const IFDE_CSSDeclaration** GetDecls() {
- return (const IFDE_CSSDeclaration**)m_ppMatchedDecls;
+ void SetDecls(const CFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount);
+ const CFDE_CSSDeclaration** GetDecls() {
+ return const_cast<const CFDE_CSSDeclaration**>(m_ppMatchedDecls);
}
uint32_t CountDecls() const { return m_dwMatchedDecls; }
IFDE_CSSComputedStyle* m_pParentStyle;
protected:
- IFDE_CSSDeclaration** m_ppMatchedDecls;
+ CFDE_CSSDeclaration** m_ppMatchedDecls;
uint32_t m_dwMatchedDecls;
FDE_CSSDISPLAY m_eDisplay;
};
class CXFA_TextParser {
public:
- CXFA_TextParser() : m_pAllocator(NULL), m_pSelector(NULL), m_pUASheet(NULL) {}
+ CXFA_TextParser();
virtual ~CXFA_TextParser();
void Reset();
void DoParse(CFDE_XMLNode* pXMLContainer, CXFA_TextProvider* pTextProvider);
@@ -83,7 +89,7 @@ class CXFA_TextParser {
IFDE_CSSComputedStyle* pParentStyle);
FX_BOOL IsParsed() const { return m_pAllocator != NULL; }
- int32_t GetVAlgin(CXFA_TextProvider* pTextProvider) const;
+ int32_t GetVAlign(CXFA_TextProvider* pTextProvider) const;
FX_FLOAT GetTabInterval(IFDE_CSSComputedStyle* pStyle) const;
int32_t CountTabs(IFDE_CSSComputedStyle* pStyle) const;
FX_BOOL IsSpaceRun(IFDE_CSSComputedStyle* pStyle) const;
@@ -125,8 +131,8 @@ class CXFA_TextParser {
void ParseTagInfo(CFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider);
IFDE_CSSStyleSheet* LoadDefaultSheetStyle();
IFDE_CSSComputedStyle* CreateStyle(IFDE_CSSComputedStyle* pParentStyle);
- IFX_MEMAllocator* m_pAllocator;
- IFDE_CSSStyleSelector* m_pSelector;
+ IFX_MemoryAllocator* m_pAllocator;
+ std::unique_ptr<CFDE_CSSStyleSelector> m_pSelector;
IFDE_CSSStyleSheet* m_pUASheet;
CFX_MapPtrTemplate<CFDE_XMLNode*, CXFA_TextParseContext*>
m_mapXMLNodeToParseContext;
@@ -164,7 +170,7 @@ class CXFA_LoaderContext {
class CXFA_LinkUserData : public IFX_Unknown, public CFX_Target {
public:
- CXFA_LinkUserData(IFX_MEMAllocator* pAllocator, FX_WCHAR* pszText)
+ CXFA_LinkUserData(IFX_MemoryAllocator* pAllocator, FX_WCHAR* pszText)
: m_pAllocator(pAllocator), m_dwRefCount(1) {
m_pszURLContent = pszText;
}
@@ -178,34 +184,34 @@ class CXFA_LinkUserData : public IFX_Unknown, public CFX_Target {
}
virtual uint32_t AddRef() { return ++m_dwRefCount; }
- public:
- const FX_WCHAR* GetLinkURL() { return m_pszURLContent; }
+ const FX_WCHAR* GetLinkURL() { return m_pszURLContent.c_str(); }
protected:
- IFX_MEMAllocator* m_pAllocator;
+ IFX_MemoryAllocator* m_pAllocator;
uint32_t m_dwRefCount;
CFX_WideString m_pszURLContent;
};
class CXFA_TextUserData : public IFX_Unknown, public CFX_Target {
public:
- CXFA_TextUserData(IFX_MEMAllocator* pAllocator, IFDE_CSSComputedStyle* pStyle)
+ CXFA_TextUserData(IFX_MemoryAllocator* pAllocator,
+ IFDE_CSSComputedStyle* pStyle)
: m_pStyle(pStyle),
m_pLinkData(nullptr),
m_pAllocator(pAllocator),
m_dwRefCount(0) {
- FXSYS_assert(m_pAllocator);
+ ASSERT(m_pAllocator);
if (m_pStyle)
m_pStyle->AddRef();
}
- CXFA_TextUserData(IFX_MEMAllocator* pAllocator,
+ CXFA_TextUserData(IFX_MemoryAllocator* pAllocator,
IFDE_CSSComputedStyle* pStyle,
CXFA_LinkUserData* pLinkData)
: m_pStyle(pStyle),
m_pLinkData(pLinkData),
m_pAllocator(pAllocator),
m_dwRefCount(0) {
- FXSYS_assert(m_pAllocator);
+ ASSERT(m_pAllocator);
if (m_pStyle)
m_pStyle->AddRef();
}
@@ -228,7 +234,7 @@ class CXFA_TextUserData : public IFX_Unknown, public CFX_Target {
CXFA_LinkUserData* m_pLinkData;
protected:
- IFX_MEMAllocator* m_pAllocator;
+ IFX_MemoryAllocator* m_pAllocator;
uint32_t m_dwRefCount;
};
@@ -342,7 +348,7 @@ class CXFA_TextLayout {
private:
void GetTextDataNode();
CFDE_XMLNode* GetXMLContainerNode();
- IFX_RTFBreak* CreateBreak(FX_BOOL bDefault);
+ CFX_RTFBreak* CreateBreak(FX_BOOL bDefault);
void InitBreak(FX_FLOAT fLineWidth);
void InitBreak(IFDE_CSSComputedStyle* pStyle,
FDE_CSSDISPLAY eDisplay,
@@ -377,14 +383,14 @@ class CXFA_TextLayout {
FX_BOOL IsEnd(FX_BOOL bSavePieces);
void ProcessText(CFX_WideString& wsText);
void UpdateAlign(FX_FLOAT fHeight, FX_FLOAT fBottom);
- void RenderString(IFDE_RenderDevice* pDevice,
- IFDE_SolidBrush* pBrush,
+ void RenderString(CFDE_RenderDevice* pDevice,
+ CFDE_Brush* pBrush,
CXFA_PieceLine* pPieceLine,
int32_t iPiece,
FXTEXT_CHARPOS* pCharPos,
const CFX_Matrix& tmDoc2Device);
- void RenderPath(IFDE_RenderDevice* pDevice,
- IFDE_Pen* pPen,
+ void RenderPath(CFDE_RenderDevice* pDevice,
+ CFDE_Pen* pPen,
CXFA_PieceLine* pPieceLine,
int32_t iPiece,
FXTEXT_CHARPOS* pCharPos,
@@ -400,8 +406,8 @@ class CXFA_TextLayout {
CXFA_TextProvider* m_pTextProvider;
CXFA_Node* m_pTextDataNode;
FX_BOOL m_bRichText;
- IFX_MEMAllocator* m_pAllocator;
- IFX_RTFBreak* m_pBreak;
+ IFX_MemoryAllocator* m_pAllocator;
+ CFX_RTFBreak* m_pBreak;
CXFA_LoaderContext* m_pLoader;
int32_t m_iLines;
FX_FLOAT m_fMaxWidth;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.cpp b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.cpp
index 69ce6083189..020d9bc5091 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.cpp
@@ -6,16 +6,12 @@
#include "xfa/fxfa/fm2js/xfa_error.h"
-static const FX_WCHAR* const gs_lpStrErrorMsgInfo[] = {
- L"unsupported char '%c'", L"bad suffix on number",
- L"invalidate char '%c'", L"expected identifier instead of '%s'",
- L"expected '%s' instead of '%s'", L"expected 'endif' instead of '%s'",
- L"unexpected expression '%s'", L"expected operator '%s' instead of '%s'",
- L"expected non-empty expression",
-};
-
-const FX_WCHAR* XFA_FM_ErrorMsg(XFA_FM_ERRMSG msg) {
- if (msg < FMERR_MAXIMUM)
- return gs_lpStrErrorMsgInfo[msg];
- return L"";
-}
+const FX_WCHAR kFMErrUnsupportedChar[] = L"unsupported char '%c'";
+const FX_WCHAR kFMErrBadSuffixNumber[] = L"bad suffix on number";
+const FX_WCHAR kFMErrExpectedIdentifier[] =
+ L"expected identifier instead of '%s'";
+const FX_WCHAR kFMErrExpectedToken[] = L"expected '%s' instead of '%s'";
+const FX_WCHAR kFMErrExpectedEndIf[] = L"expected 'endif' instead of '%s'";
+const FX_WCHAR kFMErrUnexpectedExpression[] = L"unexpected expression '%s'";
+const FX_WCHAR kFMErrExpectedNonEmptyExpression[] =
+ L"expected non-empty expression";
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.h b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.h
index 2415cd32126..6ce102e03eb 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_error.h
@@ -10,18 +10,13 @@
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-enum XFA_FM_ERRMSG {
- FMERR_UNSUPPORTED_CHAR,
- FMERR_BAD_SUFFIX_NUMBER,
- FMERR_INVALIDATE_CHAR,
- FMERR_EXPECTED_IDENTIFIER,
- FMERR_EXPECTED_TOKEN,
- FMERR_EXPECTED_IFEND,
- FMERR_UNEXPECTED_EXPRESSION,
- FMERR_EXPTECTED_OPERATOR,
- FMERR_EXPECTED_NON_EMPTY_EXPRESSION,
- FMERR_MAXIMUM
-};
+extern const FX_WCHAR kFMErrUnsupportedChar[];
+extern const FX_WCHAR kFMErrBadSuffixNumber[];
+extern const FX_WCHAR kFMErrExpectedIdentifier[];
+extern const FX_WCHAR kFMErrExpectedToken[];
+extern const FX_WCHAR kFMErrExpectedEndIf[];
+extern const FX_WCHAR kFMErrUnexpectedExpression[];
+extern const FX_WCHAR kFMErrExpectedNonEmptyExpression[];
class CXFA_FMErrorInfo {
public:
@@ -30,6 +25,5 @@ class CXFA_FMErrorInfo {
uint32_t linenum;
CFX_WideString message;
};
-const FX_WCHAR* XFA_FM_ErrorMsg(XFA_FM_ERRMSG msg);
#endif // XFA_FXFA_FM2JS_XFA_ERROR_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.cpp b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.cpp
index be9fb09c0d3..72020c3f0c7 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.cpp
@@ -33,7 +33,7 @@ CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition(
FX_BOOL isGlobal,
const CFX_WideStringC& wsName,
CFX_WideStringCArray* pArguments,
- CFX_PtrArray* pExpressions)
+ CFX_ArrayTemplate<CXFA_FMExpression*>* pExpressions)
: CXFA_FMExpression(line, XFA_FM_EXPTYPE_FUNC),
m_wsName(wsName),
m_pArguments(pArguments),
@@ -41,15 +41,11 @@ CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition(
m_isGlobal(isGlobal) {}
CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() {
- if (m_pArguments) {
- m_pArguments->RemoveAll();
- delete m_pArguments;
- }
+ delete m_pArguments;
if (m_pExpressions) {
- for (int i = 0; i < m_pExpressions->GetSize(); ++i) {
- delete reinterpret_cast<CXFA_FMExpression*>(m_pExpressions->GetAt(i));
- }
- m_pExpressions->RemoveAll();
+ for (int i = 0; i < m_pExpressions->GetSize(); ++i)
+ delete m_pExpressions->GetAt(i);
+
delete m_pExpressions;
}
}
@@ -92,8 +88,7 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L" = null;\n");
if (m_pExpressions) {
for (int i = 0; i < m_pExpressions->GetSize(); ++i) {
- CXFA_FMExpression* e =
- reinterpret_cast<CXFA_FMExpression*>(m_pExpressions->GetAt(i));
+ CXFA_FMExpression* e = m_pExpressions->GetAt(i);
if (i + 1 < m_pExpressions->GetSize()) {
e->ToJavaScript(javascript);
} else {
@@ -127,7 +122,7 @@ CXFA_FMVarExpression::CXFA_FMVarExpression(uint32_t line,
void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"var ");
- CFX_WideString tempName = m_wsName;
+ CFX_WideString tempName(m_wsName);
if (m_wsName.GetAt(0) == L'!') {
tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1);
}
@@ -148,7 +143,7 @@ void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"var ");
- CFX_WideString tempName = m_wsName;
+ CFX_WideString tempName(m_wsName);
if (m_wsName.GetAt(0) == L'!') {
tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1);
}
@@ -208,17 +203,17 @@ void CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
}
}
-CXFA_FMBlockExpression::CXFA_FMBlockExpression(uint32_t line,
- CFX_PtrArray* pExpressionList)
+CXFA_FMBlockExpression::CXFA_FMBlockExpression(
+ uint32_t line,
+ CFX_ArrayTemplate<CXFA_FMExpression*>* pExpressionList)
: CXFA_FMExpression(line, XFA_FM_EXPTYPE_BLOCK),
m_pExpressionList(pExpressionList) {}
CXFA_FMBlockExpression::~CXFA_FMBlockExpression() {
if (m_pExpressionList) {
- for (int i = 0; i < m_pExpressionList->GetSize(); ++i) {
- delete reinterpret_cast<CXFA_FMExpression*>(m_pExpressionList->GetAt(i));
- }
- m_pExpressionList->RemoveAll();
+ for (int i = 0; i < m_pExpressionList->GetSize(); ++i)
+ delete m_pExpressionList->GetAt(i);
+
delete m_pExpressionList;
}
}
@@ -226,11 +221,8 @@ CXFA_FMBlockExpression::~CXFA_FMBlockExpression() {
void CXFA_FMBlockExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"{\n");
if (m_pExpressionList) {
- for (int i = 0; i < m_pExpressionList->GetSize(); ++i) {
- CXFA_FMExpression* e =
- reinterpret_cast<CXFA_FMExpression*>(m_pExpressionList->GetAt(i));
- e->ToJavaScript(javascript);
- }
+ for (int i = 0; i < m_pExpressionList->GetSize(); ++i)
+ m_pExpressionList->GetAt(i)->ToJavaScript(javascript);
}
javascript << FX_WSTRC(L"}\n");
}
@@ -239,8 +231,7 @@ void CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"{\n");
if (m_pExpressionList) {
for (int i = 0; i < m_pExpressionList->GetSize(); ++i) {
- CXFA_FMExpression* e =
- reinterpret_cast<CXFA_FMExpression*>(m_pExpressionList->GetAt(i));
+ CXFA_FMExpression* e = m_pExpressionList->GetAt(i);
if (i + 1 == m_pExpressionList->GetSize()) {
e->ToImpliedReturnJS(javascript);
} else {
@@ -506,7 +497,7 @@ void CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMForeachExpression::CXFA_FMForeachExpression(
uint32_t line,
const CFX_WideStringC& wsIdentifier,
- CFX_PtrArray* pAccessors,
+ CFX_ArrayTemplate<CXFA_FMSimpleExpression*>* pAccessors,
CXFA_FMExpression* pList)
: CXFA_FMLoopExpression(line),
m_wsIdentifier(wsIdentifier),
@@ -515,10 +506,9 @@ CXFA_FMForeachExpression::CXFA_FMForeachExpression(
CXFA_FMForeachExpression::~CXFA_FMForeachExpression() {
if (m_pAccessors) {
- for (int i = 0; i < m_pAccessors->GetSize(); ++i) {
- delete reinterpret_cast<CXFA_FMSimpleExpression*>(m_pAccessors->GetAt(i));
- }
- m_pAccessors->RemoveAll();
+ for (int i = 0; i < m_pAccessors->GetSize(); ++i)
+ m_pAccessors->GetAt(i);
+
delete m_pAccessors;
}
}
@@ -541,8 +531,7 @@ void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"(");
for (int i = 0; i < m_pAccessors->GetSize(); ++i) {
- CXFA_FMSimpleExpression* s =
- reinterpret_cast<CXFA_FMSimpleExpression*>(m_pAccessors->GetAt(i));
+ CXFA_FMSimpleExpression* s = m_pAccessors->GetAt(i);
s->ToJavaScript(javascript);
if (i + 1 < m_pAccessors->GetSize()) {
javascript << FX_WSTRC(L", ");
@@ -593,8 +582,7 @@ void CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << XFA_FM_EXPTypeToString(CONCATFMOBJECT);
javascript << FX_WSTRC(L"(");
for (int i = 0; i < m_pAccessors->GetSize(); ++i) {
- CXFA_FMSimpleExpression* s =
- reinterpret_cast<CXFA_FMSimpleExpression*>(m_pAccessors->GetAt(i));
+ CXFA_FMSimpleExpression* s = m_pAccessors->GetAt(i);
s->ToJavaScript(javascript);
if (i + 1 < m_pAccessors->GetSize()) {
javascript << FX_WSTRC(L", ");
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.h b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.h
index 9bd0c9b89f0..ff898a9c419 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_expression.h
@@ -39,19 +39,22 @@ class CXFA_FMExpression {
class CXFA_FMFunctionDefinition : public CXFA_FMExpression {
public:
- CXFA_FMFunctionDefinition(uint32_t line,
- FX_BOOL isGlobal,
- const CFX_WideStringC& wsName,
- CFX_WideStringCArray* pArguments,
- CFX_PtrArray* pExpressions);
+ // Takes ownership of |pExpressions|.
+ CXFA_FMFunctionDefinition(
+ uint32_t line,
+ FX_BOOL isGlobal,
+ const CFX_WideStringC& wsName,
+ CFX_WideStringCArray* pArguments,
+ CFX_ArrayTemplate<CXFA_FMExpression*>* pExpressions);
~CXFA_FMFunctionDefinition() override;
+
void ToJavaScript(CFX_WideTextBuf& javascript) override;
void ToImpliedReturnJS(CFX_WideTextBuf&) override;
private:
CFX_WideStringC m_wsName;
CFX_WideStringCArray* m_pArguments;
- CFX_PtrArray* m_pExpressions;
+ CFX_ArrayTemplate<CXFA_FMExpression*>* m_pExpressions;
FX_BOOL m_isGlobal;
};
@@ -80,13 +83,17 @@ class CXFA_FMExpExpression : public CXFA_FMExpression {
class CXFA_FMBlockExpression : public CXFA_FMExpression {
public:
- CXFA_FMBlockExpression(uint32_t line, CFX_PtrArray* pExpressionList);
+ // Takes ownership of |pExpressionList|.
+ CXFA_FMBlockExpression(
+ uint32_t line,
+ CFX_ArrayTemplate<CXFA_FMExpression*>* pExpressionList);
~CXFA_FMBlockExpression() override;
+
void ToJavaScript(CFX_WideTextBuf& javascript) override;
void ToImpliedReturnJS(CFX_WideTextBuf&) override;
private:
- CFX_PtrArray* m_pExpressionList;
+ CFX_ArrayTemplate<CXFA_FMExpression*>* m_pExpressionList;
};
class CXFA_FMDoExpression : public CXFA_FMExpression {
@@ -174,17 +181,20 @@ class CXFA_FMForExpression : public CXFA_FMLoopExpression {
class CXFA_FMForeachExpression : public CXFA_FMLoopExpression {
public:
- CXFA_FMForeachExpression(uint32_t line,
- const CFX_WideStringC& wsIdentifier,
- CFX_PtrArray* pAccessors,
- CXFA_FMExpression* pList);
+ // Takes ownership of |pAccessors|.
+ CXFA_FMForeachExpression(
+ uint32_t line,
+ const CFX_WideStringC& wsIdentifier,
+ CFX_ArrayTemplate<CXFA_FMSimpleExpression*>* pAccessors,
+ CXFA_FMExpression* pList);
~CXFA_FMForeachExpression() override;
+
void ToJavaScript(CFX_WideTextBuf& javascript) override;
void ToImpliedReturnJS(CFX_WideTextBuf&) override;
private:
CFX_WideStringC m_wsIdentifier;
- CFX_PtrArray* m_pAccessors;
+ CFX_ArrayTemplate<CXFA_FMSimpleExpression*>* m_pAccessors;
std::unique_ptr<CXFA_FMExpression> m_pList;
};
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp
index 38e5f2389f1..147869dfb1e 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp
@@ -20,7 +20,7 @@ int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc,
CFX_WideString& wsError) {
if (wsFormcalc.IsEmpty()) {
wsJavascript.Clear();
- wsError.Empty();
+ wsError.clear();
return 0;
}
int32_t status = 0;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 518d233745a..e47d0af390a 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -315,8 +315,8 @@ void CXFA_FM2JSContext::Avg(FXJSE_HOBJECT hThis,
FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime);
for (int32_t j = 2; j < iLength; j++) {
FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue);
- FXJSE_Value_GetObjectProp(
- jsObjectValue, propertyStr.AsByteStringC(), newPropertyValue);
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
+ newPropertyValue);
if (!FXJSE_Value_IsNull(newPropertyValue)) {
dSum += HValueToDouble(hThis, newPropertyValue);
uCount++;
@@ -398,8 +398,8 @@ void CXFA_FM2JSContext::Count(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
for (int32_t i = 2; i < iLength; i++) {
FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue);
- FXJSE_Value_GetObjectProp(
- jsObjectValue, propertyStr.AsByteStringC(), newPropertyValue);
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
+ newPropertyValue);
uCount += (FXJSE_Value_IsNull(newPropertyValue) ? 0 : 1);
}
}
@@ -490,8 +490,8 @@ void CXFA_FM2JSContext::Max(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
for (int32_t i = 2; i < iLength; i++) {
FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue);
- FXJSE_Value_GetObjectProp(
- jsObjectValue, propertyStr.AsByteStringC(), newPropertyValue);
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
+ newPropertyValue);
if (!FXJSE_Value_IsNull(newPropertyValue)) {
uCount++;
if (uCount == 1) {
@@ -593,8 +593,8 @@ void CXFA_FM2JSContext::Min(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
for (int32_t i = 2; i < iLength; i++) {
FXJSE_Value_GetObjectPropByIdx(argValue, i, jsObjectValue);
- FXJSE_Value_GetObjectProp(
- jsObjectValue, propertyStr.AsByteStringC(), newPropertyValue);
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
+ newPropertyValue);
if (!FXJSE_Value_IsNull(newPropertyValue)) {
uCount++;
if (uCount == 1) {
@@ -679,8 +679,8 @@ void CXFA_FM2JSContext::Mod(FXJSE_HOBJECT hThis,
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime);
- FXJSE_Value_GetObjectProp(
- jsObjectValue, propertyStr.AsByteStringC(), newPropertyValue);
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
+ newPropertyValue);
dDividend = HValueToDouble(hThis, newPropertyValue);
FXJSE_Value_Release(newPropertyValue);
}
@@ -708,8 +708,8 @@ void CXFA_FM2JSContext::Mod(FXJSE_HOBJECT hThis,
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime);
- FXJSE_Value_GetObjectProp(
- jsObjectValue, propertyStr.AsByteStringC(), newPropertyValue);
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
+ newPropertyValue);
dDividor = HValueToDouble(hThis, newPropertyValue);
FXJSE_Value_Release(newPropertyValue);
}
@@ -761,7 +761,7 @@ void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis,
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime);
- FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
newPropertyValue);
dValue = HValueToDouble(hThis, newPropertyValue);
FXJSE_Value_Release(newPropertyValue);
@@ -774,7 +774,7 @@ void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis,
CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision);
CFX_WideString wsValue = decimalValue;
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- wsValue.UTF8Encode().AsByteStringC());
+ wsValue.UTF8Encode().AsStringC());
}
FXJSE_Value_Release(argOne);
} else if (argc == 2) {
@@ -795,7 +795,7 @@ void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis,
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime);
- FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
newPropertyValue);
dValue = HValueToDouble(hThis, newPropertyValue);
FXJSE_Value_Release(newPropertyValue);
@@ -817,7 +817,7 @@ void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis,
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime);
- FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
newPropertyValue);
dPrecision = HValueToDouble(hThis, newPropertyValue);
FXJSE_Value_Release(newPropertyValue);
@@ -837,7 +837,7 @@ void CXFA_FM2JSContext::Round(FXJSE_HOBJECT hThis,
CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision);
CFX_WideString wsValue = decimalValue;
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- wsValue.UTF8Encode().AsByteStringC());
+ wsValue.UTF8Encode().AsStringC());
}
FXJSE_Value_Release(argOne);
FXJSE_Value_Release(argTwo);
@@ -886,8 +886,8 @@ void CXFA_FM2JSContext::Sum(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
for (int32_t j = 2; j < iLength; j++) {
FXJSE_Value_GetObjectPropByIdx(argValue, j, jsObjectValue);
- FXJSE_Value_GetObjectProp(
- jsObjectValue, propertyStr.AsByteStringC(), newPropertyValue);
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
+ newPropertyValue);
if (!FXJSE_Value_IsNull(newPropertyValue)) {
dSum += HValueToDouble(hThis, newPropertyValue);
uCount++;
@@ -937,7 +937,7 @@ void CXFA_FM2JSContext::Date(FXJSE_HOBJECT hThis,
bufferMon.Format("%02d", pTmStruct->tm_mon + 1);
bufferDay.Format("%02d", pTmStruct->tm_mday);
CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay;
- int32_t dDays = DateString2Num(bufferCurrent.AsByteStringC());
+ int32_t dDays = DateString2Num(bufferCurrent.AsStringC());
FXJSE_Value_SetInteger(args.GetReturnValue(), dDays);
} else {
CXFA_FM2JSContext* pContext =
@@ -981,12 +981,12 @@ void CXFA_FM2JSContext::Date2Num(FXJSE_HOBJECT hThis,
}
if (!bFlags) {
CFX_ByteString szIsoDateString;
- FX_BOOL bRet = Local2IsoDate(
- hThis, dateString.AsByteStringC(), formatString.AsByteStringC(),
- localString.AsByteStringC(), szIsoDateString);
+ FX_BOOL bRet =
+ Local2IsoDate(hThis, dateString.AsStringC(), formatString.AsStringC(),
+ localString.AsStringC(), szIsoDateString);
if (bRet) {
FXJSE_Value_SetInteger(args.GetReturnValue(),
- DateString2Num(szIsoDateString.AsByteStringC()));
+ DateString2Num(szIsoDateString.AsStringC()));
} else {
FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
}
@@ -1037,12 +1037,11 @@ void CXFA_FM2JSContext::DateFmt(FXJSE_HOBJECT hThis,
}
if (!bFlags) {
CFX_ByteString formatStr;
- GetStandardDateFormat(hThis, iStyle, szLocal.AsByteStringC(), formatStr);
+ GetStandardDateFormat(hThis, iStyle, szLocal.AsStringC(), formatStr);
if (formatStr.IsEmpty()) {
formatStr = "";
}
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- formatStr.AsByteStringC());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
}
@@ -1069,7 +1068,7 @@ void CXFA_FM2JSContext::IsoDate2Num(FXJSE_HOBJECT hThis,
} else {
CFX_ByteString szArgString;
HValueToUTF8String(argOne, szArgString);
- int32_t dDays = DateString2Num(szArgString.AsByteStringC());
+ int32_t dDays = DateString2Num(szArgString.AsStringC());
FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays);
}
FXJSE_Value_Release(argOne);
@@ -1091,7 +1090,7 @@ void CXFA_FM2JSContext::IsoTime2Num(FXJSE_HOBJECT hThis,
FXJSE_Value_SetNull(args.GetReturnValue());
} else {
CXFA_Document* pDoc = pContext->GetDocument();
- FXSYS_assert(pDoc);
+ ASSERT(pDoc);
IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
CFX_ByteString szArgString;
HValueToUTF8String(argOne, szArgString);
@@ -1102,8 +1101,7 @@ void CXFA_FM2JSContext::IsoTime2Num(FXJSE_HOBJECT hThis,
return;
}
CXFA_LocaleValue timeValue(
- XFA_VT_TIME,
- CFX_WideString::FromUTF8(szArgString, szArgString.GetLength()),
+ XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsStringC()),
(CXFA_LocaleMgr*)pMgr);
if (timeValue.IsValid()) {
CFX_Unitime uniTime = timeValue.GetTime();
@@ -1112,7 +1110,7 @@ void CXFA_FM2JSContext::IsoTime2Num(FXJSE_HOBJECT hThis,
int32_t second = uniTime.GetSecond();
int32_t milSecond = uniTime.GetMillisecond();
IFX_Locale* pDefLocale = pMgr->GetDefLocale();
- FXSYS_assert(pDefLocale);
+ ASSERT(pDefLocale);
FX_TIMEZONE tzLocale;
pDefLocale->GetTimeZone(tzLocale);
int32_t mins = hour * 60 + min;
@@ -1168,13 +1166,11 @@ void CXFA_FM2JSContext::LocalDateFmt(FXJSE_HOBJECT hThis,
}
if (!bFlags) {
CFX_ByteString formatStr;
- GetLocalDateFormat(hThis, iStyle, szLocal.AsByteStringC(), formatStr,
- FALSE);
+ GetLocalDateFormat(hThis, iStyle, szLocal.AsStringC(), formatStr, FALSE);
if (formatStr.IsEmpty()) {
formatStr = "";
}
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- formatStr.AsByteStringC());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
}
@@ -1221,13 +1217,11 @@ void CXFA_FM2JSContext::LocalTimeFmt(FXJSE_HOBJECT hThis,
}
if (!bFlags) {
CFX_ByteString formatStr;
- GetLocalTimeFormat(hThis, iStyle, szLocal.AsByteStringC(), formatStr,
- FALSE);
+ GetLocalTimeFormat(hThis, iStyle, szLocal.AsStringC(), formatStr, FALSE);
if (formatStr.IsEmpty()) {
formatStr = "";
}
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- formatStr.AsByteStringC());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
}
@@ -1374,14 +1368,14 @@ void CXFA_FM2JSContext::Num2Date(FXJSE_HOBJECT hThis,
CFX_ByteString szIsoDateString;
szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay);
CFX_ByteString szLocalDateString;
- IsoDate2Local(hThis, szIsoDateString.AsByteStringC(),
- formatString.AsByteStringC(), localString.AsByteStringC(),
+ IsoDate2Local(hThis, szIsoDateString.AsStringC(),
+ formatString.AsStringC(), localString.AsStringC(),
szLocalDateString);
if (szLocalDateString.IsEmpty()) {
szLocalDateString = "";
}
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szLocalDateString.AsByteStringC());
+ szLocalDateString.AsStringC());
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
}
@@ -1437,13 +1431,13 @@ void CXFA_FM2JSContext::Num2GMTime(FXJSE_HOBJECT hThis,
}
if (!bFlags) {
CFX_ByteString szGMTTimeString;
- Num2AllTime(hThis, iTime, formatString.AsByteStringC(),
- localString.AsByteStringC(), TRUE, szGMTTimeString);
+ Num2AllTime(hThis, iTime, formatString.AsStringC(),
+ localString.AsStringC(), TRUE, szGMTTimeString);
if (szGMTTimeString.IsEmpty()) {
szGMTTimeString = "";
}
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szGMTTimeString.AsByteStringC());
+ szGMTTimeString.AsStringC());
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
}
@@ -1499,13 +1493,13 @@ void CXFA_FM2JSContext::Num2Time(FXJSE_HOBJECT hThis,
}
if (!bFlags) {
CFX_ByteString szLocalTimeString;
- Num2AllTime(hThis, (int32_t)fTime, formatString.AsByteStringC(),
- localString.AsByteStringC(), FALSE, szLocalTimeString);
+ Num2AllTime(hThis, (int32_t)fTime, formatString.AsStringC(),
+ localString.AsStringC(), FALSE, szLocalTimeString);
if (szLocalTimeString.IsEmpty()) {
szLocalTimeString = "";
}
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szLocalTimeString.AsByteStringC());
+ szLocalTimeString.AsStringC());
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
}
@@ -1584,26 +1578,23 @@ void CXFA_FM2JSContext::Time2Num(FXJSE_HOBJECT hThis,
if (localString.IsEmpty()) {
CXFA_Node* pThisNode =
ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
pLocale = widgetData.GetLocal();
} else {
pLocale = pMgr->GetLocaleByName(
- CFX_WideString::FromUTF8(localString, localString.GetLength())
- .AsWideStringC());
+ CFX_WideString::FromUTF8(localString.AsStringC()));
}
CFX_WideString wsFormat;
if (formatString.IsEmpty()) {
pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
} else {
- wsFormat =
- CFX_WideString::FromUTF8(formatString, formatString.GetLength());
+ wsFormat = CFX_WideString::FromUTF8(formatString.AsStringC());
}
wsFormat = FX_WSTRC(L"time{") + wsFormat;
wsFormat += FX_WSTRC(L"}");
CXFA_LocaleValue timeValue(
- XFA_VT_TIME,
- CFX_WideString::FromUTF8(timeString, timeString.GetLength()),
+ XFA_VT_TIME, CFX_WideString::FromUTF8(timeString.AsStringC()),
wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr);
if (timeValue.IsValid()) {
CFX_Unitime uniTime = timeValue.GetTime();
@@ -1679,12 +1670,11 @@ void CXFA_FM2JSContext::TimeFmt(FXJSE_HOBJECT hThis,
}
if (!bFlags) {
CFX_ByteString formatStr;
- GetStandardTimeFormat(hThis, iStyle, szLocal.AsByteStringC(), formatStr);
+ GetStandardTimeFormat(hThis, iStyle, szLocal.AsStringC(), formatStr);
if (formatStr.IsEmpty()) {
formatStr = "";
}
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- formatStr.AsByteStringC());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
}
@@ -2035,13 +2025,11 @@ FX_BOOL CXFA_FM2JSContext::Local2IsoDate(FXJSE_HOBJECT hThis,
IFX_Locale* pLocale = NULL;
if (szLocale.IsEmpty()) {
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
pLocale = widgetData.GetLocal();
} else {
- pLocale = pMgr->GetLocaleByName(
- CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())
- .AsWideStringC());
+ pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
}
if (!pLocale) {
return FALSE;
@@ -2050,11 +2038,10 @@ FX_BOOL CXFA_FM2JSContext::Local2IsoDate(FXJSE_HOBJECT hThis,
if (szFormat.IsEmpty()) {
pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
} else {
- wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
+ wsFormat = CFX_WideString::FromUTF8(szFormat);
}
- CXFA_LocaleValue widgetValue(
- XFA_VT_DATE, CFX_WideString::FromUTF8(szDate.c_str(), szDate.GetLength()),
- wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr);
+ CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate),
+ wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr);
CFX_Unitime dt = widgetValue.GetDate();
strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay());
return TRUE;
@@ -2074,13 +2061,11 @@ FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis,
IFX_Locale* pLocale = NULL;
if (szLocale.IsEmpty()) {
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
pLocale = widgetData.GetLocal();
} else {
- pLocale = pMgr->GetLocaleByName(
- CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())
- .AsWideStringC());
+ pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
}
if (!pLocale) {
return FALSE;
@@ -2089,13 +2074,12 @@ FX_BOOL CXFA_FM2JSContext::Local2IsoTime(FXJSE_HOBJECT hThis,
if (szFormat.IsEmpty()) {
pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
} else {
- wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
+ wsFormat = CFX_WideString::FromUTF8(szFormat);
}
wsFormat = FX_WSTRC(L"time{") + wsFormat;
wsFormat += FX_WSTRC(L"}");
- CXFA_LocaleValue widgetValue(
- XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()),
- wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr);
+ CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime),
+ wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr);
CFX_Unitime utime = widgetValue.GetTime();
strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(),
utime.GetSecond(), utime.GetMillisecond());
@@ -2116,13 +2100,11 @@ FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis,
IFX_Locale* pLocale = NULL;
if (szLocale.IsEmpty()) {
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
pLocale = widgetData.GetLocal();
} else {
- pLocale = pMgr->GetLocaleByName(
- CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())
- .AsWideStringC());
+ pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
}
if (!pLocale) {
return FALSE;
@@ -2131,15 +2113,14 @@ FX_BOOL CXFA_FM2JSContext::IsoDate2Local(FXJSE_HOBJECT hThis,
if (szFormat.IsEmpty()) {
pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
} else {
- wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
+ wsFormat = CFX_WideString::FromUTF8(szFormat);
}
- CXFA_LocaleValue widgetValue(
- XFA_VT_DATE, CFX_WideString::FromUTF8(szDate.c_str(), szDate.GetLength()),
- (CXFA_LocaleMgr*)pMgr);
+ CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate),
+ (CXFA_LocaleMgr*)pMgr);
CFX_WideString wsRet;
widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
XFA_VALUEPICTURE_Display);
- strLocalDate = FX_UTF8Encode(wsRet, wsRet.GetLength());
+ strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
return TRUE;
}
FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis,
@@ -2157,13 +2138,11 @@ FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis,
IFX_Locale* pLocale = NULL;
if (szLocale.IsEmpty()) {
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
pLocale = widgetData.GetLocal();
} else {
- pLocale = pMgr->GetLocaleByName(
- CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())
- .AsWideStringC());
+ pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
}
if (!pLocale) {
return FALSE;
@@ -2172,17 +2151,16 @@ FX_BOOL CXFA_FM2JSContext::IsoTime2Local(FXJSE_HOBJECT hThis,
if (szFormat.IsEmpty()) {
pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
} else {
- wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
+ wsFormat = CFX_WideString::FromUTF8(szFormat);
}
wsFormat = FX_WSTRC(L"time{") + wsFormat;
wsFormat += FX_WSTRC(L"}");
- CXFA_LocaleValue widgetValue(
- XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()),
- (CXFA_LocaleMgr*)pMgr);
+ CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime),
+ (CXFA_LocaleMgr*)pMgr);
CFX_WideString wsRet;
widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
XFA_VALUEPICTURE_Display);
- strLocalTime = FX_UTF8Encode(wsRet, wsRet.GetLength());
+ strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
return TRUE;
}
FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis,
@@ -2200,13 +2178,11 @@ FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis,
IFX_Locale* pLocale = NULL;
if (szLocale.IsEmpty()) {
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
pLocale = widgetData.GetLocal();
} else {
- pLocale = pMgr->GetLocaleByName(
- CFX_WideString::FromUTF8(szLocale.c_str(), szLocale.GetLength())
- .AsWideStringC());
+ pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale));
}
if (!pLocale) {
return FALSE;
@@ -2215,17 +2191,16 @@ FX_BOOL CXFA_FM2JSContext::GetGMTTime(FXJSE_HOBJECT hThis,
if (szFormat.IsEmpty()) {
pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
} else {
- wsFormat = CFX_WideString::FromUTF8(szFormat.c_str(), szFormat.GetLength());
+ wsFormat = CFX_WideString::FromUTF8(szFormat);
}
wsFormat = FX_WSTRC(L"time{") + wsFormat;
wsFormat += FX_WSTRC(L"}");
- CXFA_LocaleValue widgetValue(
- XFA_VT_TIME, CFX_WideString::FromUTF8(szTime.c_str(), szTime.GetLength()),
- (CXFA_LocaleMgr*)pMgr);
+ CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime),
+ (CXFA_LocaleMgr*)pMgr);
CFX_WideString wsRet;
widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
XFA_VALUEPICTURE_Display);
- strGMTTime = FX_UTF8Encode(wsRet, wsRet.GetLength());
+ strGMTTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
return TRUE;
}
int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) {
@@ -2384,13 +2359,11 @@ void CXFA_FM2JSContext::GetLocalDateFormat(FXJSE_HOBJECT hThis,
IFX_Locale* pLocale = NULL;
if (szLocalStr.IsEmpty()) {
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
pLocale = widgetData.GetLocal();
} else {
- pLocale = pMgr->GetLocaleByName(
- CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength())
- .AsWideStringC());
+ pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr));
}
if (!pLocale) {
return;
@@ -2402,7 +2375,7 @@ void CXFA_FM2JSContext::GetLocalDateFormat(FXJSE_HOBJECT hThis,
pLocale->GetDateTimeSymbols(wsSymbols);
XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date);
}
- strFormat = FX_UTF8Encode(strRet, strRet.GetLength());
+ strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength());
}
void CXFA_FM2JSContext::GetLocalTimeFormat(FXJSE_HOBJECT hThis,
int32_t iStyle,
@@ -2440,13 +2413,11 @@ void CXFA_FM2JSContext::GetLocalTimeFormat(FXJSE_HOBJECT hThis,
IFX_Locale* pLocale = NULL;
if (szLocalStr.IsEmpty()) {
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
pLocale = widgetData.GetLocal();
} else {
- pLocale = pMgr->GetLocaleByName(
- CFX_WideString::FromUTF8(szLocalStr.c_str(), szLocalStr.GetLength())
- .AsWideStringC());
+ pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr));
}
if (!pLocale) {
return;
@@ -2458,7 +2429,7 @@ void CXFA_FM2JSContext::GetLocalTimeFormat(FXJSE_HOBJECT hThis,
pLocale->GetDateTimeSymbols(wsSymbols);
XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time);
}
- strFormat = FX_UTF8Encode(strRet, strRet.GetLength());
+ strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength());
}
void CXFA_FM2JSContext::GetStandardDateFormat(FXJSE_HOBJECT hThis,
int32_t iStyle,
@@ -2497,10 +2468,10 @@ void CXFA_FM2JSContext::Num2AllTime(FXJSE_HOBJECT hThis,
CFX_ByteString strIsoTime;
strIsoTime.Format("%02d:%02d:%02d", iHour, iMin, iSec);
if (bGM) {
- iRet = GetGMTTime(hThis, strIsoTime.AsByteStringC(), szFormat, szLocale,
- strTime);
+ iRet =
+ GetGMTTime(hThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime);
} else {
- iRet = IsoTime2Local(hThis, strIsoTime.AsByteStringC(), szFormat, szLocale,
+ iRet = IsoTime2Local(hThis, strIsoTime.AsStringC(), szFormat, szLocale,
strTime);
}
if (!iRet) {
@@ -3085,13 +3056,13 @@ void CXFA_FM2JSContext::Choose(FXJSE_HOBJECT hThis,
} else {
CFX_ByteString propStr;
FXJSE_Value_ToUTF8String(propertyValue, propStr);
- FXJSE_Value_GetObjectProp(jsobjectValue, propStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsobjectValue, propStr.AsStringC(),
newProperty);
}
CFX_ByteString bsChoosed;
HValueToUTF8String(newProperty, bsChoosed);
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- bsChoosed.AsByteStringC());
+ bsChoosed.AsStringC());
FXJSE_Value_Release(newProperty);
FXJSE_Value_Release(jsobjectValue);
FXJSE_Value_Release(propertyValue);
@@ -3103,7 +3074,7 @@ void CXFA_FM2JSContext::Choose(FXJSE_HOBJECT hThis,
CFX_ByteString bsChoosed;
HValueToUTF8String(argIndexValue, bsChoosed);
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- bsChoosed.AsByteStringC());
+ bsChoosed.AsStringC());
bFound = TRUE;
}
}
@@ -3215,8 +3186,8 @@ void CXFA_FM2JSContext::Within(FXJSE_HOBJECT hThis,
HValueToUTF8String(argHeight, heightString);
FXJSE_Value_SetInteger(
args.GetReturnValue(),
- ((oneString.Compare(lowString.AsByteStringC()) >= 0) &&
- (oneString.Compare(heightString.AsByteStringC()) <= 0)));
+ ((oneString.Compare(lowString.AsStringC()) >= 0) &&
+ (oneString.Compare(heightString.AsStringC()) <= 0)));
}
FXJSE_Value_Release(argLow);
FXJSE_Value_Release(argHeight);
@@ -3265,16 +3236,16 @@ void CXFA_FM2JSContext::Eval(FXJSE_HOBJECT hThis,
CFX_WideTextBuf wsJavaScriptBuf;
CFX_WideString javaScript;
CFX_WideString wsError;
- XFA_FM2JS_Translate(CFX_WideString::FromUTF8(utf8ScriptString,
- utf8ScriptString.GetLength())
- .AsWideStringC(),
- wsJavaScriptBuf, wsError);
+ XFA_FM2JS_Translate(
+ CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(),
+ wsJavaScriptBuf, wsError);
FXJSE_HCONTEXT hContext = FXJSE_Context_Create(hruntime);
FXJSE_HVALUE returnValue = FXJSE_Value_Create(hruntime);
- javaScript = wsJavaScriptBuf.GetWideString();
- FXJSE_ExecuteScript(hContext,
- FX_UTF8Encode(javaScript, javaScript.GetLength()),
- returnValue);
+ javaScript = wsJavaScriptBuf.AsStringC();
+ FXJSE_ExecuteScript(
+ hContext,
+ FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(),
+ returnValue);
FXJSE_Value_Set(args.GetReturnValue(), returnValue);
FXJSE_Value_Release(returnValue);
FXJSE_Context_Release(hContext);
@@ -3309,7 +3280,7 @@ void CXFA_FM2JSContext::Ref(FXJSE_HOBJECT hThis,
#ifndef NDEBUG
FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime);
FXJSE_Value_GetObjectProp(argOne, "length", lengthValue);
- FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3);
+ ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3);
FXJSE_Value_Release(lengthValue);
#endif
FXJSE_HVALUE propertyValue = FXJSE_Value_Create(hruntime);
@@ -3389,8 +3360,8 @@ void CXFA_FM2JSContext::UnitType(FXJSE_HOBJECT hThis,
};
unitspanString.MakeLower();
CFX_WideString wsTypeString =
- CFX_WideString::FromUTF8(unitspanString, unitspanString.GetLength());
- const FX_WCHAR* pData = wsTypeString;
+ CFX_WideString::FromUTF8(unitspanString.AsStringC());
+ const FX_WCHAR* pData = wsTypeString.c_str();
int32_t u = 0;
int32_t uLen = wsTypeString.GetLength();
while (*(pData + u) == 0x20 || *(pData + u) == 0x09 ||
@@ -3493,7 +3464,7 @@ void CXFA_FM2JSContext::UnitValue(FXJSE_HOBJECT hThis,
FXJSE_Value_SetNull(args.GetReturnValue());
} else {
HValueToUTF8String(unitspanValue, unitspanString);
- const FX_CHAR* pData = unitspanString;
+ const FX_CHAR* pData = unitspanString.c_str();
if (pData) {
int32_t u = 0;
while (*(pData + u) == 0x20 || *(pData + u) == 0x09 ||
@@ -3528,7 +3499,7 @@ void CXFA_FM2JSContext::UnitValue(FXJSE_HOBJECT hThis,
unitValue = GetSimpleHValue(hThis, args, 1);
CFX_ByteString unitTempString;
HValueToUTF8String(unitValue, unitTempString);
- const FX_CHAR* pData = unitTempString;
+ const FX_CHAR* pData = unitTempString.c_str();
int32_t u = 0;
while (*(pData + u) == ' ' || *(pData + u) == 0x09 ||
*(pData + u) == 0x0B || *(pData + u) == 0x0C ||
@@ -3655,7 +3626,7 @@ void CXFA_FM2JSContext::At(FXJSE_HOBJECT hThis,
} else {
CFX_ByteString stringOne;
HValueToUTF8String(argOne, stringOne);
- FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsByteStringC());
+ FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC());
FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1);
}
}
@@ -3693,7 +3664,7 @@ void CXFA_FM2JSContext::Concat(FXJSE_HOBJECT hThis,
FXJSE_Value_SetNull(args.GetReturnValue());
} else {
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultString.AsByteStringC());
+ resultString.AsStringC());
}
} else {
pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
@@ -3714,9 +3685,8 @@ void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis,
CFX_ByteString toDecodeString;
HValueToUTF8String(argOne, toDecodeString);
CFX_ByteTextBuf resultBuf;
- DecodeURL(toDecodeString.AsByteStringC(), resultBuf);
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultBuf.GetByteString());
+ DecodeURL(toDecodeString.AsStringC(), resultBuf);
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
}
FXJSE_Value_Release(argOne);
} else if (argc == 2) {
@@ -3731,14 +3701,13 @@ void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis,
HValueToUTF8String(argTwo, identifyString);
CFX_ByteTextBuf resultBuf;
if (identifyString.EqualNoCase("html")) {
- DecodeHTML(toDecodeString.AsByteStringC(), resultBuf);
+ DecodeHTML(toDecodeString.AsStringC(), resultBuf);
} else if (identifyString.EqualNoCase("xml")) {
- DecodeXML(toDecodeString.AsByteStringC(), resultBuf);
+ DecodeXML(toDecodeString.AsStringC(), resultBuf);
} else {
- DecodeURL(toDecodeString.AsByteStringC(), resultBuf);
+ DecodeURL(toDecodeString.AsStringC(), resultBuf);
}
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultBuf.GetByteString());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
}
FXJSE_Value_Release(argOne);
FXJSE_Value_Release(argTwo);
@@ -3749,9 +3718,8 @@ void CXFA_FM2JSContext::Decode(FXJSE_HOBJECT hThis,
}
void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString,
CFX_ByteTextBuf& szResultString) {
- CFX_WideString wsURLString =
- CFX_WideString::FromUTF8(szURLString.c_str(), szURLString.GetLength());
- const FX_WCHAR* pData = wsURLString;
+ CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString);
+ const FX_WCHAR* pData = wsURLString.c_str();
int32_t iLen = wsURLString.GetLength();
int32_t i = 0;
FX_WCHAR ch = 0;
@@ -3801,19 +3769,18 @@ void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString,
szResultString.Clear();
szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(),
wsResultBuf.GetLength())
- .AsByteStringC();
+ .AsStringC();
}
void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString,
CFX_ByteTextBuf& szResultString) {
- CFX_WideString wsHTMLString =
- CFX_WideString::FromUTF8(szHTMLString.c_str(), szHTMLString.GetLength());
+ CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(szHTMLString);
FX_WCHAR strString[9];
int32_t iStrIndex = 0;
int32_t iLen = wsHTMLString.GetLength();
int32_t i = 0;
int32_t iCode = 0;
FX_WCHAR ch = 0;
- const FX_WCHAR* pData = wsHTMLString;
+ const FX_WCHAR* pData = wsHTMLString.c_str();
CFX_WideTextBuf wsResultBuf;
while (i < iLen) {
ch = *(pData + i);
@@ -3876,19 +3843,18 @@ void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString,
szResultString.Clear();
szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(),
wsResultBuf.GetLength())
- .AsByteStringC();
+ .AsStringC();
}
void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString,
CFX_ByteTextBuf& szResultString) {
- CFX_WideString wsXMLString =
- CFX_WideString::FromUTF8(szXMLString.c_str(), szXMLString.GetLength());
+ CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString);
FX_WCHAR strString[9];
int32_t iStrIndex = 0;
int32_t iLen = wsXMLString.GetLength();
int32_t i = 0;
int32_t iCode = 0;
FX_WCHAR ch = 0;
- const FX_WCHAR* pData = wsXMLString;
+ const FX_WCHAR* pData = wsXMLString.c_str();
CFX_WideTextBuf wsXMLBuf;
while (i < iLen) {
ch = *(pData + i);
@@ -3974,7 +3940,7 @@ void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString,
wsXMLBuf.AppendChar(0);
szResultString.Clear();
szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength())
- .AsByteStringC();
+ .AsStringC();
}
void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis,
const CFX_ByteStringC& szFuncName,
@@ -3990,9 +3956,8 @@ void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis,
CFX_ByteString toEncodeString;
HValueToUTF8String(argOne, toEncodeString);
CFX_ByteTextBuf resultBuf;
- EncodeURL(toEncodeString.AsByteStringC(), resultBuf);
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultBuf.GetByteString());
+ EncodeURL(toEncodeString.AsStringC(), resultBuf);
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
}
FXJSE_Value_Release(argOne);
} else if (argc == 2) {
@@ -4007,14 +3972,13 @@ void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis,
HValueToUTF8String(argTwo, identifyString);
CFX_ByteTextBuf resultBuf;
if (identifyString.EqualNoCase("html")) {
- EncodeHTML(toEncodeString.AsByteStringC(), resultBuf);
+ EncodeHTML(toEncodeString.AsStringC(), resultBuf);
} else if (identifyString.EqualNoCase("xml")) {
- EncodeXML(toEncodeString.AsByteStringC(), resultBuf);
+ EncodeXML(toEncodeString.AsStringC(), resultBuf);
} else {
- EncodeURL(toEncodeString.AsByteStringC(), resultBuf);
+ EncodeURL(toEncodeString.AsStringC(), resultBuf);
}
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultBuf.GetByteString());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
}
FXJSE_Value_Release(argOne);
FXJSE_Value_Release(argTwo);
@@ -4025,8 +3989,7 @@ void CXFA_FM2JSContext::Encode(FXJSE_HOBJECT hThis,
}
void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString,
CFX_ByteTextBuf& szResultBuf) {
- CFX_WideString wsURLString =
- CFX_WideString::FromUTF8(szURLString.c_str(), szURLString.GetLength());
+ CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString);
CFX_WideTextBuf wsResultBuf;
FX_WCHAR ch = 0;
int32_t iLength = wsURLString.GetLength();
@@ -4129,12 +4092,12 @@ void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString,
wsResultBuf.AppendChar(0);
szResultBuf.Clear();
szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
- .AsByteStringC();
+ .AsStringC();
}
void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString,
CFX_ByteTextBuf& szResultBuf) {
CFX_ByteString str = szHTMLString.c_str();
- CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str, str.GetLength());
+ CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str.AsStringC());
const FX_WCHAR* strCode = L"0123456789abcdef";
FX_WCHAR strEncode[9];
strEncode[0] = '&';
@@ -4148,12 +4111,12 @@ void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString,
uint32_t ch = 0;
int32_t iLen = wsHTMLString.GetLength();
int32_t i = 0;
- const FX_WCHAR* pData = wsHTMLString;
+ const FX_WCHAR* pData = wsHTMLString.c_str();
int32_t iIndex = 0;
CFX_WideString htmlReserve;
while (i < iLen) {
ch = *(pData + i);
- htmlReserve.Empty();
+ htmlReserve.clear();
if (HTMLCode2STR(ch, htmlReserve)) {
wsResultBuf.AppendChar(L'&');
wsResultBuf << htmlReserve;
@@ -4183,12 +4146,11 @@ void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString,
wsResultBuf.AppendChar(0);
szResultBuf.Clear();
szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
- .AsByteStringC();
+ .AsStringC();
}
void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString,
CFX_ByteTextBuf& szResultBuf) {
- CFX_WideString wsXMLString =
- CFX_WideString::FromUTF8(szXMLString.c_str(), szXMLString.GetLength());
+ CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString);
CFX_WideTextBuf wsResultBuf;
enum {
QUOT,
@@ -4211,7 +4173,7 @@ void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString,
int32_t iLength = wsXMLString.GetLength();
int32_t iIndex = 0;
int32_t u = 0;
- const FX_WCHAR* pData = wsXMLString;
+ const FX_WCHAR* pData = wsXMLString.c_str();
for (u = 0; u < iLength; ++u) {
ch = *(pData + u);
switch (ch) {
@@ -4265,23 +4227,21 @@ void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString,
wsResultBuf.AppendChar(0);
szResultBuf.Clear();
szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
- .AsByteStringC();
+ .AsStringC();
}
FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData,
uint32_t& iCode) {
- int32_t iLength = pData.GetLength();
- uint32_t uHash = FX_HashCode_String_GetW(pData.raw_str(), iLength);
- XFA_FMHtmlHashedReserveCode htmlhashedreservecode;
- int32_t iStart = 0,
- iEnd = (sizeof(reservesForDecode) / sizeof(reservesForDecode[0])) - 1;
- int32_t iMid = (iStart + iEnd) / 2;
+ uint32_t uHash = FX_HashCode_GetW(pData, false);
+ int32_t iStart = 0;
+ int32_t iEnd = FX_ArraySize(reservesForDecode) - 1;
do {
- iMid = (iStart + iEnd) / 2;
- htmlhashedreservecode = reservesForDecode[iMid];
+ int32_t iMid = (iStart + iEnd) / 2;
+ XFA_FMHtmlHashedReserveCode htmlhashedreservecode = reservesForDecode[iMid];
if (uHash == htmlhashedreservecode.m_uHash) {
iCode = htmlhashedreservecode.m_uCode;
return TRUE;
- } else if (uHash < htmlhashedreservecode.m_uHash) {
+ }
+ if (uHash < htmlhashedreservecode.m_uHash) {
iEnd = iMid - 1;
} else {
iStart = iMid + 1;
@@ -4311,8 +4271,7 @@ FX_BOOL CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode,
}
static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern,
uint32_t& patternType) {
- CFX_WideString wsPattern =
- CFX_WideString::FromUTF8(szPattern.c_str(), szPattern.GetLength());
+ CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern);
if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) {
patternType = XFA_VT_DATETIME;
return TRUE;
@@ -4341,7 +4300,7 @@ static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern,
}
patternType = XFA_VT_NULL;
wsPattern.MakeLower();
- const FX_WCHAR* pData = wsPattern;
+ const FX_WCHAR* pData = wsPattern.c_str();
int32_t iLength = wsPattern.GetLength();
int32_t iIndex = 0;
FX_BOOL bSingleQuotation = FALSE;
@@ -4410,24 +4369,22 @@ void CXFA_FM2JSContext::Format(FXJSE_HOBJECT hThis,
CXFA_Document* pDoc = pContext->GetDocument();
IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
IFX_Locale* pLocale = widgetData.GetLocal();
uint32_t patternType;
FX_BOOL bCompelte =
- XFA_PATTERN_STRING_Type(szPattern.AsByteStringC(), patternType);
- CFX_WideString wsPattern =
- CFX_WideString::FromUTF8(szPattern, szPattern.GetLength());
- CFX_WideString wsValue =
- CFX_WideString::FromUTF8(szValue, szValue.GetLength());
+ XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType);
+ CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC());
+ CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC());
if (!bCompelte) {
switch (patternType) {
case XFA_VT_DATETIME: {
FX_STRSIZE iTChar = wsPattern.Find(L'T');
- CFX_WideString wsDatePattern = FX_WSTRC(L"date{");
+ CFX_WideString wsDatePattern(L"date{");
wsDatePattern += wsPattern.Left(iTChar);
wsDatePattern += FX_WSTRC(L"} ");
- CFX_WideString wsTimePattern = FX_WSTRC(L"time{");
+ CFX_WideString wsTimePattern(L"time{");
wsTimePattern += wsPattern.Mid(iTChar + 1);
wsTimePattern += FX_WSTRC(L"}");
wsPattern = wsDatePattern + wsTimePattern;
@@ -4473,7 +4430,7 @@ void CXFA_FM2JSContext::Format(FXJSE_HOBJECT hThis,
XFA_VALUEPICTURE_Display)) {
FXJSE_Value_SetUTF8String(
args.GetReturnValue(),
- FX_UTF8Encode(wsRet, wsRet.GetLength()).AsByteStringC());
+ FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC());
} else {
FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
}
@@ -4506,7 +4463,7 @@ void CXFA_FM2JSContext::Left(FXJSE_HOBJECT hThis,
count = 0;
}
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- sourceString.Left(count).AsByteStringC());
+ sourceString.Left(count).AsStringC());
}
FXJSE_Value_Release(argOne);
FXJSE_Value_Release(argTwo);
@@ -4552,8 +4509,8 @@ void CXFA_FM2JSContext::Lower(FXJSE_HOBJECT hThis,
HValueToUTF8String(argOne, argString);
CFX_WideTextBuf lowStringBuf;
CFX_WideString wsArgString =
- CFX_WideString::FromUTF8(argString, argString.GetLength());
- const FX_WCHAR* pData = wsArgString;
+ CFX_WideString::FromUTF8(argString.AsStringC());
+ const FX_WCHAR* pData = wsArgString.c_str();
int32_t iLen = argString.GetLength();
int32_t i = 0;
int32_t ch = 0;
@@ -4573,7 +4530,7 @@ void CXFA_FM2JSContext::Lower(FXJSE_HOBJECT hThis,
FXJSE_Value_SetUTF8String(
args.GetReturnValue(),
FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength())
- .AsByteStringC());
+ .AsStringC());
if (argc == 2) {
FXJSE_Value_Release(localeValue);
}
@@ -4600,7 +4557,7 @@ void CXFA_FM2JSContext::Ltrim(FXJSE_HOBJECT hThis,
HValueToUTF8String(argOne, sourceString);
sourceString.TrimLeft();
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- sourceString.AsByteStringC());
+ sourceString.AsStringC());
}
FXJSE_Value_Release(argOne);
} else {
@@ -4626,16 +4583,15 @@ void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis,
CXFA_Document* pDoc = pContext->GetDocument();
IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
- FXSYS_assert(pThisNode);
+ ASSERT(pThisNode);
CXFA_WidgetData widgetData(pThisNode);
IFX_Locale* pLocale = widgetData.GetLocal();
uint32_t patternType;
FX_BOOL bCompletePattern =
- XFA_PATTERN_STRING_Type(szPattern.AsByteStringC(), patternType);
+ XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType);
CFX_WideString wsPattern =
- CFX_WideString::FromUTF8(szPattern, szPattern.GetLength());
- CFX_WideString wsValue =
- CFX_WideString::FromUTF8(szValue, szValue.GetLength());
+ CFX_WideString::FromUTF8(szPattern.AsStringC());
+ CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC());
CFX_ByteString szParsedValue;
if (bCompletePattern) {
CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale,
@@ -4643,7 +4599,7 @@ void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis,
if (localeValue.IsValid()) {
szParsedValue = FX_UTF8Encode(localeValue.GetValue());
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szParsedValue.AsByteStringC());
+ szParsedValue.AsStringC());
} else {
FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
}
@@ -4651,10 +4607,10 @@ void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis,
switch (patternType) {
case XFA_VT_DATETIME: {
FX_STRSIZE iTChar = wsPattern.Find(L'T');
- CFX_WideString wsDatePattern = FX_WSTRC(L"date{");
+ CFX_WideString wsDatePattern(L"date{");
wsDatePattern += wsPattern.Left(iTChar);
wsDatePattern += FX_WSTRC(L"} ");
- CFX_WideString wsTimePattern = FX_WSTRC(L"time{");
+ CFX_WideString wsTimePattern(L"time{");
wsTimePattern += wsPattern.Mid(iTChar + 1);
wsTimePattern += FX_WSTRC(L"}");
wsPattern = wsDatePattern + wsTimePattern;
@@ -4663,7 +4619,7 @@ void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis,
if (localeValue.IsValid()) {
szParsedValue = FX_UTF8Encode(localeValue.GetValue());
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szParsedValue.AsByteStringC());
+ szParsedValue.AsStringC());
} else {
FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
}
@@ -4676,7 +4632,7 @@ void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis,
if (localeValue.IsValid()) {
szParsedValue = FX_UTF8Encode(localeValue.GetValue());
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szParsedValue.AsByteStringC());
+ szParsedValue.AsStringC());
} else {
FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
}
@@ -4689,7 +4645,7 @@ void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis,
if (localeValue.IsValid()) {
szParsedValue = FX_UTF8Encode(localeValue.GetValue());
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szParsedValue.AsByteStringC());
+ szParsedValue.AsStringC());
} else {
FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
}
@@ -4702,7 +4658,7 @@ void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis,
if (localeValue.IsValid()) {
szParsedValue = FX_UTF8Encode(localeValue.GetValue());
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szParsedValue.AsByteStringC());
+ szParsedValue.AsStringC());
} else {
FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
}
@@ -4736,7 +4692,7 @@ void CXFA_FM2JSContext::Parse(FXJSE_HOBJECT hThis,
if (localeValue.IsValid()) {
szParsedValue = FX_UTF8Encode(localeValue.GetValue());
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- szParsedValue.AsByteStringC());
+ szParsedValue.AsStringC());
} else {
FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
}
@@ -4793,7 +4749,7 @@ void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis,
}
}
if (iFindIndex == iFindLen) {
- resultString << threeString.AsByteStringC();
+ resultString << threeString.AsStringC();
u += iFindLen - 1;
iFindIndex = 0;
} else {
@@ -4804,8 +4760,7 @@ void CXFA_FM2JSContext::Replace(FXJSE_HOBJECT hThis,
}
}
resultString.AppendChar(0);
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultString.GetByteString());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC());
FXJSE_Value_Release(argOne);
FXJSE_Value_Release(argTwo);
if (argc == 3) {
@@ -4840,7 +4795,7 @@ void CXFA_FM2JSContext::Right(FXJSE_HOBJECT hThis,
count = 0;
}
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- sourceString.Right(count).AsByteStringC());
+ sourceString.Right(count).AsStringC());
}
FXJSE_Value_Release(argOne);
FXJSE_Value_Release(argTwo);
@@ -4863,7 +4818,7 @@ void CXFA_FM2JSContext::Rtrim(FXJSE_HOBJECT hThis,
HValueToUTF8String(argOne, sourceString);
sourceString.TrimRight();
FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- sourceString.AsByteStringC());
+ sourceString.AsStringC());
}
FXJSE_Value_Release(argOne);
} else {
@@ -4891,8 +4846,7 @@ void CXFA_FM2JSContext::Space(FXJSE_HOBJECT hThis,
index++;
}
spaceString.AppendByte(0);
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- spaceString.GetByteString());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC());
}
FXJSE_Value_Release(argOne);
} else {
@@ -4936,8 +4890,8 @@ void CXFA_FM2JSContext::Str(FXJSE_HOBJECT hThis,
formatStr += CFX_ByteString::FormatInteger(iPrecision);
}
formatStr += "f";
- numberString.Format(formatStr, fNumber);
- const FX_CHAR* pData = numberString;
+ numberString.Format(formatStr.c_str(), fNumber);
+ const FX_CHAR* pData = numberString.c_str();
int32_t iLength = numberString.GetLength();
int32_t u = 0;
while (u < iLength) {
@@ -5008,8 +4962,7 @@ void CXFA_FM2JSContext::Str(FXJSE_HOBJECT hThis,
resultBuf.AppendChar(0);
}
}
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultBuf.GetByteString());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
}
@@ -5068,15 +5021,14 @@ void CXFA_FM2JSContext::Stuff(FXJSE_HOBJECT hThis,
resultString.AppendChar(sourceString.GetAt(i));
++i;
}
- resultString << insertString.AsByteStringC();
+ resultString << insertString.AsStringC();
i = iStart + iDelete;
while (i < iLength) {
resultString.AppendChar(sourceString.GetAt(i));
++i;
}
resultString.AppendChar(0);
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultString.GetByteString());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC());
FXJSE_Value_Release(sourceValue);
FXJSE_Value_Release(startValue);
FXJSE_Value_Release(deleteValue);
@@ -5122,9 +5074,8 @@ void CXFA_FM2JSContext::Substr(FXJSE_HOBJECT hThis,
iCount = 0;
}
iStart -= 1;
- FXJSE_Value_SetUTF8String(
- args.GetReturnValue(),
- szSourceStr.Mid(iStart, iCount).AsByteStringC());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(),
+ szSourceStr.Mid(iStart, iCount).AsStringC());
}
}
FXJSE_Value_Release(stringValue);
@@ -5152,7 +5103,7 @@ void CXFA_FM2JSContext::Uuid(FXJSE_HOBJECT hThis,
FX_GUID_CreateV4(&guid);
CFX_ByteString bsUId;
FX_GUID_ToString(&guid, bsUId, iNum);
- FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsByteStringC());
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC());
if (argc == 1) {
FXJSE_Value_Release(argOne);
}
@@ -5180,8 +5131,8 @@ void CXFA_FM2JSContext::Upper(FXJSE_HOBJECT hThis,
HValueToUTF8String(argOne, argString);
CFX_WideTextBuf upperStringBuf;
CFX_WideString wsArgString =
- CFX_WideString::FromUTF8(argString, argString.GetLength());
- const FX_WCHAR* pData = wsArgString;
+ CFX_WideString::FromUTF8(argString.AsStringC());
+ const FX_WCHAR* pData = wsArgString.c_str();
int32_t iLen = wsArgString.GetLength();
int32_t i = 0;
int32_t ch = 0;
@@ -5201,7 +5152,7 @@ void CXFA_FM2JSContext::Upper(FXJSE_HOBJECT hThis,
FXJSE_Value_SetUTF8String(
args.GetReturnValue(),
FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength())
- .AsByteStringC());
+ .AsStringC());
if (argc == 2) {
FXJSE_Value_Release(localeValue);
}
@@ -5254,9 +5205,8 @@ void CXFA_FM2JSContext::WordNum(FXJSE_HOBJECT hThis,
CFX_ByteTextBuf resultBuf;
CFX_ByteString numberString;
numberString.Format("%.2f", fNumber);
- WordUS(numberString.AsByteStringC(), iIdentifier, resultBuf);
- FXJSE_Value_SetUTF8String(args.GetReturnValue(),
- resultBuf.GetByteString());
+ WordUS(numberString.AsStringC(), iIdentifier, resultBuf);
+ FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
}
} else {
FXJSE_Value_SetNull(args.GetReturnValue());
@@ -5490,8 +5440,7 @@ void CXFA_FM2JSContext::Get(FXJSE_HOBJECT hThis,
CFX_ByteString urlString;
HValueToUTF8String(argOne, urlString);
IFX_FileRead* pFile = pAppProvider->DownloadURL(
- CFX_WideString::FromUTF8(urlString, urlString.GetLength())
- .AsWideStringC());
+ CFX_WideString::FromUTF8(urlString.AsStringC()));
if (pFile) {
int32_t size = pFile->GetSize();
uint8_t* pData = FX_Alloc(uint8_t, size);
@@ -5551,15 +5500,11 @@ void CXFA_FM2JSContext::Post(FXJSE_HOBJECT hThis,
}
CFX_WideString decodedResponse;
FX_BOOL bFlags = pAppProvider->PostRequestURL(
- CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()).AsWideStringC(),
- CFX_WideString::FromUTF8(bsData, bsData.GetLength()).AsWideStringC(),
- CFX_WideString::FromUTF8(bsContentType, bsContentType.GetLength())
- .AsWideStringC(),
- CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength())
- .AsWideStringC(),
- CFX_WideString::FromUTF8(bsHeader, bsHeader.GetLength())
- .AsWideStringC(),
- decodedResponse);
+ CFX_WideString::FromUTF8(bsURL.AsStringC()),
+ CFX_WideString::FromUTF8(bsData.AsStringC()),
+ CFX_WideString::FromUTF8(bsContentType.AsStringC()),
+ CFX_WideString::FromUTF8(bsEncode.AsStringC()),
+ CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse);
FXJSE_Value_Release(argOne);
FXJSE_Value_Release(argTwo);
if (argc > 2) {
@@ -5574,8 +5519,8 @@ void CXFA_FM2JSContext::Post(FXJSE_HOBJECT hThis,
if (bFlags) {
FXJSE_Value_SetUTF8String(
args.GetReturnValue(),
- FX_UTF8Encode(decodedResponse, decodedResponse.GetLength())
- .AsByteStringC());
+ FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength())
+ .AsStringC());
} else {
pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY);
}
@@ -5615,10 +5560,9 @@ void CXFA_FM2JSContext::Put(FXJSE_HOBJECT hThis,
HValueToUTF8String(argThree, bsEncode);
}
FX_BOOL bFlags = pAppProvider->PutRequestURL(
- CFX_WideString::FromUTF8(bsURL, bsURL.GetLength()).AsWideStringC(),
- CFX_WideString::FromUTF8(bsData, bsData.GetLength()).AsWideStringC(),
- CFX_WideString::FromUTF8(bsEncode, bsEncode.GetLength())
- .AsWideStringC());
+ CFX_WideString::FromUTF8(bsURL.AsStringC()),
+ CFX_WideString::FromUTF8(bsData.AsStringC()),
+ CFX_WideString::FromUTF8(bsEncode.AsStringC()));
FXJSE_Value_Release(argOne);
FXJSE_Value_Release(argTwo);
if (argc > 2) {
@@ -5666,7 +5610,7 @@ void CXFA_FM2JSContext::assign_value_operator(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
for (int32_t i = 2; i < iLeftLength; i++) {
FXJSE_Value_GetObjectPropByIdx(lValue, i, jsObjectValue);
- FXJSE_Value_SetObjectProp(jsObjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_SetObjectProp(jsObjectValue, propertyStr.AsStringC(),
rValue);
}
}
@@ -5852,7 +5796,7 @@ void CXFA_FM2JSContext::less_operator(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(argSecond, secondOutput);
FXJSE_Value_SetInteger(
args.GetReturnValue(),
- firstOutput.Compare(secondOutput.AsByteStringC()) == -1);
+ firstOutput.Compare(secondOutput.AsStringC()) == -1);
} else {
FX_DOUBLE first = HValueToDouble(hThis, argFirst);
FX_DOUBLE second = HValueToDouble(hThis, argSecond);
@@ -5885,7 +5829,7 @@ void CXFA_FM2JSContext::lessequal_operator(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(argSecond, secondOutput);
FXJSE_Value_SetInteger(
args.GetReturnValue(),
- firstOutput.Compare(secondOutput.AsByteStringC()) != 1);
+ firstOutput.Compare(secondOutput.AsStringC()) != 1);
} else {
FX_DOUBLE first = HValueToDouble(hThis, argFirst);
FX_DOUBLE second = HValueToDouble(hThis, argSecond);
@@ -5915,7 +5859,7 @@ void CXFA_FM2JSContext::greater_operator(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(argSecond, secondOutput);
FXJSE_Value_SetInteger(
args.GetReturnValue(),
- firstOutput.Compare(secondOutput.AsByteStringC()) == 1);
+ firstOutput.Compare(secondOutput.AsStringC()) == 1);
} else {
FX_DOUBLE first = HValueToDouble(hThis, argFirst);
FX_DOUBLE second = HValueToDouble(hThis, argSecond);
@@ -5948,7 +5892,7 @@ void CXFA_FM2JSContext::greaterequal_operator(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(argSecond, secondOutput);
FXJSE_Value_SetInteger(
args.GetReturnValue(),
- firstOutput.Compare(secondOutput.AsByteStringC()) != -1);
+ firstOutput.Compare(secondOutput.AsStringC()) != -1);
} else {
FX_DOUBLE first = HValueToDouble(hThis, argFirst);
FX_DOUBLE second = HValueToDouble(hThis, argSecond);
@@ -6128,8 +6072,8 @@ void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis,
iIndexValue = HValueToInteger(hThis, argIndex);
}
CFX_ByteString szSomExp;
- GenerateSomExpression(szName.AsByteStringC(), iIndexFlags, iIndexValue,
- bIsStar, szSomExp);
+ GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar,
+ szSomExp);
if (FXJSE_Value_IsArray(argAccessor)) {
FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(hruntime);
FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue);
@@ -6146,9 +6090,8 @@ void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis,
for (int32_t i = 2; i < iLength; i++) {
FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue);
XFA_RESOLVENODE_RS resoveNodeRS;
- int32_t iRet =
- ResolveObjects(hThis, hJSObjValue, szSomExp.AsByteStringC(),
- resoveNodeRS, TRUE, szName.IsEmpty());
+ int32_t iRet = ResolveObjects(hThis, hJSObjValue, szSomExp.AsStringC(),
+ resoveNodeRS, TRUE, szName.IsEmpty());
if (iRet > 0) {
ParseResolveResult(hThis, resoveNodeRS, hJSObjValue,
hResolveValues[i - 2], iSizes[i - 2], bAttribute);
@@ -6163,7 +6106,7 @@ void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis,
}
FXJSE_Value_SetInteger(rgValues[0], 1);
if (bAttribute) {
- FXJSE_Value_SetUTF8String(rgValues[1], szName.AsByteStringC());
+ FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC());
} else {
FXJSE_Value_SetNull(rgValues[1]);
}
@@ -6181,12 +6124,12 @@ void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis,
FX_Free(rgValues);
} else {
CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName, szName.GetLength());
+ CFX_WideString::FromUTF8(szName.AsStringC());
CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength());
+ CFX_WideString::FromUTF8(szSomExp.AsStringC());
pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- (const FX_WCHAR*)wsPropertyName,
- (const FX_WCHAR*)wsSomExpression);
+ wsPropertyName.c_str(),
+ wsSomExpression.c_str());
}
for (int32_t i = 0; i < iLength - 2; i++) {
for (int32_t j = 0; j < iSizes[i]; j++) {
@@ -6203,14 +6146,14 @@ void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis,
int32_t iRet = 0;
if (FXJSE_Value_IsObject(argAccessor) ||
(FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) {
- iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsByteStringC(),
+ iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(),
resoveNodeRS, TRUE, szName.IsEmpty());
} else if (!FXJSE_Value_IsObject(argAccessor) &&
!bsAccessorName.IsEmpty()) {
FX_BOOL bGetObject =
- GetObjectByName(hThis, argAccessor, bsAccessorName.AsByteStringC());
+ GetObjectByName(hThis, argAccessor, bsAccessorName.AsStringC());
if (bGetObject) {
- iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsByteStringC(),
+ iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(),
resoveNodeRS, TRUE, szName.IsEmpty());
}
}
@@ -6226,7 +6169,7 @@ void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis,
}
FXJSE_Value_SetInteger(rgValues[0], 1);
if (bAttribute) {
- FXJSE_Value_SetUTF8String(rgValues[1], szName.AsByteStringC());
+ FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC());
} else {
FXJSE_Value_SetNull(rgValues[1]);
}
@@ -6244,12 +6187,12 @@ void CXFA_FM2JSContext::dot_accessor(FXJSE_HOBJECT hThis,
FX_Free(hResolveValues);
} else {
CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName, szName.GetLength());
+ CFX_WideString::FromUTF8(szName.AsStringC());
CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength());
+ CFX_WideString::FromUTF8(szSomExp.AsStringC());
pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- (const FX_WCHAR*)wsPropertyName,
- (const FX_WCHAR*)wsSomExpression);
+ wsPropertyName.c_str(),
+ wsSomExpression.c_str());
}
}
if (argc == 5) {
@@ -6281,8 +6224,8 @@ void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis,
iIndexValue = HValueToInteger(hThis, argIndex);
}
CFX_ByteString szSomExp;
- GenerateSomExpression(szName.AsByteStringC(), iIndexFlags, iIndexValue,
- bIsStar, szSomExp);
+ GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar,
+ szSomExp);
if (FXJSE_Value_IsArray(argAccessor)) {
FXJSE_HVALUE hLengthValue = FXJSE_Value_Create(hruntime);
FXJSE_Value_GetObjectProp(argAccessor, "length", hLengthValue);
@@ -6295,8 +6238,8 @@ void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis,
for (int32_t i = 2; i < iLength; i++) {
FXJSE_Value_GetObjectPropByIdx(argAccessor, i, hJSObjValue);
XFA_RESOLVENODE_RS resoveNodeRS;
- int32_t iRet = ResolveObjects(
- hThis, hJSObjValue, szSomExp.AsByteStringC(), resoveNodeRS, FALSE);
+ int32_t iRet = ResolveObjects(hThis, hJSObjValue, szSomExp.AsStringC(),
+ resoveNodeRS, FALSE);
if (iRet > 0) {
ParseResolveResult(hThis, resoveNodeRS, hJSObjValue,
hResolveValues[i - 2], iSizes[i - 2], bAttribute);
@@ -6311,7 +6254,7 @@ void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis,
}
FXJSE_Value_SetInteger(rgValues[0], 1);
if (bAttribute) {
- FXJSE_Value_SetUTF8String(rgValues[1], szName.AsByteStringC());
+ FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC());
} else {
FXJSE_Value_SetNull(rgValues[1]);
}
@@ -6329,12 +6272,12 @@ void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis,
FX_Free(rgValues);
} else {
CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName, szName.GetLength());
+ CFX_WideString::FromUTF8(szName.AsStringC());
CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength());
+ CFX_WideString::FromUTF8(szSomExp.AsStringC());
pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- (const FX_WCHAR*)wsPropertyName,
- (const FX_WCHAR*)wsSomExpression);
+ wsPropertyName.c_str(),
+ wsSomExpression.c_str());
}
for (int32_t i = 0; i < iLength - 2; i++) {
for (int32_t j = 0; j < iSizes[i]; j++) {
@@ -6350,14 +6293,14 @@ void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis,
int32_t iRet = 0;
if (FXJSE_Value_IsObject(argAccessor) ||
(FXJSE_Value_IsNull(argAccessor) && bsAccessorName.IsEmpty())) {
- iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsByteStringC(),
+ iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(),
resoveNodeRS, FALSE);
} else if (!FXJSE_Value_IsObject(argAccessor) &&
!bsAccessorName.IsEmpty()) {
FX_BOOL bGetObject =
- GetObjectByName(hThis, argAccessor, bsAccessorName.AsByteStringC());
+ GetObjectByName(hThis, argAccessor, bsAccessorName.AsStringC());
if (bGetObject) {
- iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsByteStringC(),
+ iRet = ResolveObjects(hThis, argAccessor, szSomExp.AsStringC(),
resoveNodeRS, FALSE);
}
}
@@ -6373,7 +6316,7 @@ void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis,
}
FXJSE_Value_SetInteger(rgValues[0], 1);
if (bAttribute) {
- FXJSE_Value_SetUTF8String(rgValues[1], szName.AsByteStringC());
+ FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC());
} else {
FXJSE_Value_SetNull(rgValues[1]);
}
@@ -6391,12 +6334,12 @@ void CXFA_FM2JSContext::dotdot_accessor(FXJSE_HOBJECT hThis,
FX_Free(hResolveValues);
} else {
CFX_WideString wsPropertyName =
- CFX_WideString::FromUTF8(szName, szName.GetLength());
+ CFX_WideString::FromUTF8(szName.AsStringC());
CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(szSomExp, szSomExp.GetLength());
+ CFX_WideString::FromUTF8(szSomExp.AsStringC());
pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
- (const FX_WCHAR*)wsPropertyName,
- (const FX_WCHAR*)wsSomExpression);
+ wsPropertyName.c_str(),
+ wsSomExpression.c_str());
}
}
if (argc == 5) {
@@ -6421,16 +6364,16 @@ void CXFA_FM2JSContext::eval_translation(FXJSE_HOBJECT hThis,
pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH);
} else {
CFX_WideString scriptString =
- CFX_WideString::FromUTF8(argString, argString.GetLength());
+ CFX_WideString::FromUTF8(argString.AsStringC());
CFX_WideTextBuf wsJavaScriptBuf;
CFX_WideString wsError;
- XFA_FM2JS_Translate(scriptString.AsWideStringC(), wsJavaScriptBuf,
- wsError);
+ XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError);
if (wsError.IsEmpty()) {
- CFX_WideString javaScript = wsJavaScriptBuf.GetWideString();
+ CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
FXJSE_Value_SetUTF8String(
args.GetReturnValue(),
- FX_UTF8Encode(javaScript, javaScript.GetLength()).AsByteStringC());
+ FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength())
+ .AsStringC());
} else {
pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
}
@@ -6485,7 +6428,7 @@ void CXFA_FM2JSContext::get_fm_value(FXJSE_HOBJECT hThis,
} else {
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
- FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(),
args.GetReturnValue());
}
FXJSE_Value_Release(propertyValue);
@@ -6513,7 +6456,7 @@ void CXFA_FM2JSContext::get_fm_jsobj(FXJSE_HOBJECT hThis,
FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime();
FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime);
FXJSE_Value_GetObjectProp(argOne, "length", lengthValue);
- FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3);
+ ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3);
FXJSE_Value_Release(lengthValue);
#endif
FXJSE_Value_GetObjectPropByIdx(argOne, 2, args.GetReturnValue());
@@ -6538,7 +6481,7 @@ void CXFA_FM2JSContext::fm_var_filter(FXJSE_HOBJECT hThis,
#ifndef NDEBUG
FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime);
FXJSE_Value_GetObjectProp(argOne, "length", lengthValue);
- FXSYS_assert(FXJSE_Value_ToInteger(lengthValue) >= 3);
+ ASSERT(FXJSE_Value_ToInteger(lengthValue) >= 3);
FXJSE_Value_Release(lengthValue);
#endif
FXJSE_HVALUE flagsValue = FXJSE_Value_Create(hruntime);
@@ -6636,7 +6579,7 @@ FXJSE_HVALUE CXFA_FM2JSContext::GetSimpleHValue(FXJSE_HOBJECT hThis,
CXFA_FM2JSContext* pContext =
(CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL);
FXJSE_HRUNTIME hruntime = pContext->GetScriptRuntime();
- FXSYS_assert(index < (uint32_t)args.GetLength());
+ ASSERT(index < (uint32_t)args.GetLength());
FXJSE_HVALUE argIndex = args.GetValue(index);
if (FXJSE_Value_IsArray(argIndex)) {
FXJSE_HVALUE lengthValue = FXJSE_Value_Create(hruntime);
@@ -6654,7 +6597,7 @@ FXJSE_HVALUE CXFA_FM2JSContext::GetSimpleHValue(FXJSE_HOBJECT hThis,
} else {
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
- FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(),
simpleValue);
}
FXJSE_Value_Release(propertyValue);
@@ -6698,7 +6641,7 @@ FX_BOOL CXFA_FM2JSContext::HValueIsNull(FXJSE_HOBJECT hThis, FXJSE_HVALUE arg) {
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
FXJSE_HVALUE newPropertyValue = FXJSE_Value_Create(hruntime);
- FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyStr.AsStringC(),
newPropertyValue);
if (FXJSE_Value_IsNull(newPropertyValue)) {
isNull = TRUE;
@@ -6805,8 +6748,7 @@ void CXFA_FM2JSContext::unfoldArgs(FXJSE_HOBJECT hThis,
FXJSE_Value_ToUTF8String(propertyValue, propertyString);
for (int32_t j = 2; j < iLength; j++) {
FXJSE_Value_GetObjectPropByIdx(argsValue[i], j, jsObjectValue);
- FXJSE_Value_GetObjectProp(jsObjectValue,
- propertyString.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsObjectValue, propertyString.AsStringC(),
resultValues[index]);
index++;
}
@@ -6893,10 +6835,8 @@ FX_BOOL CXFA_FM2JSContext::GetObjectByName(
XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
int32_t iRet = pScriptContext->ResolveObjects(
pScriptContext->GetThisObject(),
- CFX_WideString::FromUTF8(szAccessorName.c_str(),
- szAccessorName.GetLength())
- .AsWideStringC(),
- resoveNodeRS, dwFlags);
+ CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS,
+ dwFlags);
if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap(
resoveNodeRS.nodes.GetAt(0)));
@@ -6910,8 +6850,7 @@ int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis,
XFA_RESOLVENODE_RS& resoveNodeRS,
FX_BOOL bdotAccessor,
FX_BOOL bHasNoResolveName) {
- CFX_WideString wsSomExpression =
- CFX_WideString::FromUTF8(bsSomExp.c_str(), bsSomExp.GetLength());
+ CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp);
int32_t iRet = -1;
CXFA_FM2JSContext* pContext =
(CXFA_FM2JSContext*)FXJSE_Value_ToObject(hThis, NULL);
@@ -6928,7 +6867,7 @@ int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis,
dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
} else {
pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL);
- FXSYS_assert(pNode);
+ ASSERT(pNode);
if (bHasNoResolveName) {
CFX_WideString wsName;
if (CXFA_Node* pXFANode = pNode->AsNode()) {
@@ -6952,7 +6891,7 @@ int32_t CXFA_FM2JSContext::ResolveObjects(FXJSE_HOBJECT hThis,
pNode = (CXFA_Object*)FXJSE_Value_ToObject(hRefValue, NULL);
dFlags = XFA_RESOLVENODE_AnyChild;
}
- iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsWideStringC(),
+ iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(),
resoveNodeRS, dFlags);
return iRet;
}
@@ -7017,7 +6956,7 @@ int32_t CXFA_FM2JSContext::HValueToInteger(FXJSE_HOBJECT hThis,
} else {
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
- FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(),
newProperty);
}
iValue = HValueToInteger(hThis, newProperty);
@@ -7034,7 +6973,7 @@ int32_t CXFA_FM2JSContext::HValueToInteger(FXJSE_HOBJECT hThis,
} else if (FXJSE_Value_IsUTF8String(hValue)) {
CFX_ByteString szValue;
FXJSE_Value_ToUTF8String(hValue, szValue);
- iValue = FXSYS_atoi(szValue);
+ iValue = FXSYS_atoi(szValue.c_str());
} else {
iValue = FXJSE_Value_ToInteger(hValue);
}
@@ -7061,7 +7000,7 @@ FX_FLOAT CXFA_FM2JSContext::HValueToFloat(FXJSE_HOBJECT hThis,
} else {
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
- FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(),
newProperty);
}
fRet = HValueToFloat(hThis, newProperty);
@@ -7076,7 +7015,7 @@ FX_FLOAT CXFA_FM2JSContext::HValueToFloat(FXJSE_HOBJECT hThis,
} else if (FXJSE_Value_IsUTF8String(arg)) {
CFX_ByteString bsOutput;
FXJSE_Value_ToUTF8String(arg, bsOutput);
- fRet = (FX_FLOAT)StringToDouble(bsOutput.AsByteStringC());
+ fRet = (FX_FLOAT)StringToDouble(bsOutput.AsStringC());
} else if (FXJSE_Value_IsUndefined(arg)) {
fRet = 0;
} else {
@@ -7101,7 +7040,7 @@ FX_DOUBLE CXFA_FM2JSContext::HValueToDouble(FXJSE_HOBJECT hThis,
} else {
CFX_ByteString propertyStr;
FXJSE_Value_ToUTF8String(propertyValue, propertyStr);
- FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsByteStringC(),
+ FXJSE_Value_GetObjectProp(jsobjectValue, propertyStr.AsStringC(),
newProperty);
}
dRet = HValueToDouble(hThis, newProperty);
@@ -7116,7 +7055,7 @@ FX_DOUBLE CXFA_FM2JSContext::HValueToDouble(FXJSE_HOBJECT hThis,
} else if (FXJSE_Value_IsUTF8String(arg)) {
CFX_ByteString bsOutput;
FXJSE_Value_ToUTF8String(arg, bsOutput);
- dRet = StringToDouble(bsOutput.AsByteStringC());
+ dRet = StringToDouble(bsOutput.AsStringC());
} else if (FXJSE_Value_IsUndefined(arg)) {
dRet = 0;
} else {
@@ -7268,14 +7207,14 @@ void CXFA_FM2JSContext::Release() {
}
void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) {
IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
- FXSYS_assert(pAppProvider);
+ ASSERT(pAppProvider);
CFX_WideString wsFormat;
pAppProvider->LoadString(iStringID, wsFormat);
CFX_WideString wsMessage;
va_list arg_ptr;
va_start(arg_ptr, iStringID);
- wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr);
+ wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
va_end(arg_ptr);
FXJSE_ThrowMessage(
- "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC());
+ "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.cpp b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.cpp
index e66a42f471a..efbf224a402 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.cpp
@@ -29,25 +29,25 @@ void CXFA_FMParse::NextToken() {
void CXFA_FMParse::Check(XFA_FM_TOKEN op) {
if (m_pToken->m_type != op) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN,
- XFA_FM_KeywordToString(op), ws_TempString.c_str());
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken, XFA_FM_KeywordToString(op),
+ ws_TempString.c_str());
}
NextToken();
}
-void CXFA_FMParse::Error(uint32_t lineNum, XFA_FM_ERRMSG msg, ...) {
+void CXFA_FMParse::Error(uint32_t lineNum, const FX_WCHAR* msg, ...) {
m_pErrorInfo->linenum = lineNum;
- const FX_WCHAR* lpMessageInfo = XFA_FM_ErrorMsg(msg);
va_list ap;
va_start(ap, msg);
- m_pErrorInfo->message.FormatV(lpMessageInfo, ap);
+ m_pErrorInfo->message.FormatV(msg, ap);
va_end(ap);
}
-CFX_PtrArray* CXFA_FMParse::ParseTopExpression() {
+CFX_ArrayTemplate<CXFA_FMExpression*>* CXFA_FMParse::ParseTopExpression() {
std::unique_ptr<CXFA_FMExpression> e;
- CFX_PtrArray* expression = new CFX_PtrArray();
+ CFX_ArrayTemplate<CXFA_FMExpression*>* expression =
+ new CFX_ArrayTemplate<CXFA_FMExpression*>();
while (1) {
if (m_pToken->m_type == TOKeof || m_pToken->m_type == TOKendfunc ||
m_pToken->m_type == TOKendif || m_pToken->m_type == TOKelseif ||
@@ -78,12 +78,12 @@ CXFA_FMExpression* CXFA_FMParse::ParseFunction() {
std::unique_ptr<CXFA_FMExpression> e;
CFX_WideStringC ident;
std::unique_ptr<CFX_WideStringCArray> pArguments;
- std::unique_ptr<CFX_PtrArray> pExpressions;
+ std::unique_ptr<CFX_ArrayTemplate<CXFA_FMExpression*>> pExpressions;
uint32_t line = m_pToken->m_uLinenum;
NextToken();
if (m_pToken->m_type != TOKidentifier) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
ws_TempString.c_str());
} else {
ident = m_pToken->m_wstring;
@@ -111,8 +111,8 @@ CXFA_FMExpression* CXFA_FMParse::ParseFunction() {
break;
}
} else {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
ws_TempString.c_str());
NextToken();
break;
@@ -134,7 +134,7 @@ CXFA_FMExpression* CXFA_FMParse::ParseFunction() {
pArguments->RemoveAll();
if (pExpressions) {
for (int i = 0; i < pExpressions->GetSize(); ++i)
- delete static_cast<CXFA_FMExpression*>(pExpressions->GetAt(i));
+ delete pExpressions->GetAt(i);
}
}
return e.release();
@@ -181,8 +181,8 @@ CXFA_FMExpression* CXFA_FMParse::ParseExpression() {
NextToken();
break;
default:
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression,
ws_TempString.c_str());
NextToken();
break;
@@ -196,8 +196,8 @@ CXFA_FMExpression* CXFA_FMParse::ParseVarExpression() {
uint32_t line = m_pToken->m_uLinenum;
NextToken();
if (m_pToken->m_type != TOKidentifier) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
ws_TempString.c_str());
} else {
ident = m_pToken->m_wstring;
@@ -532,8 +532,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePrimaryExpression() {
e.reset(ParseParenExpression());
break;
default:
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression,
ws_TempString.c_str());
NextToken();
break;
@@ -551,9 +551,9 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
switch (m_pToken->m_type) {
case TOKlparen: {
NextToken();
- std::unique_ptr<CFX_PtrArray> pArray;
+ std::unique_ptr<CFX_ArrayTemplate<CXFA_FMSimpleExpression*>> pArray;
if (m_pToken->m_type != TOKrparen) {
- pArray.reset(new CFX_PtrArray());
+ pArray.reset(new CFX_ArrayTemplate<CXFA_FMSimpleExpression*>());
while (m_pToken->m_type != TOKrparen) {
CXFA_FMSimpleExpression* e = ParseSimpleExpression();
if (e) {
@@ -567,8 +567,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
}
}
if (m_pToken->m_type != TOKrparen) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
}
}
@@ -589,7 +589,7 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
} else {
if (pArray) {
for (int32_t i = 0; i < pArray->GetSize(); ++i)
- delete static_cast<CXFA_FMSimpleExpression*>(pArray->GetAt(i));
+ delete pArray->GetAt(i);
}
delete e;
e = nullptr;
@@ -606,9 +606,9 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
CXFA_FMSimpleExpression* pExpCall;
pExpAccessor = e;
NextToken();
- std::unique_ptr<CFX_PtrArray> pArray;
+ std::unique_ptr<CFX_ArrayTemplate<CXFA_FMSimpleExpression*>> pArray;
if (m_pToken->m_type != TOKrparen) {
- pArray.reset(new CFX_PtrArray());
+ pArray.reset(new CFX_ArrayTemplate<CXFA_FMSimpleExpression*>());
while (m_pToken->m_type != TOKrparen) {
CXFA_FMSimpleExpression* exp = ParseSimpleExpression();
pArray->Add(exp);
@@ -620,8 +620,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
}
}
if (m_pToken->m_type != TOKrparen) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
}
}
@@ -645,10 +645,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
}
} else {
if (pArray) {
- for (int32_t i = 0; i < pArray->GetSize(); ++i) {
- delete static_cast<CXFA_FMSimpleExpression*>(
- pArray->GetAt(i));
- }
+ for (int32_t i = 0; i < pArray->GetSize(); ++i)
+ delete pArray->GetAt(i);
}
delete e;
e = nullptr;
@@ -668,8 +666,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
continue;
}
} else {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
ws_TempString.c_str());
return e;
}
@@ -696,8 +694,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
continue;
}
} else {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
ws_TempString.c_str());
return e;
}
@@ -724,8 +722,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParsePostExpression(
continue;
}
} else {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IDENTIFIER,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
ws_TempString.c_str());
return e;
}
@@ -755,8 +753,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParseIndexExpression() {
new CXFA_FMIndexExpression(line, accessorIndex, s.release(), TRUE));
NextToken();
if (m_pToken->m_type != TOKrbracket) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
pExp.reset();
}
@@ -771,8 +769,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParseIndexExpression() {
}
s.reset(ParseSimpleExpression());
if (m_pToken->m_type != TOKrbracket) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
} else {
pExp.reset(
@@ -785,7 +783,7 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() {
Check(TOKlparen);
if (m_pToken->m_type == TOKrparen) {
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_NON_EMPTY_EXPRESSION);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedNonEmptyExpression);
NextToken();
return nullptr;
}
@@ -810,7 +808,9 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParseParenExpression() {
CXFA_FMExpression* CXFA_FMParse::ParseBlockExpression() {
uint32_t line = m_pToken->m_uLinenum;
CXFA_FMExpression* e = nullptr;
- std::unique_ptr<CFX_PtrArray> expression(new CFX_PtrArray());
+ std::unique_ptr<CFX_ArrayTemplate<CXFA_FMExpression*>> expression(
+ new CFX_ArrayTemplate<CXFA_FMExpression*>());
+
while (1) {
switch (m_pToken->m_type) {
case TOKeof:
@@ -891,8 +891,8 @@ CXFA_FMExpression* CXFA_FMParse::ParseIfExpression() {
Check(TOKendif);
break;
default:
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_IFEND, ws_TempString.c_str());
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedEndIf, ws_TempString.c_str());
NextToken();
break;
}
@@ -927,8 +927,8 @@ CXFA_FMSimpleExpression* CXFA_FMParse::ParseSubassignmentInForExpression() {
e.reset(ParseSimpleExpression());
break;
default:
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression,
ws_TempString.c_str());
NextToken();
break;
@@ -941,8 +941,8 @@ CXFA_FMExpression* CXFA_FMParse::ParseForExpression() {
uint32_t line = m_pToken->m_uLinenum;
NextToken();
if (m_pToken->m_type != TOKidentifier) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str());
}
wsVariant = m_pToken->m_wstring;
@@ -952,8 +952,8 @@ CXFA_FMExpression* CXFA_FMParse::ParseForExpression() {
NextToken();
pAssignment.reset(ParseSimpleExpression());
} else {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str());
}
int32_t iDirection = 0;
@@ -962,9 +962,9 @@ CXFA_FMExpression* CXFA_FMParse::ParseForExpression() {
} else if (m_pToken->m_type == TOKdownto) {
iDirection = -1;
} else {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN, L"upto or downto",
- (const FX_WCHAR*)ws_TempString);
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken, L"upto or downto",
+ ws_TempString.c_str());
}
NextToken();
std::unique_ptr<CXFA_FMSimpleExpression> pAccessor(ParseSimpleExpression());
@@ -988,13 +988,13 @@ CXFA_FMExpression* CXFA_FMParse::ParseForExpression() {
CXFA_FMExpression* CXFA_FMParse::ParseForeachExpression() {
std::unique_ptr<CXFA_FMExpression> e;
CFX_WideStringC wsIdentifier;
- std::unique_ptr<CFX_PtrArray> pAccessors;
+ std::unique_ptr<CFX_ArrayTemplate<CXFA_FMSimpleExpression*>> pAccessors;
std::unique_ptr<CXFA_FMExpression> pList;
uint32_t line = m_pToken->m_uLinenum;
NextToken();
if (m_pToken->m_type != TOKidentifier) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_EXPECTED_TOKEN,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrExpectedToken,
XFA_FM_KeywordToString(m_pToken->m_type), ws_TempString.c_str());
}
wsIdentifier = m_pToken->m_wstring;
@@ -1002,12 +1002,12 @@ CXFA_FMExpression* CXFA_FMParse::ParseForeachExpression() {
Check(TOKin);
Check(TOKlparen);
if (m_pToken->m_type == TOKrparen) {
- CFX_WideString ws_TempString = m_pToken->m_wstring;
- Error(m_pToken->m_uLinenum, FMERR_UNEXPECTED_EXPRESSION,
+ CFX_WideString ws_TempString(m_pToken->m_wstring);
+ Error(m_pToken->m_uLinenum, kFMErrUnexpectedExpression,
ws_TempString.c_str());
NextToken();
} else {
- pAccessors.reset(new CFX_PtrArray());
+ pAccessors.reset(new CFX_ArrayTemplate<CXFA_FMSimpleExpression*>());
while (m_pToken->m_type != TOKrparen) {
CXFA_FMSimpleExpression* s = ParseSimpleExpression();
if (s) {
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.h b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.h
index 288ae907449..3c11a73572a 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_fmparse.h
@@ -18,8 +18,8 @@ class CXFA_FMParse {
int32_t Init(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo);
void NextToken();
void Check(XFA_FM_TOKEN op);
- void Error(uint32_t lineNum, XFA_FM_ERRMSG msg, ...);
- CFX_PtrArray* ParseTopExpression();
+ void Error(uint32_t lineNum, const FX_WCHAR* msg, ...);
+ CFX_ArrayTemplate<CXFA_FMExpression*>* ParseTopExpression();
CXFA_FMExpression* ParseFunction();
CXFA_FMExpression* ParseExpression();
CXFA_FMExpression* ParseVarExpression();
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.cpp b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.cpp
index b4c16eb8e4a..f048f42668a 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.cpp
@@ -165,9 +165,7 @@ CXFA_FMToken::CXFA_FMToken(uint32_t uLineNum)
CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc,
CXFA_FMErrorInfo* pErrorInfo)
- : m_ptr(wsFormCalc.raw_str()),
- m_uCurrentLine(1),
- m_pErrorInfo(pErrorInfo) {}
+ : m_ptr(wsFormCalc.c_str()), m_uCurrentLine(1), m_pErrorInfo(pErrorInfo) {}
CXFA_FMToken* CXFA_FMLexer::NextToken() {
m_pToken.reset(Scan());
@@ -179,14 +177,14 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
CXFA_FMToken* p = new CXFA_FMToken(m_uCurrentLine);
if (!XFA_FMDChar::isAvalid(m_ptr)) {
ch = XFA_FMDChar::get(m_ptr);
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return p;
}
int iRet = 0;
while (1) {
if (!XFA_FMDChar::isAvalid(m_ptr)) {
ch = XFA_FMDChar::get(m_ptr);
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return p;
}
ch = XFA_FMDChar::get(m_ptr);
@@ -229,7 +227,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
iRet = Number(p, m_ptr, pTemp);
m_ptr = pTemp;
if (iRet) {
- Error(FMERR_BAD_SUFFIX_NUMBER);
+ Error(kFMErrBadSuffixNumber);
return p;
}
}
@@ -248,7 +246,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
}
} else {
ch = XFA_FMDChar::get(m_ptr);
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return p;
}
break;
@@ -270,7 +268,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
}
} else {
ch = XFA_FMDChar::get(m_ptr);
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return p;
}
break;
@@ -288,7 +286,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
}
} else {
ch = XFA_FMDChar::get(m_ptr);
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return p;
}
break;
@@ -347,7 +345,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
}
} else {
ch = XFA_FMDChar::get(m_ptr);
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return p;
}
break;
@@ -374,7 +372,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
iRet = Number(p, m_ptr, pTemp);
m_ptr = pTemp;
if (iRet) {
- Error(FMERR_BAD_SUFFIX_NUMBER);
+ Error(kFMErrBadSuffixNumber);
}
return p;
} else {
@@ -383,7 +381,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
}
} else {
ch = XFA_FMDChar::get(m_ptr);
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return p;
}
case 0x09:
@@ -432,7 +430,7 @@ uint32_t CXFA_FMLexer::String(CXFA_FMToken* t,
ch = XFA_FMDChar::get(p);
pEnd = p;
t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart));
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return 1;
}
if (ch == '"') {
@@ -441,7 +439,7 @@ uint32_t CXFA_FMLexer::String(CXFA_FMToken* t,
ch = XFA_FMDChar::get(p);
pEnd = p;
t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart));
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return 1;
}
ch = XFA_FMDChar::get(p);
@@ -470,7 +468,7 @@ uint32_t CXFA_FMLexer::Identifiers(CXFA_FMToken* t,
if (!XFA_FMDChar::isAvalid(p)) {
pEnd = p;
t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart));
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return 1;
}
ch = XFA_FMDChar::get(p);
@@ -478,7 +476,7 @@ uint32_t CXFA_FMLexer::Identifiers(CXFA_FMToken* t,
if (!XFA_FMDChar::isAvalid(p)) {
pEnd = p;
t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart));
- Error(FMERR_UNSUPPORTED_CHAR, ch);
+ Error(kFMErrUnsupportedChar, ch);
return 1;
}
ch = XFA_FMDChar::get(p);
@@ -518,31 +516,27 @@ void CXFA_FMLexer::Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd) {
}
XFA_FM_TOKEN CXFA_FMLexer::IsKeyword(const CFX_WideStringC& str) {
- int32_t iLength = str.GetLength();
- uint32_t uHash = FX_HashCode_String_GetW(str.raw_str(), iLength, TRUE);
- int32_t iStart = KEYWORD_START, iEnd = KEYWORD_END;
- int32_t iMid = (iStart + iEnd) / 2;
- XFA_FMKeyword keyword;
+ uint32_t uHash = FX_HashCode_GetW(str, true);
+ int32_t iStart = KEYWORD_START;
+ int32_t iEnd = KEYWORD_END;
do {
- iMid = (iStart + iEnd) / 2;
- keyword = keyWords[iMid];
- if (uHash == keyword.m_uHash) {
+ int32_t iMid = (iStart + iEnd) / 2;
+ XFA_FMKeyword keyword = keyWords[iMid];
+ if (uHash == keyword.m_uHash)
return keyword.m_type;
- } else if (uHash < keyword.m_uHash) {
+ if (uHash < keyword.m_uHash)
iEnd = iMid - 1;
- } else {
+ else
iStart = iMid + 1;
- }
} while (iStart <= iEnd);
return TOKidentifier;
}
-void CXFA_FMLexer::Error(XFA_FM_ERRMSG msg, ...) {
+void CXFA_FMLexer::Error(const FX_WCHAR* msg, ...) {
m_pErrorInfo->linenum = m_uCurrentLine;
- const FX_WCHAR* lpMessageInfo = XFA_FM_ErrorMsg(msg);
va_list ap;
va_start(ap, msg);
- m_pErrorInfo->message.FormatV(lpMessageInfo, ap);
+ m_pErrorInfo->message.FormatV(msg, ap);
va_end(ap);
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.h b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.h
index fd89dc72ebd..c21c00255aa 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_lexer.h
@@ -119,7 +119,7 @@ class CXFA_FMLexer {
}
const FX_WCHAR* SavePos() { return m_ptr; }
void RestorePos(const FX_WCHAR* pPos) { m_ptr = pPos; }
- void Error(XFA_FM_ERRMSG msg, ...);
+ void Error(const FX_WCHAR* msg, ...);
FX_BOOL HasError() const;
protected:
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_program.cpp b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_program.cpp
index ef5efb214cb..a5c429765ff 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_program.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_program.cpp
@@ -17,20 +17,16 @@ int32_t CXFA_FMProgram::Init(const CFX_WideStringC& wsFormcalc) {
return m_parse.Init(wsFormcalc, &m_pErrorInfo);
}
int32_t CXFA_FMProgram::ParseProgram() {
- CFX_PtrArray* expressions = 0;
+ CFX_ArrayTemplate<CXFA_FMExpression*>* expressions = nullptr;
m_parse.NextToken();
if (!m_pErrorInfo.message.IsEmpty()) {
return -1;
}
expressions = m_parse.ParseTopExpression();
if (!m_pErrorInfo.message.IsEmpty()) {
- CXFA_FMExpression* e = 0;
- for (int32_t u = 0; u < expressions->GetSize(); ++u) {
- e = (CXFA_FMExpression*)expressions->GetAt(u);
- if (e) {
- delete e;
- }
- }
+ for (int32_t u = 0; u < expressions->GetSize(); ++u)
+ delete expressions->GetAt(u);
+
delete expressions;
return -1;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.cpp b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.cpp
index d5936bc6c15..e77623de3a9 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.cpp
@@ -146,7 +146,7 @@ CXFA_FMStringExpression::CXFA_FMStringExpression(uint32_t line,
: CXFA_FMSimpleExpression(line, TOKstring), m_wsString(wsString) {}
void CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
- CFX_WideString tempStr = m_wsString;
+ CFX_WideString tempStr(m_wsString);
if (tempStr.GetLength() > 2) {
javascript.AppendChar(L'\"');
FX_WCHAR oneChar;
@@ -178,7 +178,7 @@ CXFA_FMIdentifierExpressionn::CXFA_FMIdentifierExpressionn(
m_wsIdentifier(wsIdentifier) {}
void CXFA_FMIdentifierExpressionn::ToJavaScript(CFX_WideTextBuf& javascript) {
- CFX_WideString tempStr = m_wsIdentifier;
+ CFX_WideString tempStr(m_wsIdentifier);
if (tempStr == FX_WSTRC(L"$")) {
tempStr = FX_WSTRC(L"this");
} else if (tempStr == FX_WSTRC(L"!")) {
@@ -237,7 +237,7 @@ void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CFX_WideTextBuf tempExp1;
m_pExp1->ToJavaScript(tempExp1);
if (m_pExp1->GetOperatorToken() == TOKidentifier &&
- tempExp1.GetWideString() != FX_WSTRC(L"this")) {
+ tempExp1.AsStringC() != FX_WSTRC(L"this")) {
javascript << FX_WSTRC(L"else\n{\n");
javascript << tempExp1;
javascript << FX_WSTRC(L" = ");
@@ -267,7 +267,7 @@ void CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CFX_WideTextBuf tempExp1;
m_pExp1->ToJavaScript(tempExp1);
if (m_pExp1->GetOperatorToken() == TOKidentifier &&
- tempExp1.GetWideString() != FX_WSTRC(L"this")) {
+ tempExp1.AsStringC() != FX_WSTRC(L"this")) {
javascript << FX_WSTRC(L"else\n{\n");
javascript << RUNTIMEFUNCTIONRETURNVALUE;
javascript << FX_WSTRC(L" = ");
@@ -332,7 +332,7 @@ void CXFA_FMEqualityExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[NOTEQUALITY];
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
javascript << FX_WSTRC(L"(");
@@ -368,7 +368,7 @@ void CXFA_FMRelationalExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[GREATEREQUAL];
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
javascript << FX_WSTRC(L"(");
@@ -394,7 +394,7 @@ void CXFA_FMAdditiveExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[MINUS];
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
javascript << FX_WSTRC(L"(");
@@ -421,7 +421,7 @@ void CXFA_FMMultiplicativeExpression::ToJavaScript(
javascript << gs_lpStrExpFuncName[DIVIDE];
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
javascript << FX_WSTRC(L"(");
@@ -464,27 +464,26 @@ void CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L")");
}
-CXFA_FMCallExpression::CXFA_FMCallExpression(uint32_t line,
- CXFA_FMSimpleExpression* pExp,
- CFX_PtrArray* pArguments,
- FX_BOOL bIsSomMethod)
+CXFA_FMCallExpression::CXFA_FMCallExpression(
+ uint32_t line,
+ CXFA_FMSimpleExpression* pExp,
+ CFX_ArrayTemplate<CXFA_FMSimpleExpression*>* pArguments,
+ FX_BOOL bIsSomMethod)
: CXFA_FMUnaryExpression(line, TOKcall, pExp),
m_bIsSomMethod(bIsSomMethod),
m_pArguments(pArguments) {}
CXFA_FMCallExpression::~CXFA_FMCallExpression() {
if (m_pArguments) {
- for (int i = 0; i < m_pArguments->GetSize(); ++i) {
- delete reinterpret_cast<CXFA_FMSimpleExpression*>(m_pArguments->GetAt(i));
- }
- m_pArguments->RemoveAll();
+ for (int i = 0; i < m_pArguments->GetSize(); ++i)
+ delete m_pArguments->GetAt(i);
+
delete m_pArguments;
}
}
bool CXFA_FMCallExpression::IsBuildInFunc(CFX_WideTextBuf* funcName) {
- uint32_t uHash = FX_HashCode_String_GetW(funcName->GetBuffer(),
- funcName->GetLength(), TRUE);
+ uint32_t uHash = FX_HashCode_GetW(funcName->AsStringC(), true);
const XFA_FMBuildInFunc* pEnd = g_BuildInFuncs + FX_ArraySize(g_BuildInFuncs);
const XFA_FMBuildInFunc* pFunc =
std::lower_bound(g_BuildInFuncs, pEnd, uHash,
@@ -501,8 +500,7 @@ bool CXFA_FMCallExpression::IsBuildInFunc(CFX_WideTextBuf* funcName) {
uint32_t CXFA_FMCallExpression::IsMethodWithObjParam(
const CFX_WideStringC& methodName) {
- int32_t iLength = methodName.GetLength();
- uint32_t uHash = FX_HashCode_String_GetW(methodName.raw_str(), iLength);
+ uint32_t uHash = FX_HashCode_GetW(methodName, false);
XFA_FMSOMMethod somMethodWithObjPara;
uint32_t parameters = 0x00;
int32_t iStart = 0,
@@ -530,7 +528,7 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << funcName;
javascript << FX_WSTRC(L"(");
if (m_pArguments) {
- uint32_t methodPara = IsMethodWithObjParam(funcName.GetWideString());
+ uint32_t methodPara = IsMethodWithObjParam(funcName.AsStringC());
if (methodPara > 0) {
for (int i = 0; i < m_pArguments->GetSize(); ++i) {
if ((methodPara & (0x01 << i)) > 0) {
@@ -539,9 +537,7 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[GETFMVALUE];
}
javascript << FX_WSTRC(L"(");
- CXFA_FMSimpleExpression* e =
- reinterpret_cast<CXFA_FMSimpleExpression*>(
- m_pArguments->GetAt(i));
+ CXFA_FMSimpleExpression* e = m_pArguments->GetAt(i);
e->ToJavaScript(javascript);
javascript << FX_WSTRC(L")");
if (i + 1 < m_pArguments->GetSize()) {
@@ -552,9 +548,7 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
for (int i = 0; i < m_pArguments->GetSize(); ++i) {
javascript << gs_lpStrExpFuncName[GETFMVALUE];
javascript << FX_WSTRC(L"(");
- CXFA_FMSimpleExpression* e =
- reinterpret_cast<CXFA_FMSimpleExpression*>(
- m_pArguments->GetAt(i));
+ CXFA_FMSimpleExpression* e = m_pArguments->GetAt(i);
e->ToJavaScript(javascript);
javascript << FX_WSTRC(L")");
if (i + 1 < m_pArguments->GetSize()) {
@@ -568,12 +562,12 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
bool isEvalFunc = false;
bool isExistsFunc = false;
if (IsBuildInFunc(&funcName)) {
- if (funcName.GetWideString() == FX_WSTRC(L"Eval")) {
+ if (funcName.AsStringC() == FX_WSTRC(L"Eval")) {
isEvalFunc = true;
javascript << FX_WSTRC(L"eval.call(this, ");
javascript << gs_lpStrExpFuncName[CALL];
javascript << FX_WSTRC(L"Translate");
- } else if (funcName.GetWideString() == FX_WSTRC(L"Exists")) {
+ } else if (funcName.AsStringC() == FX_WSTRC(L"Exists")) {
isExistsFunc = true;
javascript << gs_lpStrExpFuncName[CALL];
javascript << funcName;
@@ -588,8 +582,7 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
if (isExistsFunc) {
javascript << FX_WSTRC(L"\n(\nfunction ()\n{\ntry\n{\n");
if (m_pArguments && m_pArguments->GetSize() > 0) {
- CXFA_FMSimpleExpression* e =
- reinterpret_cast<CXFA_FMSimpleExpression*>(m_pArguments->GetAt(0));
+ CXFA_FMSimpleExpression* e = m_pArguments->GetAt(0);
javascript << FX_WSTRC(L"return ");
e->ToJavaScript(javascript);
javascript << FX_WSTRC(L";\n}\n");
@@ -600,8 +593,7 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
L"catch(accessExceptions)\n{\nreturn 0;\n}\n}\n).call(this)\n");
} else if (m_pArguments) {
for (int i = 0; i < m_pArguments->GetSize(); ++i) {
- CXFA_FMSimpleExpression* e =
- reinterpret_cast<CXFA_FMSimpleExpression*>(m_pArguments->GetAt(i));
+ CXFA_FMSimpleExpression* e = m_pArguments->GetAt(i);
e->ToJavaScript(javascript);
if (i + 1 < m_pArguments->GetSize()) {
javascript << FX_WSTRC(L", ");
diff --git a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.h b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.h
index 94f628b09bd..25301288468 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/fm2js/xfa_simpleexpression.h
@@ -226,16 +226,17 @@ class CXFA_FMCallExpression : public CXFA_FMUnaryExpression {
public:
CXFA_FMCallExpression(uint32_t line,
CXFA_FMSimpleExpression* pExp,
- CFX_PtrArray* pArguments,
+ CFX_ArrayTemplate<CXFA_FMSimpleExpression*>* pArguments,
FX_BOOL bIsSomMethod);
~CXFA_FMCallExpression() override;
+
bool IsBuildInFunc(CFX_WideTextBuf* funcName);
uint32_t IsMethodWithObjParam(const CFX_WideStringC& methodName);
void ToJavaScript(CFX_WideTextBuf& javascript) override;
private:
FX_BOOL m_bIsSomMethod;
- CFX_PtrArray* m_pArguments;
+ CFX_ArrayTemplate<CXFA_FMSimpleExpression*>* m_pArguments;
};
class CXFA_FMDotAccessorExpression : public CXFA_FMBinExpression {
diff --git a/chromium/third_party/pdfium/xfa/fxfa/include/DEPS b/chromium/third_party/pdfium/xfa/fxfa/include/DEPS
new file mode 100644
index 00000000000..97ccb1faa6a
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ '+core/fxcodec/include',
+]
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/fxfa.h b/chromium/third_party/pdfium/xfa/fxfa/include/fxfa.h
index 624502aa834..f7f4a04166b 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/fxfa.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/fxfa.h
@@ -4,13 +4,13 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_FXFA_H_
-#define XFA_INCLUDE_FXFA_FXFA_H_
+#ifndef XFA_FXFA_INCLUDE_FXFA_H_
+#define XFA_FXFA_INCLUDE_FXFA_H_
#include <vector>
-#include "xfa/include/fxfa/fxfa_basic.h"
-#include "xfa/include/fxfa/fxfa_widget.h"
+#include "xfa/fxfa/include/fxfa_basic.h"
+#include "xfa/fxfa/include/fxfa_widget.h"
class CFX_Graphics;
class CPDF_Document;
@@ -137,6 +137,124 @@ class IXFA_WidgetIterator;
#define XFA_IDS_ValidateError 98
#define XFA_IDS_ValidateNumberError 99
+#define XFA_DOCVIEW_View 0x00000000
+#define XFA_DOCVIEW_MasterPage 0x00000001
+#define XFA_DOCVIEW_Design 0x00000002
+#define XFA_DOCTYPE_Dynamic 0
+#define XFA_DOCTYPE_Static 1
+#define XFA_DOCTYPE_XDP 2
+#define XFA_PARSESTATUS_StatusErr -3
+#define XFA_PARSESTATUS_StreamErr -2
+#define XFA_PARSESTATUS_SyntaxErr -1
+#define XFA_PARSESTATUS_Ready 0
+#define XFA_PARSESTATUS_Done 100
+#define XFA_VALIDATE_preSubmit 1
+#define XFA_VALIDATE_prePrint 2
+#define XFA_VALIDATE_preExecute 3
+#define XFA_VALIDATE_preSave 4
+
+#define XFA_INVALIDATE_AllPages 0x00000000
+#define XFA_INVALIDATE_CurrentPage 0x00000001
+#define XFA_PRINTOPT_ShowDialog 0x00000001
+#define XFA_PRINTOPT_CanCancel 0x00000002
+#define XFA_PRINTOPT_ShrinkPage 0x00000004
+#define XFA_PRINTOPT_AsImage 0x00000008
+#define XFA_PRINTOPT_ReverseOrder 0x00000010
+#define XFA_PRINTOPT_PrintAnnot 0x00000020
+#define XFA_PAGEVIEWEVENT_PostAdded 1
+#define XFA_PAGEVIEWEVENT_PostRemoved 3
+#define XFA_PAGEVIEWEVENT_StopLayout 4
+
+#define XFA_EVENTERROR_Success 1
+#define XFA_EVENTERROR_Error -1
+#define XFA_EVENTERROR_NotExist 0
+#define XFA_EVENTERROR_Disabled 2
+
+#define XFA_RENDERSTATUS_Ready 1
+#define XFA_RENDERSTATUS_ToBeContinued 2
+#define XFA_RENDERSTATUS_Done 3
+#define XFA_RENDERSTATUS_Failed -1
+
+#define XFA_TRAVERSEWAY_Tranvalse 0x0001
+#define XFA_TRAVERSEWAY_Form 0x0002
+
+enum XFA_WidgetStatus {
+ XFA_WidgetStatus_None = 0,
+
+ XFA_WidgetStatus_Access = 1 << 0,
+ XFA_WidgetStatus_ButtonDown = 1 << 1,
+ XFA_WidgetStatus_Disabled = 1 << 2,
+ XFA_WidgetStatus_Focused = 1 << 3,
+ XFA_WidgetStatus_Highlight = 1 << 4,
+ XFA_WidgetStatus_Printable = 1 << 5,
+ XFA_WidgetStatus_RectCached = 1 << 6,
+ XFA_WidgetStatus_TextEditValueChanged = 1 << 7,
+ XFA_WidgetStatus_Viewable = 1 << 8,
+ XFA_WidgetStatus_Visible = 1 << 9
+};
+
+enum XFA_EVENTTYPE {
+ XFA_EVENT_Click,
+ XFA_EVENT_Change,
+ XFA_EVENT_DocClose,
+ XFA_EVENT_DocReady,
+ XFA_EVENT_Enter,
+ XFA_EVENT_Exit,
+ XFA_EVENT_Full,
+ XFA_EVENT_IndexChange,
+ XFA_EVENT_Initialize,
+ XFA_EVENT_MouseDown,
+ XFA_EVENT_MouseEnter,
+ XFA_EVENT_MouseExit,
+ XFA_EVENT_MouseUp,
+ XFA_EVENT_PostExecute,
+ XFA_EVENT_PostOpen,
+ XFA_EVENT_PostPrint,
+ XFA_EVENT_PostSave,
+ XFA_EVENT_PostSign,
+ XFA_EVENT_PostSubmit,
+ XFA_EVENT_PreExecute,
+ XFA_EVENT_PreOpen,
+ XFA_EVENT_PrePrint,
+ XFA_EVENT_PreSave,
+ XFA_EVENT_PreSign,
+ XFA_EVENT_PreSubmit,
+ XFA_EVENT_Ready,
+ XFA_EVENT_InitCalculate,
+ XFA_EVENT_InitVariables,
+ XFA_EVENT_Calculate,
+ XFA_EVENT_Validate,
+ XFA_EVENT_Unknown,
+};
+
+enum XFA_WIDGETORDER {
+ XFA_WIDGETORDER_PreOrder,
+};
+
+enum XFA_WIDGETTYPE {
+ XFA_WIDGETTYPE_Barcode,
+ XFA_WIDGETTYPE_PushButton,
+ XFA_WIDGETTYPE_CheckButton,
+ XFA_WIDGETTYPE_RadioButton,
+ XFA_WIDGETTYPE_DatetimeEdit,
+ XFA_WIDGETTYPE_DecimalField,
+ XFA_WIDGETTYPE_NumericField,
+ XFA_WIDGETTYPE_Signature,
+ XFA_WIDGETTYPE_TextEdit,
+ XFA_WIDGETTYPE_DropdownList,
+ XFA_WIDGETTYPE_ListBox,
+ XFA_WIDGETTYPE_ImageField,
+ XFA_WIDGETTYPE_PasswordEdit,
+ XFA_WIDGETTYPE_Arc,
+ XFA_WIDGETTYPE_Rectangle,
+ XFA_WIDGETTYPE_Image,
+ XFA_WIDGETTYPE_Line,
+ XFA_WIDGETTYPE_Text,
+ XFA_WIDGETTYPE_ExcludeGroup,
+ XFA_WIDGETTYPE_Subform,
+ XFA_WIDGETTYPE_Unknown,
+};
+
// Probably should be called IXFA_AppDelegate.
class IXFA_AppProvider {
public:
@@ -150,7 +268,7 @@ class IXFA_AppProvider {
virtual void GetAppType(CFX_WideString& wsAppType) = 0;
virtual void SetFoxitAppType(const CFX_WideStringC& wsFoxitAppType) {}
virtual void GetFoxitAppType(CFX_WideString& wsFoxitAppType) {
- wsFoxitAppType.Empty();
+ wsFoxitAppType.clear();
}
/**
@@ -174,7 +292,7 @@ class IXFA_AppProvider {
*/
virtual void GetVersion(CFX_WideString& wsVersion) = 0;
virtual void GetFoxitVersion(CFX_WideString& wsFoxitVersion) {
- wsFoxitVersion.Empty();
+ wsFoxitVersion.clear();
}
/**
@@ -182,7 +300,7 @@ class IXFA_AppProvider {
*/
virtual void GetAppName(CFX_WideString& wsName) = 0;
virtual void GetFoxitAppName(CFX_WideString& wsFoxitName) {
- wsFoxitName.Empty();
+ wsFoxitName.clear();
}
/**
@@ -194,25 +312,30 @@ class IXFA_AppProvider {
/**
* Displays a message box.
- * @param[in] dwIconType Icon type, refer to XFA_MBICON.
- * @param[in] dwButtonType Button type, refer to XFA_MESSAGEBUTTON.
+ * @param[in] wsMessage - Message string to display in box.
+ * @param[in] wsTitle - Title string for box.
+ * @param[in] dwIconType - Icon type, refer to XFA_MBICON.
+ * @param[in] dwButtonType - Button type, refer to XFA_MESSAGEBUTTON.
* @return A valid integer representing the value of the button pressed by the
* user, refer to XFA_ID.
*/
- virtual int32_t MsgBox(const CFX_WideStringC& wsMessage,
- const CFX_WideStringC& wsTitle = FX_WSTRC(L""),
+ virtual int32_t MsgBox(const CFX_WideString& wsMessage,
+ const CFX_WideString& wsTitle = L"",
uint32_t dwIconType = 0,
uint32_t dwButtonType = 0) = 0;
/**
* Get a response from the user.
- * @param[in] bMark - Mask the user input with * (asterisks) when true,
+ * @param[in] wsQuestion - Message string to display in box.
+ * @param[in] wsTitle - Title string for box.
+ * @param[in] wsDefaultAnswer - Initial contents for answer.
+ * @param[in] bMask - Mask the user input with asterisks when true,
+ * @return A string containing the user's response.
*/
- virtual void Response(CFX_WideString& wsAnswer,
- const CFX_WideStringC& wsQuestion,
- const CFX_WideStringC& wsTitle = FX_WSTRC(L""),
- const CFX_WideStringC& wsDefaultAnswer = FX_WSTRC(L""),
- FX_BOOL bMark = TRUE) = 0;
+ virtual CFX_WideString Response(const CFX_WideString& wsQuestion,
+ const CFX_WideString& wsTitle = L"",
+ const CFX_WideString& wsDefaultAnswer = L"",
+ FX_BOOL bMask = TRUE) = 0;
virtual int32_t GetDocumentCountInBatch() = 0;
virtual int32_t GetCurDocumentInBatch() = 0;
@@ -222,7 +345,7 @@ class IXFA_AppProvider {
* @param[in] wsURL - http, ftp, such as
* "http://www.w3.org/TR/REC-xml-names/".
*/
- virtual IFX_FileRead* DownloadURL(const CFX_WideStringC& wsURL) = 0;
+ virtual IFX_FileRead* DownloadURL(const CFX_WideString& wsURL) = 0;
/**
* POST data to the given url.
@@ -239,11 +362,11 @@ class IXFA_AppProvider {
* @param[out] wsResponse decoded response from server.
* @return TRUE Server permitted the post request, FALSE otherwise.
*/
- virtual FX_BOOL PostRequestURL(const CFX_WideStringC& wsURL,
- const CFX_WideStringC& wsData,
- const CFX_WideStringC& wsContentType,
- const CFX_WideStringC& wsEncode,
- const CFX_WideStringC& wsHeader,
+ virtual FX_BOOL PostRequestURL(const CFX_WideString& wsURL,
+ const CFX_WideString& wsData,
+ const CFX_WideString& wsContentType,
+ const CFX_WideString& wsEncode,
+ const CFX_WideString& wsHeader,
CFX_WideString& wsResponse) = 0;
/**
@@ -254,35 +377,14 @@ class IXFA_AppProvider {
* ISO8859-1, any recognized [IANA]character encoding
* @return TRUE Server permitted the post request, FALSE otherwise.
*/
- virtual FX_BOOL PutRequestURL(const CFX_WideStringC& wsURL,
- const CFX_WideStringC& wsData,
- const CFX_WideStringC& wsEncode) = 0;
+ virtual FX_BOOL PutRequestURL(const CFX_WideString& wsURL,
+ const CFX_WideString& wsData,
+ const CFX_WideString& wsEncode) = 0;
virtual void LoadString(int32_t iStringID, CFX_WideString& wsString) = 0;
- virtual FX_BOOL ShowFileDialog(const CFX_WideStringC& wsTitle,
- const CFX_WideStringC& wsFilter,
- CFX_WideStringArray& wsPathArr,
- FX_BOOL bOpen = TRUE) = 0;
virtual IFWL_AdapterTimerMgr* GetTimerMgr() = 0;
};
-#define XFA_INVALIDATE_AllPages 0x00000000
-#define XFA_INVALIDATE_CurrentPage 0x00000001
-#define XFA_PRINTOPT_ShowDialog 0x00000001
-#define XFA_PRINTOPT_CanCancel 0x00000002
-#define XFA_PRINTOPT_ShrinkPage 0x00000004
-#define XFA_PRINTOPT_AsImage 0x00000008
-#define XFA_PRINTOPT_ReverseOrder 0x00000010
-#define XFA_PRINTOPT_PrintAnnot 0x00000020
-#define XFA_PAGEVIEWEVENT_PostAdded 1
-#define XFA_PAGEVIEWEVENT_PostRemoved 3
-#define XFA_PAGEVIEWEVENT_StopLayout 4
-#define XFA_WIDGETEVENT_PostAdded 2
-#define XFA_WIDGETEVENT_PreRemoved 3
-#define XFA_WIDGETEVENT_PostContentChanged 6
-#define XFA_WIDGETEVENT_ListItemRemoved 7
-#define XFA_WIDGETEVENT_ListItemAdded 8
-#define XFA_WIDGETEVENT_AccessChanged 9
class IXFA_DocProvider {
public:
virtual ~IXFA_DocProvider() {}
@@ -303,11 +405,10 @@ class IXFA_DocProvider {
CFX_PointF ptPopup,
const CFX_RectF* pRectExclude = NULL) = 0;
virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) = 0;
- virtual void WidgetEvent(CXFA_FFWidget* hWidget,
- CXFA_WidgetAcc* pWidgetData,
- uint32_t dwEvent,
- void* pParam = NULL,
- void* pAdditional = NULL) = 0;
+ virtual void WidgetPostAdd(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData) = 0;
+ virtual void WidgetPreRemove(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData) = 0;
virtual FX_BOOL RenderCustomWidget(CXFA_FFWidget* hWidget,
CFX_Graphics* pGS,
CFX_Matrix* pMatrix,
@@ -320,14 +421,14 @@ class IXFA_DocProvider {
virtual FX_BOOL IsCalculationsEnabled(CXFA_FFDoc* hDoc) = 0;
virtual void SetCalculationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) = 0;
virtual void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) = 0;
- virtual void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideStringC& wsTitle) = 0;
+ virtual void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) = 0;
virtual void ExportData(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFilePath,
+ const CFX_WideString& wsFilePath,
FX_BOOL bXDP = TRUE) = 0;
virtual void ImportData(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& wsFilePath) = 0;
+ const CFX_WideString& wsFilePath) = 0;
virtual void GotoURL(CXFA_FFDoc* hDoc,
- const CFX_WideStringC& bsURL,
+ const CFX_WideString& bsURL,
FX_BOOL bAppend = TRUE) = 0;
virtual FX_BOOL IsValidationsEnabled(CXFA_FFDoc* hDoc) = 0;
virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, FX_BOOL bEnabled) = 0;
@@ -382,79 +483,31 @@ class IXFA_DocProvider {
virtual IFX_FileRead* OpenLinkedFile(CXFA_FFDoc* hDoc,
const CFX_WideString& wsLink) = 0;
};
-#define XFA_DOCVIEW_View 0x00000000
-#define XFA_DOCVIEW_MasterPage 0x00000001
-#define XFA_DOCVIEW_Design 0x00000002
-#define XFA_DOCTYPE_Dynamic 0
-#define XFA_DOCTYPE_Static 1
-#define XFA_DOCTYPE_XDP 2
-#define XFA_PARSESTATUS_StatusErr -3
-#define XFA_PARSESTATUS_StreamErr -2
-#define XFA_PARSESTATUS_SyntaxErr -1
-#define XFA_PARSESTATUS_Ready 0
-#define XFA_PARSESTATUS_Done 100
-enum XFA_EVENTTYPE {
- XFA_EVENT_Click,
- XFA_EVENT_Change,
- XFA_EVENT_DocClose,
- XFA_EVENT_DocReady,
- XFA_EVENT_Enter,
- XFA_EVENT_Exit,
- XFA_EVENT_Full,
- XFA_EVENT_IndexChange,
- XFA_EVENT_Initialize,
- XFA_EVENT_MouseDown,
- XFA_EVENT_MouseEnter,
- XFA_EVENT_MouseExit,
- XFA_EVENT_MouseUp,
- XFA_EVENT_PostExecute,
- XFA_EVENT_PostOpen,
- XFA_EVENT_PostPrint,
- XFA_EVENT_PostSave,
- XFA_EVENT_PostSign,
- XFA_EVENT_PostSubmit,
- XFA_EVENT_PreExecute,
- XFA_EVENT_PreOpen,
- XFA_EVENT_PrePrint,
- XFA_EVENT_PreSave,
- XFA_EVENT_PreSign,
- XFA_EVENT_PreSubmit,
- XFA_EVENT_Ready,
- XFA_EVENT_InitCalculate,
- XFA_EVENT_InitVariables,
- XFA_EVENT_Calculate,
- XFA_EVENT_Validate,
- XFA_EVENT_Unknown,
-};
-#define XFA_VALIDATE_preSubmit 1
-#define XFA_VALIDATE_prePrint 2
-#define XFA_VALIDATE_preExecute 3
-#define XFA_VALIDATE_preSave 4
class CXFA_EventParam {
public:
CXFA_EventParam() {
m_pTarget = NULL;
m_eType = XFA_EVENT_Unknown;
- m_wsResult.Empty();
+ m_wsResult.clear();
Reset();
}
void Reset() {
- m_wsChange.Empty();
+ m_wsChange.clear();
m_iCommitKey = 0;
- m_wsFullText.Empty();
+ m_wsFullText.clear();
m_bKeyDown = FALSE;
m_bModifier = FALSE;
- m_wsNewContentType.Empty();
- m_wsNewText.Empty();
- m_wsPrevContentType.Empty();
- m_wsPrevText.Empty();
+ m_wsNewContentType.clear();
+ m_wsNewText.clear();
+ m_wsPrevContentType.clear();
+ m_wsPrevText.clear();
m_bReenter = FALSE;
m_iSelEnd = 0;
m_iSelStart = 0;
m_bShift = FALSE;
- m_wsSoapFaultCode.Empty();
- m_wsSoapFaultString.Empty();
+ m_wsSoapFaultCode.clear();
+ m_wsSoapFaultString.clear();
m_bIsFormReady = FALSE;
m_iValidateActivities = XFA_VALIDATE_preSubmit;
}
@@ -480,21 +533,6 @@ class CXFA_EventParam {
FX_BOOL m_bIsFormReady;
int32_t m_iValidateActivities;
};
-#define XFA_EVENTERROR_Success 1
-#define XFA_EVENTERROR_Error -1
-#define XFA_EVENTERROR_NotExist 0
-#define XFA_EVENTERROR_Disabled 2
-enum XFA_WIDGETORDER {
- XFA_WIDGETORDER_PreOrder,
-};
-
-#define XFA_TRAVERSEWAY_Tranvalse 0x0001
-#define XFA_TRAVERSEWAY_Form 0x0002
-#define XFA_WIDGETFILTER_Visible 0x0001
-#define XFA_WIDGETFILTER_Viewable 0x0010
-#define XFA_WIDGETFILTER_Printable 0x0020
-#define XFA_WIDGETFILTER_Field 0x0100
-#define XFA_WIDGETFILTER_AllType 0x0F00
class CXFA_RenderOptions {
public:
@@ -502,44 +540,11 @@ class CXFA_RenderOptions {
FX_BOOL m_bPrint;
FX_BOOL m_bHighlight;
};
-#define XFA_RENDERSTATUS_Ready 1
-#define XFA_RENDERSTATUS_ToBeContinued 2
-#define XFA_RENDERSTATUS_Done 3
-#define XFA_RENDERSTATUS_Failed -1
-
-enum XFA_WIDGETTYPE {
- XFA_WIDGETTYPE_Barcode,
- XFA_WIDGETTYPE_PushButton,
- XFA_WIDGETTYPE_CheckButton,
- XFA_WIDGETTYPE_RadioButton,
- XFA_WIDGETTYPE_DatetimeEdit,
- XFA_WIDGETTYPE_DecimalField,
- XFA_WIDGETTYPE_NumericField,
- XFA_WIDGETTYPE_Signature,
- XFA_WIDGETTYPE_TextEdit,
- XFA_WIDGETTYPE_DropdownList,
- XFA_WIDGETTYPE_ListBox,
- XFA_WIDGETTYPE_ImageField,
- XFA_WIDGETTYPE_PasswordEdit,
- XFA_WIDGETTYPE_Arc,
- XFA_WIDGETTYPE_Rectangle,
- XFA_WIDGETTYPE_Image,
- XFA_WIDGETTYPE_Line,
- XFA_WIDGETTYPE_Text,
- XFA_WIDGETTYPE_ExcludeGroup,
- XFA_WIDGETTYPE_Subform,
- XFA_WIDGETTYPE_Unknown,
-};
-#define XFA_WIDGETSTATUS_Visible 0x00000001
-#define XFA_WIDGETSTATUS_Invisible 0x00000002
-#define XFA_WIDGETSTATUS_Hidden 0x00000004
-#define XFA_WIDGETSTATUS_Viewable 0x00000010
-#define XFA_WIDGETSTATUS_Printable 0x00000020
-#define XFA_WIDGETSTATUS_Focused 0x00000100
class IXFA_WidgetIterator {
public:
- virtual void Release() = 0;
+ virtual ~IXFA_WidgetIterator() {}
+
virtual void Reset() = 0;
virtual CXFA_FFWidget* MoveToFirst() = 0;
virtual CXFA_FFWidget* MoveToLast() = 0;
@@ -547,9 +552,6 @@ class IXFA_WidgetIterator {
virtual CXFA_FFWidget* MoveToPrevious() = 0;
virtual CXFA_FFWidget* GetCurrentWidget() = 0;
virtual FX_BOOL SetCurrentWidget(CXFA_FFWidget* hWidget) = 0;
-
- protected:
- ~IXFA_WidgetIterator() {}
};
-#endif // XFA_INCLUDE_FXFA_FXFA_H_
+#endif // XFA_FXFA_INCLUDE_FXFA_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/fxfa_basic.h b/chromium/third_party/pdfium/xfa/fxfa/include/fxfa_basic.h
index ff151d19ab6..30b7b6bdfe2 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/fxfa_basic.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/fxfa_basic.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_FXFA_BASIC_H_
-#define XFA_INCLUDE_FXFA_FXFA_BASIC_H_
+#ifndef XFA_FXFA_INCLUDE_FXFA_BASIC_H_
+#define XFA_FXFA_INCLUDE_FXFA_BASIC_H_
#include "xfa/fxjse/cfxjse_arguments.h"
#include "xfa/fxjse/include/fxjse.h"
@@ -926,9 +926,10 @@ struct XFA_ELEMENTINFO {
uint32_t dwPackets;
uint32_t eObjectType;
};
-int32_t XFA_GetElementCount();
+
const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName);
const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_ELEMENT eName);
+
enum XFA_ATTRIBUTETYPE {
XFA_ATTRIBUTETYPE_NOTSURE,
XFA_ATTRIBUTETYPE_Enum,
@@ -945,7 +946,7 @@ struct XFA_ATTRIBUTEINFO {
uint32_t dwPackets;
void* pDefValue;
};
-int32_t XFA_GetAttributeCount();
+
const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName);
const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName);
FX_BOOL XFA_GetAttributeDefaultValue(void*& pValue,
@@ -962,9 +963,6 @@ CFX_WideStringC XFA_GetAttributeDefaultValue_Cdata(XFA_ELEMENT eElement,
FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement,
XFA_ATTRIBUTE eAttribute,
uint32_t dwPacket);
-int32_t XFA_GetAttributeDefaultValue_Integer(XFA_ELEMENT eElement,
- XFA_ATTRIBUTE eAttribute,
- uint32_t dwPacket);
CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement,
XFA_ATTRIBUTE eAttribute,
uint32_t dwPacket);
@@ -981,12 +979,9 @@ struct XFA_SCRIPTHIERARCHY {
int16_t wParentIndex;
};
-typedef XFA_SCRIPTHIERARCHY const* XFA_LPCSCRIPTHIERARCHY;
const uint16_t* XFA_GetElementChildren(XFA_ELEMENT eElement, int32_t& iCount);
const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount);
-const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement,
- XFA_ELEMENT eChild,
- uint32_t dwPacket);
+
const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement,
XFA_ATTRIBUTE eAttribute,
uint32_t dwPacket);
@@ -1047,15 +1042,17 @@ class CXFA_Measurement {
FX_FLOAT m_fValue;
XFA_UNIT m_eUnit;
};
+
class CFXJSE_Arguments;
class CXFA_Object;
+
typedef void (CXFA_Object::*XFA_METHOD_CALLBACK)(CFXJSE_Arguments* pArguments);
struct XFA_METHODINFO {
uint32_t uHash;
const FX_WCHAR* pName;
XFA_METHOD_CALLBACK lpfnCallback;
};
-int32_t XFA_GetMethodCount();
+
const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement,
const CFX_WideStringC& wsMethodName);
typedef void (CXFA_Object::*XFA_ATTRIBUTE_CALLBACK)(FXJSE_HVALUE hValue,
@@ -1076,4 +1073,4 @@ const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(
XFA_ELEMENT eElement,
const CFX_WideStringC& wsAttributeName);
-#endif // XFA_INCLUDE_FXFA_FXFA_BASIC_H_
+#endif // XFA_FXFA_INCLUDE_FXFA_BASIC_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/fxfa_widget.h b/chromium/third_party/pdfium/xfa/fxfa/include/fxfa_widget.h
index f1fcffefc4a..3745a38ec02 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/fxfa_widget.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/fxfa_widget.h
@@ -4,10 +4,18 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_FXFA_WIDGET_H_
-#define XFA_INCLUDE_FXFA_FXFA_WIDGET_H_
+#ifndef XFA_FXFA_INCLUDE_FXFA_WIDGET_H_
+#define XFA_FXFA_INCLUDE_FXFA_WIDGET_H_
-#include "xfa/include/fxfa/fxfa_objectacc.h"
+#include "core/fxcrt/include/fx_coordinates.h"
+#include "core/fxge/include/fx_dib.h"
+#include "xfa/fxfa/parser/cxfa_box.h"
+#include "xfa/fxfa/parser/cxfa_event.h"
+#include "xfa/fxfa/parser/cxfa_image.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
+#include "xfa/fxfa/parser/cxfa_widgetdata.h"
class CXFA_Node;
class CXFA_FFDocView;
@@ -27,13 +35,11 @@ class CXFA_WidgetAcc : public CXFA_WidgetData {
FX_BOOL GetName(CFX_WideString& wsName, int32_t iNameType = 0);
FX_BOOL ProcessValueChanged();
-
- public:
void ResetData();
- void SetImageEdit(const CFX_WideStringC& wsContentType,
- const CFX_WideStringC& wsHref,
- const CFX_WideStringC& wsData);
+ void SetImageEdit(const CFX_WideString& wsContentType,
+ const CFX_WideString& wsHref,
+ const CFX_WideString& wsData);
CXFA_WidgetAcc* GetExclGroup();
CXFA_FFDocView* GetDocView();
@@ -65,10 +71,6 @@ class CXFA_WidgetAcc : public CXFA_WidgetData {
void SetImageImage(CFX_DIBitmap* newImage);
void SetImageEditImage(CFX_DIBitmap* newImage);
void UpdateUIDisplay(CXFA_FFWidget* pExcept = NULL);
- void NotifyEvent(uint32_t dwEvent,
- CXFA_FFWidget* pWidget = NULL,
- void* pParam = NULL,
- void* pAdditional = NULL);
CXFA_Node* GetDatasets();
IFX_Font* GetFDEFont();
@@ -117,4 +119,4 @@ class CXFA_WidgetAcc : public CXFA_WidgetData {
uint32_t m_nRecursionDepth;
};
-#endif // XFA_INCLUDE_FXFA_FXFA_WIDGET_H_
+#endif // XFA_FXFA_INCLUDE_FXFA_WIDGET_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/include/xfa_checksum.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_checksum.h
new file mode 100644
index 00000000000..6c7ea7a04c9
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_checksum.h
@@ -0,0 +1,78 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_INCLUDE_XFA_CHECKSUM_H_
+#define XFA_FXFA_INCLUDE_XFA_CHECKSUM_H_
+
+#include "xfa/fgas/xml/fgas_sax.h"
+#include "xfa/fxfa/include/fxfa.h"
+
+class CXFA_SAXReaderHandler;
+class CXFA_ChecksumContext;
+
+class CXFA_SAXContext {
+ public:
+ CXFA_SAXContext() : m_eNode(FX_SAXNODE_Unknown) {}
+
+ CFX_ByteTextBuf m_TextBuf;
+ CFX_ByteString m_bsTagName;
+ FX_SAXNODE m_eNode;
+};
+
+class CXFA_SAXReaderHandler {
+ public:
+ CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext);
+ ~CXFA_SAXReaderHandler();
+
+ void* OnTagEnter(const CFX_ByteStringC& bsTagName,
+ FX_SAXNODE eType,
+ uint32_t dwStartPos);
+ void OnTagAttribute(void* pTag,
+ const CFX_ByteStringC& bsAttri,
+ const CFX_ByteStringC& bsValue);
+ void OnTagBreak(void* pTag);
+ void OnTagData(void* pTag,
+ FX_SAXNODE eType,
+ const CFX_ByteStringC& bsData,
+ uint32_t dwStartPos);
+ void OnTagClose(void* pTag, uint32_t dwEndPos);
+ void OnTagEnd(void* pTag,
+ const CFX_ByteStringC& bsTagName,
+ uint32_t dwEndPos);
+
+ void OnTargetData(void* pTag,
+ FX_SAXNODE eType,
+ const CFX_ByteStringC& bsData,
+ uint32_t dwStartPos);
+
+ protected:
+ void UpdateChecksum(FX_BOOL bCheckSpace);
+
+ CXFA_ChecksumContext* m_pContext;
+ CXFA_SAXContext m_SAXContext;
+};
+
+class CXFA_ChecksumContext {
+ public:
+ CXFA_ChecksumContext();
+ ~CXFA_ChecksumContext();
+
+ void Release() { delete this; }
+ void StartChecksum();
+ FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile,
+ FX_FILESIZE offset = 0,
+ size_t size = 0);
+ void FinishChecksum();
+ void GetChecksum(CFX_ByteString& bsChecksum);
+ void Update(const CFX_ByteStringC& bsText);
+
+ protected:
+ CFX_SAXReader* m_pSAXReader;
+ uint8_t* m_pByteContext;
+ CFX_ByteString m_bsChecksum;
+};
+
+#endif // XFA_FXFA_INCLUDE_XFA_CHECKSUM_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffapp.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffapp.h
index c17b9e66de9..c8df27da5b9 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffapp.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffapp.h
@@ -4,22 +4,22 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_FFAPP_H_
-#define XFA_INCLUDE_FXFA_XFA_FFAPP_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_FFAPP_H_
+#define XFA_FXFA_INCLUDE_XFA_FFAPP_H_
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "xfa/fgas/font/fgas_font.h"
-#include "xfa/fwl/core/fwl_sdadapterimp.h"
-#include "xfa/fwl/core/ifwl_adapternative.h"
#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/include/fxfa/fxfa.h"
+#include "xfa/fxfa/include/fxfa.h"
+class CFWL_WidgetMgrDelegate;
class CXFA_DefFontMgr;
class CXFA_FWLAdapterWidgetMgr;
class CXFA_FWLTheme;
class CXFA_FFDocHandler;
class CXFA_FontMgr;
+class IFWL_AdapterTimerMgr;
class CXFA_FileRead : public IFX_FileRead {
public:
@@ -34,10 +34,10 @@ class CXFA_FileRead : public IFX_FileRead {
CFX_ObjectArray<CPDF_StreamAcc> m_Data;
};
-class CXFA_FFApp : public IFWL_AdapterNative {
+class CXFA_FFApp {
public:
CXFA_FFApp(IXFA_AppProvider* pProvider);
- ~CXFA_FFApp() override;
+ ~CXFA_FFApp();
CXFA_FFDocHandler* GetDocHandler();
CXFA_FFDoc* CreateDoc(IXFA_DocProvider* pProvider,
@@ -47,16 +47,13 @@ class CXFA_FFApp : public IFWL_AdapterNative {
IXFA_AppProvider* GetAppProvider() { return m_pProvider; }
void SetDefaultFontMgr(CXFA_DefFontMgr* pFontMgr);
- // IFWL_AdapterNative:
- IFWL_AdapterWidgetMgr* GetWidgetMgr(
- IFWL_WidgetMgrDelegate* pDelegate) override;
- IFWL_AdapterThreadMgr* GetThreadMgr() override;
- IFWL_AdapterTimerMgr* GetTimerMgr() override;
+ CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(CFWL_WidgetMgrDelegate* pDelegate);
+ IFWL_AdapterTimerMgr* GetTimerMgr();
CXFA_FontMgr* GetXFAFontMgr();
IFX_FontMgr* GetFDEFontMgr();
CXFA_FWLTheme* GetFWLTheme();
- IFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() {
+ CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() {
return m_pWidgetMgrDelegate;
}
@@ -67,12 +64,11 @@ class CXFA_FFApp : public IFWL_AdapterNative {
IXFA_AppProvider* m_pProvider;
CXFA_FontMgr* m_pFontMgr;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- IFX_FontSourceEnum* m_pFontSource;
+ CFX_FontSourceEnum_File* m_pFontSource;
#endif
CXFA_FWLAdapterWidgetMgr* m_pAdapterWidgetMgr;
- IFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate;
+ CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate;
IFX_FontMgr* m_pFDEFontMgr;
- CFWL_SDAdapterThreadMgr* m_pAdapterThreadMgr;
};
-#endif // XFA_INCLUDE_FXFA_XFA_FFAPP_H_
+#endif // XFA_FXFA_INCLUDE_XFA_FFAPP_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdoc.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdoc.h
index ebae04b7919..2569b505ff3 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdoc.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdoc.h
@@ -4,11 +4,14 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_FFDOC_H_
-#define XFA_INCLUDE_FXFA_XFA_FFDOC_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_FFDOC_H_
+#define XFA_FXFA_INCLUDE_XFA_FFDOC_H_
+#include <map>
+#include <memory>
+
+#include "xfa/fxfa/include/fxfa.h"
#include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/include/fxfa/fxfa.h"
class CXFA_ChecksumContext;
class CXFA_FFApp;
@@ -56,10 +59,10 @@ class CXFA_FFDoc {
CXFA_FFApp* m_pApp;
CXFA_FFNotify* m_pNotify;
CPDF_Document* m_pPDFDoc;
- CFX_MapPtrToPtr m_mapNamedImages;
- CFX_MapPtrToPtr m_mapTypeToDocView;
+ std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap;
+ std::map<uint32_t, std::unique_ptr<CXFA_FFDocView>> m_TypeToDocViewMap;
uint32_t m_dwDocType;
FX_BOOL m_bOwnStream;
};
-#endif // XFA_INCLUDE_FXFA_XFA_FFDOC_H_
+#endif // XFA_FXFA_INCLUDE_XFA_FFDOC_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdochandler.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdochandler.h
index 6350d650794..9cd9b0e632a 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdochandler.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdochandler.h
@@ -4,10 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_FFDOCHANDLER_H_
-#define XFA_INCLUDE_FXFA_XFA_FFDOCHANDLER_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_FFDOCHANDLER_H_
+#define XFA_FXFA_INCLUDE_XFA_FFDOCHANDLER_H_
-#include "xfa/include/fxfa/fxfa.h"
+#include "xfa/fxfa/include/fxfa.h"
class CXFA_ChecksumContext;
@@ -28,4 +28,4 @@ class CXFA_FFDocHandler {
protected:
};
-#endif // XFA_INCLUDE_FXFA_XFA_FFDOCHANDLER_H_
+#endif // XFA_FXFA_INCLUDE_XFA_FFDOCHANDLER_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdocview.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdocview.h
index e8a29111a7a..473b820defe 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffdocview.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffdocview.h
@@ -4,10 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_FFDOCVIEW_H_
-#define XFA_INCLUDE_FXFA_XFA_FFDOCVIEW_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_FFDOCVIEW_H_
+#define XFA_FXFA_INCLUDE_XFA_FFDOCVIEW_H_
-#include "xfa/include/fxfa/xfa_ffdoc.h"
+#include "xfa/fxfa/include/xfa_ffdoc.h"
class CXFA_FFWidgetHandler;
class CXFA_FFDoc;
@@ -38,16 +38,16 @@ class CXFA_FFDocView {
CXFA_FFDoc* GetDoc() { return m_pDoc; }
int32_t StartLayout(int32_t iStartPage = 0);
- int32_t DoLayout(IFX_Pause* pPause = NULL);
+ int32_t DoLayout(IFX_Pause* pPause = nullptr);
void StopLayout();
int32_t GetLayoutStatus();
void UpdateDocView();
int32_t CountPageViews();
CXFA_FFPageView* GetPageView(int32_t nIndex);
- void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc = NULL);
+ void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc = nullptr);
int32_t ProcessWidgetEvent(CXFA_EventParam* pParam,
- CXFA_WidgetAcc* pWidgetAcc = NULL);
+ CXFA_WidgetAcc* pWidgetAcc = nullptr);
CXFA_FFWidgetHandler* GetWidgetHandler();
IXFA_WidgetIterator* CreateWidgetIterator();
CXFA_WidgetAccIterator* CreateWidgetAccIterator(
@@ -55,14 +55,12 @@ class CXFA_FFDocView {
CXFA_FFWidget* GetFocusWidget();
void KillFocus();
FX_BOOL SetFocus(CXFA_FFWidget* hWidget);
- CXFA_FFWidget* GetWidgetByName(const CFX_WideStringC& wsName,
- CXFA_FFWidget* pRefWidget = NULL);
- CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideStringC& wsName,
- CXFA_WidgetAcc* pRefWidgetAcc = NULL);
+ CXFA_FFWidget* GetWidgetByName(const CFX_WideString& wsName,
+ CXFA_FFWidget* pRefWidget = nullptr);
+ CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideString& wsName,
+ CXFA_WidgetAcc* pRefWidgetAcc = nullptr);
CXFA_LayoutProcessor* GetXFALayout() const;
- void OnPageEvent(CXFA_ContainerLayoutItem* pSender,
- XFA_PAGEEVENT eEvent,
- int32_t iPageIndex);
+ void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent);
void LockUpdate();
void UnlockUpdate();
FX_BOOL IsUpdateLocked();
@@ -95,7 +93,7 @@ class CXFA_FFDocView {
XFA_EVENTTYPE eEventType,
FX_BOOL bIsFormReady = FALSE,
FX_BOOL bRecursive = TRUE,
- CXFA_Node* pExclude = NULL);
+ CXFA_Node* pExclude = nullptr);
FX_BOOL m_bLayoutEvent;
CFX_WideStringArray m_arrNullTestMsg;
CXFA_FFWidget* m_pListFocusWidget;
@@ -118,30 +116,29 @@ class CXFA_FFDocView {
CXFA_FFWidget* m_pFocusWidget;
CXFA_FFWidget* m_pOldFocusWidget;
CFX_MapPtrToPtr m_mapPageInvalidate;
- CFX_PtrArray m_ValidateAccs;
- CFX_PtrArray m_bindItems;
- CFX_PtrArray m_CalculateAccs;
-
- CFX_PtrArray m_NewAddedNodes;
- CFX_PtrArray m_IndexChangedSubforms;
+ CFX_ArrayTemplate<CXFA_WidgetAcc*> m_ValidateAccs;
+ CFX_ArrayTemplate<CXFA_WidgetAcc*> m_CalculateAccs;
+ CFX_ArrayTemplate<CXFA_Node*> m_BindItems;
+ CFX_ArrayTemplate<CXFA_Node*> m_NewAddedNodes;
+ CFX_ArrayTemplate<CXFA_Node*> m_IndexChangedSubforms;
XFA_DOCVIEW_LAYOUTSTATUS m_iStatus;
int32_t m_iLock;
friend class CXFA_FFNotify;
};
+
class CXFA_FFDocWidgetIterator : public IXFA_WidgetIterator {
public:
CXFA_FFDocWidgetIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot);
- virtual ~CXFA_FFDocWidgetIterator();
-
- virtual void Release() { delete this; }
+ ~CXFA_FFDocWidgetIterator() override;
- virtual void Reset();
- virtual CXFA_FFWidget* MoveToFirst();
- virtual CXFA_FFWidget* MoveToLast();
- virtual CXFA_FFWidget* MoveToNext();
- virtual CXFA_FFWidget* MoveToPrevious();
- virtual CXFA_FFWidget* GetCurrentWidget();
- virtual FX_BOOL SetCurrentWidget(CXFA_FFWidget* hWidget);
+ // IXFA_WidgetIterator:
+ void Reset() override;
+ CXFA_FFWidget* MoveToFirst() override;
+ CXFA_FFWidget* MoveToLast() override;
+ CXFA_FFWidget* MoveToNext() override;
+ CXFA_FFWidget* MoveToPrevious() override;
+ CXFA_FFWidget* GetCurrentWidget() override;
+ FX_BOOL SetCurrentWidget(CXFA_FFWidget* hWidget) override;
protected:
CXFA_ContainerIterator m_ContentIterator;
@@ -169,4 +166,4 @@ class CXFA_WidgetAccIterator {
CXFA_WidgetAcc* m_pCurWidgetAcc;
};
-#endif // XFA_INCLUDE_FXFA_XFA_FFDOCVIEW_H_
+#endif // XFA_FXFA_INCLUDE_XFA_FFDOCVIEW_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffpageview.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffpageview.h
index cce1cc13e1a..124c8db4d27 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffpageview.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffpageview.h
@@ -4,48 +4,42 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_FFPAGEVIEW_H_
-#define XFA_INCLUDE_FXFA_XFA_FFPAGEVIEW_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_FFPAGEVIEW_H_
+#define XFA_FXFA_INCLUDE_XFA_FFPAGEVIEW_H_
#include "xfa/fxfa/parser/xfa_doclayout.h"
class CXFA_FFWidget;
class CXFA_FFDocView;
+
class CXFA_FFPageView : public CXFA_ContainerLayoutItem {
public:
CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea);
~CXFA_FFPageView() override;
- CXFA_FFDocView* GetDocView();
- int32_t GetPageViewIndex();
- void GetPageViewRect(CFX_RectF& rtPage);
+ CXFA_FFDocView* GetDocView() const;
+ int32_t GetPageViewIndex() const;
+ void GetPageViewRect(CFX_RectF& rtPage) const;
void GetDisplayMatrix(CFX_Matrix& mt,
const CFX_Rect& rtDisp,
- int32_t iRotate);
- int32_t LoadPageView(IFX_Pause* pPause = NULL);
- void UnloadPageView();
- CXFA_FFWidget* GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy);
+ int32_t iRotate) const;
IXFA_WidgetIterator* CreateWidgetIterator(
uint32_t dwTraverseWay = XFA_TRAVERSEWAY_Form,
- uint32_t dwWidgetFilter = XFA_WIDGETFILTER_Visible |
- XFA_WIDGETFILTER_Viewable |
- XFA_WIDGETFILTER_AllType);
-
- FX_BOOL IsPageViewLoaded();
+ uint32_t dwWidgetFilter = XFA_WidgetStatus_Visible |
+ XFA_WidgetStatus_Viewable);
protected:
- CXFA_FFDocView* m_pDocView;
- FX_BOOL m_bLoaded;
+ CXFA_FFDocView* const m_pDocView;
};
+
typedef CXFA_NodeIteratorTemplate<CXFA_LayoutItem,
CXFA_TraverseStrategy_LayoutItem>
CXFA_LayoutItemIterator;
+
class CXFA_FFPageWidgetIterator : public IXFA_WidgetIterator {
public:
CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, uint32_t dwFilter);
- virtual ~CXFA_FFPageWidgetIterator();
-
- void Release() override { delete this; }
+ ~CXFA_FFPageWidgetIterator() override;
void Reset() override;
CXFA_FFWidget* MoveToFirst() override;
@@ -77,9 +71,7 @@ class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator {
public:
CXFA_FFTabOrderPageWidgetIterator(CXFA_FFPageView* pPageView,
uint32_t dwFilter);
- virtual ~CXFA_FFTabOrderPageWidgetIterator();
-
- void Release() override;
+ ~CXFA_FFTabOrderPageWidgetIterator() override;
void Reset() override;
CXFA_FFWidget* MoveToFirst() override;
@@ -91,7 +83,7 @@ class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator {
protected:
CXFA_FFWidget* GetTraverseWidget(CXFA_FFWidget* pWidget);
- CXFA_FFWidget* FindWidgetByName(const CFX_WideStringC& wsWidgetName,
+ CXFA_FFWidget* FindWidgetByName(const CFX_WideString& wsWidgetName,
CXFA_FFWidget* pRefWidget);
void CreateTabOrderWidgetArray();
void CreateSpaceOrderWidgetArray(CXFA_WidgetArray& WidgetArray);
@@ -110,4 +102,4 @@ class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator {
FX_BOOL m_bIgnorerelevant;
};
-#endif // XFA_INCLUDE_FXFA_XFA_FFPAGEVIEW_H_
+#endif // XFA_FXFA_INCLUDE_XFA_FFPAGEVIEW_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffwidget.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffwidget.h
index f82bf2faf7e..783bac5ab45 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffwidget.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffwidget.h
@@ -4,20 +4,21 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_FFWIDGET_H_
-#define XFA_INCLUDE_FXFA_XFA_FFWIDGET_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_FFWIDGET_H_
+#define XFA_FXFA_INCLUDE_XFA_FFWIDGET_H_
#include <vector>
-#include "core/include/fxcodec/fx_codec_def.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxcodec/include/fx_codec_def.h"
+#include "core/fxge/include/fx_ge.h"
+#include "xfa/fxfa/include/fxfa.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
-#include "xfa/include/fxfa/fxfa.h"
class CXFA_FFPageView;
class CXFA_FFDocView;
class CXFA_FFDoc;
class CXFA_FFApp;
+enum class FWL_WidgetHit;
inline FX_FLOAT XFA_UnitPx2Pt(FX_FLOAT fPx, FX_FLOAT fDpi) {
return fPx * 72.0f / fDpi;
@@ -29,13 +30,16 @@ enum XFA_WIDGETITEM {
XFA_WIDGETITEM_NextSibling,
XFA_WIDGETITEM_PrevSibling,
};
+
class CXFA_CalcData {
public:
CXFA_CalcData() : m_iRefCount(0) {}
~CXFA_CalcData() { m_Globals.RemoveAll(); }
- CFX_PtrArray m_Globals;
+
+ CFX_ArrayTemplate<CXFA_WidgetAcc*> m_Globals;
int32_t m_iRefCount;
};
+
class CXFA_FFWidget : public CFX_PrivateData, public CXFA_ContentLayoutItem {
public:
CXFA_FFWidget(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc);
@@ -81,7 +85,7 @@ class CXFA_FFWidget : public CFX_PrivateData, public CXFA_ContentLayoutItem {
virtual FX_BOOL OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags);
virtual FX_BOOL OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags);
virtual FX_BOOL OnChar(uint32_t dwChar, uint32_t dwFlags);
- virtual uint32_t OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_WidgetHit OnHitTest(FX_FLOAT fx, FX_FLOAT fy);
virtual FX_BOOL OnSetCursor(FX_FLOAT fx, FX_FLOAT fy);
virtual FX_BOOL CanUndo() { return FALSE; }
virtual FX_BOOL CanRedo() { return FALSE; }
@@ -115,7 +119,7 @@ class CXFA_FFWidget : public CFX_PrivateData, public CXFA_ContentLayoutItem {
void InvalidateWidget(const CFX_RectF* pRect = NULL);
void AddInvalidateRect(const CFX_RectF* pRect = NULL);
FX_BOOL GetCaptionText(CFX_WideString& wsCap);
- FX_BOOL IsFocused();
+ bool IsFocused();
void Rotate2Normal(FX_FLOAT& fx, FX_FLOAT& fy);
void GetRotateMatrix(CFX_Matrix& mt);
FX_BOOL IsLayoutRectEmpty();
@@ -132,7 +136,7 @@ class CXFA_FFWidget : public CFX_PrivateData, public CXFA_ContentLayoutItem {
void GetMinMaxWidth(FX_FLOAT fMinWidth, FX_FLOAT fMaxWidth);
void GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight);
void GetRectWithoutRotate(CFX_RectF& rtWidget);
- FX_BOOL IsMatchVisibleStatus(uint32_t dwStatus);
+ bool IsMatchVisibleStatus(uint32_t dwStatus);
void EventKillFocus();
FX_BOOL IsButtonDown();
@@ -169,9 +173,6 @@ FX_CHAR* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len);
void XFA_RectWidthoutMargin(CFX_RectF& rt,
const CXFA_Margin& mg,
FX_BOOL bUI = FALSE);
-FX_FLOAT XFA_GetEdgeThickness(const CXFA_StrokeArray& strokes,
- FX_BOOL b3DStyle,
- int32_t nIndex);
CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem);
FX_BOOL XFA_IsCreateWidget(XFA_ELEMENT iType);
#define XFA_DRAWBOX_ForceRound 1
@@ -182,4 +183,4 @@ void XFA_DrawBox(CXFA_Box box,
CFX_Matrix* pMatrix,
uint32_t dwFlags = 0);
-#endif // XFA_INCLUDE_FXFA_XFA_FFWIDGET_H_
+#endif // XFA_FXFA_INCLUDE_XFA_FFWIDGET_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffwidgethandler.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffwidgethandler.h
index 52472084310..8159d87cf09 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_ffwidgethandler.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_ffwidgethandler.h
@@ -4,15 +4,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_FFWIDGETHANDLER_H_
-#define XFA_INCLUDE_FXFA_XFA_FFWIDGETHANDLER_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_FFWIDGETHANDLER_H_
+#define XFA_FXFA_INCLUDE_XFA_FFWIDGETHANDLER_H_
#include <vector>
+#include "xfa/fxfa/include/fxfa.h"
#include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/include/fxfa/fxfa.h"
class CXFA_FFDocView;
+enum class FWL_WidgetHit;
class CXFA_FFWidgetHandler {
public:
@@ -64,7 +65,7 @@ class CXFA_FFWidgetHandler {
uint32_t dwFlags);
FX_BOOL OnKeyUp(CXFA_FFWidget* hWidget, uint32_t dwKeyCode, uint32_t dwFlags);
FX_BOOL OnChar(CXFA_FFWidget* hWidget, uint32_t dwChar, uint32_t dwFlags);
- uint32_t OnHitTest(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy);
+ FWL_WidgetHit OnHitTest(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy);
FX_BOOL OnSetCursor(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy);
void RenderWidget(CXFA_FFWidget* hWidget,
CFX_Graphics* pGS,
@@ -124,4 +125,4 @@ class CXFA_FFWidgetHandler {
CXFA_FFDocView* m_pDocView;
};
-#endif // XFA_INCLUDE_FXFA_XFA_FFWIDGETHANDLER_H_
+#endif // XFA_FXFA_INCLUDE_XFA_FFWIDGETHANDLER_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_fontmgr.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_fontmgr.h
index 082c672805f..c7358a4c2ae 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_fontmgr.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_fontmgr.h
@@ -4,15 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_FONTMGR_H_
-#define XFA_INCLUDE_FXFA_XFA_FONTMGR_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_FONTMGR_H_
+#define XFA_FXFA_INCLUDE_XFA_FONTMGR_H_
#include <map>
#include "core/fxcrt/include/fx_ext.h"
#include "core/fxcrt/include/fx_system.h"
#include "xfa/fgas/font/fgas_font.h"
-#include "xfa/include/fxfa/fxfa.h"
+#include "xfa/fxfa/include/fxfa.h"
class CPDF_Font;
@@ -39,13 +39,14 @@ class CXFA_DefFontMgr {
uint16_t wCodePage = 0xFFFF);
protected:
- CFX_PtrArray m_CacheFonts;
+ CFX_ArrayTemplate<IFX_Font*> m_CacheFonts;
};
-class CXFA_PDFFontMgr : public IFX_FontProvider {
+class CXFA_PDFFontMgr {
public:
CXFA_PDFFontMgr(CXFA_FFDoc* pDoc);
~CXFA_PDFFontMgr();
+
IFX_Font* GetFont(const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
CPDF_Font** pPDFFont,
@@ -96,4 +97,4 @@ class CXFA_FontMgr {
std::map<CFX_ByteString, IFX_Font*> m_FontMap;
};
-#endif // XFA_INCLUDE_FXFA_XFA_FONTMGR_H_
+#endif // XFA_FXFA_INCLUDE_XFA_FONTMGR_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_rendercontext.h b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_rendercontext.h
index d6205275dfa..cd7949d78bf 100644
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_rendercontext.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/include/xfa_rendercontext.h
@@ -4,10 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_INCLUDE_FXFA_XFA_RENDERCONTEXT_H_
-#define XFA_INCLUDE_FXFA_XFA_RENDERCONTEXT_H_
+#ifndef XFA_FXFA_INCLUDE_XFA_RENDERCONTEXT_H_
+#define XFA_FXFA_INCLUDE_XFA_RENDERCONTEXT_H_
-#include "xfa/include/fxfa/fxfa.h"
+#include "xfa/fxfa/include/fxfa.h"
class CXFA_RenderContext {
public:
@@ -33,4 +33,4 @@ class CXFA_RenderContext {
CFX_RectF m_rtClipRect;
};
-#endif // XFA_INCLUDE_FXFA_XFA_RENDERCONTEXT_H_
+#endif // XFA_FXFA_INCLUDE_XFA_RENDERCONTEXT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/DEPS b/chromium/third_party/pdfium/xfa/fxfa/parser/DEPS
new file mode 100644
index 00000000000..97ccb1faa6a
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ '+core/fxcodec/include',
+]
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_arc.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_arc.h
new file mode 100644
index 00000000000..e712d806a72
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_arc.h
@@ -0,0 +1,19 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_ARC_H_
+#define XFA_FXFA_PARSER_CXFA_ARC_H_
+
+#include "xfa/fxfa/parser/cxfa_box.h"
+
+class CXFA_Node;
+
+class CXFA_Arc : public CXFA_Box {
+ public:
+ explicit CXFA_Arc(CXFA_Node* pNode) : CXFA_Box(pNode) {}
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_ARC_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_assist.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_assist.cpp
new file mode 100644
index 00000000000..e19be348ab4
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_assist.cpp
@@ -0,0 +1,15 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_assist.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Assist::CXFA_Assist(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+CXFA_ToolTip CXFA_Assist::GetToolTip() {
+ return CXFA_ToolTip(m_pNode->GetChild(0, XFA_ELEMENT_ToolTip));
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_assist.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_assist.h
new file mode 100644
index 00000000000..c583ff59d52
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_assist.h
@@ -0,0 +1,22 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_ASSIST_H_
+#define XFA_FXFA_PARSER_CXFA_ASSIST_H_
+
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_tooltip.h"
+
+class CXFA_Node;
+
+class CXFA_Assist : public CXFA_Data {
+ public:
+ explicit CXFA_Assist(CXFA_Node* pNode);
+
+ CXFA_ToolTip GetToolTip();
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_ASSIST_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_bind.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_bind.cpp
new file mode 100644
index 00000000000..e27a8b1e0d1
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_bind.cpp
@@ -0,0 +1,16 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_bind.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+void CXFA_Bind::GetPicture(CFX_WideString& wsPicture) {
+ if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture))
+ pPicture->TryContent(wsPicture);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_bind.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_bind.h
new file mode 100644
index 00000000000..2e2954eae2a
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_bind.h
@@ -0,0 +1,22 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_BIND_H_
+#define XFA_FXFA_PARSER_CXFA_BIND_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Bind : public CXFA_Data {
+ public:
+ explicit CXFA_Bind(CXFA_Node* pNode);
+
+ void GetPicture(CFX_WideString& wsPicture);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_BIND_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_binditems.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_binditems.cpp
new file mode 100644
index 00000000000..fa691fe38b9
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_binditems.cpp
@@ -0,0 +1,27 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_binditems.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+void CXFA_BindItems::GetLabelRef(CFX_WideStringC& wsLabelRef) {
+ m_pNode->TryCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef);
+}
+
+void CXFA_BindItems::GetValueRef(CFX_WideStringC& wsValueRef) {
+ m_pNode->TryCData(XFA_ATTRIBUTE_ValueRef, wsValueRef);
+}
+
+void CXFA_BindItems::GetRef(CFX_WideStringC& wsRef) {
+ m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
+}
+
+FX_BOOL CXFA_BindItems::SetConnection(const CFX_WideString& wsConnection) {
+ return m_pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_binditems.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_binditems.h
new file mode 100644
index 00000000000..3dc0b28878d
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_binditems.h
@@ -0,0 +1,25 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_BINDITEMS_H_
+#define XFA_FXFA_PARSER_CXFA_BINDITEMS_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_BindItems : public CXFA_Data {
+ public:
+ explicit CXFA_BindItems(CXFA_Node* pNode);
+
+ void GetLabelRef(CFX_WideStringC& wsLabelRef);
+ void GetValueRef(CFX_WideStringC& wsValueRef);
+ void GetRef(CFX_WideStringC& wsRef);
+ FX_BOOL SetConnection(const CFX_WideString& wsConnection);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_BINDITEMS_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_border.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_border.h
new file mode 100644
index 00000000000..27b469cd2f8
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_border.h
@@ -0,0 +1,19 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_BORDER_H_
+#define XFA_FXFA_PARSER_CXFA_BORDER_H_
+
+#include "xfa/fxfa/parser/cxfa_box.h"
+
+class CXFA_Node;
+
+class CXFA_Border : public CXFA_Box {
+ public:
+ explicit CXFA_Border(CXFA_Node* pNode) : CXFA_Box(pNode) {}
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_BORDER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_box.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_box.cpp
new file mode 100644
index 00000000000..fc572017506
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_box.cpp
@@ -0,0 +1,168 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_box.h"
+
+#include "xfa/fxfa/parser/cxfa_corner.h"
+#include "xfa/fxfa/parser/xfa_object.h"
+
+namespace {
+
+void GetStrokesInternal(CXFA_Node* pNode,
+ CXFA_StrokeArray& strokes,
+ FX_BOOL bNULL) {
+ strokes.RemoveAll();
+ if (!pNode)
+ return;
+
+ strokes.SetSize(8);
+ int32_t i, j;
+ for (i = 0, j = 0; i < 4; i++) {
+ CXFA_Corner corner =
+ CXFA_Corner(pNode->GetProperty(i, XFA_ELEMENT_Corner, i == 0));
+ if (corner || i == 0)
+ strokes.SetAt(j, corner);
+ else if (bNULL)
+ strokes.SetAt(j, CXFA_Stroke(nullptr));
+ else if (i == 1)
+ strokes.SetAt(j, strokes[0]);
+ else if (i == 2)
+ strokes.SetAt(j, strokes[0]);
+ else
+ strokes.SetAt(j, strokes[2]);
+
+ j++;
+ CXFA_Edge edge = CXFA_Edge(pNode->GetProperty(i, XFA_ELEMENT_Edge, i == 0));
+ if (edge || i == 0)
+ strokes.SetAt(j, edge);
+ else if (bNULL)
+ strokes.SetAt(j, CXFA_Stroke(nullptr));
+ else if (i == 1)
+ strokes.SetAt(j, strokes[1]);
+ else if (i == 2)
+ strokes.SetAt(j, strokes[1]);
+ else
+ strokes.SetAt(j, strokes[3]);
+
+ j++;
+ }
+}
+
+static int32_t Style3D(const CXFA_StrokeArray& strokes, CXFA_Stroke& stroke) {
+ int32_t iCount = strokes.GetSize();
+ if (iCount < 1)
+ return 0;
+
+ stroke = strokes[0];
+ for (int32_t i = 1; i < iCount; i++) {
+ CXFA_Stroke find = strokes[i];
+ if (!find)
+ continue;
+
+ if (!stroke)
+ stroke = find;
+ else if (stroke.GetStrokeType() != find.GetStrokeType())
+ stroke = find;
+ break;
+ }
+ int32_t iType = stroke.GetStrokeType();
+ if (iType == XFA_ATTRIBUTEENUM_Lowered || iType == XFA_ATTRIBUTEENUM_Raised ||
+ iType == XFA_ATTRIBUTEENUM_Etched ||
+ iType == XFA_ATTRIBUTEENUM_Embossed) {
+ return iType;
+ }
+ return 0;
+}
+
+} // namespace
+
+int32_t CXFA_Box::GetHand() const {
+ if (!m_pNode)
+ return XFA_ATTRIBUTEENUM_Even;
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
+}
+
+int32_t CXFA_Box::GetPresence() const {
+ if (!m_pNode)
+ return XFA_ATTRIBUTEENUM_Hidden;
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
+}
+
+int32_t CXFA_Box::CountEdges() const {
+ if (!m_pNode)
+ return 0;
+ return m_pNode->CountChildren(XFA_ELEMENT_Edge);
+}
+
+CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const {
+ return CXFA_Edge(
+ m_pNode ? m_pNode->GetProperty(nIndex, XFA_ELEMENT_Edge, nIndex == 0)
+ : nullptr);
+}
+
+void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const {
+ GetStrokesInternal(m_pNode, strokes, FALSE);
+}
+
+FX_BOOL CXFA_Box::IsCircular() const {
+ if (!m_pNode)
+ return FALSE;
+ return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular);
+}
+
+FX_BOOL CXFA_Box::GetStartAngle(FX_FLOAT& fStartAngle) const {
+ fStartAngle = 0;
+ if (!m_pNode)
+ return FALSE;
+
+ CXFA_Measurement ms;
+ FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, FALSE);
+ if (bRet)
+ fStartAngle = ms.GetValue();
+
+ return bRet;
+}
+
+FX_BOOL CXFA_Box::GetSweepAngle(FX_FLOAT& fSweepAngle) const {
+ fSweepAngle = 360;
+ if (!m_pNode)
+ return FALSE;
+
+ CXFA_Measurement ms;
+ FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, FALSE);
+ if (bRet)
+ fSweepAngle = ms.GetValue();
+
+ return bRet;
+}
+
+CXFA_Fill CXFA_Box::GetFill(FX_BOOL bModified) const {
+ if (!m_pNode)
+ return CXFA_Fill(nullptr);
+
+ CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_ELEMENT_Fill, bModified);
+ return CXFA_Fill(pFillNode);
+}
+
+CXFA_Margin CXFA_Box::GetMargin() const {
+ return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin)
+ : nullptr);
+}
+
+int32_t CXFA_Box::Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const {
+ if (IsArc())
+ return 0;
+
+ CXFA_StrokeArray strokes;
+ GetStrokesInternal(m_pNode, strokes, TRUE);
+ CXFA_Stroke stroke(NULL);
+ int32_t iType = Style3D(strokes, stroke);
+ if (iType) {
+ bVisible = stroke.IsVisible();
+ fThickness = stroke.GetThickness();
+ }
+ return iType;
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_box.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_box.h
new file mode 100644
index 00000000000..6123f946bd8
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_box.h
@@ -0,0 +1,50 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_BOX_H_
+#define XFA_FXFA_PARSER_CXFA_BOX_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_edge.h"
+#include "xfa/fxfa/parser/cxfa_fill.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
+
+class CXFA_Node;
+
+class CXFA_Box : public CXFA_Data {
+ public:
+ explicit CXFA_Box(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+ bool IsArc() const { return GetClassID() == XFA_ELEMENT_Arc; }
+ bool IsBorder() const { return GetClassID() == XFA_ELEMENT_Border; }
+ bool IsRectangle() const { return GetClassID() == XFA_ELEMENT_Rectangle; }
+ int32_t GetHand() const;
+ int32_t GetPresence() const;
+ int32_t CountEdges() const;
+ CXFA_Edge GetEdge(int32_t nIndex = 0) const;
+ void GetStrokes(CXFA_StrokeArray& strokes) const;
+ FX_BOOL IsCircular() const;
+ FX_BOOL GetStartAngle(FX_FLOAT& fStartAngle) const;
+ FX_FLOAT GetStartAngle() const {
+ FX_FLOAT fStartAngle;
+ GetStartAngle(fStartAngle);
+ return fStartAngle;
+ }
+
+ FX_BOOL GetSweepAngle(FX_FLOAT& fSweepAngle) const;
+ FX_FLOAT GetSweepAngle() const {
+ FX_FLOAT fSweepAngle;
+ GetSweepAngle(fSweepAngle);
+ return fSweepAngle;
+ }
+
+ CXFA_Fill GetFill(FX_BOOL bModified = FALSE) const;
+ CXFA_Margin GetMargin() const;
+ int32_t Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const;
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_BOX_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_calculate.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_calculate.cpp
new file mode 100644
index 00000000000..8984c5e8173
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_calculate.cpp
@@ -0,0 +1,32 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_calculate.h"
+
+#include "xfa/fxfa/parser/cxfa_text.h"
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Calculate::CXFA_Calculate(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+int32_t CXFA_Calculate::GetOverride() {
+ XFA_ATTRIBUTEENUM eAtt = XFA_ATTRIBUTEENUM_Error;
+ m_pNode->TryEnum(XFA_ATTRIBUTE_Override, eAtt, FALSE);
+ return eAtt;
+}
+
+CXFA_Script CXFA_Calculate::GetScript() {
+ return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script));
+}
+
+void CXFA_Calculate::GetMessageText(CFX_WideString& wsMessage) {
+ CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Message);
+ if (!pNode)
+ return;
+
+ CXFA_Text text(pNode->GetChild(0, XFA_ELEMENT_Text));
+ if (text)
+ text.GetContent(wsMessage);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_calculate.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_calculate.h
new file mode 100644
index 00000000000..c90656a314d
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_calculate.h
@@ -0,0 +1,25 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_CALCULATE_H_
+#define XFA_FXFA_PARSER_CXFA_CALCULATE_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
+
+class CXFA_Node;
+
+class CXFA_Calculate : public CXFA_Data {
+ public:
+ explicit CXFA_Calculate(CXFA_Node* pNode);
+
+ int32_t GetOverride();
+ CXFA_Script GetScript();
+ void GetMessageText(CFX_WideString& wsMessage);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_CALCULATE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_caption.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_caption.cpp
new file mode 100644
index 00000000000..1d343e7e432
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_caption.cpp
@@ -0,0 +1,41 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_caption.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Caption::CXFA_Caption(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+int32_t CXFA_Caption::GetPresence() {
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Visible;
+ m_pNode->TryEnum(XFA_ATTRIBUTE_Presence, eAttr);
+ return eAttr;
+}
+
+int32_t CXFA_Caption::GetPlacementType() {
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
+ m_pNode->TryEnum(XFA_ATTRIBUTE_Placement, eAttr);
+ return eAttr;
+}
+
+FX_FLOAT CXFA_Caption::GetReserve() {
+ CXFA_Measurement ms;
+ m_pNode->TryMeasure(XFA_ATTRIBUTE_Reserve, ms);
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
+
+CXFA_Margin CXFA_Caption::GetMargin() {
+ return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin) : NULL);
+}
+
+CXFA_Font CXFA_Caption::GetFont() {
+ return CXFA_Font(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Font) : NULL);
+}
+
+CXFA_Value CXFA_Caption::GetValue() {
+ return CXFA_Value(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Value) : NULL);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_caption.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_caption.h
new file mode 100644
index 00000000000..70dd435653f
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_caption.h
@@ -0,0 +1,29 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_CAPTION_H_
+#define XFA_FXFA_PARSER_CXFA_CAPTION_H_
+
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
+
+class CXFA_Node;
+
+class CXFA_Caption : public CXFA_Data {
+ public:
+ explicit CXFA_Caption(CXFA_Node* pNode);
+
+ int32_t GetPresence();
+ int32_t GetPlacementType();
+ FX_FLOAT GetReserve();
+ CXFA_Margin GetMargin();
+ CXFA_Font GetFont();
+ CXFA_Value GetValue();
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_CAPTION_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_corner.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_corner.h
new file mode 100644
index 00000000000..7665c538123
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_corner.h
@@ -0,0 +1,19 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_CORNER_H_
+#define XFA_FXFA_PARSER_CXFA_CORNER_H_
+
+#include "xfa/fxfa/parser/cxfa_stroke.h"
+
+class CXFA_Node;
+
+class CXFA_Corner : public CXFA_Stroke {
+ public:
+ explicit CXFA_Corner(CXFA_Node* pNode) : CXFA_Stroke(pNode) {}
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_CORNER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_data.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_data.cpp
new file mode 100644
index 00000000000..cbcb079cadc
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_data.cpp
@@ -0,0 +1,80 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+// Static.
+FX_ARGB CXFA_Data::ToColor(const CFX_WideStringC& wsValue) {
+ uint8_t r = 0, g = 0, b = 0;
+ if (wsValue.GetLength() == 0)
+ return 0xff000000;
+
+ int cc = 0;
+ const FX_WCHAR* str = wsValue.c_str();
+ int len = wsValue.GetLength();
+ while (XFA_IsSpace(str[cc]) && cc < len)
+ cc++;
+
+ if (cc >= len)
+ return 0xff000000;
+
+ while (cc < len) {
+ if (str[cc] == ',' || !XFA_IsDigit(str[cc]))
+ break;
+
+ r = r * 10 + str[cc] - '0';
+ cc++;
+ }
+ if (cc < len && str[cc] == ',') {
+ cc++;
+ while (XFA_IsSpace(str[cc]) && cc < len)
+ cc++;
+
+ while (cc < len) {
+ if (str[cc] == ',' || !XFA_IsDigit(str[cc]))
+ break;
+
+ g = g * 10 + str[cc] - '0';
+ cc++;
+ }
+ if (cc < len && str[cc] == ',') {
+ cc++;
+ while (XFA_IsSpace(str[cc]) && cc < len)
+ cc++;
+
+ while (cc < len) {
+ if (str[cc] == ',' || !XFA_IsDigit(str[cc]))
+ break;
+
+ b = b * 10 + str[cc] - '0';
+ cc++;
+ }
+ }
+ }
+ return (0xff << 24) | (r << 16) | (g << 8) | b;
+}
+
+XFA_ELEMENT CXFA_Data::GetClassID() const {
+ return m_pNode ? m_pNode->GetClassID() : XFA_ELEMENT_UNKNOWN;
+}
+
+FX_BOOL CXFA_Data::TryMeasure(XFA_ATTRIBUTE eAttr,
+ FX_FLOAT& fValue,
+ FX_BOOL bUseDefault) const {
+ CXFA_Measurement ms;
+ if (m_pNode->TryMeasure(eAttr, ms, bUseDefault)) {
+ fValue = ms.ToUnit(XFA_UNIT_Pt);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+FX_BOOL CXFA_Data::SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue) {
+ CXFA_Measurement ms(fValue, XFA_UNIT_Pt);
+ return m_pNode->SetMeasure(eAttr, ms);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_data.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_data.h
new file mode 100644
index 00000000000..e5913931530
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_data.h
@@ -0,0 +1,35 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_DATA_H_
+#define XFA_FXFA_PARSER_CXFA_DATA_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "core/fxge/include/fx_dib.h"
+#include "xfa/fxfa/include/fxfa_basic.h"
+
+class CXFA_Node;
+
+class CXFA_Data {
+ public:
+ static FX_ARGB ToColor(const CFX_WideStringC& wsValue);
+
+ explicit CXFA_Data(CXFA_Node* pNode) : m_pNode(pNode) {}
+
+ operator bool() const { return !!m_pNode; }
+ CXFA_Node* GetNode() const { return m_pNode; }
+ XFA_ELEMENT GetClassID() const;
+
+ protected:
+ FX_BOOL TryMeasure(XFA_ATTRIBUTE eAttr,
+ FX_FLOAT& fValue,
+ FX_BOOL bUseDefault = FALSE) const;
+ FX_BOOL SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue);
+
+ CXFA_Node* m_pNode;
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_DATA_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_edge.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_edge.h
new file mode 100644
index 00000000000..96e725f4c6d
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_edge.h
@@ -0,0 +1,19 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_EDGE_H_
+#define XFA_FXFA_PARSER_CXFA_EDGE_H_
+
+#include "xfa/fxfa/parser/cxfa_stroke.h"
+
+class CXFA_Node;
+
+class CXFA_Edge : public CXFA_Stroke {
+ public:
+ explicit CXFA_Edge(CXFA_Node* pNode) : CXFA_Stroke(pNode) {}
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_EDGE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_event.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_event.cpp
new file mode 100644
index 00000000000..efff3e5161b
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_event.cpp
@@ -0,0 +1,49 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_event.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Event::CXFA_Event(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+int32_t CXFA_Event::GetActivity() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Activity);
+}
+
+int32_t CXFA_Event::GetEventType() {
+ CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ while (pChild) {
+ int32_t eType = pChild->GetClassID();
+ if (eType != XFA_ELEMENT_Extras)
+ return eType;
+
+ pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
+ }
+ return XFA_ELEMENT_UNKNOWN;
+}
+
+void CXFA_Event::GetRef(CFX_WideStringC& wsRef) {
+ m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
+}
+
+CXFA_Script CXFA_Event::GetScript() {
+ return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script));
+}
+
+CXFA_Submit CXFA_Event::GetSubmit() {
+ return CXFA_Submit(m_pNode->GetChild(0, XFA_ELEMENT_Submit));
+}
+
+void CXFA_Event::GetSignDataTarget(CFX_WideString& wsTarget) {
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData);
+ if (!pNode)
+ return;
+
+ CFX_WideStringC wsCData;
+ pNode->TryCData(XFA_ATTRIBUTE_Target, wsCData);
+ wsTarget = wsCData;
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_event.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_event.h
new file mode 100644
index 00000000000..91d0812f957
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_event.h
@@ -0,0 +1,33 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_EVENT_H_
+#define XFA_FXFA_PARSER_CXFA_EVENT_H_
+
+#include <stdint.h>
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
+#include "xfa/fxfa/parser/cxfa_submit.h"
+
+class CXFA_Node;
+
+class CXFA_Event : public CXFA_Data {
+ public:
+ explicit CXFA_Event(CXFA_Node* pNode);
+
+ int32_t GetActivity();
+ int32_t GetEventType();
+ void GetRef(CFX_WideStringC& wsRef);
+
+ CXFA_Script GetScript();
+ CXFA_Submit GetSubmit();
+
+ void GetSignDataTarget(CFX_WideString& wsTarget);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_EVENT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_exdata.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_exdata.cpp
new file mode 100644
index 00000000000..358cc3d6114
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_exdata.cpp
@@ -0,0 +1,15 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_exdata.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+FX_BOOL CXFA_ExData::SetContentType(const CFX_WideString& wsContentType) {
+ return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_exdata.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_exdata.h
new file mode 100644
index 00000000000..eb04398379d
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_exdata.h
@@ -0,0 +1,22 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_EXDATA_H_
+#define XFA_FXFA_PARSER_CXFA_EXDATA_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_ExData : public CXFA_Data {
+ public:
+ explicit CXFA_ExData(CXFA_Node* pNode);
+
+ FX_BOOL SetContentType(const CFX_WideString& wsContentType);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_EXDATA_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_fill.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_fill.cpp
new file mode 100644
index 00000000000..c67e303eb2a
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_fill.cpp
@@ -0,0 +1,103 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_fill.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+CXFA_Fill::~CXFA_Fill() {}
+
+int32_t CXFA_Fill::GetPresence() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
+}
+
+void CXFA_Fill::SetColor(FX_ARGB color) {
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color);
+ CFX_WideString wsColor;
+ int a, r, g, b;
+ ArgbDecode(color, a, r, g, b);
+ wsColor.Format(L"%d,%d,%d", r, g, b);
+ pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
+}
+
+FX_ARGB CXFA_Fill::GetColor(FX_BOOL bText) {
+ if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color)) {
+ CFX_WideStringC wsColor;
+ if (pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE))
+ return CXFA_Data::ToColor(wsColor);
+ }
+ if (bText)
+ return 0xFF000000;
+ return 0xFFFFFFFF;
+}
+
+int32_t CXFA_Fill::GetFillType() {
+ CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ while (pChild) {
+ int32_t eType = pChild->GetClassID();
+ if (eType != XFA_ELEMENT_Color && eType != XFA_ELEMENT_Extras)
+ return eType;
+
+ pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
+ }
+ return XFA_ELEMENT_Solid;
+}
+
+int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) {
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Pattern);
+ if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
+ CFX_WideStringC wsColor;
+ pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
+ foreColor = CXFA_Data::ToColor(wsColor);
+ } else {
+ foreColor = 0xFF000000;
+ }
+ return pNode->GetEnum(XFA_ATTRIBUTE_Type);
+}
+
+int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) {
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Stipple);
+ int32_t eAttr = 50;
+ pNode->TryInteger(XFA_ATTRIBUTE_Rate, eAttr);
+ if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
+ CFX_WideStringC wsColor;
+ pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
+ stippleColor = CXFA_Data::ToColor(wsColor);
+ } else {
+ stippleColor = 0xFF000000;
+ }
+ return eAttr;
+}
+
+int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) {
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Linear);
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight;
+ pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
+ if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
+ CFX_WideStringC wsColor;
+ pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
+ endColor = CXFA_Data::ToColor(wsColor);
+ } else {
+ endColor = 0xFF000000;
+ }
+ return eAttr;
+}
+
+int32_t CXFA_Fill::GetRadial(FX_ARGB& endColor) {
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Radial);
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge;
+ pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
+ if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
+ CFX_WideStringC wsColor;
+ pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
+ endColor = CXFA_Data::ToColor(wsColor);
+ } else {
+ endColor = 0xFF000000;
+ }
+ return eAttr;
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_fill.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_fill.h
new file mode 100644
index 00000000000..57f0410741b
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_fill.h
@@ -0,0 +1,31 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_FILL_H_
+#define XFA_FXFA_PARSER_CXFA_FILL_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "core/fxge/include/fx_dib.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Fill : public CXFA_Data {
+ public:
+ explicit CXFA_Fill(CXFA_Node* pNode);
+ ~CXFA_Fill();
+
+ int32_t GetPresence();
+ FX_ARGB GetColor(FX_BOOL bText = FALSE);
+ int32_t GetFillType();
+ int32_t GetPattern(FX_ARGB& foreColor);
+ int32_t GetStipple(FX_ARGB& stippleColor);
+ int32_t GetLinear(FX_ARGB& endColor);
+ int32_t GetRadial(FX_ARGB& endColor);
+ void SetColor(FX_ARGB color);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_FILL_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_font.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_font.cpp
new file mode 100644
index 00000000000..261ef1f9ea2
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_font.cpp
@@ -0,0 +1,92 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_font.h"
+
+#include "core/fxge/include/fx_dib.h"
+#include "xfa/fxfa/parser/cxfa_fill.h"
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Font::CXFA_Font(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+FX_FLOAT CXFA_Font::GetBaselineShift() {
+ return m_pNode->GetMeasure(XFA_ATTRIBUTE_BaselineShift).ToUnit(XFA_UNIT_Pt);
+}
+
+FX_FLOAT CXFA_Font::GetHorizontalScale() {
+ CFX_WideString wsValue;
+ m_pNode->TryCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue);
+ int32_t iScale = FXSYS_wtoi(wsValue.c_str());
+ return iScale > 0 ? (FX_FLOAT)iScale : 100.0f;
+}
+
+FX_FLOAT CXFA_Font::GetVerticalScale() {
+ CFX_WideString wsValue;
+ m_pNode->TryCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue);
+ int32_t iScale = FXSYS_wtoi(wsValue.c_str());
+ return iScale > 0 ? (FX_FLOAT)iScale : 100.0f;
+}
+
+FX_FLOAT CXFA_Font::GetLetterSpacing() {
+ CFX_WideStringC wsValue;
+ if (!m_pNode->TryCData(XFA_ATTRIBUTE_LetterSpacing, wsValue))
+ return 0;
+
+ CXFA_Measurement ms(wsValue);
+ if (ms.GetUnit() == XFA_UNIT_Em)
+ return ms.GetValue() * GetFontSize();
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
+
+int32_t CXFA_Font::GetLineThrough() {
+ int32_t iValue = 0;
+ m_pNode->TryInteger(XFA_ATTRIBUTE_LineThrough, iValue);
+ return iValue;
+}
+
+int32_t CXFA_Font::GetUnderline() {
+ int32_t iValue = 0;
+ m_pNode->TryInteger(XFA_ATTRIBUTE_Underline, iValue);
+ return iValue;
+}
+
+int32_t CXFA_Font::GetUnderlinePeriod() {
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All;
+ m_pNode->TryEnum(XFA_ATTRIBUTE_UnderlinePeriod, eAttr);
+ return eAttr;
+}
+
+FX_FLOAT CXFA_Font::GetFontSize() {
+ CXFA_Measurement ms;
+ m_pNode->TryMeasure(XFA_ATTRIBUTE_Size, ms);
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
+
+void CXFA_Font::GetTypeface(CFX_WideStringC& wsTypeFace) {
+ m_pNode->TryCData(XFA_ATTRIBUTE_Typeface, wsTypeFace);
+}
+
+FX_BOOL CXFA_Font::IsBold() {
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
+ m_pNode->TryEnum(XFA_ATTRIBUTE_Weight, eAttr);
+ return eAttr == XFA_ATTRIBUTEENUM_Bold;
+}
+
+FX_BOOL CXFA_Font::IsItalic() {
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
+ m_pNode->TryEnum(XFA_ATTRIBUTE_Posture, eAttr);
+ return eAttr == XFA_ATTRIBUTEENUM_Italic;
+}
+
+void CXFA_Font::SetColor(FX_ARGB color) {
+ CXFA_Fill fill(m_pNode->GetProperty(0, XFA_ELEMENT_Fill));
+ fill.SetColor(color);
+}
+
+FX_ARGB CXFA_Font::GetColor() {
+ CXFA_Fill fill(m_pNode->GetChild(0, XFA_ELEMENT_Fill));
+ return fill ? fill.GetColor(TRUE) : 0xFF000000;
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_font.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_font.h
new file mode 100644
index 00000000000..e2e1809aa36
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_font.h
@@ -0,0 +1,36 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_FONT_H_
+#define XFA_FXFA_PARSER_CXFA_FONT_H_
+
+#include "core/fxge/include/fx_dib.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Font : public CXFA_Data {
+ public:
+ explicit CXFA_Font(CXFA_Node* pNode);
+
+ FX_FLOAT GetBaselineShift();
+ FX_FLOAT GetHorizontalScale();
+ FX_FLOAT GetVerticalScale();
+ FX_FLOAT GetLetterSpacing();
+ int32_t GetLineThrough();
+ int32_t GetUnderline();
+ int32_t GetUnderlinePeriod();
+ FX_FLOAT GetFontSize();
+ void GetTypeface(CFX_WideStringC& wsTypeFace);
+
+ FX_BOOL IsBold();
+ FX_BOOL IsItalic();
+
+ FX_ARGB GetColor();
+ void SetColor(FX_ARGB color);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_FONT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_image.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_image.cpp
new file mode 100644
index 00000000000..bcc7466dce2
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_image.cpp
@@ -0,0 +1,54 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_image.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Image::CXFA_Image(CXFA_Node* pNode, FX_BOOL bDefValue)
+ : CXFA_Data(pNode), m_bDefValue(bDefValue) {}
+
+int32_t CXFA_Image::GetAspect() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Aspect);
+}
+
+FX_BOOL CXFA_Image::GetContentType(CFX_WideString& wsContentType) {
+ return m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+}
+
+FX_BOOL CXFA_Image::GetHref(CFX_WideString& wsHref) {
+ if (m_bDefValue)
+ return m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref);
+ return m_pNode->GetAttribute(FX_WSTRC(L"href"), wsHref);
+}
+
+int32_t CXFA_Image::GetTransferEncoding() {
+ if (m_bDefValue)
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding);
+ return XFA_ATTRIBUTEENUM_Base64;
+}
+
+FX_BOOL CXFA_Image::GetContent(CFX_WideString& wsText) {
+ return m_pNode->TryContent(wsText);
+}
+
+FX_BOOL CXFA_Image::SetContentType(const CFX_WideString& wsContentType) {
+ return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+}
+
+FX_BOOL CXFA_Image::SetHref(const CFX_WideString& wsHref) {
+ if (m_bDefValue)
+ return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref);
+ return m_pNode->SetAttribute(XFA_ATTRIBUTE_Href, wsHref.AsStringC());
+}
+
+FX_BOOL CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) {
+ if (m_bDefValue) {
+ return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding,
+ (XFA_ATTRIBUTEENUM)iTransferEncoding);
+ }
+ return TRUE;
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_image.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_image.h
new file mode 100644
index 00000000000..9f8b3bb2281
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_image.h
@@ -0,0 +1,33 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_IMAGE_H_
+#define XFA_FXFA_PARSER_CXFA_IMAGE_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Image : public CXFA_Data {
+ public:
+ CXFA_Image(CXFA_Node* pNode, FX_BOOL bDefValue);
+
+ int32_t GetAspect();
+ FX_BOOL GetContentType(CFX_WideString& wsContentType);
+ FX_BOOL GetHref(CFX_WideString& wsHref);
+ int32_t GetTransferEncoding();
+ FX_BOOL GetContent(CFX_WideString& wsText);
+ FX_BOOL SetContentType(const CFX_WideString& wsContentType);
+ FX_BOOL SetHref(const CFX_WideString& wsHref);
+ FX_BOOL SetTransferEncoding(int32_t iTransferEncoding);
+
+ protected:
+ FX_BOOL m_bDefValue;
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_IMAGE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_line.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_line.cpp
new file mode 100644
index 00000000000..07ca6d7a69b
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_line.cpp
@@ -0,0 +1,22 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_line.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+int32_t CXFA_Line::GetHand() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
+}
+
+FX_BOOL CXFA_Line::GetSlop() {
+ XFA_ATTRIBUTEENUM eSlop = m_pNode->GetEnum(XFA_ATTRIBUTE_Slope);
+ return eSlop == XFA_ATTRIBUTEENUM_Slash;
+}
+
+CXFA_Edge CXFA_Line::GetEdge() {
+ return CXFA_Edge(m_pNode->GetChild(0, XFA_ELEMENT_Edge));
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_line.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_line.h
new file mode 100644
index 00000000000..38076048531
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_line.h
@@ -0,0 +1,25 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_LINE_H_
+#define XFA_FXFA_PARSER_CXFA_LINE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_edge.h"
+
+class CXFA_Node;
+
+class CXFA_Line : public CXFA_Data {
+ public:
+ explicit CXFA_Line(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+ int32_t GetHand();
+ FX_BOOL GetSlop();
+ CXFA_Edge GetEdge();
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_LINE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_margin.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_margin.cpp
new file mode 100644
index 00000000000..c3ced3df937
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_margin.cpp
@@ -0,0 +1,32 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_margin.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Margin::CXFA_Margin(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+FX_BOOL CXFA_Margin::GetLeftInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
+ fInset = fDefInset;
+ return TryMeasure(XFA_ATTRIBUTE_LeftInset, fInset);
+}
+
+FX_BOOL CXFA_Margin::GetTopInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
+ fInset = fDefInset;
+ return TryMeasure(XFA_ATTRIBUTE_TopInset, fInset);
+}
+
+FX_BOOL CXFA_Margin::GetRightInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
+ fInset = fDefInset;
+ return TryMeasure(XFA_ATTRIBUTE_RightInset, fInset);
+}
+
+FX_BOOL CXFA_Margin::GetBottomInset(FX_FLOAT& fInset,
+ FX_FLOAT fDefInset) const {
+ fInset = fDefInset;
+ return TryMeasure(XFA_ATTRIBUTE_BottomInset, fInset);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_margin.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_margin.h
new file mode 100644
index 00000000000..ecfc628b894
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_margin.h
@@ -0,0 +1,25 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_MARGIN_H_
+#define XFA_FXFA_PARSER_CXFA_MARGIN_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Margin : public CXFA_Data {
+ public:
+ explicit CXFA_Margin(CXFA_Node* pNode);
+
+ FX_BOOL GetLeftInset(FX_FLOAT& fInset, FX_FLOAT fDefInset = 0) const;
+ FX_BOOL GetTopInset(FX_FLOAT& fInset, FX_FLOAT fDefInset = 0) const;
+ FX_BOOL GetRightInset(FX_FLOAT& fInset, FX_FLOAT fDefInset = 0) const;
+ FX_BOOL GetBottomInset(FX_FLOAT& fInset, FX_FLOAT fDefInset = 0) const;
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_MARGIN_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_occur.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_occur.cpp
new file mode 100644
index 00000000000..6d105abec6c
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_occur.cpp
@@ -0,0 +1,67 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_occur.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Occur::CXFA_Occur(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+int32_t CXFA_Occur::GetMax() {
+ int32_t iMax = 1;
+ if (m_pNode) {
+ if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, TRUE))
+ iMax = GetMin();
+ }
+ return iMax;
+}
+
+int32_t CXFA_Occur::GetMin() {
+ int32_t iMin = 1;
+ if (m_pNode) {
+ if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, TRUE) || iMin < 0)
+ iMin = 1;
+ }
+ return iMin;
+}
+
+FX_BOOL CXFA_Occur::GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit) {
+ if (!m_pNode)
+ return FALSE;
+ if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE) || iMin < 0)
+ iMin = 1;
+ if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) {
+ if (iMin == 0)
+ iMax = 1;
+ else
+ iMax = iMin;
+ }
+ if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, FALSE) ||
+ iInit < iMin) {
+ iInit = iMin;
+ }
+ return TRUE;
+}
+
+void CXFA_Occur::SetMax(int32_t iMax) {
+ iMax = (iMax != -1 && iMax < 1) ? 1 : iMax;
+ m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE);
+ int32_t iMin = GetMin();
+ if (iMax != -1 && iMax < iMin) {
+ iMin = iMax;
+ m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE);
+ }
+}
+
+void CXFA_Occur::SetMin(int32_t iMin) {
+ iMin = (iMin < 0) ? 1 : iMin;
+ m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE);
+ int32_t iMax = GetMax();
+ if (iMax > 0 && iMax < iMin) {
+ iMax = iMin;
+ m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE);
+ }
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_occur.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_occur.h
new file mode 100644
index 00000000000..0f10540b92b
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_occur.h
@@ -0,0 +1,26 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_OCCUR_H_
+#define XFA_FXFA_PARSER_CXFA_OCCUR_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Occur : public CXFA_Data {
+ public:
+ explicit CXFA_Occur(CXFA_Node* pNode);
+
+ int32_t GetMax();
+ int32_t GetMin();
+ FX_BOOL GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit);
+ void SetMax(int32_t iMax);
+ void SetMin(int32_t iMin);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_OCCUR_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_para.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_para.cpp
new file mode 100644
index 00000000000..4f4a1696669
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_para.cpp
@@ -0,0 +1,59 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_para.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Para::CXFA_Para(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+int32_t CXFA_Para::GetHorizontalAlign() {
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
+ m_pNode->TryEnum(XFA_ATTRIBUTE_HAlign, eAttr);
+ return eAttr;
+}
+
+int32_t CXFA_Para::GetVerticalAlign() {
+ XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Top;
+ m_pNode->TryEnum(XFA_ATTRIBUTE_VAlign, eAttr);
+ return eAttr;
+}
+
+FX_FLOAT CXFA_Para::GetLineHeight() {
+ CXFA_Measurement ms;
+ m_pNode->TryMeasure(XFA_ATTRIBUTE_LineHeight, ms);
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
+
+FX_FLOAT CXFA_Para::GetMarginLeft() {
+ CXFA_Measurement ms;
+ m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginLeft, ms);
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
+
+FX_FLOAT CXFA_Para::GetMarginRight() {
+ CXFA_Measurement ms;
+ m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginRight, ms);
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
+
+FX_FLOAT CXFA_Para::GetSpaceAbove() {
+ CXFA_Measurement ms;
+ m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceAbove, ms);
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
+
+FX_FLOAT CXFA_Para::GetSpaceBelow() {
+ CXFA_Measurement ms;
+ m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceBelow, ms);
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
+
+FX_FLOAT CXFA_Para::GetTextIndent() {
+ CXFA_Measurement ms;
+ m_pNode->TryMeasure(XFA_ATTRIBUTE_TextIndent, ms);
+ return ms.ToUnit(XFA_UNIT_Pt);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_para.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_para.h
new file mode 100644
index 00000000000..109d05d2f02
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_para.h
@@ -0,0 +1,29 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_PARA_H_
+#define XFA_FXFA_PARSER_CXFA_PARA_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Para : public CXFA_Data {
+ public:
+ explicit CXFA_Para(CXFA_Node* pNode);
+
+ int32_t GetHorizontalAlign();
+ int32_t GetVerticalAlign();
+ FX_FLOAT GetLineHeight();
+ FX_FLOAT GetMarginLeft();
+ FX_FLOAT GetMarginRight();
+ FX_FLOAT GetSpaceAbove();
+ FX_FLOAT GetSpaceBelow();
+ FX_FLOAT GetTextIndent();
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_PARA_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_rectangle.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_rectangle.h
new file mode 100644
index 00000000000..8d18ace0de3
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_rectangle.h
@@ -0,0 +1,19 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_RECTANGLE_H_
+#define XFA_FXFA_PARSER_CXFA_RECTANGLE_H_
+
+#include "xfa/fxfa/parser/cxfa_box.h"
+
+class CXFA_Node;
+
+class CXFA_Rectangle : public CXFA_Box {
+ public:
+ explicit CXFA_Rectangle(CXFA_Node* pNode) : CXFA_Box(pNode) {}
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_RECTANGLE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_script.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_script.cpp
new file mode 100644
index 00000000000..b99d8a39453
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_script.cpp
@@ -0,0 +1,31 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_script.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+XFA_SCRIPTTYPE CXFA_Script::GetContentType() {
+ CFX_WideStringC cData;
+ if (m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, cData, FALSE)) {
+ if (cData == FX_WSTRC(L"application/x-javascript"))
+ return XFA_SCRIPTTYPE_Javascript;
+ if (cData == FX_WSTRC(L"application/x-formcalc"))
+ return XFA_SCRIPTTYPE_Formcalc;
+ return XFA_SCRIPTTYPE_Unkown;
+ }
+ return XFA_SCRIPTTYPE_Formcalc;
+}
+
+int32_t CXFA_Script::GetRunAt() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_RunAt);
+}
+
+void CXFA_Script::GetExpression(CFX_WideString& wsExpression) {
+ m_pNode->TryContent(wsExpression);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_script.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_script.h
new file mode 100644
index 00000000000..f265961b079
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_script.h
@@ -0,0 +1,32 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_SCRIPT_H_
+#define XFA_FXFA_PARSER_CXFA_SCRIPT_H_
+
+#include <stdint.h>
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+enum XFA_SCRIPTTYPE {
+ XFA_SCRIPTTYPE_Formcalc = 0,
+ XFA_SCRIPTTYPE_Javascript,
+ XFA_SCRIPTTYPE_Unkown,
+};
+
+class CXFA_Node;
+
+class CXFA_Script : public CXFA_Data {
+ public:
+ explicit CXFA_Script(CXFA_Node* pNode);
+
+ XFA_SCRIPTTYPE GetContentType();
+ int32_t GetRunAt();
+ void GetExpression(CFX_WideString& wsExpression);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_SCRIPT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_stroke.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_stroke.cpp
new file mode 100644
index 00000000000..ac175bed584
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_stroke.cpp
@@ -0,0 +1,105 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_stroke.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+int32_t CXFA_Stroke::GetPresence() const {
+ return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence)
+ : XFA_ATTRIBUTEENUM_Invisible;
+}
+
+int32_t CXFA_Stroke::GetCapType() const {
+ if (!m_pNode)
+ return XFA_ATTRIBUTEENUM_Square;
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Cap);
+}
+
+int32_t CXFA_Stroke::GetStrokeType() const {
+ return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Stroke)
+ : XFA_ATTRIBUTEENUM_Solid;
+}
+
+FX_FLOAT CXFA_Stroke::GetThickness() const {
+ return GetMSThickness().ToUnit(XFA_UNIT_Pt);
+}
+
+CXFA_Measurement CXFA_Stroke::GetMSThickness() const {
+ return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Thickness)
+ : XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT_Edge,
+ XFA_ATTRIBUTE_Thickness,
+ XFA_XDPPACKET_Form);
+}
+
+void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) {
+ if (!m_pNode)
+ return;
+
+ m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness);
+}
+
+FX_ARGB CXFA_Stroke::GetColor() const {
+ if (!m_pNode)
+ return 0xFF000000;
+
+ CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color);
+ if (!pNode)
+ return 0xFF000000;
+
+ CFX_WideStringC wsColor;
+ pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor);
+ return CXFA_Data::ToColor(wsColor);
+}
+
+void CXFA_Stroke::SetColor(FX_ARGB argb) {
+ if (!m_pNode)
+ return;
+
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color);
+ CFX_WideString wsColor;
+ int a;
+ int r;
+ int g;
+ int b;
+ ArgbDecode(argb, a, r, g, b);
+ wsColor.Format(L"%d,%d,%d", r, g, b);
+ pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
+}
+
+int32_t CXFA_Stroke::GetJoinType() const {
+ return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Join)
+ : XFA_ATTRIBUTEENUM_Square;
+}
+
+FX_BOOL CXFA_Stroke::IsInverted() const {
+ return m_pNode ? m_pNode->GetBoolean(XFA_ATTRIBUTE_Inverted) : FALSE;
+}
+
+FX_FLOAT CXFA_Stroke::GetRadius() const {
+ return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Radius).ToUnit(XFA_UNIT_Pt)
+ : 0;
+}
+
+FX_BOOL CXFA_Stroke::SameStyles(CXFA_Stroke stroke, uint32_t dwFlags) const {
+ if (m_pNode == stroke.GetNode())
+ return TRUE;
+ if (FXSYS_fabs(GetThickness() - stroke.GetThickness()) >= 0.01f)
+ return FALSE;
+ if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 &&
+ IsVisible() != stroke.IsVisible()) {
+ return FALSE;
+ }
+ if (GetStrokeType() != stroke.GetStrokeType())
+ return FALSE;
+ if (GetColor() != stroke.GetColor())
+ return FALSE;
+ if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 &&
+ FXSYS_fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) {
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_stroke.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_stroke.h
new file mode 100644
index 00000000000..719ac1bbcf2
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_stroke.h
@@ -0,0 +1,45 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_STROKE_H_
+#define XFA_FXFA_PARSER_CXFA_STROKE_H_
+
+#include "core/fxcrt/include/fx_system.h"
+#include "core/fxge/include/fx_dib.h"
+#include "xfa/fxfa/include/fxfa_basic.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+enum StrokeSameStyle {
+ XFA_STROKE_SAMESTYLE_NoPresence = 1,
+ XFA_STROKE_SAMESTYLE_Corner = 2
+};
+
+class CXFA_Node;
+
+class CXFA_Stroke : public CXFA_Data {
+ public:
+ explicit CXFA_Stroke(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+ bool IsCorner() const { return GetClassID() == XFA_ELEMENT_Corner; }
+ bool IsEdge() const { return GetClassID() == XFA_ELEMENT_Edge; }
+ bool IsVisible() const { return GetPresence() == XFA_ATTRIBUTEENUM_Visible; }
+ int32_t GetPresence() const;
+ int32_t GetCapType() const;
+ int32_t GetStrokeType() const;
+ FX_FLOAT GetThickness() const;
+ CXFA_Measurement GetMSThickness() const;
+ void SetMSThickness(CXFA_Measurement msThinkness);
+ FX_ARGB GetColor() const;
+ void SetColor(FX_ARGB argb);
+ int32_t GetJoinType() const;
+ FX_BOOL IsInverted() const;
+ FX_FLOAT GetRadius() const;
+ FX_BOOL SameStyles(CXFA_Stroke stroke, uint32_t dwFlags = 0) const;
+};
+
+typedef CFX_ArrayTemplate<CXFA_Stroke> CXFA_StrokeArray;
+
+#endif // XFA_FXFA_PARSER_CXFA_STROKE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_submit.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_submit.cpp
new file mode 100644
index 00000000000..2aa011b0e3b
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_submit.cpp
@@ -0,0 +1,27 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_submit.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Submit::CXFA_Submit(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+FX_BOOL CXFA_Submit::IsSubmitEmbedPDF() {
+ return m_pNode->GetBoolean(XFA_ATTRIBUTE_EmbedPDF);
+}
+
+int32_t CXFA_Submit::GetSubmitFormat() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Format);
+}
+
+void CXFA_Submit::GetSubmitTarget(CFX_WideStringC& wsTarget) {
+ m_pNode->TryCData(XFA_ATTRIBUTE_Target, wsTarget);
+}
+
+void CXFA_Submit::GetSubmitXDPContent(CFX_WideStringC& wsContent) {
+ m_pNode->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_submit.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_submit.h
new file mode 100644
index 00000000000..598431102dd
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_submit.h
@@ -0,0 +1,26 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_SUBMIT_H_
+#define XFA_FXFA_PARSER_CXFA_SUBMIT_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Submit : public CXFA_Data {
+ public:
+ explicit CXFA_Submit(CXFA_Node* pNode);
+
+ FX_BOOL IsSubmitEmbedPDF();
+ int32_t GetSubmitFormat();
+ void GetSubmitTarget(CFX_WideStringC& wsTarget);
+ void GetSubmitXDPContent(CFX_WideStringC& wsContent);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_SUBMIT_H_
diff --git a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_text.cpp
index d22b6f13c93..fc7d7aa280e 100644
--- a/chromium/third_party/pdfium/core/fpdfapi/fpdf_page/cpdf_parseoptions.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_text.cpp
@@ -3,10 +3,13 @@
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fpdfapi/fpdf_page/cpdf_parseoptions.h"
-CPDF_ParseOptions::CPDF_ParseOptions()
- : m_bTextOnly(FALSE),
- m_bMarkedContent(TRUE),
- m_bSeparateForm(TRUE),
- m_bDecodeInlineImage(FALSE) {}
+#include "xfa/fxfa/parser/cxfa_text.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+void CXFA_Text::GetContent(CFX_WideString& wsText) {
+ m_pNode->TryContent(wsText);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_text.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_text.h
new file mode 100644
index 00000000000..7467647791d
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_text.h
@@ -0,0 +1,22 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_TEXT_H_
+#define XFA_FXFA_PARSER_CXFA_TEXT_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_Text : public CXFA_Data {
+ public:
+ explicit CXFA_Text(CXFA_Node* pNode);
+
+ void GetContent(CFX_WideString& wsText);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_TEXT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_tooltip.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_tooltip.cpp
new file mode 100644
index 00000000000..079b365e468
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_tooltip.cpp
@@ -0,0 +1,15 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_tooltip.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_ToolTip::CXFA_ToolTip(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+FX_BOOL CXFA_ToolTip::GetTip(CFX_WideString& wsTip) {
+ return m_pNode->TryContent(wsTip);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_tooltip.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_tooltip.h
new file mode 100644
index 00000000000..af1791e2ec3
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_tooltip.h
@@ -0,0 +1,22 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_TOOLTIP_H_
+#define XFA_FXFA_PARSER_CXFA_TOOLTIP_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+
+class CXFA_Node;
+
+class CXFA_ToolTip : public CXFA_Data {
+ public:
+ explicit CXFA_ToolTip(CXFA_Node* pNode);
+
+ FX_BOOL GetTip(CFX_WideString& wsTip);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_TOOLTIP_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_validate.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_validate.cpp
new file mode 100644
index 00000000000..17140fbbc37
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_validate.cpp
@@ -0,0 +1,119 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_validate.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+CXFA_Validate::CXFA_Validate(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+int32_t CXFA_Validate::GetFormatTest() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_FormatTest);
+}
+
+FX_BOOL CXFA_Validate::SetTestValue(int32_t iType,
+ CFX_WideString& wsValue,
+ XFA_ATTRIBUTEENUM eName) {
+ const XFA_ATTRIBUTEENUMINFO* pInfo =
+ XFA_GetAttributeEnumByName(wsValue.AsStringC());
+ if (pInfo)
+ eName = pInfo->eName;
+
+ m_pNode->SetEnum((XFA_ATTRIBUTE)iType, eName, FALSE);
+ return TRUE;
+}
+
+FX_BOOL CXFA_Validate::SetNullTest(CFX_WideString wsValue) {
+ return SetTestValue(XFA_ATTRIBUTE_NullTest, wsValue,
+ XFA_ATTRIBUTEENUM_Disabled);
+}
+
+int32_t CXFA_Validate::GetNullTest() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_NullTest);
+}
+
+int32_t CXFA_Validate::GetScriptTest() {
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_ScriptTest);
+}
+
+void CXFA_Validate::GetMessageText(CFX_WideString& wsMessage,
+ const CFX_WideString& wsMessageType) {
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, FALSE);
+ if (!pNode)
+ return;
+
+ CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ for (; pItemNode;
+ pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ if (pItemNode->GetClassID() != XFA_ELEMENT_Text)
+ continue;
+
+ CFX_WideStringC wsName;
+ pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ if (wsName.IsEmpty() || wsName == wsMessageType) {
+ pItemNode->TryContent(wsMessage);
+ return;
+ }
+ }
+}
+
+void CXFA_Validate::SetFormatMessageText(CFX_WideString wsMessage) {
+ SetMessageText(wsMessage, L"formatTest");
+}
+
+void CXFA_Validate::GetFormatMessageText(CFX_WideString& wsMessage) {
+ GetMessageText(wsMessage, L"formatTest");
+}
+
+void CXFA_Validate::SetNullMessageText(CFX_WideString wsMessage) {
+ SetMessageText(wsMessage, L"nullTest");
+}
+
+void CXFA_Validate::GetNullMessageText(CFX_WideString& wsMessage) {
+ GetMessageText(wsMessage, L"nullTest");
+}
+
+void CXFA_Validate::SetMessageText(CFX_WideString& wsMessage,
+ const CFX_WideString& wsMessageType) {
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, TRUE);
+ if (!pNode)
+ return;
+
+ CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ for (; pItemNode;
+ pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ if (pItemNode->GetClassID() != XFA_ELEMENT_Text)
+ continue;
+
+ CFX_WideStringC wsName;
+ pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ if (wsName.IsEmpty() || wsName == wsMessageType) {
+ pItemNode->SetContent(wsMessage, wsMessage, FALSE);
+ return;
+ }
+ }
+ CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_ELEMENT_Text);
+ pNode->InsertChild(pTextNode);
+ pTextNode->SetCData(XFA_ATTRIBUTE_Name, wsMessageType, FALSE);
+ pTextNode->SetContent(wsMessage, wsMessage, FALSE);
+}
+
+void CXFA_Validate::GetScriptMessageText(CFX_WideString& wsMessage) {
+ GetMessageText(wsMessage, L"scriptTest");
+}
+
+void CXFA_Validate::SetScriptMessageText(CFX_WideString wsMessage) {
+ SetMessageText(wsMessage, L"scriptTest");
+}
+
+void CXFA_Validate::GetPicture(CFX_WideString& wsPicture) {
+ if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Picture))
+ pNode->TryContent(wsPicture);
+}
+
+CXFA_Script CXFA_Validate::GetScript() {
+ return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script));
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_validate.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_validate.h
new file mode 100644
index 00000000000..bdd7be98b2b
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_validate.h
@@ -0,0 +1,44 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_VALIDATE_H_
+#define XFA_FXFA_PARSER_CXFA_VALIDATE_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_script.h"
+
+class CXFA_Node;
+
+class CXFA_Validate : public CXFA_Data {
+ public:
+ explicit CXFA_Validate(CXFA_Node* pNode);
+
+ int32_t GetFormatTest();
+ int32_t GetNullTest();
+ FX_BOOL SetNullTest(CFX_WideString wsValue);
+ int32_t GetScriptTest();
+ void GetFormatMessageText(CFX_WideString& wsMessage);
+ void SetFormatMessageText(CFX_WideString wsMessage);
+ void GetNullMessageText(CFX_WideString& wsMessage);
+ void SetNullMessageText(CFX_WideString wsMessage);
+ void GetScriptMessageText(CFX_WideString& wsMessage);
+ void SetScriptMessageText(CFX_WideString wsMessage);
+ void GetPicture(CFX_WideString& wsPicture);
+ CXFA_Script GetScript();
+
+ protected:
+ void GetMessageText(CFX_WideString& wsMessage,
+ const CFX_WideString& wsMessageType);
+ void SetMessageText(CFX_WideString& wsMessage,
+ const CFX_WideString& wsMessageType);
+ FX_BOOL SetTestValue(int32_t iType,
+ CFX_WideString& wsValue,
+ XFA_ATTRIBUTEENUM eName);
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_VALIDATE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_value.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_value.cpp
new file mode 100644
index 00000000000..1e41ab27d32
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_value.cpp
@@ -0,0 +1,56 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_value.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+XFA_ELEMENT CXFA_Value::GetChildValueClassID() {
+ if (!m_pNode)
+ return XFA_ELEMENT_UNKNOWN;
+ if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
+ return pNode->GetClassID();
+ return XFA_ELEMENT_UNKNOWN;
+}
+
+FX_BOOL CXFA_Value::GetChildValueContent(CFX_WideString& wsContent) {
+ if (!m_pNode)
+ return FALSE;
+ if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
+ return pNode->TryContent(wsContent);
+ return FALSE;
+}
+
+CXFA_Arc CXFA_Value::GetArc() {
+ return CXFA_Arc(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
+ : nullptr);
+}
+
+CXFA_Line CXFA_Value::GetLine() {
+ return CXFA_Line(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
+ : nullptr);
+}
+
+CXFA_Rectangle CXFA_Value::GetRectangle() {
+ return CXFA_Rectangle(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
+ : nullptr);
+}
+
+CXFA_Text CXFA_Value::GetText() {
+ return CXFA_Text(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
+ : nullptr);
+}
+
+CXFA_ExData CXFA_Value::GetExData() {
+ return CXFA_ExData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
+ : nullptr);
+}
+
+CXFA_Image CXFA_Value::GetImage() {
+ return CXFA_Image(
+ m_pNode ? (m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) : nullptr,
+ TRUE);
+}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_value.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_value.h
new file mode 100644
index 00000000000..5c9a684828c
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_value.h
@@ -0,0 +1,35 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_VALUE_H_
+#define XFA_FXFA_PARSER_CXFA_VALUE_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fxfa/parser/cxfa_arc.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_exdata.h"
+#include "xfa/fxfa/parser/cxfa_image.h"
+#include "xfa/fxfa/parser/cxfa_line.h"
+#include "xfa/fxfa/parser/cxfa_rectangle.h"
+#include "xfa/fxfa/parser/cxfa_text.h"
+
+class CXFA_Node;
+
+class CXFA_Value : public CXFA_Data {
+ public:
+ explicit CXFA_Value(CXFA_Node* pNode) : CXFA_Data(pNode) {}
+
+ XFA_ELEMENT GetChildValueClassID();
+ FX_BOOL GetChildValueContent(CFX_WideString& wsContent);
+ CXFA_Arc GetArc();
+ CXFA_Line GetLine();
+ CXFA_Rectangle GetRectangle();
+ CXFA_Text GetText();
+ CXFA_ExData GetExData();
+ CXFA_Image GetImage();
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_VALUE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_objectacc_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 22f8fc2b342..6ef88cdc741 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_objectacc_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -1,938 +1,153 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "xfa/fxfa/parser/cxfa_widgetdata.h"
+
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fxbarcode/include/BC_Library.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
-#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
-#include "xfa/fxfa/parser/xfa_doclayout.h"
+#include "xfa/fxfa/parser/cxfa_event.h"
#include "xfa/fxfa/parser/xfa_document.h"
-#include "xfa/fxfa/parser/xfa_localemgr.h"
#include "xfa/fxfa/parser/xfa_localevalue.h"
#include "xfa/fxfa/parser/xfa_object.h"
-#include "xfa/fxfa/parser/xfa_parser.h"
-#include "xfa/fxfa/parser/xfa_script.h"
-#include "xfa/fxfa/parser/xfa_utils.h"
-
-static FX_ARGB XFA_WStringToColor(const CFX_WideStringC& wsValue) {
- uint8_t r = 0, g = 0, b = 0;
- if (wsValue.GetLength() == 0) {
- return 0xff000000;
- }
- int cc = 0;
- const FX_WCHAR* str = wsValue.raw_str();
- int len = wsValue.GetLength();
- while (XFA_IsSpace(str[cc]) && cc < len) {
- cc++;
- }
- if (cc >= len) {
- return 0xff000000;
- }
- while (cc < len) {
- if (str[cc] == ',' || !XFA_IsDigit(str[cc])) {
- break;
- }
- r = r * 10 + str[cc] - '0';
- cc++;
- }
- if (cc < len && str[cc] == ',') {
- cc++;
- while (XFA_IsSpace(str[cc]) && cc < len) {
- cc++;
- }
- while (cc < len) {
- if (str[cc] == ',' || !XFA_IsDigit(str[cc])) {
- break;
- }
- g = g * 10 + str[cc] - '0';
- cc++;
- }
- if (cc < len && str[cc] == ',') {
- cc++;
- while (XFA_IsSpace(str[cc]) && cc < len) {
- cc++;
- }
- while (cc < len) {
- if (str[cc] == ',' || !XFA_IsDigit(str[cc])) {
- break;
- }
- b = b * 10 + str[cc] - '0';
- cc++;
- }
- }
- }
- return (0xff << 24) | (r << 16) | (g << 8) | b;
-}
-XFA_ELEMENT CXFA_Data::GetClassID() const {
- return m_pNode ? m_pNode->GetClassID() : XFA_ELEMENT_UNKNOWN;
-}
-FX_BOOL CXFA_Data::TryMeasure(XFA_ATTRIBUTE eAttr,
- FX_FLOAT& fValue,
- FX_BOOL bUseDefault) const {
- CXFA_Measurement ms;
- if (m_pNode->TryMeasure(eAttr, ms, bUseDefault)) {
- fValue = ms.ToUnit(XFA_UNIT_Pt);
- return TRUE;
- }
- return FALSE;
-}
-FX_BOOL CXFA_Data::SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue) {
- CXFA_Measurement ms(fValue, XFA_UNIT_Pt);
- return m_pNode->SetMeasure(eAttr, ms);
-}
-CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-CXFA_Fill::~CXFA_Fill() {}
-int32_t CXFA_Fill::GetPresence() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
-}
-void CXFA_Fill::SetColor(FX_ARGB color) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color);
- CFX_WideString wsColor;
- int a, r, g, b;
- ArgbDecode(color, a, r, g, b);
- wsColor.Format(L"%d,%d,%d", r, g, b);
- pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
-}
-FX_ARGB CXFA_Fill::GetColor(FX_BOOL bText) {
- if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color)) {
- CFX_WideStringC wsColor;
- if (pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE)) {
- return XFA_WStringToColor(wsColor);
- }
- }
- if (bText) {
- return 0xFF000000;
- }
- return 0xFFFFFFFF;
-}
-int32_t CXFA_Fill::GetFillType() {
- CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- while (pChild) {
- int32_t eType = pChild->GetClassID();
- if (eType != XFA_ELEMENT_Color && eType != XFA_ELEMENT_Extras) {
- return eType;
- }
- pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
- }
- return XFA_ELEMENT_Solid;
-}
-int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Pattern);
- if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
- CFX_WideStringC wsColor;
- pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
- foreColor = XFA_WStringToColor(wsColor);
- } else {
- foreColor = 0xFF000000;
- }
- return pNode->GetEnum(XFA_ATTRIBUTE_Type);
-}
-int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Stipple);
- int32_t eAttr = 50;
- pNode->TryInteger(XFA_ATTRIBUTE_Rate, eAttr);
- if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
- CFX_WideStringC wsColor;
- pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
- stippleColor = XFA_WStringToColor(wsColor);
- } else {
- stippleColor = 0xFF000000;
- }
- return eAttr;
-}
-int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Linear);
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight;
- pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
- if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
- CFX_WideStringC wsColor;
- pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
- endColor = XFA_WStringToColor(wsColor);
- } else {
- endColor = 0xFF000000;
- }
- return eAttr;
-}
-int32_t CXFA_Fill::GetRadial(FX_ARGB& endColor) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Radial);
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge;
- pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
- if (CXFA_Node* pColor = pNode->GetChild(0, XFA_ELEMENT_Color)) {
- CFX_WideStringC wsColor;
- pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE);
- endColor = XFA_WStringToColor(wsColor);
- } else {
- endColor = 0xFF000000;
- }
- return eAttr;
-}
-CXFA_Margin::CXFA_Margin(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-FX_BOOL CXFA_Margin::GetLeftInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
- fInset = fDefInset;
- return TryMeasure(XFA_ATTRIBUTE_LeftInset, fInset);
-}
-FX_BOOL CXFA_Margin::GetTopInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
- fInset = fDefInset;
- return TryMeasure(XFA_ATTRIBUTE_TopInset, fInset);
-}
-FX_BOOL CXFA_Margin::GetRightInset(FX_FLOAT& fInset, FX_FLOAT fDefInset) const {
- fInset = fDefInset;
- return TryMeasure(XFA_ATTRIBUTE_RightInset, fInset);
-}
-FX_BOOL CXFA_Margin::GetBottomInset(FX_FLOAT& fInset,
- FX_FLOAT fDefInset) const {
- fInset = fDefInset;
- return TryMeasure(XFA_ATTRIBUTE_BottomInset, fInset);
-}
-CXFA_Font::CXFA_Font(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-FX_FLOAT CXFA_Font::GetBaselineShift() {
- return m_pNode->GetMeasure(XFA_ATTRIBUTE_BaselineShift).ToUnit(XFA_UNIT_Pt);
-}
-FX_FLOAT CXFA_Font::GetHorizontalScale() {
- CFX_WideString wsValue;
- m_pNode->TryCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue);
- int32_t iScale = FXSYS_wtoi((const FX_WCHAR*)wsValue);
- return iScale > 0 ? (FX_FLOAT)iScale : 100.0f;
-}
-FX_FLOAT CXFA_Font::GetVerticalScale() {
- CFX_WideString wsValue;
- m_pNode->TryCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue);
- int32_t iScale = FXSYS_wtoi((const FX_WCHAR*)wsValue);
- return iScale > 0 ? (FX_FLOAT)iScale : 100.0f;
-}
-FX_FLOAT CXFA_Font::GetLetterSpacing() {
- CFX_WideStringC wsValue;
- if (!m_pNode->TryCData(XFA_ATTRIBUTE_LetterSpacing, wsValue)) {
- return 0;
- }
- CXFA_Measurement ms(wsValue);
- if (ms.GetUnit() == XFA_UNIT_Em) {
- return ms.GetValue() * GetFontSize();
- }
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-int32_t CXFA_Font::GetLineThrough() {
- int32_t iValue = 0;
- m_pNode->TryInteger(XFA_ATTRIBUTE_LineThrough, iValue);
- return iValue;
-}
-int32_t CXFA_Font::GetUnderline() {
- int32_t iValue = 0;
- m_pNode->TryInteger(XFA_ATTRIBUTE_Underline, iValue);
- return iValue;
-}
-int32_t CXFA_Font::GetUnderlinePeriod() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All;
- m_pNode->TryEnum(XFA_ATTRIBUTE_UnderlinePeriod, eAttr);
- return eAttr;
-}
-FX_FLOAT CXFA_Font::GetFontSize() {
- CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_Size, ms);
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-void CXFA_Font::GetTypeface(CFX_WideStringC& wsTypeFace) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Typeface, wsTypeFace);
-}
-FX_BOOL CXFA_Font::IsBold() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Weight, eAttr);
- return eAttr == XFA_ATTRIBUTEENUM_Bold;
-}
-FX_BOOL CXFA_Font::IsItalic() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Posture, eAttr);
- return eAttr == XFA_ATTRIBUTEENUM_Italic;
-}
-void CXFA_Font::SetColor(FX_ARGB color) {
- CXFA_Fill fill(m_pNode->GetProperty(0, XFA_ELEMENT_Fill));
- fill.SetColor(color);
-}
-FX_ARGB CXFA_Font::GetColor() {
- CXFA_Fill fill(m_pNode->GetChild(0, XFA_ELEMENT_Fill));
- return fill ? fill.GetColor(TRUE) : 0xFF000000;
-}
-CXFA_Caption::CXFA_Caption(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-int32_t CXFA_Caption::GetPresence() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Visible;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Presence, eAttr);
- return eAttr;
-}
-int32_t CXFA_Caption::GetPlacementType() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Placement, eAttr);
- return eAttr;
-}
-FX_FLOAT CXFA_Caption::GetReserve() {
- CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_Reserve, ms);
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-CXFA_Margin CXFA_Caption::GetMargin() {
- return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin) : NULL);
-}
-CXFA_Font CXFA_Caption::GetFont() {
- return CXFA_Font(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Font) : NULL);
-}
-CXFA_Value CXFA_Caption::GetValue() {
- return CXFA_Value(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Value) : NULL);
-}
-CXFA_Para::CXFA_Para(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-int32_t CXFA_Para::GetHorizontalAlign() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
- m_pNode->TryEnum(XFA_ATTRIBUTE_HAlign, eAttr);
- return eAttr;
-}
-int32_t CXFA_Para::GetVerticalAlign() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Top;
- m_pNode->TryEnum(XFA_ATTRIBUTE_VAlign, eAttr);
- return eAttr;
-}
-FX_FLOAT CXFA_Para::GetLineHeight() {
- CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_LineHeight, ms);
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-FX_FLOAT CXFA_Para::GetMarginLeft() {
- CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginLeft, ms);
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-FX_FLOAT CXFA_Para::GetMarginRight() {
- CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginRight, ms);
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-FX_FLOAT CXFA_Para::GetSpaceAbove() {
- CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceAbove, ms);
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-FX_FLOAT CXFA_Para::GetSpaceBelow() {
- CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceBelow, ms);
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-FX_FLOAT CXFA_Para::GetTextIndent() {
- CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_TextIndent, ms);
- return ms.ToUnit(XFA_UNIT_Pt);
-}
-CXFA_Event::CXFA_Event(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-int32_t CXFA_Event::GetActivity() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Activity);
-}
-int32_t CXFA_Event::GetEventType() {
- CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- while (pChild) {
- int32_t eType = pChild->GetClassID();
- if (eType != XFA_ELEMENT_Extras) {
- return eType;
- }
- pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
- }
- return XFA_ELEMENT_UNKNOWN;
-}
-void CXFA_Event::GetRef(CFX_WideStringC& wsRef) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
-}
-CXFA_Script CXFA_Event::GetScript() {
- return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script));
-}
-CXFA_Submit CXFA_Event::GetSubmit() {
- return CXFA_Submit(m_pNode->GetChild(0, XFA_ELEMENT_Submit));
-}
-void CXFA_Event::GetSignDataTarget(CFX_WideString& wsTarget) {
- if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_SignData)) {
- CFX_WideStringC wsCData;
- pNode->TryCData(XFA_ATTRIBUTE_Target, wsCData);
- wsTarget = wsCData;
- }
-}
-CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-XFA_SCRIPTTYPE CXFA_Script::GetContentType() {
- CFX_WideStringC cData;
- if (m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, cData, FALSE)) {
- if (cData == FX_WSTRC(L"application/x-javascript")) {
- return XFA_SCRIPTTYPE_Javascript;
- } else if (cData == FX_WSTRC(L"application/x-formcalc")) {
- return XFA_SCRIPTTYPE_Formcalc;
- } else {
- return XFA_SCRIPTTYPE_Unkown;
- }
- }
- return XFA_SCRIPTTYPE_Formcalc;
-}
-int32_t CXFA_Script::GetRunAt() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_RunAt);
-}
-void CXFA_Script::GetExpression(CFX_WideString& wsExpression) {
- m_pNode->TryContent(wsExpression);
-}
-CXFA_Submit::CXFA_Submit(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-FX_BOOL CXFA_Submit::IsSubmitEmbedPDF() {
- return m_pNode->GetBoolean(XFA_ATTRIBUTE_EmbedPDF);
-}
-int32_t CXFA_Submit::GetSubmitFormat() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Format);
-}
-void CXFA_Submit::GetSubmitTarget(CFX_WideStringC& wsTarget) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Target, wsTarget);
-}
-void CXFA_Submit::GetSubmitXDPContent(CFX_WideStringC& wsContent) {
- m_pNode->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent);
-}
-XFA_ELEMENT CXFA_Value::GetChildValueClassID() {
- if (!m_pNode) {
- return XFA_ELEMENT_UNKNOWN;
- }
- if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) {
- return pNode->GetClassID();
- }
- return XFA_ELEMENT_UNKNOWN;
-}
-FX_BOOL CXFA_Value::GetChildValueContent(CFX_WideString& wsContent) {
- if (!m_pNode) {
- return FALSE;
- }
- if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) {
- return pNode->TryContent(wsContent);
- }
- return FALSE;
-}
-CXFA_Arc CXFA_Value::GetArc() {
- return CXFA_Arc(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-CXFA_Line CXFA_Value::GetLine() {
- return CXFA_Line(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-CXFA_Rectangle CXFA_Value::GetRectangle() {
- return CXFA_Rectangle(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-CXFA_Text CXFA_Value::GetText() {
- return CXFA_Text(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-CXFA_ExData CXFA_Value::GetExData() {
- return CXFA_ExData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)
- : nullptr);
-}
-CXFA_Image CXFA_Value::GetImage() {
- return CXFA_Image(
- m_pNode ? (m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) : nullptr,
- TRUE);
-}
-int32_t CXFA_Line::GetHand() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
-}
-FX_BOOL CXFA_Line::GetSlop() {
- XFA_ATTRIBUTEENUM eSlop = m_pNode->GetEnum(XFA_ATTRIBUTE_Slope);
- return eSlop == XFA_ATTRIBUTEENUM_Slash;
-}
-CXFA_Edge CXFA_Line::GetEdge() {
- return CXFA_Edge(m_pNode->GetChild(0, XFA_ELEMENT_Edge));
-}
-CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-void CXFA_Text::GetContent(CFX_WideString& wsText) {
- m_pNode->TryContent(wsText);
-}
-CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-FX_BOOL CXFA_ExData::SetContentType(const CFX_WideString& wsContentType) {
- return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
-}
-CXFA_Image::CXFA_Image(CXFA_Node* pNode, FX_BOOL bDefValue)
- : CXFA_Data(pNode), m_bDefValue(bDefValue) {}
-int32_t CXFA_Image::GetAspect() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Aspect);
-}
-FX_BOOL CXFA_Image::GetContentType(CFX_WideString& wsContentType) {
- return m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType);
-}
-FX_BOOL CXFA_Image::GetHref(CFX_WideString& wsHref) {
- if (m_bDefValue) {
- return m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref);
- }
- return m_pNode->GetAttribute(FX_WSTRC(L"href"), wsHref);
-}
-int32_t CXFA_Image::GetTransferEncoding() {
- if (m_bDefValue) {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding);
- }
- return XFA_ATTRIBUTEENUM_Base64;
-}
-FX_BOOL CXFA_Image::GetContent(CFX_WideString& wsText) {
- return m_pNode->TryContent(wsText);
-}
-FX_BOOL CXFA_Image::SetContentType(const CFX_WideString& wsContentType) {
- return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
-}
-FX_BOOL CXFA_Image::SetHref(const CFX_WideString& wsHref) {
- if (m_bDefValue) {
- return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref);
- }
- return m_pNode->SetAttribute(XFA_ATTRIBUTE_Href, wsHref.AsWideStringC());
-}
-FX_BOOL CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) {
- if (m_bDefValue) {
- return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding,
- (XFA_ATTRIBUTEENUM)iTransferEncoding);
- }
- return TRUE;
-}
-CXFA_Calculate::CXFA_Calculate(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-int32_t CXFA_Calculate::GetOverride() {
- XFA_ATTRIBUTEENUM eAtt = XFA_ATTRIBUTEENUM_Error;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Override, eAtt, FALSE);
- return eAtt;
-}
-CXFA_Script CXFA_Calculate::GetScript() {
- return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script));
-}
-void CXFA_Calculate::GetMessageText(CFX_WideString& wsMessage) {
- if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Message)) {
- CXFA_Text text(pNode->GetChild(0, XFA_ELEMENT_Text));
- if (text) {
- text.GetContent(wsMessage);
- }
- }
-}
-CXFA_Validate::CXFA_Validate(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-int32_t CXFA_Validate::GetFormatTest() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_FormatTest);
-}
-FX_BOOL CXFA_Validate::SetTestValue(int32_t iType,
- CFX_WideString& wsValue,
- XFA_ATTRIBUTEENUM eName) {
- const XFA_ATTRIBUTEENUMINFO* pInfo =
- XFA_GetAttributeEnumByName(wsValue.AsWideStringC());
- if (pInfo) {
- eName = pInfo->eName;
- }
- m_pNode->SetEnum((XFA_ATTRIBUTE)iType, eName, FALSE);
- return TRUE;
-}
-FX_BOOL CXFA_Validate::SetNullTest(CFX_WideString wsValue) {
- return SetTestValue(XFA_ATTRIBUTE_NullTest, wsValue,
- XFA_ATTRIBUTEENUM_Disabled);
-}
-int32_t CXFA_Validate::GetNullTest() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_NullTest);
-}
-int32_t CXFA_Validate::GetScriptTest() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_ScriptTest);
-}
-void CXFA_Validate::GetMessageText(CFX_WideString& wsMessage,
- const CFX_WideStringC& wsMessageType) {
- if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, FALSE)) {
- CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pItemNode;
- pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pItemNode->GetClassID() != XFA_ELEMENT_Text) {
- continue;
- }
- CFX_WideStringC wsName;
- pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
- if (wsName.IsEmpty() || wsName == wsMessageType) {
- pItemNode->TryContent(wsMessage);
- return;
- }
- }
- }
-}
-void CXFA_Validate::SetFormatMessageText(CFX_WideString wsMessage) {
- SetMessageText(wsMessage, FX_WSTRC(L"formatTest"));
-}
-void CXFA_Validate::GetFormatMessageText(CFX_WideString& wsMessage) {
- GetMessageText(wsMessage, FX_WSTRC(L"formatTest"));
-}
-void CXFA_Validate::SetNullMessageText(CFX_WideString wsMessage) {
- SetMessageText(wsMessage, FX_WSTRC(L"nullTest"));
-}
-void CXFA_Validate::GetNullMessageText(CFX_WideString& wsMessage) {
- GetMessageText(wsMessage, FX_WSTRC(L"nullTest"));
-}
-void CXFA_Validate::SetMessageText(CFX_WideString& wsMessage,
- const CFX_WideStringC& wsMessageType) {
- if (CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Message, TRUE)) {
- CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pItemNode;
- pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pItemNode->GetClassID() != XFA_ELEMENT_Text) {
- continue;
- }
- CFX_WideStringC wsName;
- pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
- if (wsName.IsEmpty() || wsName == wsMessageType) {
- pItemNode->SetContent(wsMessage, wsMessage, FALSE);
- return;
- }
- }
- CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_ELEMENT_Text);
- pNode->InsertChild(pTextNode);
- pTextNode->SetCData(XFA_ATTRIBUTE_Name, wsMessageType, FALSE);
- pTextNode->SetContent(wsMessage, wsMessage, FALSE);
- }
-}
-void CXFA_Validate::GetScriptMessageText(CFX_WideString& wsMessage) {
- GetMessageText(wsMessage, FX_WSTRC(L"scriptTest"));
-}
-void CXFA_Validate::SetScriptMessageText(CFX_WideString wsMessage) {
- SetMessageText(wsMessage, FX_WSTRC(L"scriptTest"));
-}
-void CXFA_Validate::GetPicture(CFX_WideString& wsPicture) {
- if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) {
- pNode->TryContent(wsPicture);
- }
-}
-CXFA_Script CXFA_Validate::GetScript() {
- return CXFA_Script(m_pNode->GetChild(0, XFA_ELEMENT_Script));
-}
-CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-void CXFA_Bind::GetPicture(CFX_WideString& wsPicture) {
- if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_ELEMENT_Picture)) {
- pPicture->TryContent(wsPicture);
- }
-}
-CXFA_Assist::CXFA_Assist(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-CXFA_ToolTip CXFA_Assist::GetToolTip() {
- return CXFA_ToolTip(m_pNode->GetChild(0, XFA_ELEMENT_ToolTip));
-}
-CXFA_ToolTip::CXFA_ToolTip(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-FX_BOOL CXFA_ToolTip::GetTip(CFX_WideString& wsTip) {
- return m_pNode->TryContent(wsTip);
-}
-CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-void CXFA_BindItems::GetLabelRef(CFX_WideStringC& wsLabelRef) {
- m_pNode->TryCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef);
-}
-void CXFA_BindItems::GetValueRef(CFX_WideStringC& wsValueRef) {
- m_pNode->TryCData(XFA_ATTRIBUTE_ValueRef, wsValueRef);
-}
-void CXFA_BindItems::GetRef(CFX_WideStringC& wsRef) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
-}
-FX_BOOL CXFA_BindItems::SetConnection(const CFX_WideString& wsConnection) {
- return m_pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection);
-}
-int32_t CXFA_Box::GetHand() const {
- if (!m_pNode) {
- return XFA_ATTRIBUTEENUM_Even;
- }
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
-}
-int32_t CXFA_Box::GetPresence() const {
- if (!m_pNode) {
- return XFA_ATTRIBUTEENUM_Hidden;
- }
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
-}
-int32_t CXFA_Box::CountEdges() const {
- if (!m_pNode) {
- return 0;
- }
- return m_pNode->CountChildren(XFA_ELEMENT_Edge);
-}
-CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const {
- return CXFA_Edge(
- m_pNode ? m_pNode->GetProperty(nIndex, XFA_ELEMENT_Edge, nIndex == 0)
- : nullptr);
-}
-static void XFA_BOX_GetStrokes(CXFA_Node* pNode,
- CXFA_StrokeArray& strokes,
- FX_BOOL bNULL) {
- strokes.RemoveAll();
- if (!pNode) {
- return;
- }
- strokes.SetSize(8);
- int32_t i, j;
- for (i = 0, j = 0; i < 4; i++) {
- CXFA_Corner corner =
- CXFA_Corner(pNode->GetProperty(i, XFA_ELEMENT_Corner, i == 0));
- if (corner || i == 0) {
- strokes.SetAt(j, corner);
- } else if (bNULL) {
- strokes.SetAt(j, CXFA_Stroke(nullptr));
- } else if (i == 1) {
- strokes.SetAt(j, strokes[0]);
- } else if (i == 2) {
- strokes.SetAt(j, strokes[0]);
- } else {
- strokes.SetAt(j, strokes[2]);
- }
- j++;
- CXFA_Edge edge = CXFA_Edge(pNode->GetProperty(i, XFA_ELEMENT_Edge, i == 0));
- if (edge || i == 0) {
- strokes.SetAt(j, edge);
- } else if (bNULL) {
- strokes.SetAt(j, CXFA_Stroke(nullptr));
- } else if (i == 1) {
- strokes.SetAt(j, strokes[1]);
- } else if (i == 2) {
- strokes.SetAt(j, strokes[1]);
- } else {
- strokes.SetAt(j, strokes[3]);
- }
- j++;
- }
-}
-void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const {
- XFA_BOX_GetStrokes(m_pNode, strokes, FALSE);
-}
-FX_BOOL CXFA_Box::IsCircular() const {
- if (!m_pNode) {
- return FALSE;
+
+namespace {
+
+FX_FLOAT GetEdgeThickness(const CXFA_StrokeArray& strokes,
+ FX_BOOL b3DStyle,
+ int32_t nIndex) {
+ FX_FLOAT fThickness = 0;
+
+ if (strokes[nIndex * 2 + 1].GetPresence() == XFA_ATTRIBUTEENUM_Visible) {
+ if (nIndex == 0)
+ fThickness += 2.5f;
+
+ fThickness += strokes[nIndex * 2 + 1].GetThickness() * (b3DStyle ? 4 : 2);
}
- return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular);
+ return fThickness;
}
-FX_BOOL CXFA_Box::GetStartAngle(FX_FLOAT& fStartAngle) const {
- fStartAngle = 0;
- if (!m_pNode) {
+
+FX_BOOL SplitDateTime(const CFX_WideString& wsDateTime,
+ CFX_WideString& wsDate,
+ CFX_WideString& wsTime) {
+ wsDate = L"";
+ wsTime = L"";
+ if (wsDateTime.IsEmpty())
return FALSE;
- }
- CXFA_Measurement ms;
- FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, FALSE);
- if (bRet) {
- fStartAngle = ms.GetValue();
- }
- return bRet;
-}
-FX_BOOL CXFA_Box::GetSweepAngle(FX_FLOAT& fSweepAngle) const {
- fSweepAngle = 360;
- if (!m_pNode) {
+
+ int nSplitIndex = -1;
+ nSplitIndex = wsDateTime.Find('T');
+ if (nSplitIndex < 0)
+ nSplitIndex = wsDateTime.Find(' ');
+ if (nSplitIndex < 0)
return FALSE;
- }
- CXFA_Measurement ms;
- FX_BOOL bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, FALSE);
- if (bRet) {
- fSweepAngle = ms.GetValue();
- }
- return bRet;
-}
-CXFA_Fill CXFA_Box::GetFill(FX_BOOL bModified) const {
- if (!m_pNode) {
- return CXFA_Fill(nullptr);
- }
- CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_ELEMENT_Fill, bModified);
- return CXFA_Fill(pFillNode);
-}
-CXFA_Margin CXFA_Box::GetMargin() const {
- return CXFA_Margin(m_pNode ? m_pNode->GetChild(0, XFA_ELEMENT_Margin)
- : nullptr);
-}
-static int32_t XFA_BOX_3DStyle(const CXFA_StrokeArray& strokes,
- CXFA_Stroke& stroke) {
- int32_t iCount = strokes.GetSize();
- if (iCount < 1) {
- return 0;
- }
- stroke = strokes[0];
- for (int32_t i = 1; i < iCount; i++) {
- CXFA_Stroke find = strokes[i];
- if (!find) {
- continue;
- }
- if (!stroke) {
- stroke = find;
- } else if (stroke.GetStrokeType() != find.GetStrokeType()) {
- stroke = find;
- break;
+
+ wsDate = wsDateTime.Left(nSplitIndex);
+ if (!wsDate.IsEmpty()) {
+ int32_t iCount = wsDate.GetLength();
+ int32_t i = 0;
+ for (i = 0; i < iCount; i++) {
+ if (wsDate[i] >= '0' && wsDate[i] <= '9')
+ break;
}
+ if (i == iCount)
+ return FALSE;
}
- int32_t iType = stroke.GetStrokeType();
- if (iType == XFA_ATTRIBUTEENUM_Lowered || iType == XFA_ATTRIBUTEENUM_Raised ||
- iType == XFA_ATTRIBUTEENUM_Etched ||
- iType == XFA_ATTRIBUTEENUM_Embossed) {
- return iType;
- }
- return 0;
-}
-int32_t CXFA_Box::Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const {
- if (IsArc()) {
- return 0;
- }
- CXFA_StrokeArray strokes;
- XFA_BOX_GetStrokes(m_pNode, strokes, TRUE);
- CXFA_Stroke stroke(NULL);
- int32_t iType = XFA_BOX_3DStyle(strokes, stroke);
- if (iType) {
- bVisible = stroke.IsVisible();
- fThickness = stroke.GetThickness();
- }
- return iType;
-}
-int32_t CXFA_Stroke::GetPresence() const {
- return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence)
- : XFA_ATTRIBUTEENUM_Invisible;
-}
-int32_t CXFA_Stroke::GetCapType() const {
- if (!m_pNode) {
- return XFA_ATTRIBUTEENUM_Square;
- }
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Cap);
-}
-int32_t CXFA_Stroke::GetStrokeType() const {
- return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Stroke)
- : XFA_ATTRIBUTEENUM_Solid;
-}
-FX_FLOAT CXFA_Stroke::GetThickness() const {
- return GetMSThickness().ToUnit(XFA_UNIT_Pt);
-}
-CXFA_Measurement CXFA_Stroke::GetMSThickness() const {
- return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Thickness)
- : XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT_Edge,
- XFA_ATTRIBUTE_Thickness,
- XFA_XDPPACKET_Form);
-}
-void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) {
- if (!m_pNode) {
- return;
- }
- m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness);
-}
-FX_ARGB CXFA_Stroke::GetColor() const {
- if (!m_pNode) {
- return 0xFF000000;
- }
- CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color);
- if (!pNode) {
- return 0xFF000000;
- }
- CFX_WideStringC wsColor;
- pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor);
- return XFA_WStringToColor(wsColor);
-}
-void CXFA_Stroke::SetColor(FX_ARGB argb) {
- if (!m_pNode) {
- return;
- }
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color);
- CFX_WideString wsColor;
- int a, r, g, b;
- ArgbDecode(argb, a, r, g, b);
- wsColor.Format(L"%d,%d,%d", r, g, b);
- pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
-}
-int32_t CXFA_Stroke::GetJoinType() const {
- return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Join)
- : XFA_ATTRIBUTEENUM_Square;
-}
-FX_BOOL CXFA_Stroke::IsInverted() const {
- return m_pNode ? m_pNode->GetBoolean(XFA_ATTRIBUTE_Inverted) : FALSE;
-}
-FX_FLOAT CXFA_Stroke::GetRadius() const {
- return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Radius).ToUnit(XFA_UNIT_Pt)
- : 0;
-}
-FX_BOOL CXFA_Stroke::SameStyles(CXFA_Stroke stroke, uint32_t dwFlags) const {
- if (m_pNode == stroke.GetNode()) {
- return TRUE;
- }
- if (FXSYS_fabs(GetThickness() - stroke.GetThickness()) >= 0.01f) {
- return FALSE;
- }
- if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 &&
- IsVisible() != stroke.IsVisible()) {
- return FALSE;
- }
- if (GetStrokeType() != stroke.GetStrokeType()) {
- return FALSE;
- }
- if (GetColor() != stroke.GetColor()) {
- return FALSE;
- }
- if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 &&
- FXSYS_fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) {
- return FALSE;
- }
- return TRUE;
-}
-FX_FLOAT XFA_GetEdgeThickness(const CXFA_StrokeArray& strokes,
- FX_BOOL b3DStyle,
- int32_t nIndex) {
- FX_FLOAT fThickness = 0;
- {
- if (strokes[nIndex * 2 + 1].GetPresence() == XFA_ATTRIBUTEENUM_Visible) {
- if (nIndex == 0) {
- fThickness += 2.5f;
- }
- fThickness += strokes[nIndex * 2 + 1].GetThickness() * (b3DStyle ? 4 : 2);
+ wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1);
+ if (!wsTime.IsEmpty()) {
+ int32_t iCount = wsTime.GetLength();
+ int32_t i = 0;
+ for (i = 0; i < iCount; i++) {
+ if (wsTime[i] >= '0' && wsTime[i] <= '9')
+ break;
}
+ if (i == iCount)
+ return FALSE;
}
- return fThickness;
+ return TRUE;
}
+
+} // namespace
+
CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode)
: CXFA_Data(pNode),
m_bIsNull(TRUE),
m_bPreNull(TRUE),
m_pUiChildNode(NULL),
m_eUIType(XFA_ELEMENT_UNKNOWN) {}
+
CXFA_Node* CXFA_WidgetData::GetUIChild() {
- if (m_eUIType == XFA_ELEMENT_UNKNOWN) {
+ if (m_eUIType == XFA_ELEMENT_UNKNOWN)
m_pUiChildNode = XFA_CreateUIChild(m_pNode, m_eUIType);
- }
+
return m_pUiChildNode;
}
+
XFA_ELEMENT CXFA_WidgetData::GetUIType() {
GetUIChild();
return m_eUIType;
}
+
CFX_WideString CXFA_WidgetData::GetRawValue() {
return m_pNode->GetContent();
}
+
int32_t CXFA_WidgetData::GetAccess(FX_BOOL bTemplate) {
if (bTemplate) {
CXFA_Node* pNode = m_pNode->GetTemplateNode();
- if (pNode) {
+ if (pNode)
return pNode->GetEnum(XFA_ATTRIBUTE_Access);
- }
return XFA_ATTRIBUTEENUM_Open;
}
CXFA_Node* pNode = m_pNode;
while (pNode) {
int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Access);
- if (iAcc != XFA_ATTRIBUTEENUM_Open) {
+ if (iAcc != XFA_ATTRIBUTEENUM_Open)
return iAcc;
- }
+
pNode =
pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode);
}
return XFA_ATTRIBUTEENUM_Open;
}
+
int32_t CXFA_WidgetData::GetRotate() {
CXFA_Measurement ms;
- if (!m_pNode->TryMeasure(XFA_ATTRIBUTE_Rotate, ms, FALSE)) {
+ if (!m_pNode->TryMeasure(XFA_ATTRIBUTE_Rotate, ms, FALSE))
return 0;
- }
+
int32_t iRotate = FXSYS_round(ms.GetValue());
iRotate = XFA_MapRotation(iRotate);
return iRotate / 90 * 90;
}
+
CXFA_Border CXFA_WidgetData::GetBorder(FX_BOOL bModified) {
return CXFA_Border(m_pNode->GetProperty(0, XFA_ELEMENT_Border, bModified));
}
+
CXFA_Caption CXFA_WidgetData::GetCaption(FX_BOOL bModified) {
return CXFA_Caption(m_pNode->GetProperty(0, XFA_ELEMENT_Caption, bModified));
}
+
CXFA_Font CXFA_WidgetData::GetFont(FX_BOOL bModified) {
return CXFA_Font(m_pNode->GetProperty(0, XFA_ELEMENT_Font, bModified));
}
+
CXFA_Margin CXFA_WidgetData::GetMargin(FX_BOOL bModified) {
return CXFA_Margin(m_pNode->GetProperty(0, XFA_ELEMENT_Margin, bModified));
}
+
CXFA_Para CXFA_WidgetData::GetPara(FX_BOOL bModified) {
return CXFA_Para(m_pNode->GetProperty(0, XFA_ELEMENT_Para, bModified));
}
+
void CXFA_WidgetData::GetEventList(CXFA_NodeArray& events) {
m_pNode->GetNodeList(events, 0, XFA_ELEMENT_Event);
}
+
int32_t CXFA_WidgetData::GetEventByActivity(int32_t iActivity,
CXFA_NodeArray& events,
FX_BOOL bIsFormReady) {
@@ -946,13 +161,11 @@ int32_t CXFA_WidgetData::GetEventByActivity(int32_t iActivity,
CFX_WideStringC wsRef;
event.GetRef(wsRef);
if (bIsFormReady) {
- if (wsRef == CFX_WideStringC(L"$form")) {
+ if (wsRef == CFX_WideStringC(L"$form"))
events.Add(allEvents[i]);
- }
} else {
- if (wsRef == CFX_WideStringC(L"$layout")) {
+ if (wsRef == CFX_WideStringC(L"$layout"))
events.Add(allEvents[i]);
- }
}
} else {
events.Add(allEvents[i]);
@@ -961,69 +174,84 @@ int32_t CXFA_WidgetData::GetEventByActivity(int32_t iActivity,
}
return events.GetSize();
}
+
CXFA_Value CXFA_WidgetData::GetDefaultValue(FX_BOOL bModified) {
CXFA_Node* pTemNode = m_pNode->GetTemplateNode();
return CXFA_Value(pTemNode
? pTemNode->GetProperty(0, XFA_ELEMENT_Value, bModified)
: nullptr);
}
+
CXFA_Value CXFA_WidgetData::GetFormValue(FX_BOOL bModified) {
return CXFA_Value(m_pNode->GetProperty(0, XFA_ELEMENT_Value, bModified));
}
+
CXFA_Calculate CXFA_WidgetData::GetCalculate(FX_BOOL bModified) {
return CXFA_Calculate(
m_pNode->GetProperty(0, XFA_ELEMENT_Calculate, bModified));
}
+
CXFA_Validate CXFA_WidgetData::GetValidate(FX_BOOL bModified) {
return CXFA_Validate(
m_pNode->GetProperty(0, XFA_ELEMENT_Validate, bModified));
}
+
CXFA_Bind CXFA_WidgetData::GetBind(FX_BOOL bModified) {
return CXFA_Bind(m_pNode->GetProperty(0, XFA_ELEMENT_Bind, bModified));
}
+
CXFA_Assist CXFA_WidgetData::GetAssist(FX_BOOL bModified) {
return CXFA_Assist(m_pNode->GetProperty(0, XFA_ELEMENT_Assist, bModified));
}
+
FX_BOOL CXFA_WidgetData::GetWidth(FX_FLOAT& fWidth) {
return TryMeasure(XFA_ATTRIBUTE_W, fWidth);
}
+
FX_BOOL CXFA_WidgetData::GetHeight(FX_FLOAT& fHeight) {
return TryMeasure(XFA_ATTRIBUTE_H, fHeight);
}
+
FX_BOOL CXFA_WidgetData::GetMinWidth(FX_FLOAT& fMinWidth) {
return TryMeasure(XFA_ATTRIBUTE_MinW, fMinWidth);
}
+
FX_BOOL CXFA_WidgetData::GetMinHeight(FX_FLOAT& fMinHeight) {
return TryMeasure(XFA_ATTRIBUTE_MinH, fMinHeight);
}
+
FX_BOOL CXFA_WidgetData::GetMaxWidth(FX_FLOAT& fMaxWidth) {
return TryMeasure(XFA_ATTRIBUTE_MaxW, fMaxWidth);
}
+
FX_BOOL CXFA_WidgetData::GetMaxHeight(FX_FLOAT& fMaxHeight) {
return TryMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight);
}
+
CXFA_Border CXFA_WidgetData::GetUIBorder(FX_BOOL bModified) {
CXFA_Node* pUIChild = GetUIChild();
return CXFA_Border(
pUIChild ? pUIChild->GetProperty(0, XFA_ELEMENT_Border, bModified)
: nullptr);
}
+
CXFA_Margin CXFA_WidgetData::GetUIMargin(FX_BOOL bModified) {
CXFA_Node* pUIChild = GetUIChild();
return CXFA_Margin(
pUIChild ? pUIChild->GetProperty(0, XFA_ELEMENT_Margin, bModified)
: nullptr);
}
+
void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) {
rtUIMargin.Reset();
CXFA_Margin mgUI = GetUIMargin();
- if (!mgUI) {
+ if (!mgUI)
return;
- }
+
CXFA_Border border = GetUIBorder();
- if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible) {
+ if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
return;
- }
+
FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset;
FX_BOOL bLeft = mgUI.GetLeftInset(fLeftInset);
FX_BOOL bTop = mgUI.GetTopInset(fTopInset);
@@ -1036,30 +264,27 @@ void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) {
if (!bLeft || !bTop || !bRight || !bBottom) {
CXFA_StrokeArray strokes;
border.GetStrokes(strokes);
- if (!bTop) {
- fTopInset = XFA_GetEdgeThickness(strokes, bVisible, 0);
- }
- if (!bRight) {
- fRightInset = XFA_GetEdgeThickness(strokes, bVisible, 1);
- }
- if (!bBottom) {
- fBottomInset = XFA_GetEdgeThickness(strokes, bVisible, 2);
- }
- if (!bLeft) {
- fLeftInset = XFA_GetEdgeThickness(strokes, bVisible, 3);
- }
+ if (!bTop)
+ fTopInset = GetEdgeThickness(strokes, bVisible, 0);
+ if (!bRight)
+ fRightInset = GetEdgeThickness(strokes, bVisible, 1);
+ if (!bBottom)
+ fBottomInset = GetEdgeThickness(strokes, bVisible, 2);
+ if (!bLeft)
+ fLeftInset = GetEdgeThickness(strokes, bVisible, 3);
}
}
rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset);
}
+
int32_t CXFA_WidgetData::GetButtonHighlight() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetEnum(XFA_ATTRIBUTE_Highlight);
- }
return XFA_GetAttributeDefaultValue_Enum(
XFA_ELEMENT_Button, XFA_ATTRIBUTE_Highlight, XFA_XDPPACKET_Form);
}
+
FX_BOOL CXFA_WidgetData::GetButtonRollover(CFX_WideString& wsRollover,
FX_BOOL& bRichText) {
if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) {
@@ -1077,6 +302,7 @@ FX_BOOL CXFA_WidgetData::GetButtonRollover(CFX_WideString& wsRollover,
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetButtonDown(CFX_WideString& wsDown,
FX_BOOL& bRichText) {
if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) {
@@ -1094,64 +320,66 @@ FX_BOOL CXFA_WidgetData::GetButtonDown(CFX_WideString& wsDown,
}
return FALSE;
}
+
int32_t CXFA_WidgetData::GetCheckButtonShape() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetEnum(XFA_ATTRIBUTE_Shape);
- }
return XFA_GetAttributeDefaultValue_Enum(
XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Shape, XFA_XDPPACKET_Form);
}
+
int32_t CXFA_WidgetData::GetCheckButtonMark() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetEnum(XFA_ATTRIBUTE_Mark);
- }
return XFA_GetAttributeDefaultValue_Enum(
XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Mark, XFA_XDPPACKET_Form);
}
+
FX_BOOL CXFA_WidgetData::IsRadioButton() {
- if (CXFA_Node* pParent = m_pNode->GetNodeItem(XFA_NODEITEM_Parent)) {
+ if (CXFA_Node* pParent = m_pNode->GetNodeItem(XFA_NODEITEM_Parent))
return pParent->GetClassID() == XFA_ELEMENT_ExclGroup;
- }
return FALSE;
}
+
FX_FLOAT CXFA_WidgetData::GetCheckButtonSize() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetMeasure(XFA_ATTRIBUTE_Size).ToUnit(XFA_UNIT_Pt);
- }
return XFA_GetAttributeDefaultValue_Measure(
XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_Size, XFA_XDPPACKET_Form)
.ToUnit(XFA_UNIT_Pt);
}
+
FX_BOOL CXFA_WidgetData::IsAllowNeutral() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetBoolean(XFA_ATTRIBUTE_AllowNeutral);
- }
return XFA_GetAttributeDefaultValue_Boolean(
XFA_ELEMENT_CheckButton, XFA_ATTRIBUTE_AllowNeutral, XFA_XDPPACKET_Form);
}
+
XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() {
CFX_WideString wsValue = GetRawValue();
- if (wsValue.IsEmpty()) {
+ if (wsValue.IsEmpty())
return XFA_CHECKSTATE_Off;
- }
+
if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
int32_t i = 0;
while (pText) {
CFX_WideString wsContent;
- if (pText->TryContent(wsContent) && (wsContent == wsValue)) {
+ if (pText->TryContent(wsContent) && (wsContent == wsValue))
return (XFA_CHECKSTATE)i;
- }
+
i++;
pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling);
}
}
return XFA_CHECKSTATE_Off;
}
+
void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState,
FX_BOOL bNotify) {
CXFA_WidgetData exclGroup(GetExclGroupNode());
@@ -1160,34 +388,32 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState,
if (eCheckState != XFA_CHECKSTATE_Off) {
if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items)) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (pText) {
+ if (pText)
pText->TryContent(wsValue);
- }
}
}
CXFA_Node* pChild =
exclGroup.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pChild->GetClassID() != XFA_ELEMENT_Field) {
+ if (pChild->GetClassID() != XFA_ELEMENT_Field)
continue;
- }
+
CXFA_Node* pItem = pChild->GetChild(0, XFA_ELEMENT_Items);
- if (!pItem) {
+ if (!pItem)
continue;
- }
+
CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pItemchild) {
+ if (!pItemchild)
continue;
- }
+
CFX_WideString text = pItemchild->GetContent();
CFX_WideString wsChildValue = text;
if (wsValue != text) {
pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling);
- if (pItemchild) {
+ if (pItemchild)
wsChildValue = pItemchild->GetContent();
- } else {
- wsChildValue.Empty();
- }
+ else
+ wsChildValue.clear();
}
CXFA_WidgetData ch(pChild);
ch.SyncValue(wsChildValue, bNotify);
@@ -1195,9 +421,9 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState,
exclGroup.SyncValue(wsValue, bNotify);
} else {
CXFA_Node* pItems = m_pNode->GetChild(0, XFA_ELEMENT_Items);
- if (!pItems) {
+ if (!pItems)
return;
- }
+
int32_t i = -1;
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
CFX_WideString wsContent;
@@ -1212,19 +438,20 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState,
SyncValue(wsContent, bNotify);
}
}
+
CXFA_Node* CXFA_WidgetData::GetExclGroupNode() {
CXFA_Node* pExcl = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_Parent));
- if (!pExcl || pExcl->GetClassID() != XFA_ELEMENT_ExclGroup) {
+ if (!pExcl || pExcl->GetClassID() != XFA_ELEMENT_ExclGroup)
return NULL;
- }
return pExcl;
}
+
CXFA_Node* CXFA_WidgetData::GetSelectedMember() {
CXFA_Node* pSelectedMember = NULL;
CFX_WideString wsState = GetRawValue();
- if (wsState.IsEmpty()) {
+ if (wsState.IsEmpty())
return pSelectedMember;
- }
+
for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild));
pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
CXFA_WidgetData widgetData(pNode);
@@ -1235,11 +462,11 @@ CXFA_Node* CXFA_WidgetData::GetSelectedMember() {
}
return pSelectedMember;
}
+
CXFA_Node* CXFA_WidgetData::SetSelectedMember(const CFX_WideStringC& wsName,
FX_BOOL bNotify) {
CXFA_Node* pSelectedMember = NULL;
- uint32_t nameHash =
- FX_HashCode_String_GetW(wsName.raw_str(), wsName.GetLength());
+ uint32_t nameHash = FX_HashCode_GetW(wsName, false);
for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild));
pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pNode->GetNameHash() == nameHash) {
@@ -1251,6 +478,7 @@ CXFA_Node* CXFA_WidgetData::SetSelectedMember(const CFX_WideStringC& wsName,
}
return pSelectedMember;
}
+
void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
FX_BOOL bNotify,
FX_BOOL bScriptModify,
@@ -1258,25 +486,24 @@ void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
CFX_WideString wsExclGroup;
for (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pNode->GetClassID() != XFA_ELEMENT_Field) {
+ if (pNode->GetClassID() != XFA_ELEMENT_Field)
continue;
- }
+
CXFA_Node* pItem = pNode->GetChild(0, XFA_ELEMENT_Items);
- if (!pItem) {
+ if (!pItem)
continue;
- }
+
CXFA_Node* pItemchild = pItem->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pItemchild) {
+ if (!pItemchild)
continue;
- }
+
CFX_WideString wsChildValue = pItemchild->GetContent();
if (wsValue != wsChildValue) {
pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling);
- if (pItemchild) {
+ if (pItemchild)
wsChildValue = pItemchild->GetContent();
- } else {
- wsChildValue.Empty();
- }
+ else
+ wsChildValue.clear();
} else {
wsExclGroup = wsValue;
}
@@ -1288,119 +515,119 @@ void CXFA_WidgetData::SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
bSyncData);
}
}
+
CXFA_Node* CXFA_WidgetData::GetExclGroupFirstMember() {
CXFA_Node* pExcl = GetNode();
- if (!pExcl) {
+ if (!pExcl)
return NULL;
- }
+
CXFA_Node* pNode = pExcl->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pNode) {
- if (pNode->GetClassID() == XFA_ELEMENT_Field) {
+ if (pNode->GetClassID() == XFA_ELEMENT_Field)
return pNode;
- }
+
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
return NULL;
}
CXFA_Node* CXFA_WidgetData::GetExclGroupNextMember(CXFA_Node* pNode) {
- if (!pNode) {
+ if (!pNode)
return NULL;
- }
+
CXFA_Node* pNodeField = pNode->GetNodeItem(XFA_NODEITEM_NextSibling);
while (pNodeField) {
- if (pNodeField->GetClassID() == XFA_ELEMENT_Field) {
+ if (pNodeField->GetClassID() == XFA_ELEMENT_Field)
return pNodeField;
- }
+
pNodeField = pNodeField->GetNodeItem(XFA_NODEITEM_NextSibling);
}
return NULL;
}
+
int32_t CXFA_WidgetData::GetChoiceListCommitOn() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetEnum(XFA_ATTRIBUTE_CommitOn);
- }
return XFA_GetAttributeDefaultValue_Enum(
XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_CommitOn, XFA_XDPPACKET_Form);
}
+
FX_BOOL CXFA_WidgetData::IsChoiceListAllowTextEntry() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetBoolean(XFA_ATTRIBUTE_TextEntry);
- }
return XFA_GetAttributeDefaultValue_Boolean(
XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_TextEntry, XFA_XDPPACKET_Form);
}
+
int32_t CXFA_WidgetData::GetChoiceListOpen() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetEnum(XFA_ATTRIBUTE_Open);
- }
return XFA_GetAttributeDefaultValue_Enum(
XFA_ELEMENT_ChoiceList, XFA_ATTRIBUTE_Open, XFA_XDPPACKET_Form);
}
+
FX_BOOL CXFA_WidgetData::IsListBox() {
int32_t iOpenMode = GetChoiceListOpen();
return (iOpenMode == XFA_ATTRIBUTEENUM_Always ||
iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect);
}
+
int32_t CXFA_WidgetData::CountChoiceListItems(FX_BOOL bSaveValue) {
CXFA_NodeArray pItems;
CXFA_Node* pItem = NULL;
int32_t iCount = 0;
CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pNode->GetClassID() != XFA_ELEMENT_Items) {
+ if (pNode->GetClassID() != XFA_ELEMENT_Items)
continue;
- }
+
iCount++;
pItems.Add(pNode);
- if (iCount == 2) {
+ if (iCount == 2)
break;
- }
}
- if (iCount == 0) {
+ if (iCount == 0)
return 0;
- }
+
pItem = pItems[0];
if (iCount > 1) {
FX_BOOL bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save);
FX_BOOL bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save);
- if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) {
+ if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
pItem = pItems[1];
- }
}
pItems.RemoveAll();
return pItem->CountChildren(XFA_ELEMENT_UNKNOWN);
}
+
FX_BOOL CXFA_WidgetData::GetChoiceListItem(CFX_WideString& wsText,
int32_t nIndex,
FX_BOOL bSaveValue) {
- wsText.Empty();
+ wsText.clear();
CXFA_NodeArray pItemsArray;
CXFA_Node* pItems = NULL;
int32_t iCount = 0;
CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pNode->GetClassID() != XFA_ELEMENT_Items) {
+ if (pNode->GetClassID() != XFA_ELEMENT_Items)
continue;
- }
+
iCount++;
pItemsArray.Add(pNode);
- if (iCount == 2) {
+ if (iCount == 2)
break;
- }
}
- if (iCount == 0) {
+ if (iCount == 0)
return FALSE;
- }
+
pItems = pItemsArray[0];
if (iCount > 1) {
FX_BOOL bItemOneHasSave = pItemsArray[0]->GetBoolean(XFA_ATTRIBUTE_Save);
FX_BOOL bItemTwoHasSave = pItemsArray[1]->GetBoolean(XFA_ATTRIBUTE_Save);
- if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) {
+ if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
pItems = pItemsArray[1];
- }
}
if (pItems) {
CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_ELEMENT_UNKNOWN);
@@ -1411,6 +638,7 @@ FX_BOOL CXFA_WidgetData::GetChoiceListItem(CFX_WideString& wsText,
}
return FALSE;
}
+
void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray,
FX_BOOL bSaveValue) {
CXFA_NodeArray pItems;
@@ -1418,38 +646,36 @@ void CXFA_WidgetData::GetChoiceListItems(CFX_WideStringArray& wsTextArray,
int32_t iCount = 0;
CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pNode->GetClassID() != XFA_ELEMENT_Items) {
+ if (pNode->GetClassID() != XFA_ELEMENT_Items)
continue;
- }
+
iCount++;
pItems.Add(pNode);
- if (iCount == 2) {
+ if (iCount == 2)
break;
- }
}
- if (iCount == 0) {
+ if (iCount == 0)
return;
- }
+
pItem = pItems[0];
if (iCount > 1) {
FX_BOOL bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save);
FX_BOOL bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save);
- if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave) {
+ if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
pItem = pItems[1];
- }
}
pItems.RemoveAll();
pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling))
pNode->TryContent(wsTextArray.Add());
- }
}
+
int32_t CXFA_WidgetData::CountSelectedItems() {
CFX_WideStringArray wsValueArray;
GetSelectedItemsValue(wsValueArray);
- if (IsListBox() || !IsChoiceListAllowTextEntry()) {
+ if (IsListBox() || !IsChoiceListAllowTextEntry())
return wsValueArray.GetSize();
- }
+
int32_t iSelected = 0;
CFX_WideStringArray wsSaveTextArray;
GetChoiceListItems(wsSaveTextArray, TRUE);
@@ -1465,6 +691,7 @@ int32_t CXFA_WidgetData::CountSelectedItems() {
}
return iSelected;
}
+
int32_t CXFA_WidgetData::GetSelectedItem(int32_t nIndex) {
CFX_WideStringArray wsValueArray;
GetSelectedItemsValue(wsValueArray);
@@ -1472,19 +699,19 @@ int32_t CXFA_WidgetData::GetSelectedItem(int32_t nIndex) {
GetChoiceListItems(wsSaveTextArray, TRUE);
int32_t iSaves = wsSaveTextArray.GetSize();
for (int32_t j = 0; j < iSaves; j++) {
- if (wsValueArray[nIndex] == wsSaveTextArray[j]) {
+ if (wsValueArray[nIndex] == wsSaveTextArray[j])
return j;
- }
}
return -1;
}
+
void CXFA_WidgetData::GetSelectedItems(CFX_Int32Array& iSelArray) {
CFX_WideStringArray wsValueArray;
GetSelectedItemsValue(wsValueArray);
int32_t iValues = wsValueArray.GetSize();
- if (iValues < 1) {
+ if (iValues < 1)
return;
- }
+
CFX_WideStringArray wsSaveTextArray;
GetChoiceListItems(wsSaveTextArray, TRUE);
int32_t iSaves = wsSaveTextArray.GetSize();
@@ -1497,6 +724,7 @@ void CXFA_WidgetData::GetSelectedItems(CFX_Int32Array& iSelArray) {
}
}
}
+
void CXFA_WidgetData::GetSelectedItemsValue(
CFX_WideStringArray& wsSelTextArray) {
CFX_WideString wsValue = GetRawValue();
@@ -1509,51 +737,51 @@ void CXFA_WidgetData::GetSelectedItemsValue(
while (iEnd >= iStart) {
wsSelTextArray.Add(wsValue.Mid(iStart, iEnd - iStart));
iStart = iEnd + 1;
- if (iStart >= iLength) {
+ if (iStart >= iLength)
break;
- }
+
iEnd = wsValue.Find(L'\n', iStart);
- if (iEnd < 0) {
+ if (iEnd < 0)
wsSelTextArray.Add(wsValue.Mid(iStart, iLength - iStart));
- }
}
}
} else {
wsSelTextArray.Add(wsValue);
}
}
+
FX_BOOL CXFA_WidgetData::GetItemState(int32_t nIndex) {
- if (nIndex < 0) {
+ if (nIndex < 0)
return FALSE;
- }
+
CFX_WideStringArray wsSaveTextArray;
GetChoiceListItems(wsSaveTextArray, TRUE);
- if (wsSaveTextArray.GetSize() <= nIndex) {
+ if (wsSaveTextArray.GetSize() <= nIndex)
return FALSE;
- }
+
CFX_WideStringArray wsValueArray;
GetSelectedItemsValue(wsValueArray);
int32_t iValues = wsValueArray.GetSize();
for (int32_t j = 0; j < iValues; j++) {
- if (wsValueArray[j] == wsSaveTextArray[nIndex]) {
+ if (wsValueArray[j] == wsSaveTextArray[nIndex])
return TRUE;
- }
}
return FALSE;
}
+
void CXFA_WidgetData::SetItemState(int32_t nIndex,
FX_BOOL bSelected,
FX_BOOL bNotify,
FX_BOOL bScriptModify,
FX_BOOL bSyncData) {
- if (nIndex < 0) {
+ if (nIndex < 0)
return;
- }
+
CFX_WideStringArray wsSaveTextArray;
GetChoiceListItems(wsSaveTextArray, TRUE);
- if (wsSaveTextArray.GetSize() <= nIndex) {
+ if (wsSaveTextArray.GetSize() <= nIndex)
return;
- }
+
int32_t iSel = -1;
CFX_WideStringArray wsValueArray;
GetSelectedItemsValue(wsValueArray);
@@ -1584,14 +812,14 @@ void CXFA_WidgetData::SetItemState(int32_t nIndex,
break;
}
}
- SetSelectdItems(iSelArray, bNotify, bScriptModify, bSyncData);
+ SetSelectedItems(iSelArray, bNotify, bScriptModify, bSyncData);
}
} else {
if (bSelected) {
if (iSel < 0) {
CFX_WideString wsSaveText = wsSaveTextArray[nIndex];
CFX_WideString wsFormatText(wsSaveText);
- GetFormatDataValue(wsSaveText.AsWideStringC(), wsFormatText);
+ GetFormatDataValue(wsSaveText, wsFormatText);
m_pNode->SetContent(wsSaveText, wsFormatText, bNotify, bScriptModify,
bSyncData);
}
@@ -1601,10 +829,11 @@ void CXFA_WidgetData::SetItemState(int32_t nIndex,
}
}
}
-void CXFA_WidgetData::SetSelectdItems(CFX_Int32Array& iSelArray,
- FX_BOOL bNotify,
- FX_BOOL bScriptModify,
- FX_BOOL bSyncData) {
+
+void CXFA_WidgetData::SetSelectedItems(CFX_Int32Array& iSelArray,
+ FX_BOOL bNotify,
+ FX_BOOL bScriptModify,
+ FX_BOOL bSyncData) {
CFX_WideString wsValue;
int32_t iSize = iSelArray.GetSize();
if (iSize >= 1) {
@@ -1619,11 +848,12 @@ void CXFA_WidgetData::SetSelectdItems(CFX_Int32Array& iSelArray,
}
}
CFX_WideString wsFormat(wsValue);
- if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect) {
- GetFormatDataValue(wsValue.AsWideStringC(), wsFormat);
- }
+ if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect)
+ GetFormatDataValue(wsValue, wsFormat);
+
m_pNode->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData);
}
+
void CXFA_WidgetData::ClearAllSelections() {
CXFA_Node* pBind = m_pNode->GetBindData();
if (pBind && GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
@@ -1635,42 +865,42 @@ void CXFA_WidgetData::ClearAllSelections() {
SyncValue(CFX_WideString(), FALSE);
}
}
+
void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
const CFX_WideString& wsValue,
int32_t nIndex,
FX_BOOL bNotify) {
CFX_WideString wsNewValue(wsValue);
- if (wsNewValue.IsEmpty()) {
+ if (wsNewValue.IsEmpty())
wsNewValue = wsLabel;
- }
+
CXFA_NodeArray listitems;
int32_t iCount = 0;
CXFA_Node* pItemNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pItemNode;
pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pItemNode->GetClassID() != XFA_ELEMENT_Items) {
+ if (pItemNode->GetClassID() != XFA_ELEMENT_Items)
continue;
- }
+
listitems.Add(pItemNode);
iCount++;
}
if (iCount < 1) {
CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items);
m_pNode->InsertChild(-1, pItems);
- InsertListTextItem(pItems, wsLabel.AsWideStringC(), nIndex);
+ InsertListTextItem(pItems, wsLabel, nIndex);
CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_ELEMENT_Items);
m_pNode->InsertChild(-1, pSaveItems);
pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, TRUE);
- InsertListTextItem(pSaveItems, wsNewValue.AsWideStringC(), nIndex);
+ InsertListTextItem(pSaveItems, wsNewValue, nIndex);
} else if (iCount > 1) {
for (int32_t i = 0; i < 2; i++) {
CXFA_Node* pNode = listitems[i];
FX_BOOL bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save);
- if (bHasSave) {
- InsertListTextItem(pNode, wsNewValue.AsWideStringC(), nIndex);
- } else {
- InsertListTextItem(pNode, wsLabel.AsWideStringC(), nIndex);
- }
+ if (bHasSave)
+ InsertListTextItem(pNode, wsNewValue, nIndex);
+ else
+ InsertListTextItem(pNode, wsLabel, nIndex);
}
} else {
CXFA_Node* pNode = listitems[0];
@@ -1686,29 +916,29 @@ void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
while (pListNode) {
CFX_WideString wsOldValue;
pListNode->TryContent(wsOldValue);
- InsertListTextItem(pSaveItems, wsOldValue.AsWideStringC(), i);
+ InsertListTextItem(pSaveItems, wsOldValue, i);
i++;
pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
- InsertListTextItem(pNode, wsLabel.AsWideStringC(), nIndex);
- InsertListTextItem(pSaveItems, wsNewValue.AsWideStringC(), nIndex);
+ InsertListTextItem(pNode, wsLabel, nIndex);
+ InsertListTextItem(pSaveItems, wsNewValue, nIndex);
}
- if (!bNotify) {
+ if (!bNotify)
return;
- }
- m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent(
- this, XFA_WIDGETEVENT_ListItemAdded, (void*)(const FX_WCHAR*)wsLabel,
- (void*)(const FX_WCHAR*)wsValue, (void*)(uintptr_t)nIndex);
+
+ m_pNode->GetDocument()->GetNotify()->OnWidgetListItemAdded(
+ this, wsLabel.c_str(), wsValue.c_str(), nIndex);
}
+
void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue,
CFX_WideString& wsLabel) {
int32_t iCount = 0;
CXFA_NodeArray listitems;
CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pItems->GetClassID() != XFA_ELEMENT_Items) {
+ if (pItems->GetClassID() != XFA_ELEMENT_Items)
continue;
- }
+
iCount++;
listitems.Add(pItems);
}
@@ -1737,24 +967,24 @@ void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue,
}
iCount++;
}
- if (iSearch < 0) {
+ if (iSearch < 0)
return;
- }
if (CXFA_Node* pText =
pLabelItems->GetChild(iSearch, XFA_ELEMENT_UNKNOWN)) {
pText->TryContent(wsLabel);
}
}
}
+
void CXFA_WidgetData::GetItemValue(const CFX_WideStringC& wsLabel,
CFX_WideString& wsValue) {
int32_t iCount = 0;
CXFA_NodeArray listitems;
CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pItems->GetClassID() != XFA_ELEMENT_Items) {
+ if (pItems->GetClassID() != XFA_ELEMENT_Items)
continue;
- }
+
iCount++;
listitems.Add(pItems);
}
@@ -1783,14 +1013,13 @@ void CXFA_WidgetData::GetItemValue(const CFX_WideStringC& wsLabel,
}
iCount++;
}
- if (iSearch < 0) {
+ if (iSearch < 0)
return;
- }
- if (CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_ELEMENT_UNKNOWN)) {
+ if (CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_ELEMENT_UNKNOWN))
pText->TryContent(wsValue);
- }
}
}
+
FX_BOOL CXFA_WidgetData::DeleteItem(int32_t nIndex,
FX_BOOL bNotify,
FX_BOOL bScriptModify,
@@ -1798,9 +1027,9 @@ FX_BOOL CXFA_WidgetData::DeleteItem(int32_t nIndex,
FX_BOOL bSetValue = FALSE;
CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pItems->GetClassID() != XFA_ELEMENT_Items) {
+ if (pItems->GetClassID() != XFA_ELEMENT_Items)
continue;
- }
+
if (nIndex < 0) {
while (CXFA_Node* pNode = pItems->GetNodeItem(XFA_NODEITEM_FirstChild)) {
pItems->RemoveChild(pNode);
@@ -1822,34 +1051,33 @@ FX_BOOL CXFA_WidgetData::DeleteItem(int32_t nIndex,
}
}
}
- if (!bNotify) {
- return TRUE;
- }
- m_pNode->GetDocument()->GetNotify()->OnWidgetDataEvent(
- this, XFA_WIDGETEVENT_ListItemRemoved, (void*)(uintptr_t)nIndex);
+ if (bNotify)
+ m_pNode->GetDocument()->GetNotify()->OnWidgetListItemRemoved(this, nIndex);
return TRUE;
}
+
int32_t CXFA_WidgetData::GetHorizontalScrollPolicy() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetEnum(XFA_ATTRIBUTE_HScrollPolicy);
- }
return XFA_ATTRIBUTEENUM_Auto;
}
+
int32_t CXFA_WidgetData::GetNumberOfCells() {
CXFA_Node* pUIChild = GetUIChild();
- if (!pUIChild) {
+ if (!pUIChild)
return -1;
- }
- if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_ELEMENT_Comb)) {
+ if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_ELEMENT_Comb))
return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells);
- }
return -1;
}
+
CFX_WideString CXFA_WidgetData::GetBarcodeType() {
CXFA_Node* pUIChild = GetUIChild();
- return pUIChild ? pUIChild->GetCData(XFA_ATTRIBUTE_Type) : NULL;
+ return pUIChild ? CFX_WideString(pUIChild->GetCData(XFA_ATTRIBUTE_Type))
+ : nullptr;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) {
CXFA_Node* pUIChild = GetUIChild();
CFX_WideString wsCharEncoding;
@@ -1857,13 +1085,15 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t& val) {
if (wsCharEncoding.CompareNoCase(L"UTF-16")) {
val = CHAR_ENCODING_UNICODE;
return TRUE;
- } else if (wsCharEncoding.CompareNoCase(L"UTF-8")) {
+ }
+ if (wsCharEncoding.CompareNoCase(L"UTF-8")) {
val = CHAR_ENCODING_UTF8;
return TRUE;
}
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(int32_t& val) {
CXFA_Node* pUIChild = GetUIChild();
XFA_ATTRIBUTEENUM eChecksum;
@@ -1887,15 +1117,17 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Checksum(int32_t& val) {
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t& val) {
CXFA_Node* pUIChild = GetUIChild();
CFX_WideString wsDataLength;
if (pUIChild->TryCData(XFA_ATTRIBUTE_DataLength, wsDataLength)) {
- val = FXSYS_wtoi(wsDataLength);
+ val = FXSYS_wtoi(wsDataLength.c_str());
return TRUE;
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_StartChar(FX_CHAR& val) {
CXFA_Node* pUIChild = GetUIChild();
CFX_WideStringC wsStartEndChar;
@@ -1907,6 +1139,7 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_StartChar(FX_CHAR& val) {
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_EndChar(FX_CHAR& val) {
CXFA_Node* pUIChild = GetUIChild();
CFX_WideStringC wsStartEndChar;
@@ -1918,15 +1151,17 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_EndChar(FX_CHAR& val) {
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ECLevel(int32_t& val) {
CXFA_Node* pUIChild = GetUIChild();
CFX_WideString wsECLevel;
if (pUIChild->TryCData(XFA_ATTRIBUTE_ErrorCorrectionLevel, wsECLevel)) {
- val = FXSYS_wtoi(wsECLevel);
+ val = FXSYS_wtoi(wsECLevel.c_str());
return TRUE;
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t& val) {
CXFA_Node* pUIChild = GetUIChild();
CXFA_Measurement mModuleWidthHeight;
@@ -1936,6 +1171,7 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t& val) {
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t& val) {
CXFA_Node* pUIChild = GetUIChild();
CXFA_Measurement mModuleWidthHeight;
@@ -1945,6 +1181,7 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t& val) {
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(FX_BOOL& val) {
CXFA_Node* pUIChild = GetUIChild();
FX_BOOL bPrintCheckDigit;
@@ -1954,6 +1191,7 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(FX_BOOL& val) {
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t& val) {
CXFA_Node* pUIChild = GetUIChild();
XFA_ATTRIBUTEENUM eTextLocation;
@@ -1980,6 +1218,7 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t& val) {
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Truncate(FX_BOOL& val) {
CXFA_Node* pUIChild = GetUIChild();
FX_BOOL bTruncate;
@@ -1989,6 +1228,7 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_Truncate(FX_BOOL& val) {
}
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val) {
CXFA_Node* pUIChild = GetUIChild();
CFX_WideString wsWideNarrowRatio;
@@ -1996,20 +1236,20 @@ FX_BOOL CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val) {
FX_STRSIZE ptPos = wsWideNarrowRatio.Find(':');
FX_FLOAT fRatio = 0;
if (ptPos >= 0) {
- fRatio = (FX_FLOAT)FXSYS_wtoi(wsWideNarrowRatio);
+ fRatio = (FX_FLOAT)FXSYS_wtoi(wsWideNarrowRatio.c_str());
} else {
int32_t fA, fB;
- fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos));
- fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1));
- if (fB) {
+ fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos).c_str());
+ fB = FXSYS_wtoi(wsWideNarrowRatio.Mid(ptPos + 1).c_str());
+ if (fB)
fRatio = (FX_FLOAT)fA / fB;
- }
}
val = fRatio;
return TRUE;
}
return FALSE;
}
+
void CXFA_WidgetData::GetPasswordChar(CFX_WideString& wsPassWord) {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild) {
@@ -2020,22 +1260,23 @@ void CXFA_WidgetData::GetPasswordChar(CFX_WideString& wsPassWord) {
XFA_XDPPACKET_Form);
}
}
+
FX_BOOL CXFA_WidgetData::IsMultiLine() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetBoolean(XFA_ATTRIBUTE_MultiLine);
- }
return XFA_GetAttributeDefaultValue_Boolean(
XFA_ELEMENT_TextEdit, XFA_ATTRIBUTE_MultiLine, XFA_XDPPACKET_Form);
}
+
int32_t CXFA_WidgetData::GetVerticalScrollPolicy() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
return pUIChild->GetEnum(XFA_ATTRIBUTE_VScrollPolicy);
- }
return XFA_GetAttributeDefaultValue_Enum(
XFA_ELEMENT_TextEdit, XFA_ATTRIBUTE_VScrollPolicy, XFA_XDPPACKET_Form);
}
+
int32_t CXFA_WidgetData::GetMaxChars(XFA_ELEMENT& eType) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) {
if (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) {
@@ -2055,68 +1296,25 @@ int32_t CXFA_WidgetData::GetMaxChars(XFA_ELEMENT& eType) {
}
return 0;
}
+
FX_BOOL CXFA_WidgetData::GetFracDigits(int32_t& iFracDigits) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) {
- if (CXFA_Node* pChild = pNode->GetChild(0, XFA_ELEMENT_Decimal)) {
+ if (CXFA_Node* pChild = pNode->GetChild(0, XFA_ELEMENT_Decimal))
return pChild->TryInteger(XFA_ATTRIBUTE_FracDigits, iFracDigits);
- }
}
iFracDigits = -1;
return FALSE;
}
+
FX_BOOL CXFA_WidgetData::GetLeadDigits(int32_t& iLeadDigits) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Value)) {
- if (CXFA_Node* pChild = pNode->GetChild(0, XFA_ELEMENT_Decimal)) {
+ if (CXFA_Node* pChild = pNode->GetChild(0, XFA_ELEMENT_Decimal))
return pChild->TryInteger(XFA_ATTRIBUTE_LeadDigits, iLeadDigits);
- }
}
iLeadDigits = -1;
return FALSE;
}
-CFX_WideString XFA_NumericLimit(const CFX_WideString& wsValue,
- int32_t iLead,
- int32_t iTread) {
- if ((iLead == -1) && (iTread == -1)) {
- return wsValue;
- }
- CFX_WideString wsRet;
- int32_t iLead_ = 0, iTread_ = -1;
- int32_t iCount = wsValue.GetLength();
- if (iCount == 0) {
- return wsValue;
- }
- int32_t i = 0;
- if (wsValue[i] == L'-') {
- wsRet += L'-';
- i++;
- }
- for (; i < iCount; i++) {
- FX_WCHAR wc = wsValue[i];
- if (XFA_IsDigit(wc)) {
- if (iLead >= 0) {
- iLead_++;
- if (iLead_ > iLead) {
- return L"0";
- }
- } else if (iTread_ >= 0) {
- iTread_++;
- if (iTread_ > iTread) {
- if (iTread != -1) {
- CFX_Decimal wsDeci = CFX_Decimal(wsValue.AsWideStringC());
- wsDeci.SetScale(iTread);
- wsRet = wsDeci;
- }
- return wsRet;
- }
- }
- } else if (wc == L'.') {
- iTread_ = 0;
- iLead = -1;
- }
- wsRet += wc;
- }
- return wsRet;
-}
+
FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue,
XFA_VALUEPICTURE eValueType) {
if (wsValue.IsEmpty()) {
@@ -2131,9 +1329,9 @@ FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue,
FX_BOOL bValidate = TRUE;
FX_BOOL bSyncData = FALSE;
CXFA_Node* pNode = GetUIChild();
- if (!pNode) {
+ if (!pNode)
return TRUE;
- }
+
XFA_ELEMENT uiType = pNode->GetClassID();
if (!wsPicture.IsEmpty()) {
CXFA_LocaleMgr* pLocalMgr = m_pNode->GetDocument()->GetLocalMgr();
@@ -2150,7 +1348,7 @@ FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue,
int32_t iFracDigits = 0;
GetLeadDigits(iLeadDigits);
GetFracDigits(iFracDigits);
- wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits);
+ wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits);
}
bSyncData = TRUE;
}
@@ -2161,36 +1359,36 @@ FX_BOOL CXFA_WidgetData::SetValue(const CFX_WideString& wsValue,
int32_t iFracDigits = 0;
GetLeadDigits(iLeadDigits);
GetFracDigits(iFracDigits);
- wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits);
+ wsNewText = NumericLimit(wsNewText, iLeadDigits, iFracDigits);
}
bSyncData = TRUE;
}
}
- if (uiType != XFA_ELEMENT_NumericEdit || bSyncData) {
+ if (uiType != XFA_ELEMENT_NumericEdit || bSyncData)
SyncValue(wsNewText, TRUE);
- }
+
return bValidate;
}
+
FX_BOOL CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture,
XFA_VALUEPICTURE ePicture) {
- if (ePicture == XFA_VALUEPICTURE_Raw) {
+ if (ePicture == XFA_VALUEPICTURE_Raw)
return FALSE;
- }
+
CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
switch (ePicture) {
case XFA_VALUEPICTURE_Display: {
if (CXFA_Node* pFormat = m_pNode->GetChild(0, XFA_ELEMENT_Format)) {
if (CXFA_Node* pPicture = pFormat->GetChild(0, XFA_ELEMENT_Picture)) {
- if (pPicture->TryContent(wsPicture)) {
+ if (pPicture->TryContent(wsPicture))
return TRUE;
- }
}
}
CFX_WideString wsDataPicture, wsTimePicture;
IFX_Locale* pLocale = GetLocal();
- if (!pLocale) {
+ if (!pLocale)
return FALSE;
- }
+
uint32_t dwType = widgetValue.GetType();
switch (dwType) {
case XFA_VT_DATE:
@@ -2214,15 +1412,15 @@ FX_BOOL CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture,
default:
break;
}
- }
return TRUE;
+ }
+
case XFA_VALUEPICTURE_Edit: {
CXFA_Node* pUI = m_pNode->GetChild(0, XFA_ELEMENT_Ui);
if (pUI) {
if (CXFA_Node* pPicture = pUI->GetChild(0, XFA_ELEMENT_Picture)) {
- if (pPicture->TryContent(wsPicture)) {
+ if (pPicture->TryContent(wsPicture))
return TRUE;
- }
}
}
{
@@ -2252,24 +1450,26 @@ FX_BOOL CXFA_WidgetData::GetPictureContent(CFX_WideString& wsPicture,
break;
}
}
- }
return TRUE;
+ }
case XFA_VALUEPICTURE_DataBind: {
if (CXFA_Bind bind = GetBind()) {
bind.GetPicture(wsPicture);
return TRUE;
}
- } break;
+ break;
+ }
default:
break;
}
return FALSE;
}
+
IFX_Locale* CXFA_WidgetData::GetLocal() {
IFX_Locale* pLocale = NULL;
- if (!m_pNode) {
+ if (!m_pNode)
return pLocale;
- }
+
FX_BOOL bLocale = FALSE;
CFX_WideString wsLocaleName;
bLocale = m_pNode->GetLocaleName(wsLocaleName);
@@ -2277,63 +1477,19 @@ IFX_Locale* CXFA_WidgetData::GetLocal() {
if (wsLocaleName == FX_WSTRC(L"ambient")) {
pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale();
} else {
- pLocale = m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(
- wsLocaleName.AsWideStringC());
+ pLocale =
+ m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName);
}
}
return pLocale;
}
-static FX_BOOL XFA_SplitDateTime(const CFX_WideString& wsDateTime,
- CFX_WideString& wsDate,
- CFX_WideString& wsTime) {
- wsDate = L"";
- wsTime = L"";
- if (wsDateTime.IsEmpty()) {
- return FALSE;
- }
- int nSplitIndex = -1;
- nSplitIndex = wsDateTime.Find('T');
- if (nSplitIndex < 0) {
- nSplitIndex = wsDateTime.Find(' ');
- }
- if (nSplitIndex < 0) {
- return FALSE;
- }
- wsDate = wsDateTime.Left(nSplitIndex);
- if (!wsDate.IsEmpty()) {
- int32_t iCount = wsDate.GetLength();
- int32_t i = 0;
- for (i = 0; i < iCount; i++) {
- if (wsDate[i] >= '0' && wsDate[i] <= '9') {
- break;
- }
- }
- if (i == iCount) {
- return FALSE;
- }
- }
- wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1);
- if (!wsTime.IsEmpty()) {
- int32_t iCount = wsTime.GetLength();
- int32_t i = 0;
- for (i = 0; i < iCount; i++) {
- if (wsTime[i] >= '0' && wsTime[i] <= '9') {
- break;
- }
- }
- if (i == iCount) {
- return FALSE;
- }
- }
- return TRUE;
-}
FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue,
XFA_VALUEPICTURE eValueType) {
wsValue = m_pNode->GetContent();
if (eValueType == XFA_VALUEPICTURE_Display)
- GetItemLabel(wsValue.AsWideStringC(), wsValue);
+ GetItemLabel(wsValue.AsStringC(), wsValue);
CFX_WideString wsPicture;
GetPictureContent(wsPicture, eValueType);
@@ -2348,7 +1504,7 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue,
int32_t iSelItemIndex = GetSelectedItem(0);
if (iSelItemIndex >= 0) {
GetChoiceListItem(wsValue, iSelItemIndex);
- wsPicture.Empty();
+ wsPicture.clear();
}
}
} break;
@@ -2375,7 +1531,7 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue,
switch (widgetValue.GetType()) {
case XFA_VT_DATE: {
CFX_WideString wsDate, wsTime;
- if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) {
+ if (SplitDateTime(wsValue, wsDate, wsTime)) {
CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr);
if (date.FormatPatterns(wsValue, wsPicture, pLocale, eValueType))
return TRUE;
@@ -2384,7 +1540,7 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue,
}
case XFA_VT_TIME: {
CFX_WideString wsDate, wsTime;
- if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) {
+ if (SplitDateTime(wsValue, wsDate, wsTime)) {
CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr);
if (time.FormatPatterns(wsValue, wsPicture, pLocale, eValueType))
return TRUE;
@@ -2400,18 +1556,18 @@ FX_BOOL CXFA_WidgetData::GetValue(CFX_WideString& wsValue,
}
FX_BOOL CXFA_WidgetData::GetNormalizeDataValue(
- const CFX_WideStringC& wsValue,
+ const CFX_WideString& wsValue,
CFX_WideString& wsNormalizeValue) {
wsNormalizeValue = wsValue;
- if (wsValue.IsEmpty()) {
+ if (wsValue.IsEmpty())
return TRUE;
- }
+
CFX_WideString wsPicture;
GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind);
- if (wsPicture.IsEmpty()) {
+ if (wsPicture.IsEmpty())
return TRUE;
- }
- FXSYS_assert(GetNode());
+
+ ASSERT(GetNode());
CXFA_LocaleMgr* pLocalMgr = GetNode()->GetDocument()->GetLocalMgr();
IFX_Locale* pLocale = GetLocal();
CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(this);
@@ -2423,27 +1579,28 @@ FX_BOOL CXFA_WidgetData::GetNormalizeDataValue(
}
return FALSE;
}
-FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideStringC& wsValue,
+
+FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideString& wsValue,
CFX_WideString& wsFormatedValue) {
wsFormatedValue = wsValue;
- if (wsValue.IsEmpty()) {
+ if (wsValue.IsEmpty())
return TRUE;
- }
+
CFX_WideString wsPicture;
GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind);
- if (wsPicture.IsEmpty()) {
+ if (wsPicture.IsEmpty())
return TRUE;
- }
+
if (IFX_Locale* pLocale = GetLocal()) {
- FXSYS_assert(GetNode());
+ ASSERT(GetNode());
CXFA_Node* pNodeValue = GetNode()->GetChild(0, XFA_ELEMENT_Value);
- if (!pNodeValue) {
+ if (!pNodeValue)
return FALSE;
- }
+
CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pValueChild) {
+ if (!pValueChild)
return FALSE;
- }
+
int32_t iVTType = XFA_VT_NULL;
XFA_ELEMENT eType = pValueChild->GetClassID();
switch (eType) {
@@ -2480,7 +1637,7 @@ FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideStringC& wsValue,
switch (widgetValue.GetType()) {
case XFA_VT_DATE: {
CFX_WideString wsDate, wsTime;
- if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) {
+ if (SplitDateTime(wsValue, wsDate, wsTime)) {
CXFA_LocaleValue date(XFA_VT_DATE, wsDate, pLocalMgr);
if (date.FormatPatterns(wsFormatedValue, wsPicture, pLocale,
XFA_VALUEPICTURE_DataBind)) {
@@ -2491,7 +1648,7 @@ FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideStringC& wsValue,
}
case XFA_VT_TIME: {
CFX_WideString wsDate, wsTime;
- if (XFA_SplitDateTime(wsValue, wsDate, wsTime)) {
+ if (SplitDateTime(wsValue, wsDate, wsTime)) {
CXFA_LocaleValue time(XFA_VT_TIME, wsTime, pLocalMgr);
if (time.FormatPatterns(wsFormatedValue, wsPicture, pLocale,
XFA_VALUEPICTURE_DataBind)) {
@@ -2508,11 +1665,12 @@ FX_BOOL CXFA_WidgetData::GetFormatDataValue(const CFX_WideStringC& wsValue,
}
return FALSE;
}
+
void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue,
CFX_WideString& wsOutput) {
- if (wsValue.IsEmpty()) {
+ if (wsValue.IsEmpty())
return;
- }
+
wsOutput = wsValue;
wsOutput.TrimLeft('0');
int32_t dot_index = wsOutput.Find('.');
@@ -2522,16 +1680,16 @@ void CXFA_WidgetData::NormalizeNumStr(const CFX_WideString& wsValue,
wsOutput.TrimRight(L"0");
wsOutput.TrimRight(L".");
}
- if (wsOutput.IsEmpty() || wsOutput[0] == '.') {
+ if (wsOutput.IsEmpty() || wsOutput[0] == '.')
wsOutput.Insert(0, '0');
- }
}
+
void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
IFX_Locale* pLocale,
CFX_WideString& wsOutput) {
- if (wsValue.IsEmpty()) {
+ if (wsValue.IsEmpty())
return;
- }
+
CFX_WideString wsSrcNum = wsValue;
CFX_WideString wsGroupSymbol;
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol);
@@ -2542,17 +1700,17 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
}
int32_t len = wsSrcNum.GetLength();
int32_t dot_index = wsSrcNum.Find('.');
- if (dot_index == -1) {
+ if (dot_index == -1)
dot_index = len;
- }
+
int32_t cc = dot_index - 1;
if (cc >= 0) {
int nPos = dot_index % 3;
- wsOutput.Empty();
+ wsOutput.clear();
for (int32_t i = 0; i < dot_index; i++) {
- if (i % 3 == nPos && i != 0) {
+ if (i % 3 == nPos && i != 0)
wsOutput += wsGroupSymbol;
- }
+
wsOutput += wsSrcNum[i];
}
if (dot_index < len) {
@@ -2568,92 +1726,68 @@ void CXFA_WidgetData::FormatNumStr(const CFX_WideString& wsValue,
}
}
}
+
void CXFA_WidgetData::SyncValue(const CFX_WideString& wsValue,
FX_BOOL bNotify) {
- if (!m_pNode) {
+ if (!m_pNode)
return;
- }
+
CFX_WideString wsFormatValue(wsValue);
CXFA_WidgetData* pContainerWidgetData = m_pNode->GetContainerWidgetData();
- if (pContainerWidgetData) {
- pContainerWidgetData->GetFormatDataValue(wsValue.AsWideStringC(),
- wsFormatValue);
- }
+ if (pContainerWidgetData)
+ pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue);
+
m_pNode->SetContent(wsValue, wsFormatValue, bNotify);
}
+
void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems,
- const CFX_WideStringC& wsText,
+ const CFX_WideString& wsText,
int32_t nIndex) {
CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_ELEMENT_Text);
pItems->InsertChild(nIndex, pText);
pText->SetContent(wsText, wsText, FALSE, FALSE, FALSE);
}
-CXFA_Occur::CXFA_Occur(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-int32_t CXFA_Occur::GetMax() {
- int32_t iMax = 1;
- if (m_pNode) {
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, TRUE)) {
- iMax = GetMin();
- }
- }
- return iMax;
-}
-int32_t CXFA_Occur::GetMin() {
- int32_t iMin = 1;
- if (m_pNode) {
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, TRUE) || iMin < 0) {
- iMin = 1;
- }
- }
- return iMin;
-}
-FX_BOOL CXFA_Occur::GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit) {
- if (!m_pNode) {
- return FALSE;
- }
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, FALSE) || iMin < 0) {
- iMin = 1;
- }
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, FALSE)) {
- if (iMin == 0) {
- iMax = 1;
- } else {
- iMax = iMin;
- }
- }
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, FALSE) ||
- iInit < iMin) {
- iInit = iMin;
+
+CFX_WideString CXFA_WidgetData::NumericLimit(const CFX_WideString& wsValue,
+ int32_t iLead,
+ int32_t iTread) const {
+ if ((iLead == -1) && (iTread == -1))
+ return wsValue;
+
+ CFX_WideString wsRet;
+ int32_t iLead_ = 0, iTread_ = -1;
+ int32_t iCount = wsValue.GetLength();
+ if (iCount == 0)
+ return wsValue;
+
+ int32_t i = 0;
+ if (wsValue[i] == L'-') {
+ wsRet += L'-';
+ i++;
}
- return TRUE;
-}
-void CXFA_Occur::SetMax(int32_t iMax) {
- iMax = (iMax != -1 && iMax < 1) ? 1 : iMax;
- m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE);
- int32_t iMin = GetMin();
- if (iMax != -1 && iMax < iMin) {
- iMin = iMax;
- m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE);
- }
-}
-void CXFA_Occur::SetMin(int32_t iMin) {
- iMin = (iMin < 0) ? 1 : iMin;
- m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, FALSE);
- int32_t iMax = GetMax();
- if (iMax > 0 && iMax < iMin) {
- iMax = iMin;
- m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, FALSE);
- }
-}
-XFA_ATTRIBUTEENUM XFA_GetEnumTypeAttribute(
- CXFA_Node* pNode,
- XFA_ATTRIBUTE attributeValue = XFA_ATTRIBUTE_Type,
- XFA_ATTRIBUTEENUM eDefaultValue = XFA_ATTRIBUTEENUM_Optional) {
- XFA_ATTRIBUTEENUM eType = eDefaultValue;
- if (pNode) {
- if (!pNode->TryEnum(attributeValue, eType, TRUE)) {
- eType = eDefaultValue;
+ for (; i < iCount; i++) {
+ FX_WCHAR wc = wsValue[i];
+ if (XFA_IsDigit(wc)) {
+ if (iLead >= 0) {
+ iLead_++;
+ if (iLead_ > iLead)
+ return L"0";
+ } else if (iTread_ >= 0) {
+ iTread_++;
+ if (iTread_ > iTread) {
+ if (iTread != -1) {
+ CFX_Decimal wsDeci = CFX_Decimal(wsValue.AsStringC());
+ wsDeci.SetScale(iTread);
+ wsRet = wsDeci;
+ }
+ return wsRet;
+ }
+ }
+ } else if (wc == L'.') {
+ iTread_ = 0;
+ iLead = -1;
}
+ wsRet += wc;
}
- return eType;
+ return wsRet;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_widgetdata.h b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_widgetdata.h
new file mode 100644
index 00000000000..c0d06e353c1
--- /dev/null
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -0,0 +1,181 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FXFA_PARSER_CXFA_WIDGETDATA_H_
+#define XFA_FXFA_PARSER_CXFA_WIDGETDATA_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_assist.h"
+#include "xfa/fxfa/parser/cxfa_bind.h"
+#include "xfa/fxfa/parser/cxfa_border.h"
+#include "xfa/fxfa/parser/cxfa_calculate.h"
+#include "xfa/fxfa/parser/cxfa_caption.h"
+#include "xfa/fxfa/parser/cxfa_data.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
+#include "xfa/fxfa/parser/cxfa_para.h"
+#include "xfa/fxfa/parser/cxfa_validate.h"
+#include "xfa/fxfa/parser/xfa_object.h"
+
+enum XFA_CHECKSTATE {
+ XFA_CHECKSTATE_On = 0,
+ XFA_CHECKSTATE_Off = 1,
+ XFA_CHECKSTATE_Neutral = 2,
+};
+
+enum XFA_VALUEPICTURE {
+ XFA_VALUEPICTURE_Raw = 0,
+ XFA_VALUEPICTURE_Display,
+ XFA_VALUEPICTURE_Edit,
+ XFA_VALUEPICTURE_DataBind,
+};
+
+class CXFA_Node;
+class IFX_Locale;
+
+class CXFA_WidgetData : public CXFA_Data {
+ public:
+ explicit CXFA_WidgetData(CXFA_Node* pNode);
+
+ CXFA_Node* GetUIChild();
+ XFA_ELEMENT GetUIType();
+ CFX_WideString GetRawValue();
+ int32_t GetAccess(FX_BOOL bTemplate = FALSE);
+ int32_t GetRotate();
+ CXFA_Border GetBorder(FX_BOOL bModified = FALSE);
+ CXFA_Caption GetCaption(FX_BOOL bModified = FALSE);
+ CXFA_Font GetFont(FX_BOOL bModified = FALSE);
+ CXFA_Margin GetMargin(FX_BOOL bModified = FALSE);
+ CXFA_Para GetPara(FX_BOOL bModified = FALSE);
+ void GetEventList(CXFA_NodeArray& events);
+ int32_t GetEventByActivity(int32_t iActivity,
+ CXFA_NodeArray& events,
+ FX_BOOL bIsFormReady = FALSE);
+ CXFA_Value GetDefaultValue(FX_BOOL bModified = FALSE);
+ CXFA_Value GetFormValue(FX_BOOL bModified = FALSE);
+ CXFA_Calculate GetCalculate(FX_BOOL bModified = FALSE);
+ CXFA_Validate GetValidate(FX_BOOL bModified = FALSE);
+ CXFA_Bind GetBind(FX_BOOL bModified = FALSE);
+ CXFA_Assist GetAssist(FX_BOOL bModified = FALSE);
+ uint32_t GetRelevantStatus();
+ FX_BOOL GetWidth(FX_FLOAT& fWidth);
+ FX_BOOL GetHeight(FX_FLOAT& fHeight);
+ FX_BOOL GetMinWidth(FX_FLOAT& fMinWidth);
+ FX_BOOL GetMinHeight(FX_FLOAT& fMinHeight);
+ FX_BOOL GetMaxWidth(FX_FLOAT& fMaxWidth);
+ FX_BOOL GetMaxHeight(FX_FLOAT& fMaxHeight);
+ CXFA_Border GetUIBorder(FX_BOOL bModified = FALSE);
+ CXFA_Margin GetUIMargin(FX_BOOL bModified = FALSE);
+ void GetUIMargin(CFX_RectF& rtUIMargin);
+ int32_t GetButtonHighlight();
+ FX_BOOL GetButtonRollover(CFX_WideString& wsRollover, FX_BOOL& bRichText);
+ FX_BOOL GetButtonDown(CFX_WideString& wsDown, FX_BOOL& bRichText);
+ int32_t GetCheckButtonShape();
+ int32_t GetCheckButtonMark();
+ FX_FLOAT GetCheckButtonSize();
+ FX_BOOL IsAllowNeutral();
+ FX_BOOL IsRadioButton();
+ XFA_CHECKSTATE GetCheckState();
+ void SetCheckState(XFA_CHECKSTATE eCheckState, FX_BOOL bNotify = TRUE);
+ CXFA_Node* GetExclGroupNode();
+ CXFA_Node* GetSelectedMember();
+ CXFA_Node* SetSelectedMember(const CFX_WideStringC& wsName,
+ FX_BOOL bNotify = TRUE);
+ void SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
+ FX_BOOL bNotify = TRUE,
+ FX_BOOL bScriptModify = FALSE,
+ FX_BOOL bSyncData = TRUE);
+ CXFA_Node* GetExclGroupFirstMember();
+ CXFA_Node* GetExclGroupNextMember(CXFA_Node* pNode);
+ int32_t GetChoiceListCommitOn();
+ FX_BOOL IsChoiceListAllowTextEntry();
+ int32_t GetChoiceListOpen();
+ FX_BOOL IsListBox();
+ int32_t CountChoiceListItems(FX_BOOL bSaveValue = FALSE);
+ FX_BOOL GetChoiceListItem(CFX_WideString& wsText,
+ int32_t nIndex,
+ FX_BOOL bSaveValue = FALSE);
+ void GetChoiceListItems(CFX_WideStringArray& wsTextArray,
+ FX_BOOL bSaveValue = FALSE);
+ int32_t CountSelectedItems();
+ int32_t GetSelectedItem(int32_t nIndex = 0);
+ void GetSelectedItems(CFX_Int32Array& iSelArray);
+ void GetSelectedItemsValue(CFX_WideStringArray& wsSelTextArray);
+ FX_BOOL GetItemState(int32_t nIndex);
+ void SetItemState(int32_t nIndex,
+ FX_BOOL bSelected,
+ FX_BOOL bNotify = FALSE,
+ FX_BOOL bScriptModify = FALSE,
+ FX_BOOL bSyncData = TRUE);
+ void SetSelectedItems(CFX_Int32Array& iSelArray,
+ FX_BOOL bNotify = FALSE,
+ FX_BOOL bScriptModify = FALSE,
+ FX_BOOL bSyncData = TRUE);
+ void ClearAllSelections();
+ void InsertItem(const CFX_WideString& wsLabel,
+ const CFX_WideString& wsValue,
+ int32_t nIndex = -1,
+ FX_BOOL bNotify = FALSE);
+ void GetItemLabel(const CFX_WideStringC& wsValue, CFX_WideString& wsLabel);
+ void GetItemValue(const CFX_WideStringC& wsLabel, CFX_WideString& wsValue);
+ FX_BOOL DeleteItem(int32_t nIndex,
+ FX_BOOL bNotify = FALSE,
+ FX_BOOL bScriptModify = FALSE,
+ FX_BOOL bSyncData = TRUE);
+ int32_t GetHorizontalScrollPolicy();
+ int32_t GetNumberOfCells();
+ FX_BOOL SetValue(const CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType);
+ FX_BOOL GetPictureContent(CFX_WideString& wsPicture,
+ XFA_VALUEPICTURE ePicture);
+ IFX_Locale* GetLocal();
+ FX_BOOL GetValue(CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType);
+ FX_BOOL GetNormalizeDataValue(const CFX_WideString& wsValue,
+ CFX_WideString& wsNormalizeValue);
+ FX_BOOL GetFormatDataValue(const CFX_WideString& wsValue,
+ CFX_WideString& wsFormatedValue);
+ void NormalizeNumStr(const CFX_WideString& wsValue, CFX_WideString& wsOutput);
+ CFX_WideString GetBarcodeType();
+ FX_BOOL GetBarcodeAttribute_CharEncoding(int32_t& val);
+ FX_BOOL GetBarcodeAttribute_Checksum(int32_t& val);
+ FX_BOOL GetBarcodeAttribute_DataLength(int32_t& val);
+ FX_BOOL GetBarcodeAttribute_StartChar(FX_CHAR& val);
+ FX_BOOL GetBarcodeAttribute_EndChar(FX_CHAR& val);
+ FX_BOOL GetBarcodeAttribute_ECLevel(int32_t& val);
+ FX_BOOL GetBarcodeAttribute_ModuleWidth(int32_t& val);
+ FX_BOOL GetBarcodeAttribute_ModuleHeight(int32_t& val);
+ FX_BOOL GetBarcodeAttribute_PrintChecksum(FX_BOOL& val);
+ FX_BOOL GetBarcodeAttribute_TextLocation(int32_t& val);
+ FX_BOOL GetBarcodeAttribute_Truncate(FX_BOOL& val);
+ FX_BOOL GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val);
+ void GetPasswordChar(CFX_WideString& wsPassWord);
+ FX_BOOL IsMultiLine();
+ int32_t GetVerticalScrollPolicy();
+ int32_t GetMaxChars(XFA_ELEMENT& eType);
+ FX_BOOL GetFracDigits(int32_t& iFracDigits);
+ FX_BOOL GetLeadDigits(int32_t& iLeadDigits);
+
+ CFX_WideString NumericLimit(const CFX_WideString& wsValue,
+ int32_t iLead,
+ int32_t iTread) const;
+
+ FX_BOOL m_bIsNull;
+ FX_BOOL m_bPreNull;
+
+ protected:
+ void SyncValue(const CFX_WideString& wsValue, FX_BOOL bNotify);
+ void InsertListTextItem(CXFA_Node* pItems,
+ const CFX_WideString& wsText,
+ int32_t nIndex = -1);
+ void FormatNumStr(const CFX_WideString& wsValue,
+ IFX_Locale* pLocale,
+ CFX_WideString& wsOutput);
+
+ CXFA_Node* m_pUiChildNode;
+ XFA_ELEMENT m_eUIType;
+};
+
+#endif // XFA_FXFA_PARSER_CXFA_WIDGETDATA_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.cpp
index f8a26dc1cd6..822b23f5e6d 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.cpp
@@ -8,7 +8,6 @@
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
#include "xfa/fxfa/parser/xfa_basic_imp.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.h
index 9bc6dcb23b9..b3f67dca077 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_data.h
@@ -7,8 +7,8 @@
#ifndef XFA_FXFA_PARSER_XFA_BASIC_DATA_H_
#define XFA_FXFA_PARSER_XFA_BASIC_DATA_H_
+#include "xfa/fxfa/include/fxfa_basic.h"
#include "xfa/fxfa/parser/xfa_basic_imp.h"
-#include "xfa/include/fxfa/fxfa_basic.h"
extern const XFA_PACKETINFO g_XFAPacketData[];
extern const int32_t g_iXFAPacketCount;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.cpp
index 13c879a31e7..728ecfc3198 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.cpp
@@ -12,7 +12,6 @@
#include "xfa/fgas/crt/fgas_system.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -22,12 +21,12 @@
#include "xfa/fxfa/parser/xfa_utils.h"
const XFA_PACKETINFO* XFA_GetPacketByName(const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.raw_str(), iLength);
- int32_t iStart = 0, iEnd = g_iXFAPacketCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, false);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFAPacketCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_PACKETINFO* pInfo = g_XFAPacketData + iMid;
@@ -64,12 +63,12 @@ const XFA_PACKETINFO* XFA_GetPacketByIndex(XFA_PACKET ePacket) {
const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName(
const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.raw_str(), iLength);
- int32_t iStart = 0, iEnd = g_iXFAEnumCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, false);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFAEnumCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid;
@@ -86,16 +85,14 @@ const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName(
const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) {
return g_XFAEnumData + eName;
}
-int32_t XFA_GetAttributeCount() {
- return g_iXFAAttributeCount;
-}
+
const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.raw_str(), iLength);
- int32_t iStart = 0, iEnd = g_iXFAAttributeCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, false);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFAAttributeCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_ATTRIBUTEINFO* pInfo = g_XFAAttributeData + iMid;
@@ -107,7 +104,7 @@ const XFA_ATTRIBUTEINFO* XFA_GetAttributeByName(const CFX_WideStringC& wsName) {
iStart = iMid + 1;
}
} while (iStart <= iEnd);
- return NULL;
+ return nullptr;
}
const XFA_ATTRIBUTEINFO* XFA_GetAttributeByID(XFA_ATTRIBUTE eName) {
return (eName < g_iXFAAttributeCount) ? (g_XFAAttributeData + eName) : NULL;
@@ -167,16 +164,7 @@ FX_BOOL XFA_GetAttributeDefaultValue_Boolean(XFA_ELEMENT eElement,
}
return FALSE;
}
-int32_t XFA_GetAttributeDefaultValue_Integer(XFA_ELEMENT eElement,
- XFA_ATTRIBUTE eAttribute,
- uint32_t dwPacket) {
- void* pValue;
- if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
- XFA_ATTRIBUTETYPE_Integer, dwPacket)) {
- return (int32_t)(uintptr_t)pValue;
- }
- return 0;
-}
+
CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement,
XFA_ATTRIBUTE eAttribute,
uint32_t dwPacket) {
@@ -187,16 +175,14 @@ CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT eElement,
}
return CXFA_Measurement();
}
-int32_t XFA_GetElementCount() {
- return g_iXFAElementCount;
-}
+
const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) {
- int32_t iLength = wsName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
- uint32_t uHash = FX_HashCode_String_GetW(wsName.raw_str(), iLength);
- int32_t iStart = 0, iEnd = g_iXFAElementCount - 1;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t uHash = FX_HashCode_GetW(wsName, false);
+ int32_t iStart = 0;
+ int32_t iEnd = g_iXFAElementCount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid;
@@ -248,25 +234,7 @@ const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement,
return pInfo;
return (dwPacket & pInfo->dwPackets) ? pInfo : NULL;
}
-const XFA_ELEMENTINFO* XFA_GetChildOfElement(XFA_ELEMENT eElement,
- XFA_ELEMENT eChild,
- uint32_t dwPacket) {
- int32_t iCount = 0;
- const uint16_t* pChild = XFA_GetElementChildren(eElement, iCount);
- if (pChild == NULL || iCount < 1) {
- return NULL;
- }
- CFX_DSPATemplate<uint16_t> search;
- int32_t index = search.Lookup(eChild, pChild, iCount);
- if (index < 0) {
- return NULL;
- }
- const XFA_ELEMENTINFO* pInfo = XFA_GetElementByID(eChild);
- ASSERT(pInfo);
- if (dwPacket == XFA_XDPPACKET_UNKNOWN)
- return pInfo;
- return (dwPacket & pInfo->dwPackets) ? pInfo : NULL;
-}
+
const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement,
int32_t& iCount) {
if (eElement >= g_iXFAElementCount) {
@@ -363,25 +331,23 @@ const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(XFA_ELEMENT eElement,
} while (iStart <= iEnd);
return NULL;
}
-int32_t XFA_GetMethodCount() {
- return g_iSomMethodCount;
-}
+
const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement,
const CFX_WideStringC& wsMethodName) {
- int32_t iLength = wsMethodName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
+ if (wsMethodName.IsEmpty())
+ return nullptr;
+
int32_t iElementIndex = eElement;
while (iElementIndex != -1) {
- XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex;
+ const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex;
int32_t icount = scriptIndex->wMethodCount;
if (icount == 0) {
iElementIndex = scriptIndex->wParentIndex;
continue;
}
- uint32_t uHash = FX_HashCode_String_GetW(wsMethodName.raw_str(), iLength);
- int32_t iStart = scriptIndex->wMethodStart, iEnd = iStart + icount - 1;
+ uint32_t uHash = FX_HashCode_GetW(wsMethodName, false);
+ int32_t iStart = scriptIndex->wMethodStart;
+ int32_t iEnd = iStart + icount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_METHODINFO* pInfo = g_SomMethodData + iMid;
@@ -400,20 +366,18 @@ const XFA_METHODINFO* XFA_GetMethodByName(XFA_ELEMENT eElement,
const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(
XFA_ELEMENT eElement,
const CFX_WideStringC& wsAttributeName) {
- int32_t iLength = wsAttributeName.GetLength();
- if (iLength == 0) {
- return NULL;
- }
+ if (wsAttributeName.IsEmpty())
+ return nullptr;
+
int32_t iElementIndex = eElement;
while (iElementIndex != -1) {
- XFA_LPCSCRIPTHIERARCHY scriptIndex = g_XFAScriptIndex + iElementIndex;
+ const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex;
int32_t icount = scriptIndex->wAttributeCount;
if (icount == 0) {
iElementIndex = scriptIndex->wParentIndex;
continue;
}
- uint32_t uHash =
- FX_HashCode_String_GetW(wsAttributeName.raw_str(), iLength);
+ uint32_t uHash = FX_HashCode_GetW(wsAttributeName, false);
int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1;
do {
int32_t iMid = (iStart + iEnd) / 2;
@@ -438,7 +402,7 @@ void CXFA_Measurement::Set(const CFX_WideStringC& wsMeasure) {
}
int32_t iUsedLen = 0;
int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0;
- FX_FLOAT fValue = FX_wcstof(wsMeasure.raw_str() + iOffset,
+ FX_FLOAT fValue = FX_wcstof(wsMeasure.c_str() + iOffset,
wsMeasure.GetLength() - iOffset, &iUsedLen);
XFA_UNIT eUnit = GetUnit(wsMeasure.Mid(iOffset + iUsedLen));
Set(fValue, eUnit);
@@ -600,7 +564,7 @@ int32_t CXFA_WideTextRead::ReadString(FX_WCHAR* pStr,
if (iMaxLength > m_wsBuffer.GetLength() - m_iPosition) {
iMaxLength = m_wsBuffer.GetLength() - m_iPosition;
}
- FXSYS_wcsncpy(pStr, (const FX_WCHAR*)m_wsBuffer + m_iPosition, iMaxLength);
+ FXSYS_wcsncpy(pStr, m_wsBuffer.c_str() + m_iPosition, iMaxLength);
m_iPosition += iMaxLength;
bEOS = IsEOF();
return iMaxLength;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.h
index ac0f8692eec..108b00d00f0 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_basic_imp.h
@@ -8,7 +8,7 @@
#define XFA_FXFA_PARSER_XFA_BASIC_IMP_H_
#include "xfa/fgas/crt/fgas_stream.h"
-#include "xfa/include/fxfa/fxfa_basic.h"
+#include "xfa/fxfa/include/fxfa_basic.h"
struct XFA_NOTSUREATTRIBUTE {
XFA_ELEMENT eElement;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_docdata.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_docdata.h
deleted file mode 100644
index 690ff3334f6..00000000000
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_docdata.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_XFA_DOCDATA_H_
-#define XFA_FXFA_PARSER_XFA_DOCDATA_H_
-
-#include "xfa/fxfa/parser/xfa_document.h"
-
-enum XFA_DATAFORMAT {
- XFA_DATAFORMAT_XDP,
-};
-
-#endif // XFA_FXFA_PARSER_XFA_DOCDATA_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_doclayout.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_doclayout.h
index 0bae0184ec8..a0b29e5ff88 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_doclayout.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_doclayout.h
@@ -57,19 +57,12 @@ class CXFA_ContainerLayoutItem : public CXFA_LayoutItem {
CXFA_LayoutProcessor* GetLayout() const;
int32_t GetPageIndex() const;
- void GetPageSize(CFX_SizeF& size);
+ void GetPageSize(CFX_SizeF& size) const;
CXFA_Node* GetMasterPage() const;
CXFA_Node* m_pOldSubform;
};
-#define XFA_WIDGETSTATUS_Access 0x80000000
-#define XFA_WIDGETSTATUS_Disabled 0x40000000
-#define XFA_WIDGETSTATUS_RectCached 0x20000000
-#define XFA_WIDGETSTATUS_ButtonDown 0x10000000
-#define XFA_WIDGETSTATUS_Highlight 0x08000000
-#define XFA_WIDGETSTATUS_TextEditValueChanged 0x04000000
-
class CXFA_ContentLayoutItem : public CXFA_LayoutItem {
public:
CXFA_ContentLayoutItem(CXFA_Node* pNode);
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document.h
index 3c96e9a711f..86b2a6f62c0 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document.h
@@ -7,9 +7,9 @@
#ifndef XFA_FXFA_PARSER_XFA_DOCUMENT_H_
#define XFA_FXFA_PARSER_XFA_DOCUMENT_H_
+#include "xfa/fxfa/include/fxfa.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
#include "xfa/fxfa/parser/xfa_object.h"
-#include "xfa/include/fxfa/fxfa.h"
class CXFA_Document;
class CXFA_LayoutItem;
@@ -39,26 +39,6 @@ enum XFA_VERSION {
XFA_VERSION_MAX = 400,
};
-#define XFA_LAYOUTSTATUS_Visible 0x0001
-#define XFA_LAYOUTSTATUS_Viewable 0x0010
-#define XFA_LAYOUTSTATUS_Printable 0x0020
-enum XFA_NODEEVENT {
- XFA_NODEEVENT_Ready,
- XFA_NODEEVENT_ValueChanging,
- XFA_NODEEVENT_ValueChanged,
- XFA_NODEEVENT_ChildAdded,
- XFA_NODEEVENT_ChildRemoved,
-};
-enum XFA_PAGEEVENT {
- XFA_PAGEEVENT_PageAdded,
- XFA_PAGEEVENT_PageRemoved,
-};
-enum XFA_LAYOUTEVENT {
- XFA_LAYOUTEVENT_ItemAdded,
- XFA_LAYOUTEVENT_ItemRemoving,
- XFA_LAYOUTEVENT_RectChanged,
- XFA_LAYOUTEVENT_StatusChanged,
-};
enum XFA_LAYOUTRESULT {
XFA_LAYOUTRESULT_Continue,
XFA_LAYOUTRESULT_Done,
@@ -131,7 +111,7 @@ class CXFA_Document {
CScript_LogPseudoModel* m_pScriptLog;
CScript_LayoutPseudoModel* m_pScriptLayout;
CScript_SignaturePseudoModel* m_pScriptSignature;
- CXFA_NodeSet m_rgPurgeNodes;
+ CXFA_NodeSet m_PurgeNodes;
XFA_VERSION m_eCurVersionMode;
uint32_t m_dwDocFlags;
friend class CXFA_SimpleParser;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp
index 1a6ca1b5feb..31cf4119ad9 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.cpp
@@ -5,7 +5,6 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -30,7 +29,7 @@ class CXFA_TraverseStrategy_DDGroup {
};
void XFA_DataDescription_UpdateDataRelation(CXFA_Node* pDataNode,
CXFA_Node* pDataDescriptionNode) {
- FXSYS_assert(pDataDescriptionNode);
+ ASSERT(pDataDescriptionNode);
for (CXFA_Node* pDataChild = pDataNode->GetNodeItem(XFA_NODEITEM_FirstChild);
pDataChild;
pDataChild = pDataChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
@@ -70,7 +69,7 @@ CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
CXFA_Document* pDocument,
CXFA_Node* pDataParent,
XFA_ELEMENT eNodeType,
- const CFX_WideStringC& wsName) {
+ const CFX_WideString& wsName) {
if (!pDataParent) {
return NULL;
}
@@ -78,11 +77,11 @@ CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
if (!pParentDDNode) {
CXFA_Node* pDataNode =
pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
- FXSYS_assert(pDataNode);
+ ASSERT(pDataNode);
pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
pDataNode->CreateXMLMappingNode();
pDataParent->InsertChild(pDataNode);
- pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pDataNode->SetFlag(XFA_NODEFLAG_Initialized, false);
return pDataNode;
} else {
CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_DDGroup>
@@ -99,7 +98,8 @@ CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
continue;
}
}
- CXFA_Node* pDDNode = pDDGroupNode->GetFirstChildByName(wsName);
+ CXFA_Node* pDDNode =
+ pDDGroupNode->GetFirstChildByName(wsName.AsStringC());
if (!pDDNode) {
continue;
}
@@ -108,7 +108,7 @@ CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
}
CXFA_Node* pDataNode =
pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
- FXSYS_assert(pDataNode);
+ ASSERT(pDataNode);
pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
pDataNode->CreateXMLMappingNode();
if (eNodeType == XFA_ELEMENT_DataValue &&
@@ -118,7 +118,7 @@ CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
}
pDataParent->InsertChild(pDataNode);
pDataNode->SetDataDescriptionNode(pDDNode);
- pDataNode->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pDataNode->SetFlag(XFA_NODEFLAG_Initialized, false);
return pDataNode;
}
return NULL;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.h
index f7c626dfb7b..47bc358972e 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datadescription_imp.h
@@ -13,6 +13,6 @@ CXFA_Node* XFA_DataDescription_MaybeCreateDataNode(
CXFA_Document* pDocument,
CXFA_Node* pDataParent,
XFA_ELEMENT eNodeType,
- const CFX_WideStringC& wsName);
+ const CFX_WideString& wsName);
#endif // XFA_FXFA_PARSER_XFA_DOCUMENT_DATADESCRIPTION_IMP_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index a28b4994abc..41a0acd70bf 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -9,8 +9,8 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/xfa_basic_imp.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_datadescription_imp.h"
@@ -52,7 +52,7 @@ static CXFA_Node* XFA_DataMerge_FormValueNode_CreateChild(
static void XFA_DataMerge_FormValueNode_MatchNoneCreateChild(
CXFA_Node* pFormNode) {
CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
- FXSYS_assert(pWidgetData);
+ ASSERT(pWidgetData);
pWidgetData->GetUIType();
}
static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent(
@@ -62,7 +62,7 @@ static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent(
if (!pValueNode) {
return FALSE;
}
- FXSYS_assert(pValueNode->GetPacketID() == XFA_XDPPACKET_Form);
+ ASSERT(pValueNode->GetPacketID() == XFA_XDPPACKET_Form);
CXFA_Node* pChildNode =
XFA_DataMerge_FormValueNode_CreateChild(pValueNode, iType);
if (!pChildNode) {
@@ -96,7 +96,7 @@ static FX_BOOL XFA_DataMerge_FormValueNode_SetChildContent(
pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
} break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
return TRUE;
@@ -111,7 +111,7 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
return;
}
CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
- FXSYS_assert(pWidgetData);
+ ASSERT(pWidgetData);
FX_BOOL bNotify = FALSE;
XFA_ELEMENT eUIType = pWidgetData->GetUIType();
CXFA_Value defValue(pFormNode->GetProperty(0, XFA_ELEMENT_Value));
@@ -130,13 +130,12 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
}
CFDE_XMLElement* pXMLDataElement =
static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode());
- FXSYS_assert(pXMLDataElement);
- pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(),
- wsFormatedValue);
+ ASSERT(pXMLDataElement);
+ pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
if (!wsHref.IsEmpty()) {
- pXMLDataElement->SetString(FX_WSTRC(L"href"), wsHref);
+ pXMLDataElement->SetString(L"href", wsHref);
}
} break;
case XFA_ELEMENT_ChoiceList:
@@ -149,20 +148,19 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
CXFA_Node* pValue = NULL;
for (int32_t i = 0; i < iSize; i++) {
pValue = pDataNode->CreateSamePacketNode(XFA_ELEMENT_DataValue);
- pValue->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"value"));
+ pValue->SetCData(XFA_ATTRIBUTE_Name, L"value");
pValue->CreateXMLMappingNode();
pDataNode->InsertChild(pValue);
pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]);
}
} else {
CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode();
- FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element);
- static_cast<CFDE_XMLElement*>(pXMLNode)
- ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup"));
+ ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element);
+ static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode",
+ L"dataGroup");
}
} else if (!wsValue.IsEmpty()) {
- pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(),
- wsFormatedValue);
+ pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
}
break;
@@ -171,8 +169,7 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
if (wsValue.IsEmpty()) {
break;
}
- pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(),
- wsFormatedValue);
+ pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
break;
case XFA_ELEMENT_ExclGroup: {
@@ -242,8 +239,7 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
CFX_WideString wsOutput;
pWidgetData->NormalizeNumStr(wsValue, wsOutput);
wsValue = wsOutput;
- pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(),
- wsFormatedValue);
+ pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_ELEMENT_Value);
XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsValue,
@@ -254,8 +250,7 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
if (wsValue.IsEmpty()) {
break;
}
- pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(),
- wsFormatedValue);
+ pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue);
pDataNode->SetAttributeValue(wsValue, wsFormatedValue);
break;
}
@@ -263,8 +258,7 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
CFX_WideString wsXMLValue;
pDataNode->TryContent(wsXMLValue);
CFX_WideString wsNormailizeValue;
- pWidgetData->GetNormalizeDataValue(wsXMLValue.AsWideStringC(),
- wsNormailizeValue);
+ pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormailizeValue);
pDataNode->SetAttributeValue(wsNormailizeValue, wsXMLValue);
switch (eUIType) {
case XFA_ELEMENT_ImageEdit: {
@@ -274,7 +268,7 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
if (image) {
CFDE_XMLElement* pXMLDataElement =
static_cast<CFDE_XMLElement*>(pDataNode->GetXMLMappingNode());
- FXSYS_assert(pXMLDataElement);
+ ASSERT(pXMLDataElement);
CFX_WideString wsContentType;
CFX_WideString wsHref;
pXMLDataElement->GetString(L"xfa:contentType", wsContentType);
@@ -294,7 +288,7 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
pDataNode->GetNodeList(items);
int32_t iCounts = items.GetSize();
if (iCounts > 0) {
- wsNormailizeValue.Empty();
+ wsNormailizeValue.clear();
CFX_WideString wsItem;
for (int32_t i = 0; i < iCounts; i++) {
items[i]->TryContent(wsItem);
@@ -302,9 +296,8 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
wsNormailizeValue += wsItem;
}
CXFA_ExData exData = defValue.GetExData();
- FXSYS_assert(exData);
- exData.SetContentType((iCounts == 1) ? FX_WSTRC(L"text/plain")
- : FX_WSTRC(L"text/xml"));
+ ASSERT(exData);
+ exData.SetContentType(iCounts == 1 ? L"text/plain" : L"text/xml");
}
XFA_DataMerge_FormValueNode_SetChildContent(
defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_ExData);
@@ -318,7 +311,7 @@ static void XFA_DataMerge_CreateDataBinding(CXFA_Node* pFormNode,
defValue.GetNode(), wsNormailizeValue, XFA_ELEMENT_Text);
break;
case XFA_ELEMENT_ExclGroup: {
- pWidgetData->SetSelectedMemberByValue(wsNormailizeValue.AsWideStringC(),
+ pWidgetData->SetSelectedMemberByValue(wsNormailizeValue.AsStringC(),
bNotify, FALSE, FALSE);
} break;
case XFA_ELEMENT_DateTimeEdit:
@@ -403,52 +396,48 @@ static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument,
CFX_WideStringC wsName,
CXFA_Node* pDataScope,
XFA_ELEMENT eMatchNodeType) {
- uint32_t dwNameHash =
- wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.raw_str(),
- wsName.GetLength());
- if (dwNameHash != 0) {
- CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash);
- if (!pBounded) {
- pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash,
- eMatchNodeType);
- if (pBounded) {
- XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded);
- }
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t dwNameHash = FX_HashCode_GetW(wsName, false);
+ CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash);
+ if (!pBounded) {
+ pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash,
+ eMatchNodeType);
+ if (pBounded) {
+ XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded);
}
- return pBounded;
}
- return NULL;
+ return pBounded;
}
+
static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument,
CFX_WideStringC wsName,
CXFA_Node* pDataScope,
XFA_ELEMENT eMatchNodeType) {
- uint32_t dwNameHash =
- wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.raw_str(),
- wsName.GetLength());
- if (dwNameHash != 0) {
- for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL;
- pCurDataScope &&
- pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets;
- pLastDataScope = pCurDataScope,
- pCurDataScope =
- pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) {
- for (CXFA_Node* pDataChild =
- pCurDataScope->GetFirstChildByName(dwNameHash);
- pDataChild;
- pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) {
- if (pDataChild == pLastDataScope ||
- (eMatchNodeType != XFA_ELEMENT_DataModel &&
- pDataChild->GetClassID() != eMatchNodeType) ||
- pDataChild->HasBindItem()) {
- continue;
- }
- return pDataChild;
+ if (wsName.IsEmpty())
+ return nullptr;
+
+ uint32_t dwNameHash = FX_HashCode_GetW(wsName, false);
+ CXFA_Node* pLastDataScope = nullptr;
+ for (CXFA_Node* pCurDataScope = pDataScope;
+ pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets;
+ pCurDataScope = pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) {
+ for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash);
+ pDataChild;
+ pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) {
+ if (pDataChild == pLastDataScope || pDataChild->HasBindItem() ||
+ (eMatchNodeType != XFA_ELEMENT_DataModel &&
+ pDataChild->GetClassID() != eMatchNodeType)) {
+ continue;
}
+ return pDataChild;
}
+ pLastDataScope = pCurDataScope;
}
- return NULL;
+ return nullptr;
}
+
static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument,
CFX_WideStringC wsRef,
CXFA_Node* pDataScope,
@@ -529,7 +518,7 @@ CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument,
pFormParent->RemoveChild(pExistingNode);
pFormParent->InsertChild(pExistingNode);
}
- pExistingNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
+ pExistingNode->ClearFlag(XFA_NODEFLAG_UnusedNode);
pExistingNode->SetTemplateNode(pTemplateNode);
if (bRecursive && pExistingNode->GetClassID() != XFA_ELEMENT_Items) {
for (CXFA_Node* pTemplateChild =
@@ -542,7 +531,7 @@ CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument,
}
}
}
- pExistingNode->SetFlag(XFA_NODEFLAG_Initialized);
+ pExistingNode->SetFlag(XFA_NODEFLAG_Initialized, true);
return pExistingNode;
}
CXFA_Node* pNewNode = pTemplateNode->CloneTemplateToForm(FALSE);
@@ -568,7 +557,7 @@ static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager(
CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName;
uint32_t dwInstNameHash =
- FX_HashCode_String_GetW(wsInstMgrNodeName, wsInstMgrNodeName.GetLength());
+ FX_HashCode_GetW(wsInstMgrNodeName.AsStringC(), false);
CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance(
pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent);
if (pExistingNode) {
@@ -595,13 +584,13 @@ static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager(
}
pFormParent->RemoveChild(pExistingNode);
pFormParent->InsertChild(pExistingNode);
- pExistingNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
+ pExistingNode->ClearFlag(XFA_NODEFLAG_UnusedNode);
pExistingNode->SetTemplateNode(pTemplateNode);
return pExistingNode;
}
CXFA_Node* pNewNode = pDocument->GetParser()->GetFactory()->CreateNode(
XFA_XDPPACKET_Form, XFA_ELEMENT_InstanceManager);
- FXSYS_assert(pNewNode);
+ ASSERT(pNewNode);
wsInstMgrNodeName =
FX_WSTRC(L"_") + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName);
@@ -789,11 +778,11 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
} else if (pInstMgrNode) {
pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_ELEMENT_Occur);
if (pOccurNode) {
- pOccurNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
+ pOccurNode->ClearFlag(XFA_NODEFLAG_UnusedNode);
}
}
if (pInstMgrNode) {
- pInstMgrNode->SetFlag(XFA_NODEFLAG_Initialized);
+ pInstMgrNode->SetFlag(XFA_NODEFLAG_Initialized, true);
pSearchArray = &subformArray;
if (pFormParentNode->GetClassID() == XFA_ELEMENT_PageArea) {
bOneInstance = TRUE;
@@ -841,7 +830,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
pFirstInstance = pSubformNode;
}
XFA_DataMerge_CreateDataBinding(pSubformNode, pDataNode);
- FXSYS_assert(pSubformNode);
+ ASSERT(pSubformNode);
subformMapArray.SetAt(pSubformNode, pDataNode);
subformArray.Add(pSubformNode);
}
@@ -882,7 +871,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
eRelation == XFA_ATTRIBUTEENUM_Unordered) {
CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
- FXSYS_assert(pSubformSetNode);
+ ASSERT(pSubformSetNode);
if (!pFirstInstance) {
pFirstInstance = pSubformSetNode;
}
@@ -918,7 +907,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
}
switch (eRelation) {
case XFA_ATTRIBUTEENUM_Choice: {
- FXSYS_assert(rgItemMatchList.GetSize());
+ ASSERT(rgItemMatchList.GetSize());
XFA_DataMerge_SortRecurseRecord(rgItemMatchList, pDataScope, TRUE);
pDocument->DataMerge_CopyContainer(
rgItemMatchList[0].pTemplateChild, pSubformSetNode, pDataScope);
@@ -945,7 +934,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
} else {
CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
- FXSYS_assert(pSubformSetNode);
+ ASSERT(pSubformSetNode);
if (!pFirstInstance) {
pFirstInstance = pSubformSetNode;
}
@@ -987,7 +976,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
}
CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer(
pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
- FXSYS_assert(pSubformNode);
+ ASSERT(pSubformNode);
if (!pFirstInstance) {
pFirstInstance = pSubformNode;
}
@@ -1011,7 +1000,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet(
for (; iCurRepeatIndex < iMinimalLimit; iCurRepeatIndex++) {
CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray);
- FXSYS_assert(pSubformSetNode);
+ ASSERT(pSubformSetNode);
if (!pFirstInstance) {
pFirstInstance = pSubformSetNode;
}
@@ -1044,7 +1033,7 @@ static CXFA_Node* XFA_DataMerge_CopyContainer_Field(CXFA_Document* pDocument,
FX_BOOL bUpLevel = TRUE) {
CXFA_Node* pFieldNode = XFA_NodeMerge_CloneOrMergeContainer(
pDocument, pFormNode, pTemplateNode, FALSE);
- FXSYS_assert(pFieldNode);
+ ASSERT(pFieldNode);
for (CXFA_Node* pTemplateChildNode =
pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem(
@@ -1099,7 +1088,7 @@ CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode,
case XFA_ELEMENT_Variables:
break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
return NULL;
@@ -1140,7 +1129,7 @@ static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument,
: XFA_ELEMENT_DataValue;
pDataNode = XFA_DataDescription_MaybeCreateDataNode(
pDocument, pDataScope, eDataNodeType,
- pFormNode->GetCData(XFA_ATTRIBUTE_Name));
+ CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name)));
if (pDataNode) {
XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE);
}
@@ -1152,7 +1141,7 @@ static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument,
CXFA_Node* pDataParent =
pDataNode->GetNodeItem(XFA_NODEITEM_Parent);
if (pDataParent != pDataScope) {
- FXSYS_assert(pDataParent);
+ ASSERT(pDataParent);
pDataParent->RemoveChild(pDataNode);
pDataScope->InsertChild(pDataNode);
}
@@ -1173,7 +1162,7 @@ static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument,
ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
pDataNode = XFA_DataDescription_MaybeCreateDataNode(
pDocument, pRecordNode, eDataNodeType,
- pFormNode->GetCData(XFA_ATTRIBUTE_Name));
+ CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name)));
if (pDataNode) {
XFA_DataMerge_CreateDataBinding(pFormNode, pDataNode, FALSE);
XFA_DataMerge_RegisterGlobalBinding(
@@ -1270,14 +1259,11 @@ CXFA_Node* CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes) {
void CXFA_Document::DoDataMerge() {
CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets));
if (!pDatasetsRoot) {
- CFDE_XMLElement* pDatasetsXMLNode =
- new CFDE_XMLElement(FX_WSTRC(L"xfa:datasets"));
-
- pDatasetsXMLNode->SetString(
- FX_WSTRC(L"xmlns:xfa"),
- FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/"));
+ CFDE_XMLElement* pDatasetsXMLNode = new CFDE_XMLElement(L"xfa:datasets");
+ pDatasetsXMLNode->SetString(L"xmlns:xfa",
+ L"http://www.xfa.org/schema/xfa-data/1.0/");
pDatasetsRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataModel);
- pDatasetsRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"datasets"));
+ pDatasetsRoot->SetCData(XFA_ATTRIBUTE_Name, L"datasets");
m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode);
m_pRootNode->InsertChild(pDatasetsRoot);
pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode);
@@ -1314,11 +1300,9 @@ void CXFA_Document::DoDataMerge() {
}
}
if (!pDataRoot) {
- CFDE_XMLElement* pDataRootXMLNode =
- new CFDE_XMLElement(FX_WSTRC(L"xfa:data"));
-
+ CFDE_XMLElement* pDataRootXMLNode = new CFDE_XMLElement(L"xfa:data");
pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup);
- pDataRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"data"));
+ pDataRoot->SetCData(XFA_ATTRIBUTE_Name, L"data");
pDataRoot->SetXMLMappingNode(pDataRootXMLNode);
pDatasetsRoot->InsertChild(pDataRoot);
}
@@ -1344,24 +1328,24 @@ void CXFA_Document::DoDataMerge() {
if (!pFormRoot) {
bEmptyForm = TRUE;
pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_ELEMENT_Form);
- FXSYS_assert(pFormRoot);
- pFormRoot->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"form"));
+ ASSERT(pFormRoot);
+ pFormRoot->SetCData(XFA_ATTRIBUTE_Name, L"form");
m_pRootNode->InsertChild(pFormRoot, NULL);
} else {
CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
sIterator(pFormRoot);
for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode;
pNode = sIterator.MoveToNext()) {
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode);
+ pNode->SetFlag(XFA_NODEFLAG_UnusedNode, true);
}
}
CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
this, pFormRoot, pTemplateChosen, FALSE);
- FXSYS_assert(pSubformSetNode);
+ ASSERT(pSubformSetNode);
if (!pDataTopLevel) {
CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name);
- CFX_WideString wsDataTopLevelName =
- wsFormName.IsEmpty() ? FX_WSTRC(L"form") : wsFormName;
+ CFX_WideString wsDataTopLevelName(wsFormName.IsEmpty() ? L"form"
+ : wsFormName);
CFDE_XMLElement* pDataTopLevelXMLNode =
new CFDE_XMLElement(wsDataTopLevelName);
@@ -1371,7 +1355,7 @@ void CXFA_Document::DoDataMerge() {
CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
pDataRoot->InsertChild(pDataTopLevel, pBeforeNode);
}
- FXSYS_assert(pDataTopLevel);
+ ASSERT(pDataTopLevel);
XFA_DataMerge_CreateDataBinding(pSubformSetNode, pDataTopLevel);
for (CXFA_Node* pTemplateChild =
pTemplateChosen->GetNodeItem(XFA_NODEITEM_FirstChild);
@@ -1410,12 +1394,12 @@ void CXFA_Document::DoDataMerge() {
pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode);
pNode = pNext;
} else {
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
- pNode->SetFlag(XFA_NODEFLAG_Initialized);
+ pNode->ClearFlag(XFA_NODEFLAG_UnusedNode);
+ pNode->SetFlag(XFA_NODEFLAG_Initialized, true);
pNode = sIterator.MoveToNext();
}
} else {
- pNode->SetFlag(XFA_NODEFLAG_Initialized);
+ pNode->SetFlag(XFA_NODEFLAG_Initialized, true);
pNode = sIterator.MoveToNext();
}
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_imp.cpp
index bb2001e8032..0421683e07e 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_imp.cpp
@@ -8,7 +8,6 @@
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
#include "xfa/fxfa/parser/xfa_basic_imp.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
@@ -46,44 +45,31 @@ CXFA_Document::~CXFA_Document() {
delete m_pRootNode;
PurgeNodes();
}
+
void CXFA_Document::ClearLayoutData() {
- if (m_pLayoutProcessor) {
- delete m_pLayoutProcessor;
- m_pLayoutProcessor = NULL;
- }
+ delete m_pLayoutProcessor;
+ m_pLayoutProcessor = nullptr;
+
if (m_pScriptContext) {
m_pScriptContext->Release();
- m_pScriptContext = NULL;
- }
- if (m_pLocalMgr) {
- delete m_pLocalMgr;
- m_pLocalMgr = NULL;
- }
- if (m_pScriptDataWindow) {
- delete m_pScriptDataWindow;
- m_pScriptDataWindow = NULL;
- }
- if (m_pScriptEvent) {
- delete m_pScriptEvent;
- m_pScriptEvent = NULL;
- }
- if (m_pScriptHost) {
- delete m_pScriptHost;
- m_pScriptHost = NULL;
- }
- if (m_pScriptLog) {
- delete m_pScriptLog;
- m_pScriptLog = NULL;
- }
- if (m_pScriptLayout) {
- delete m_pScriptLayout;
- m_pScriptLayout = NULL;
- }
- if (m_pScriptSignature) {
- delete m_pScriptSignature;
- m_pScriptSignature = NULL;
- }
+ m_pScriptContext = nullptr;
+ }
+ delete m_pLocalMgr;
+ m_pLocalMgr = nullptr;
+ delete m_pScriptDataWindow;
+ m_pScriptDataWindow = nullptr;
+ delete m_pScriptEvent;
+ m_pScriptEvent = nullptr;
+ delete m_pScriptHost;
+ m_pScriptHost = nullptr;
+ delete m_pScriptLog;
+ m_pScriptLog = nullptr;
+ delete m_pScriptLayout;
+ m_pScriptLayout = nullptr;
+ delete m_pScriptSignature;
+ m_pScriptSignature = nullptr;
}
+
void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) {
if (m_pRootNode) {
AddPurgeNode(m_pRootNode);
@@ -95,8 +81,7 @@ CXFA_FFNotify* CXFA_Document::GetNotify() const {
return m_pParser->GetNotify();
}
CXFA_Object* CXFA_Document::GetXFAObject(const CFX_WideStringC& wsNodeName) {
- return GetXFAObject(
- FX_HashCode_String_GetW(wsNodeName.raw_str(), wsNodeName.GetLength()));
+ return GetXFAObject(FX_HashCode_GetW(wsNodeName, false));
}
CXFA_Object* CXFA_Document::GetXFAObject(uint32_t dwNodeNameHash) {
switch (dwNodeNameHash) {
@@ -174,36 +159,37 @@ CXFA_Object* CXFA_Document::GetXFAObject(uint32_t dwNodeNameHash) {
CXFA_Node* CXFA_Document::CreateNode(uint32_t dwPacket, XFA_ELEMENT eElement) {
return CreateNode(XFA_GetPacketByID(dwPacket), eElement);
}
+
CXFA_Node* CXFA_Document::CreateNode(const XFA_PACKETINFO* pPacket,
XFA_ELEMENT eElement) {
- if (pPacket == NULL) {
- return NULL;
- }
+ if (!pPacket)
+ return nullptr;
+
const XFA_ELEMENTINFO* pElement = XFA_GetElementByID(eElement);
if (pElement && (pElement->dwPackets & pPacket->eName)) {
CXFA_Node* pNode = new CXFA_Node(this, pPacket->eName, pElement->eName);
- if (pNode) {
- AddPurgeNode(pNode);
- }
+ AddPurgeNode(pNode);
return pNode;
}
- return NULL;
+
+ return nullptr;
}
+
void CXFA_Document::AddPurgeNode(CXFA_Node* pNode) {
- m_rgPurgeNodes.Add(pNode);
+ m_PurgeNodes.insert(pNode);
}
+
FX_BOOL CXFA_Document::RemovePurgeNode(CXFA_Node* pNode) {
- return m_rgPurgeNodes.RemoveKey(pNode);
+ return !!m_PurgeNodes.erase(pNode);
}
+
void CXFA_Document::PurgeNodes() {
- FX_POSITION psNode = m_rgPurgeNodes.GetStartPosition();
- while (psNode) {
- CXFA_Node* pNode;
- m_rgPurgeNodes.GetNextAssoc(psNode, pNode);
+ for (CXFA_Node* pNode : m_PurgeNodes)
delete pNode;
- }
- m_rgPurgeNodes.RemoveAll();
+
+ m_PurgeNodes.clear();
}
+
void CXFA_Document::SetFlag(uint32_t dwFlag, FX_BOOL bOn) {
if (bOn) {
m_dwDocFlags |= dwFlag;
@@ -213,7 +199,7 @@ void CXFA_Document::SetFlag(uint32_t dwFlag, FX_BOOL bOn) {
}
FX_BOOL CXFA_Document::IsInteractive() {
if (m_dwDocFlags & XFA_DOCFLAG_HasInteractive) {
- return m_dwDocFlags & XFA_DOCFLAG_Interactive;
+ return !!(m_dwDocFlags & XFA_DOCFLAG_Interactive);
}
CXFA_Node* pConfig = ToNode(GetXFAObject(XFA_HASHCODE_Config));
if (!pConfig) {
@@ -264,7 +250,7 @@ XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber(
CFX_WideStringC wsTemplateURIPrefix =
XFA_GetPacketByIndex(XFA_PACKET_Template)->pURI;
FX_STRSIZE nPrefixLength = wsTemplateURIPrefix.GetLength();
- if (CFX_WideStringC(wsTemplateNS, wsTemplateNS.GetLength()) !=
+ if (CFX_WideStringC(wsTemplateNS.c_str(), wsTemplateNS.GetLength()) !=
wsTemplateURIPrefix) {
return XFA_VERSION_UNKNOWN;
}
@@ -272,10 +258,11 @@ XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber(
if (nDotPos == (FX_STRSIZE)-1) {
return XFA_VERSION_UNKNOWN;
}
- int8_t iMajor =
- FXSYS_wtoi(wsTemplateNS.Mid(nPrefixLength, nDotPos - nPrefixLength));
+ int8_t iMajor = FXSYS_wtoi(
+ wsTemplateNS.Mid(nPrefixLength, nDotPos - nPrefixLength).c_str());
int8_t iMinor = FXSYS_wtoi(
- wsTemplateNS.Mid(nDotPos + 1, wsTemplateNS.GetLength() - nDotPos - 2));
+ wsTemplateNS.Mid(nDotPos + 1, wsTemplateNS.GetLength() - nDotPos - 2)
+ .c_str());
XFA_VERSION eVersion = (XFA_VERSION)((int32_t)iMajor * 100 + iMinor);
if (eVersion < XFA_VERSION_MIN || eVersion > XFA_VERSION_MAX) {
return XFA_VERSION_UNKNOWN;
@@ -311,7 +298,7 @@ static void XFA_ProtoMerge_MergeNodeRecurse(CXFA_Document* pDocument,
if (pFormChild->GetClassID() == pProtoNode->GetClassID() &&
pFormChild->GetNameHash() == pProtoNode->GetNameHash() &&
pFormChild->HasFlag(XFA_NODEFLAG_UnusedNode)) {
- pFormChild->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
+ pFormChild->ClearFlag(XFA_NODEFLAG_UnusedNode);
pExistingNode = pFormChild;
break;
}
@@ -337,7 +324,7 @@ static void XFA_ProtoMerge_MergeNode(CXFA_Document* pDocument,
CXFA_NodeIterator sIterator(pDestNode);
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode);
+ pNode->SetFlag(XFA_NODEFLAG_UnusedNode, true);
}
}
pDestNode->SetTemplateNode(pProtoNode);
@@ -351,7 +338,7 @@ static void XFA_ProtoMerge_MergeNode(CXFA_Document* pDocument,
CXFA_NodeIterator sIterator(pDestNode);
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
+ pNode->ClearFlag(XFA_NODEFLAG_UnusedNode);
}
}
}
@@ -367,50 +354,44 @@ void CXFA_Document::DoProtoMerge() {
pNode = sIterator.MoveToNext()) {
CFX_WideStringC wsIDVal;
if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) {
- mIDMap[FX_HashCode_String_GetW(wsIDVal.raw_str(), wsIDVal.GetLength())] =
- pNode;
+ mIDMap[FX_HashCode_GetW(wsIDVal, false)] = pNode;
}
CFX_WideStringC wsUseVal;
if (pNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && !wsUseVal.IsEmpty()) {
- sUseNodes.Add(pNode);
+ sUseNodes.insert(pNode);
} else if (pNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
!wsUseVal.IsEmpty()) {
- sUseNodes.Add(pNode);
+ sUseNodes.insert(pNode);
}
}
- FX_POSITION pos = sUseNodes.GetStartPosition();
- while (pos) {
- CXFA_Node* pUseHrefNode = NULL;
- sUseNodes.GetNextAssoc(pos, pUseHrefNode);
+ for (CXFA_Node* pUseHrefNode : sUseNodes) {
CFX_WideString wsUseVal;
CFX_WideStringC wsURI, wsID, wsSOM;
if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
!wsUseVal.IsEmpty()) {
FX_STRSIZE uSharpPos = wsUseVal.Find('#');
if (uSharpPos < 0) {
- wsURI = wsUseVal;
+ wsURI = wsUseVal.AsStringC();
} else {
- wsURI = CFX_WideStringC((const FX_WCHAR*)wsUseVal, uSharpPos);
+ wsURI = CFX_WideStringC(wsUseVal.c_str(), uSharpPos);
FX_STRSIZE uLen = wsUseVal.GetLength();
if (uLen >= uSharpPos + 5 &&
- CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos, 5) ==
+ CFX_WideStringC(wsUseVal.c_str() + uSharpPos, 5) ==
FX_WSTRC(L"#som(") &&
wsUseVal[uLen - 1] == ')') {
- wsSOM = CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos + 5,
+ wsSOM = CFX_WideStringC(wsUseVal.c_str() + uSharpPos + 5,
uLen - 1 - uSharpPos - 5);
} else {
- wsID = CFX_WideStringC((const FX_WCHAR*)wsUseVal + uSharpPos + 1,
+ wsID = CFX_WideStringC(wsUseVal.c_str() + uSharpPos + 1,
uLen - uSharpPos - 1);
}
}
} else if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) &&
!wsUseVal.IsEmpty()) {
if (wsUseVal[0] == '#') {
- wsID = CFX_WideStringC((const FX_WCHAR*)wsUseVal + 1,
- wsUseVal.GetLength() - 1);
+ wsID = CFX_WideStringC(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1);
} else {
- wsSOM =
- CFX_WideStringC((const FX_WCHAR*)wsUseVal, wsUseVal.GetLength());
+ wsSOM = CFX_WideStringC(wsUseVal.c_str(), wsUseVal.GetLength());
}
}
if (!wsURI.IsEmpty() && wsURI != FX_WSTRC(L".")) {
@@ -428,9 +409,7 @@ void CXFA_Document::DoProtoMerge() {
pProtoNode = resoveNodeRS.nodes[0]->AsNode();
}
} else if (!wsID.IsEmpty()) {
- if (!mIDMap.Lookup(
- FX_HashCode_String_GetW(wsID.raw_str(), wsID.GetLength()),
- pProtoNode)) {
+ if (!mIDMap.Lookup(FX_HashCode_GetW(wsID, false), pProtoNode)) {
continue;
}
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_layout_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_layout_imp.cpp
index 79037d7ec7d..44d053b8c24 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_layout_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_layout_imp.cpp
@@ -8,7 +8,6 @@
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
#include "xfa/fxfa/parser/xfa_basic_imp.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_datamerger_imp.h"
@@ -43,14 +42,13 @@ CXFA_LayoutProcessor::~CXFA_LayoutProcessor() {
CXFA_Document* CXFA_LayoutProcessor::GetDocument() const {
return m_pDocument;
}
+
int32_t CXFA_LayoutProcessor::StartLayout(FX_BOOL bForceRestart) {
- if (!bForceRestart && !IsNeedLayout()) {
+ if (!bForceRestart && !IsNeedLayout())
return 100;
- }
- if (m_pRootItemLayoutProcessor) {
- delete m_pRootItemLayoutProcessor;
- m_pRootItemLayoutProcessor = NULL;
- }
+
+ delete m_pRootItemLayoutProcessor;
+ m_pRootItemLayoutProcessor = nullptr;
m_nProgressCounter = 0;
CXFA_Node* pFormPacketNode =
ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form));
@@ -148,17 +146,15 @@ void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) {
CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetRootLayoutItem() const {
return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetRootLayoutItem() : NULL;
}
+
void CXFA_LayoutProcessor::ClearLayoutData() {
- if (m_pLayoutPageMgr) {
- delete m_pLayoutPageMgr;
- m_pLayoutPageMgr = NULL;
- }
- if (m_pRootItemLayoutProcessor) {
- delete m_pRootItemLayoutProcessor;
- m_pRootItemLayoutProcessor = NULL;
- }
+ delete m_pLayoutPageMgr;
+ m_pLayoutPageMgr = nullptr;
+ delete m_pRootItemLayoutProcessor;
+ m_pRootItemLayoutProcessor = nullptr;
m_nProgressCounter = 0;
}
+
FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() {
return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0;
}
@@ -180,7 +176,8 @@ int32_t CXFA_ContainerLayoutItem::GetPageIndex() const {
->GetLayoutPageMgr()
->GetPageIndex(this);
}
-void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) {
+
+void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) const {
size.clear();
CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Medium);
if (!pMedium)
@@ -193,6 +190,7 @@ void CXFA_ContainerLayoutItem::GetPageSize(CFX_SizeF& size) {
size = CFX_SizeF(size.y, size.x);
}
}
+
CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const {
return m_pFormNode;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.cpp
index 39590f6e8f8..ef85d0e2660 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.cpp
@@ -9,7 +9,6 @@
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -94,7 +93,7 @@ CFX_WideString XFA_ExportEncodeAttribute(const CFX_WideString& str) {
textBuf.AppendChar(str[i]);
}
}
- return textBuf.GetWideString();
+ return textBuf.MakeString();
}
CFX_WideString XFA_ExportEncodeContent(const CFX_WideStringC& str) {
CFX_WideTextBuf textBuf;
@@ -124,7 +123,7 @@ CFX_WideString XFA_ExportEncodeContent(const CFX_WideStringC& str) {
textBuf.AppendChar(str.GetAt(i));
}
}
- return textBuf.GetWideString();
+ return textBuf.MakeString();
}
static void XFA_SaveAttribute(CXFA_Node* pNode,
XFA_ATTRIBUTE eName,
@@ -166,7 +165,7 @@ FX_BOOL XFA_DataExporter_ContentNodeNeedtoExport(CXFA_Node* pContentNode) {
if (!pContentNode->TryContent(wsContent, FALSE, FALSE)) {
return FALSE;
}
- FXSYS_assert(pContentNode->GetObjectType() == XFA_OBJECTTYPE_ContentNode);
+ ASSERT(pContentNode->GetObjectType() == XFA_OBJECTTYPE_ContentNode);
CXFA_Node* pParentNode = pContentNode->GetNodeItem(XFA_NODEITEM_Parent);
if (!pParentNode || pParentNode->GetClassID() != XFA_ELEMENT_Value) {
return TRUE;
@@ -189,7 +188,7 @@ FX_BOOL XFA_DataExporter_ContentNodeNeedtoExport(CXFA_Node* pContentNode) {
static void XFA_DataExporter_RecognizeXFAVersionNumber(
CXFA_Node* pTemplateRoot,
CFX_WideString& wsVersionNumber) {
- wsVersionNumber.Empty();
+ wsVersionNumber.clear();
if (!pTemplateRoot) {
return;
}
@@ -260,7 +259,7 @@ static void XFA_DataExporter_RegenerateFormFile_Changed(
pTempStream->SetCodePage(FX_CODEPAGE_UTF8);
pRichTextXML->SaveXMLNode(pTempStream);
wsChildren += CFX_WideString::FromUTF8(
- (const FX_CHAR*)pMemStream->GetBuffer(), pMemStream->GetSize());
+ CFX_ByteStringC(pMemStream->GetBuffer(), pMemStream->GetSize()));
pTempStream->Release();
pMemStream->Release();
} else if (pRawValueNode->GetClassID() == XFA_ELEMENT_Sharpxml &&
@@ -283,10 +282,10 @@ static void XFA_DataExporter_RegenerateFormFile_Changed(
iEnd = wsRawValue.Find(L'\n', iStart);
}
CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent);
- FXSYS_assert(pParentNode);
+ ASSERT(pParentNode);
CXFA_Node* pGrandparentNode =
pParentNode->GetNodeItem(XFA_NODEITEM_Parent);
- FXSYS_assert(pGrandparentNode);
+ ASSERT(pGrandparentNode);
CFX_WideString bodyTagName;
bodyTagName = pGrandparentNode->GetCData(XFA_ATTRIBUTE_Name);
if (bodyTagName.IsEmpty()) {
@@ -297,13 +296,13 @@ static void XFA_DataExporter_RegenerateFormFile_Changed(
buf << FX_WSTRC(L" xmlns=\"\"\n>");
for (int32_t i = 0; i < wsSelTextArray.GetSize(); i++) {
buf << FX_WSTRC(L"<value\n>");
- buf << XFA_ExportEncodeContent(wsSelTextArray[i].AsWideStringC());
+ buf << XFA_ExportEncodeContent(wsSelTextArray[i].AsStringC());
buf << FX_WSTRC(L"</value\n>");
}
buf << FX_WSTRC(L"</");
buf << bodyTagName;
buf << FX_WSTRC(L"\n>");
- wsChildren += buf.GetWideString();
+ wsChildren += buf.AsStringC();
buf.Clear();
} else {
CFX_WideStringC wsValue = pRawValueNode->GetCData(XFA_ATTRIBUTE_Value);
@@ -330,19 +329,19 @@ static void XFA_DataExporter_RegenerateFormFile_Changed(
while (pChildNode) {
XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf,
bSaveXML);
- wsChildren += newBuf.GetWideString();
+ wsChildren += newBuf.AsStringC();
newBuf.Clear();
pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
if (!bSaveXML && !wsChildren.IsEmpty() &&
pNode->GetClassID() == XFA_ELEMENT_Items) {
- wsChildren.Empty();
+ wsChildren.clear();
bSaveXML = TRUE;
CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pChildNode) {
XFA_DataExporter_RegenerateFormFile_Changed(pChildNode, newBuf,
bSaveXML);
- wsChildren += newBuf.GetWideString();
+ wsChildren += newBuf.AsStringC();
newBuf.Clear();
pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
@@ -389,7 +388,7 @@ static void XFA_DataExporter_RegenerateFormFile_Container(
CFX_WideStringC wsElement;
pNode->GetClassName(wsElement);
pStream->WriteString(L"<", 1);
- pStream->WriteString(wsElement.raw_str(), wsElement.GetLength());
+ pStream->WriteString(wsElement.c_str(), wsElement.GetLength());
CFX_WideString wsOutput;
XFA_SaveAttribute(pNode, XFA_ATTRIBUTE_Name, FX_WSTRC(L"name"), TRUE,
wsOutput);
@@ -407,7 +406,7 @@ static void XFA_DataExporter_RegenerateFormFile_Container(
wsOutput += wsAttr;
}
if (!wsOutput.IsEmpty()) {
- pStream->WriteString((const FX_WCHAR*)wsOutput, wsOutput.GetLength());
+ pStream->WriteString(wsOutput.c_str(), wsOutput.GetLength());
}
CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
if (pChildNode) {
@@ -418,7 +417,7 @@ static void XFA_DataExporter_RegenerateFormFile_Container(
pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
pStream->WriteString(L"</", 2);
- pStream->WriteString(wsElement.raw_str(), wsElement.GetLength());
+ pStream->WriteString(wsElement.c_str(), wsElement.GetLength());
pStream->WriteString(L"\n>", 2);
} else {
pStream->WriteString(L"\n/>", 3);
@@ -429,15 +428,14 @@ void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode,
const FX_CHAR* pChecksum,
FX_BOOL bSaveXML) {
if (pNode->GetObjectType() == XFA_OBJECTTYPE_ModelNode) {
- static const FX_WCHAR* s_pwsTagName = L"<form";
- static const FX_WCHAR* s_pwsClose = L"</form\n>";
+ static const FX_WCHAR s_pwsTagName[] = L"<form";
+ static const FX_WCHAR s_pwsClose[] = L"</form\n>";
pStream->WriteString(s_pwsTagName, FXSYS_wcslen(s_pwsTagName));
if (pChecksum) {
- static const FX_WCHAR* s_pwChecksum = L" checksum=\"";
- CFX_WideString wsChecksum =
- CFX_WideString::FromUTF8(pChecksum, FXSYS_strlen(pChecksum));
+ static const FX_WCHAR s_pwChecksum[] = L" checksum=\"";
+ CFX_WideString wsChecksum = CFX_WideString::FromUTF8(pChecksum);
pStream->WriteString(s_pwChecksum, FXSYS_wcslen(s_pwChecksum));
- pStream->WriteString((const FX_WCHAR*)wsChecksum, wsChecksum.GetLength());
+ pStream->WriteString(wsChecksum.c_str(), wsChecksum.GetLength());
pStream->WriteString(L"\"", 1);
}
pStream->WriteString(L" xmlns=\"", FXSYS_wcslen(L" xmlns=\""));
@@ -451,8 +449,7 @@ void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode,
wsVersionNumber = FX_WSTRC(L"2.8");
}
wsVersionNumber += FX_WSTRC(L"/\"\n>");
- pStream->WriteString((const FX_WCHAR*)wsVersionNumber,
- wsVersionNumber.GetLength());
+ pStream->WriteString(wsVersionNumber.c_str(), wsVersionNumber.GetLength());
CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pChildNode) {
XFA_DataExporter_RegenerateFormFile_Container(pChildNode, pStream);
@@ -498,14 +495,14 @@ FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream,
if (pNode->GetObjectType() == XFA_OBJECTTYPE_ModelNode) {
switch (pNode->GetPacketID()) {
case XFA_XDPPACKET_XDP: {
- static const FX_WCHAR* s_pwsPreamble =
+ static const FX_WCHAR s_pwsPreamble[] =
L"<xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">";
pStream->WriteString(s_pwsPreamble, FXSYS_wcslen(s_pwsPreamble));
for (CXFA_Node* pChild = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
Export(pStream, pChild, dwFlag, pChecksum);
}
- static const FX_WCHAR* s_pwsPostamble = L"</xdp:xdp\n>";
+ static const FX_WCHAR s_pwsPostamble[] = L"</xdp:xdp\n>";
pStream->WriteString(s_pwsPostamble, FXSYS_wcslen(s_pwsPostamble));
} break;
case XFA_XDPPACKET_Datasets: {
@@ -515,7 +512,7 @@ FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream,
return FALSE;
}
CXFA_Node* pDataNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- FXSYS_assert(pDataNode);
+ ASSERT(pDataNode);
XFA_DataExporter_DealWithDataGroupNode(pDataNode);
pXMLDoc->SaveXMLNode(pStream, pElement);
} break;
@@ -550,8 +547,8 @@ FX_BOOL CXFA_DataExporter::Export(IFX_Stream* pStream,
return FALSE;
}
XFA_DataExporter_DealWithDataGroupNode(pExportNode);
- pElement->SetString(FX_WSTRC(L"xmlns:xfa"),
- FX_WSTRC(L"http://www.xfa.org/schema/xfa-data/1.0/"));
+ pElement->SetString(L"xmlns:xfa",
+ L"http://www.xfa.org/schema/xfa-data/1.0/");
pXMLDoc->SaveXMLNode(pStream, pElement);
pElement->RemoveAttribute(L"xmlns:xfa");
}
@@ -571,16 +568,16 @@ void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode) {
if (pDataNode->GetClassID() == XFA_ELEMENT_DataGroup) {
if (iChildNum > 0) {
CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode();
- FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element);
+ ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element);
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
if (pXMLElement->HasAttribute(L"xfa:dataNode")) {
pXMLElement->RemoveAttribute(L"xfa:dataNode");
}
} else {
CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode();
- FXSYS_assert(pXMLNode->GetType() == FDE_XMLNODE_Element);
- static_cast<CFDE_XMLElement*>(pXMLNode)
- ->SetString(FX_WSTRC(L"xfa:dataNode"), FX_WSTRC(L"dataGroup"));
+ ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element);
+ static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode",
+ L"dataGroup");
}
}
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.h
index 9bde4b038e2..9136efce90a 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_document_serialize.h
@@ -7,13 +7,18 @@
#ifndef XFA_FXFA_PARSER_XFA_DOCUMENT_SERIALIZE_H_
#define XFA_FXFA_PARSER_XFA_DOCUMENT_SERIALIZE_H_
-#include "xfa/fxfa/parser/xfa_docdata.h"
+#include "core/fxcrt/include/fx_string.h"
+
+class CXFA_Document;
+class CXFA_Node;
+class IFX_FileRead;
+class IFX_FileWrite;
+class IFX_Stream;
class CXFA_DataImporter {
public:
explicit CXFA_DataImporter(CXFA_Document* pDocument);
- void Release() { delete this; }
FX_BOOL ImportData(IFX_FileRead* pDataDocument);
protected:
@@ -24,7 +29,6 @@ class CXFA_DataExporter {
public:
explicit CXFA_DataExporter(CXFA_Document* pDocument);
- void Release() { delete this; }
FX_BOOL Export(IFX_FileWrite* pWrite);
FX_BOOL Export(IFX_FileWrite* pWrite,
CXFA_Node* pNode,
@@ -36,6 +40,7 @@ class CXFA_DataExporter {
CXFA_Node* pNode,
uint32_t dwFlag,
const FX_CHAR* pChecksum);
+
CXFA_Document* const m_pDocument;
};
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.cpp
index e223ab8ce74..dca11da80f5 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.cpp
@@ -8,7 +8,6 @@
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
@@ -21,26 +20,6 @@
#include "xfa/fxfa/parser/xfa_script.h"
#include "xfa/fxfa/parser/xfa_utils.h"
-uint32_t XFA_GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) {
- uint32_t dwRelevant = XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable;
- CFX_WideStringC wsRelevant;
- if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) {
- if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) {
- dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable;
- } else if (wsRelevant == FX_WSTRC(L"-print")) {
- dwRelevant &= ~XFA_LAYOUTSTATUS_Printable;
- }
- }
- if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Viewable) &&
- (dwRelevant != XFA_LAYOUTSTATUS_Viewable)) {
- dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable;
- }
- if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Printable) &&
- (dwRelevant != XFA_LAYOUTSTATUS_Printable)) {
- dwRelevant &= ~XFA_LAYOUTSTATUS_Printable;
- }
- return dwRelevant;
-}
void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) {
CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild;
CXFA_FFNotify* pNotify =
@@ -50,15 +29,15 @@ void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) {
while (pNode) {
CXFA_LayoutItem* pNext = pNode->m_pNextSibling;
pNode->m_pParent = nullptr;
- pNotify->OnLayoutEvent(pDocLayout, static_cast<CXFA_LayoutItem*>(pNode),
- XFA_LAYOUTEVENT_ItemRemoving);
+ pNotify->OnLayoutItemRemoving(pDocLayout,
+ static_cast<CXFA_LayoutItem*>(pNode));
XFA_ReleaseLayoutItem(pNode);
pNode = pNext;
}
- pNotify->OnLayoutEvent(pDocLayout, pLayoutItem, XFA_LAYOUTEVENT_ItemRemoving);
+ pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) {
pNotify->OnPageEvent(static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem),
- XFA_PAGEEVENT_PageRemoved);
+ XFA_PAGEVIEWEVENT_PostRemoved);
}
delete pLayoutItem;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.h
index eb4a9631d6f..be7072b704e 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_appadapter.h
@@ -71,7 +71,7 @@ class CXFA_TraverseStrategy_ContentLayoutItem {
return (CXFA_ContentLayoutItem*)pLayoutItem->m_pParent;
}
};
-uint32_t XFA_GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant);
+
void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem);
#endif // XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_itemlayout.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
index d69bf2506c0..ef2df840c99 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_itemlayout.cpp
@@ -12,7 +12,7 @@
#include "xfa/fgas/crt/fgas_algorithm.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
@@ -46,8 +46,8 @@ CXFA_ItemLayoutProcessor::CXFA_ItemLayoutProcessor(CXFA_Node* pNode,
m_bUseInheriated(FALSE),
m_ePreProcessRs(XFA_ItemLayoutProcessorResult_Done),
m_bHasAvailHeight(TRUE) {
- FXSYS_assert(m_pFormNode && (m_pFormNode->IsContainerNode() ||
- m_pFormNode->GetClassID() == XFA_ELEMENT_Form));
+ ASSERT(m_pFormNode && (m_pFormNode->IsContainerNode() ||
+ m_pFormNode->GetClassID() == XFA_ELEMENT_Form));
m_pOldLayoutItem =
(CXFA_ContentLayoutItem*)m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY);
}
@@ -545,28 +545,29 @@ void CXFA_LayoutItem::RemoveChild(CXFA_LayoutItem* pChildItem) {
CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::ExtractLayoutItem() {
CXFA_ContentLayoutItem* pLayoutItem = m_pLayoutItem;
if (pLayoutItem) {
- m_pLayoutItem = (CXFA_ContentLayoutItem*)pLayoutItem->m_pNextSibling;
- pLayoutItem->m_pNextSibling = NULL;
- }
- if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done &&
- ToContentLayoutItem(m_pOldLayoutItem)) {
- if (m_pOldLayoutItem->m_pPrev) {
- m_pOldLayoutItem->m_pPrev->m_pNext = NULL;
- }
- CXFA_FFNotify* pNotify =
- m_pOldLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify();
- CXFA_LayoutProcessor* pDocLayout =
- m_pOldLayoutItem->m_pFormNode->GetDocument()->GetDocLayout();
- CXFA_ContentLayoutItem* pOldLayoutItem = m_pOldLayoutItem;
- while (pOldLayoutItem) {
- CXFA_ContentLayoutItem* pNextOldLayoutItem = pOldLayoutItem->m_pNext;
- pNotify->OnLayoutEvent(pDocLayout, pOldLayoutItem,
- XFA_LAYOUTEVENT_ItemRemoving);
- delete pOldLayoutItem;
- pOldLayoutItem = pNextOldLayoutItem;
- }
- m_pOldLayoutItem = NULL;
+ m_pLayoutItem =
+ static_cast<CXFA_ContentLayoutItem*>(pLayoutItem->m_pNextSibling);
+ pLayoutItem->m_pNextSibling = nullptr;
}
+ if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages_Done ||
+ !ToContentLayoutItem(m_pOldLayoutItem))
+ return pLayoutItem;
+ if (m_pOldLayoutItem->m_pPrev)
+ m_pOldLayoutItem->m_pPrev->m_pNext = nullptr;
+ CXFA_FFNotify* pNotify =
+ m_pOldLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify();
+ CXFA_LayoutProcessor* pDocLayout =
+ m_pOldLayoutItem->m_pFormNode->GetDocument()->GetDocLayout();
+ CXFA_ContentLayoutItem* pOldLayoutItem = m_pOldLayoutItem;
+ while (pOldLayoutItem) {
+ CXFA_ContentLayoutItem* pNextOldLayoutItem = pOldLayoutItem->m_pNext;
+ pNotify->OnLayoutItemRemoving(pDocLayout, pOldLayoutItem);
+ if (pOldLayoutItem->m_pParent)
+ pOldLayoutItem->m_pParent->RemoveChild(pOldLayoutItem);
+ delete pOldLayoutItem;
+ pOldLayoutItem = pNextOldLayoutItem;
+ }
+ m_pOldLayoutItem = nullptr;
return pLayoutItem;
}
static FX_BOOL XFA_ItemLayoutProcessor_FindBreakNode(
@@ -629,8 +630,7 @@ static void XFA_DeleteLayoutGeneratedNode(CXFA_Node* pGenerateNode) {
CXFA_ContentLayoutItem* pNextLayoutItem = NULL;
while (pCurLayoutItem) {
pNextLayoutItem = pCurLayoutItem->m_pNext;
- pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem,
- XFA_LAYOUTEVENT_ItemRemoving);
+ pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
delete pCurLayoutItem;
pCurLayoutItem = pNextLayoutItem;
}
@@ -1380,7 +1380,7 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
CFX_WideStringC wsColumnWidths;
if (pLayoutNode->TryCData(XFA_ATTRIBUTE_ColumnWidths, wsColumnWidths)) {
CFX_WideStringArray widths;
- if (FX_SeparateStringW(wsColumnWidths.raw_str(), wsColumnWidths.GetLength(),
+ if (FX_SeparateStringW(wsColumnWidths.c_str(), wsColumnWidths.GetLength(),
L' ', widths) > 0) {
int32_t iCols = widths.GetSize();
CFX_WideString wsWidth;
@@ -1388,7 +1388,7 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
wsWidth = widths[i];
wsWidth.TrimLeft(L' ');
if (!wsWidth.IsEmpty()) {
- CXFA_Measurement measure(wsWidth.AsWideStringC());
+ CXFA_Measurement measure(wsWidth.AsStringC());
m_rgSpecifiedColumnWidths.Add(measure.ToUnit(XFA_UNIT_Pt));
}
}
@@ -1867,7 +1867,7 @@ void CXFA_ItemLayoutProcessor::ProcessUnUseBinds(CXFA_Node* pFormNode) {
pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL);
}
}
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode);
+ pNode->SetFlag(XFA_NODEFLAG_UnusedNode, true);
}
}
void CXFA_ItemLayoutProcessor::ProcessUnUseOverFlow(
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
index b12f4ce55dc..374d1dc44e7 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp
@@ -8,7 +8,6 @@
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_datamerger_imp.h"
@@ -23,6 +22,206 @@
#include "xfa/fxfa/parser/xfa_script_imp.h"
#include "xfa/fxfa/parser/xfa_utils.h"
+namespace {
+
+class PageSetContainerLayoutItem {
+ public:
+ static inline CXFA_ContainerLayoutItem* GetFirstChild(
+ CXFA_ContainerLayoutItem* pLayoutItem) {
+ if (pLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet)
+ return nullptr;
+
+ CXFA_ContainerLayoutItem* pChildItem =
+ static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pFirstChild);
+ while (pChildItem &&
+ pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) {
+ pChildItem =
+ static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling);
+ }
+ return pChildItem;
+ }
+
+ static inline CXFA_ContainerLayoutItem* GetNextSibling(
+ CXFA_ContainerLayoutItem* pLayoutItem) {
+ CXFA_ContainerLayoutItem* pChildItem =
+ static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pNextSibling);
+ while (pChildItem &&
+ pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) {
+ pChildItem =
+ static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling);
+ }
+ return pChildItem;
+ }
+
+ static inline CXFA_ContainerLayoutItem* GetParent(
+ CXFA_ContainerLayoutItem* pLayoutItem) {
+ return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent);
+ }
+};
+
+uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) {
+ uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable;
+ CFX_WideStringC wsRelevant;
+ if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) {
+ if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print"))
+ dwRelevant &= ~XFA_WidgetStatus_Viewable;
+ else if (wsRelevant == FX_WSTRC(L"-print"))
+ dwRelevant &= ~XFA_WidgetStatus_Printable;
+ }
+ if (!(dwParentRelvant & XFA_WidgetStatus_Viewable) &&
+ (dwRelevant != XFA_WidgetStatus_Viewable)) {
+ dwRelevant &= ~XFA_WidgetStatus_Viewable;
+ }
+ if (!(dwParentRelvant & XFA_WidgetStatus_Printable) &&
+ (dwRelevant != XFA_WidgetStatus_Printable)) {
+ dwRelevant &= ~XFA_WidgetStatus_Printable;
+ }
+ return dwRelevant;
+}
+
+void SyncContainer(CXFA_FFNotify* pNotify,
+ CXFA_LayoutProcessor* pDocLayout,
+ CXFA_LayoutItem* pContainerItem,
+ uint32_t dwRelevant,
+ FX_BOOL bVisible,
+ int32_t nPageIndex) {
+ FX_BOOL bVisibleItem = FALSE;
+ uint32_t dwStatus = 0;
+ uint32_t dwRelevantContainer = 0;
+ if (bVisible) {
+ XFA_ATTRIBUTEENUM eAttributeValue =
+ pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence);
+ if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible ||
+ eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) {
+ bVisibleItem = TRUE;
+ }
+ dwRelevantContainer = GetRelevant(pContainerItem->m_pFormNode, dwRelevant);
+ dwStatus =
+ (bVisibleItem ? XFA_WidgetStatus_Visible : 0) | dwRelevantContainer;
+ }
+ pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus);
+ for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild;
+ pChild = pChild->m_pNextSibling) {
+ if (pChild->IsContentLayoutItem()) {
+ SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer,
+ bVisibleItem, nPageIndex);
+ }
+ }
+}
+
+void ReorderLayoutItemToTail(CXFA_ContainerLayoutItem* pLayoutItem) {
+ CXFA_ContainerLayoutItem* pParentLayoutItem =
+ (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent;
+ if (!pParentLayoutItem)
+ return;
+
+ pParentLayoutItem->RemoveChild(pLayoutItem);
+ pParentLayoutItem->AddChild(pLayoutItem);
+}
+
+void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) {
+ CXFA_ContainerLayoutItem* pParentLayoutItem =
+ (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent;
+ if (!pParentLayoutItem)
+ return;
+
+ pParentLayoutItem->RemoveChild(pLayoutItem);
+}
+
+CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
+ FX_BOOL bNewExprStyle,
+ CFX_WideStringC& wsTargetExpr) {
+ CXFA_Document* pDocument = pPageSetRoot->GetDocument();
+ if (wsTargetExpr.IsEmpty())
+ return nullptr;
+
+ CFX_WideString wsTargetAll(wsTargetExpr);
+ wsTargetAll.TrimLeft();
+ wsTargetAll.TrimRight();
+ int32_t iSpliteIndex = 0;
+ FX_BOOL bTargetAllFind = TRUE;
+ while (iSpliteIndex != -1) {
+ CFX_WideString wsTargetExpr;
+ int32_t iSpliteNextIndex = 0;
+ if (!bTargetAllFind) {
+ iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex);
+ wsTargetExpr =
+ wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex);
+ } else {
+ wsTargetExpr = wsTargetAll;
+ }
+ if (wsTargetExpr.IsEmpty())
+ return nullptr;
+
+ bTargetAllFind = FALSE;
+ if (wsTargetExpr.GetAt(0) == '#') {
+ CXFA_Node* pNode = pDocument->GetNodeByID(
+ ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)),
+ wsTargetExpr.Mid(1).AsStringC());
+ if (pNode)
+ return pNode;
+ } else if (bNewExprStyle) {
+ CFX_WideString wsProcessedTarget = wsTargetExpr;
+ if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") &&
+ wsTargetExpr.Right(1) == FX_WSTRC(L")")) {
+ wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5);
+ }
+ XFA_RESOLVENODE_RS rs;
+ int32_t iCount = pDocument->GetScriptContext()->ResolveObjects(
+ pPageSetRoot, wsProcessedTarget.AsStringC(), rs,
+ XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
+ XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings |
+ XFA_RESOLVENODE_Parent);
+ if (iCount > 0 && rs.nodes[0]->IsNode())
+ return rs.nodes[0]->AsNode();
+ }
+ iSpliteIndex = iSpliteNextIndex;
+ }
+ return nullptr;
+}
+
+void SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) {
+ pNode->SetFlag(XFA_NODEFLAG_LayoutGeneratedNode, false);
+ pNode->ClearFlag(XFA_NODEFLAG_UnusedNode);
+}
+
+FX_BOOL CheckContentAreaNotUsed(
+ CXFA_ContainerLayoutItem* pPageAreaLayoutItem,
+ CXFA_Node* pContentArea,
+ CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) {
+ for (CXFA_ContainerLayoutItem* pLayoutItem =
+ (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild;
+ pLayoutItem;
+ pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) {
+ if (pLayoutItem->m_pFormNode == pContentArea) {
+ if (pLayoutItem->m_pFirstChild == NULL) {
+ pContentAreaLayoutItem = pLayoutItem;
+ return TRUE;
+ }
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem,
+ CXFA_FFNotify* pNotify,
+ CXFA_LayoutProcessor* pDocLayout) {
+ CXFA_LayoutItem* pNextLayoutItem;
+ CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
+ while (pCurLayoutItem) {
+ pNextLayoutItem = pCurLayoutItem->m_pNextSibling;
+ if (pCurLayoutItem->m_pFirstChild)
+ SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
+
+ pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
+ delete pCurLayoutItem;
+ pCurLayoutItem = pNextLayoutItem;
+ }
+}
+
+} // namespace
+
CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor)
: m_pLayoutProcessor(pLayoutProcessor),
m_pTemplatePageSetRoot(nullptr),
@@ -94,7 +293,7 @@ FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
return FALSE;
}
m_pTemplatePageSetRoot->InsertChild(pPageArea, NULL);
- pPageArea->SetFlag(XFA_NODEFLAG_Initialized);
+ pPageArea->SetFlag(XFA_NODEFLAG_Initialized, true);
}
CXFA_Node* pContentArea = pPageArea->GetChild(0, XFA_ELEMENT_ContentArea);
if (!pContentArea) {
@@ -104,7 +303,7 @@ FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
return FALSE;
}
pPageArea->InsertChild(pContentArea, NULL);
- pContentArea->SetFlag(XFA_NODEFLAG_Initialized);
+ pContentArea->SetFlag(XFA_NODEFLAG_Initialized, true);
pContentArea->SetMeasure(XFA_ATTRIBUTE_X,
CXFA_Measurement(0.25f, XFA_UNIT_In));
pContentArea->SetMeasure(XFA_ATTRIBUTE_Y,
@@ -122,7 +321,7 @@ FX_BOOL CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
return FALSE;
}
pPageArea->InsertChild(pMedium, NULL);
- pMedium->SetFlag(XFA_NODEFLAG_Initialized);
+ pMedium->SetFlag(XFA_NODEFLAG_Initialized, true);
pMedium->SetMeasure(XFA_ATTRIBUTE_Short,
CXFA_Measurement(8.5f, XFA_UNIT_In));
pMedium->SetMeasure(XFA_ATTRIBUTE_Long,
@@ -180,40 +379,22 @@ FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) {
}
return !bFirstTemPage || m_pCurrentContainerRecord;
}
-static void XFA_LayoutItemMgr_ReorderLayoutItemToTail(
- CXFA_ContainerLayoutItem* pLayoutItem) {
- CXFA_ContainerLayoutItem* pParentLayoutItem =
- (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent;
- if (!pParentLayoutItem) {
- return;
- }
- pParentLayoutItem->RemoveChild(pLayoutItem);
- pParentLayoutItem->AddChild(pLayoutItem);
-}
-static void XFA_LayoutItemMgr_RemoveLayoutItem(
- CXFA_ContainerLayoutItem* pLayoutItem) {
- CXFA_ContainerLayoutItem* pParentLayoutItem =
- (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent;
- if (!pParentLayoutItem) {
- return;
- }
- pParentLayoutItem->RemoveChild(pLayoutItem);
-}
+
void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord,
CXFA_ContainerRecord* pPrevRecord) {
if (!pNewRecord || !pPrevRecord) {
return;
}
if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) {
- XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurPageSet);
+ RemoveLayoutItem(pNewRecord->pCurPageSet);
return;
}
if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) {
- XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurPageArea);
+ RemoveLayoutItem(pNewRecord->pCurPageArea);
return;
}
if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) {
- XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurContentArea);
+ RemoveLayoutItem(pNewRecord->pCurContentArea);
return;
}
}
@@ -224,15 +405,15 @@ void CXFA_LayoutPageMgr::ReorderPendingLayoutRecordToTail(
return;
}
if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) {
- XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageSet);
+ ReorderLayoutItemToTail(pNewRecord->pCurPageSet);
return;
}
if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) {
- XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageArea);
+ ReorderLayoutItemToTail(pNewRecord->pCurPageArea);
return;
}
if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) {
- XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurContentArea);
+ ReorderLayoutItemToTail(pNewRecord->pCurContentArea);
return;
}
}
@@ -268,59 +449,6 @@ FX_FLOAT CXFA_LayoutPageMgr::GetAvailHeight() {
}
return XFA_LAYOUT_FLOAT_MAX;
}
-static CXFA_Node* XFA_ResolveBreakTarget(CXFA_Node* pPageSetRoot,
- FX_BOOL bNewExprStyle,
- CFX_WideStringC& wsTargetExpr) {
- CXFA_Document* pDocument = pPageSetRoot->GetDocument();
- if (wsTargetExpr.IsEmpty()) {
- return NULL;
- }
- CFX_WideString wsTargetAll = wsTargetExpr;
- wsTargetAll.TrimLeft();
- wsTargetAll.TrimRight();
- int32_t iSpliteIndex = 0;
- FX_BOOL bTargetAllFind = TRUE;
- while (iSpliteIndex != -1) {
- CFX_WideString wsTargetExpr;
- int32_t iSpliteNextIndex = 0;
- if (!bTargetAllFind) {
- iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex);
- wsTargetExpr =
- wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex);
- } else {
- wsTargetExpr = wsTargetAll;
- }
- if (wsTargetExpr.IsEmpty()) {
- return NULL;
- }
- bTargetAllFind = FALSE;
- if (wsTargetExpr.GetAt(0) == '#') {
- CXFA_Node* pNode = pDocument->GetNodeByID(
- ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)),
- wsTargetExpr.Mid(1).AsWideStringC());
- if (pNode) {
- return pNode;
- }
- } else if (bNewExprStyle) {
- CFX_WideString wsProcessedTarget = wsTargetExpr;
- if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") &&
- wsTargetExpr.Right(1) == FX_WSTRC(L")")) {
- wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5);
- }
- XFA_RESOLVENODE_RS rs;
- int32_t iCount = pDocument->GetScriptContext()->ResolveObjects(
- pPageSetRoot, wsProcessedTarget.AsWideStringC(), rs,
- XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
- XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings |
- XFA_RESOLVENODE_Parent);
- if (iCount > 0 && rs.nodes[0]->IsNode()) {
- return rs.nodes[0]->AsNode();
- }
- }
- iSpliteIndex = iSpliteNextIndex;
- }
- return NULL;
-}
FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) {
CFX_WideString wsExpression;
@@ -415,8 +543,7 @@ void CXFA_LayoutPageMgr::AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord,
(CXFA_ContainerLayoutItem*)pNotify->OnCreateLayoutItem(pNewPageArea);
m_PageArray.Add(pContainerItem);
m_nAvailPages++;
- pNotify->OnPageEvent(pContainerItem, XFA_PAGEEVENT_PageAdded,
- (void*)(uintptr_t)m_nAvailPages);
+ pNotify->OnPageEvent(pContainerItem, XFA_PAGEVIEWEVENT_PostRemoved);
pNewPageAreaLayoutItem = pContainerItem;
}
pNewRecord->pCurPageSet->AddChild(pNewPageAreaLayoutItem);
@@ -436,43 +563,14 @@ void CXFA_LayoutPageMgr::AddContentAreaLayoutItem(
pNewRecord->pCurPageArea->AddChild(pNewContentAreaLayoutItem);
pNewRecord->pCurContentArea = pNewContentAreaLayoutItem;
}
-class CXFA_TraverseStrategy_PageSetContainerLayoutItem {
- public:
- static inline CXFA_ContainerLayoutItem* GetFirstChild(
- CXFA_ContainerLayoutItem* pLayoutItem) {
- if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageSet) {
- CXFA_ContainerLayoutItem* pChildItem =
- (CXFA_ContainerLayoutItem*)pLayoutItem->m_pFirstChild;
- while (pChildItem &&
- pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) {
- pChildItem = (CXFA_ContainerLayoutItem*)pChildItem->m_pNextSibling;
- }
- return pChildItem;
- }
- return NULL;
- }
- static inline CXFA_ContainerLayoutItem* GetNextSibling(
- CXFA_ContainerLayoutItem* pLayoutItem) {
- CXFA_ContainerLayoutItem* pChildItem =
- (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling;
- while (pChildItem &&
- pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) {
- pChildItem = (CXFA_ContainerLayoutItem*)pChildItem->m_pNextSibling;
- }
- return pChildItem;
- }
- static inline CXFA_ContainerLayoutItem* GetParent(
- CXFA_ContainerLayoutItem* pLayoutItem) {
- return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent;
- }
-};
+
void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
CXFA_ContainerLayoutItem* pRootPageSetLayoutItem = m_pPageSetLayoutItemRoot;
for (; pRootPageSetLayoutItem;
pRootPageSetLayoutItem =
(CXFA_ContainerLayoutItem*)pRootPageSetLayoutItem->m_pNextSibling) {
CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem,
- CXFA_TraverseStrategy_PageSetContainerLayoutItem>
+ PageSetContainerLayoutItem>
sIterator(pRootPageSetLayoutItem);
for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent();
pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) {
@@ -649,25 +747,11 @@ FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_ELEMENT eBreakType,
if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) {
pTarget = NULL;
}
- if (m_nAvailPages % 2 != 1 || !m_pCurrentContainerRecord ||
- (pTarget &&
- pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode) ||
- bStartNew) {
- if (m_nAvailPages % 2 == 1) {
- }
- }
break;
case XFA_ATTRIBUTEENUM_PageEven:
if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) {
pTarget = NULL;
}
- if (m_nAvailPages % 2 != 0 || !m_pCurrentContainerRecord ||
- (pTarget &&
- pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode) ||
- bStartNew) {
- if (m_nAvailPages % 2 == 0) {
- }
- }
break;
case XFA_ATTRIBUTEENUM_Auto:
default:
@@ -695,13 +779,13 @@ FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
}
CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target);
CXFA_Node* pTarget =
- XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget);
+ ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget);
wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer);
wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader);
pBreakLeaderTemplate =
- XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakLeader);
+ ResolveBreakTarget(pContainer, TRUE, wsBreakLeader);
pBreakTrailerTemplate =
- XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer);
+ ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer);
if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget,
bStartNew)) {
return TRUE;
@@ -731,7 +815,7 @@ FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
CFX_WideStringC wsTarget = pCurNode->GetCData(
bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget);
CXFA_Node* pTarget =
- XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget);
+ ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget);
if (RunBreak(bBefore ? XFA_ELEMENT_BreakBefore : XFA_ELEMENT_BreakAfter,
pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before
: XFA_ATTRIBUTE_After),
@@ -744,10 +828,7 @@ FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
}
return FALSE;
}
-static void XFA_SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) {
- pNode->SetFlag(XFA_NODEFLAG_LayoutGeneratedNode, TRUE, FALSE);
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE, FALSE);
-}
+
FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter(
CXFA_Node* pBreakNode,
FX_BOOL bBefore,
@@ -771,7 +852,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter(
pBreakLeaderNode = pDocument->DataMerge_CopyContainer(
pLeaderTemplate, pFormNode, pDataScope, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode);
- XFA_SetLayoutGeneratedNodeFlag(pBreakLeaderNode);
+ SetLayoutGeneratedNodeFlag(pBreakLeaderNode);
}
if (pTrailerTemplate) {
if (!pDataScope) {
@@ -780,7 +861,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter(
pBreakTrailerNode = pDocument->DataMerge_CopyContainer(
pTrailerTemplate, pFormNode, pDataScope, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode);
- XFA_SetLayoutGeneratedNodeFlag(pBreakTrailerNode);
+ SetLayoutGeneratedNodeFlag(pBreakTrailerNode);
}
return TRUE;
}
@@ -803,7 +884,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer(
pBookendAppendNode = pDocument->DataMerge_CopyContainer(
pLeaderTemplate, pFormNode, pDataScope, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode);
- XFA_SetLayoutGeneratedNodeFlag(pBookendAppendNode);
+ SetLayoutGeneratedNodeFlag(pBookendAppendNode);
return TRUE;
}
}
@@ -829,8 +910,8 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
!wsOverflowTarget.IsEmpty()) {
if (!wsOverflowTarget.IsEmpty() && bCreatePage &&
!m_bCreateOverFlowPage) {
- CXFA_Node* pTarget = XFA_ResolveBreakTarget(m_pTemplatePageSetRoot,
- TRUE, wsOverflowTarget);
+ CXFA_Node* pTarget =
+ ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget);
if (pTarget) {
m_bCreateOverFlowPage = TRUE;
switch (pTarget->GetClassID()) {
@@ -849,9 +930,9 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
}
if (!bCreatePage) {
pLeaderTemplate =
- XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader);
+ ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader);
pTrailerTemplate =
- XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer);
+ ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer);
}
return pOverflowNode;
}
@@ -862,8 +943,8 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer);
pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget);
if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) {
- CXFA_Node* pTarget = XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE,
- wsOverflowTarget);
+ CXFA_Node* pTarget =
+ ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget);
if (pTarget) {
m_bCreateOverFlowPage = TRUE;
switch (pTarget->GetClassID()) {
@@ -881,10 +962,9 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
}
}
if (!bCreatePage) {
- pLeaderTemplate =
- XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader);
+ pLeaderTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader);
pTrailerTemplate =
- XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer);
+ ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer);
}
return pOverflowNode;
}
@@ -922,7 +1002,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode,
pLeaderNode = pDocument->DataMerge_CopyContainer(
pLeaderTemplate, pFormNode, pDataScope, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pLeaderNode);
- XFA_SetLayoutGeneratedNodeFlag(pLeaderNode);
+ SetLayoutGeneratedNodeFlag(pLeaderNode);
}
if (pTrailerTemplate) {
if (!pDataScope) {
@@ -931,7 +1011,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode,
pTrailerNode = pDocument->DataMerge_CopyContainer(
pTrailerTemplate, pFormNode, pDataScope, TRUE);
pDocument->DataMerge_UpdateBindingRelations(pTrailerNode);
- XFA_SetLayoutGeneratedNodeFlag(pTrailerNode);
+ SetLayoutGeneratedNodeFlag(pTrailerNode);
}
return TRUE;
}
@@ -956,7 +1036,7 @@ FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
wsBookendLeader);
if (!wsBookendLeader.IsEmpty()) {
pBookendAppendTemplate =
- XFA_ResolveBreakTarget(pContainer, FALSE, wsBookendLeader);
+ ResolveBreakTarget(pContainer, FALSE, wsBookendLeader);
return TRUE;
}
return FALSE;
@@ -965,7 +1045,7 @@ FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer,
wsBookendLeader);
pBookendAppendTemplate =
- XFA_ResolveBreakTarget(pContainer, TRUE, wsBookendLeader);
+ ResolveBreakTarget(pContainer, TRUE, wsBookendLeader);
return TRUE;
}
return FALSE;
@@ -1253,24 +1333,7 @@ CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea(
}
return NULL;
}
-static FX_BOOL XFA_LayoutPageMgr_CheckContentAreaNotUsed(
- CXFA_ContainerLayoutItem* pPageAreaLayoutItem,
- CXFA_Node* pContentArea,
- CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) {
- for (CXFA_ContainerLayoutItem* pLayoutItem =
- (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild;
- pLayoutItem;
- pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) {
- if (pLayoutItem->m_pFormNode == pContentArea) {
- if (pLayoutItem->m_pFirstChild == NULL) {
- pContentAreaLayoutItem = pLayoutItem;
- return TRUE;
- }
- return FALSE;
- }
- }
- return TRUE;
-}
+
FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) {
CXFA_Node* pCurContentNode =
GetCurrentContainerRecord()->pCurContentArea->m_pFormNode;
@@ -1285,9 +1348,8 @@ FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) {
return FALSE;
}
CXFA_ContainerLayoutItem* pContentAreaLayout = NULL;
- if (!XFA_LayoutPageMgr_CheckContentAreaNotUsed(
- GetCurrentContainerRecord()->pCurPageArea, pContentArea,
- pContentAreaLayout)) {
+ if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea,
+ pContentArea, pContentAreaLayout)) {
return FALSE;
}
if (pContentAreaLayout) {
@@ -1497,22 +1559,7 @@ CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem(
return pFormNode->GetDocument()->GetParser()->GetNotify()->OnCreateLayoutItem(
pFormNode);
}
-static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem,
- CXFA_FFNotify* pNotify,
- CXFA_LayoutProcessor* pDocLayout) {
- CXFA_LayoutItem* pNextLayoutItem;
- CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
- while (pCurLayoutItem) {
- pNextLayoutItem = pCurLayoutItem->m_pNextSibling;
- if (pCurLayoutItem->m_pFirstChild) {
- XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
- }
- pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem,
- XFA_LAYOUTEVENT_ItemRemoving);
- delete pCurLayoutItem;
- pCurLayoutItem = pNextLayoutItem;
- }
-}
+
void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) {
CXFA_LayoutItem* pNextLayoutItem;
CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
@@ -1526,10 +1573,9 @@ void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) {
CXFA_LayoutProcessor* pDocLayout =
m_pTemplatePageSetRoot->GetDocument()->GetDocLayout();
if (pCurLayoutItem->m_pFirstChild) {
- XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
+ SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
}
- pNotify->OnLayoutEvent(pDocLayout, pCurLayoutItem,
- XFA_LAYOUTEVENT_ItemRemoving);
+ pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
delete pCurLayoutItem;
pCurLayoutItem = pNextLayoutItem;
continue;
@@ -1539,7 +1585,7 @@ void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) {
sIterator(pCurLayoutItem->m_pFormNode);
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode, TRUE, FALSE);
+ pNode->SetFlag(XFA_NODEFLAG_UnusedNode, false);
}
}
}
@@ -1579,6 +1625,7 @@ CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow(
}
return NULL;
}
+
void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument();
CXFA_FFNotify* pNotify = pDocument->GetParser()->GetNotify();
@@ -1598,15 +1645,14 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
pNode->SetObject(XFA_ATTRIBUTE_BindingNode, NULL);
}
}
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode);
+ pNode->SetFlag(XFA_NODEFLAG_UnusedNode, true);
}
}
}
int32_t iIndex = 0;
- CXFA_Node* pPendingPageSet = NULL;
for (; pRootLayout;
pRootLayout = (CXFA_ContainerLayoutItem*)pRootLayout->m_pNextSibling) {
- pPendingPageSet = NULL;
+ CXFA_Node* pPendingPageSet = nullptr;
CXFA_NodeIteratorTemplate<
CXFA_ContainerLayoutItem,
CXFA_TraverseStrategy_ContentAreaContainerLayoutItem>
@@ -1633,7 +1679,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
NULL);
}
pRootPageSetContainerItem->m_pFormNode = pPendingPageSet;
- pPendingPageSet->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
+ pPendingPageSet->ClearFlag(XFA_NODEFLAG_UnusedNode);
for (CXFA_ContainerLayoutItem* pContainerItem = iterator.MoveToNext();
pContainerItem; pContainerItem = iterator.MoveToNext()) {
CXFA_Node* pNode = pContainerItem->m_pFormNode;
@@ -1679,8 +1725,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
pNode->GetUserData(XFA_LAYOUTITEMKEY));
if (pLayoutItem) {
- pNotify->OnLayoutEvent(pDocLayout, pLayoutItem,
- XFA_LAYOUTEVENT_ItemRemoving);
+ pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
delete pLayoutItem;
}
}
@@ -1720,14 +1765,14 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
pFormToplevelSubform->InsertChild(pPendingPageSet);
}
pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet);
- pPendingPageSet->SetFlag(XFA_NODEFLAG_Initialized);
+ pPendingPageSet->SetFlag(XFA_NODEFLAG_Initialized, true);
}
- pPendingPageSet = GetRootLayoutItem()->m_pFormNode;
- while (pPendingPageSet) {
- CXFA_Node* pNextPendingPageSet =
- pPendingPageSet->GetNextSameClassSibling(XFA_ELEMENT_PageSet);
+ CXFA_Node* pPageSet = GetRootLayoutItem()->m_pFormNode;
+ while (pPageSet) {
+ CXFA_Node* pNextPageSet =
+ pPageSet->GetNextSameClassSibling(XFA_ELEMENT_PageSet);
CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
- sIterator(pPendingPageSet);
+ sIterator(pPageSet);
CXFA_Node* pNode = sIterator.GetCurrent();
while (pNode) {
if (pNode->HasFlag(XFA_NODEFLAG_UnusedNode)) {
@@ -1740,8 +1785,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
pChildNode->GetUserData(XFA_LAYOUTITEMKEY));
if (pLayoutItem) {
- pNotify->OnLayoutEvent(pDocLayout, pLayoutItem,
- XFA_LAYOUTEVENT_ItemRemoving);
+ pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
delete pLayoutItem;
}
}
@@ -1749,8 +1793,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
pNode->GetUserData(XFA_LAYOUTITEMKEY));
if (pLayoutItem) {
- pNotify->OnLayoutEvent(pDocLayout, pLayoutItem,
- XFA_LAYOUTEVENT_ItemRemoving);
+ pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
delete pLayoutItem;
}
}
@@ -1758,18 +1801,19 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
pNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pNode);
pNode = pNext;
} else {
- pNode->SetFlag(XFA_NODEFLAG_UnusedNode, FALSE);
- pNode->SetFlag(XFA_NODEFLAG_Initialized);
+ pNode->ClearFlag(XFA_NODEFLAG_UnusedNode);
+ pNode->SetFlag(XFA_NODEFLAG_Initialized, true);
pNode = sIterator.MoveToNext();
}
} else {
- pNode->SetFlag(XFA_NODEFLAG_Initialized);
+ pNode->SetFlag(XFA_NODEFLAG_Initialized, true);
pNode = sIterator.MoveToNext();
}
}
- pPendingPageSet = pNextPendingPageSet;
+ pPageSet = pNextPageSet;
}
}
+
void CXFA_LayoutPageMgr::LayoutPageSetContents() {
CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem();
for (; pRootLayoutItem;
@@ -1793,38 +1837,7 @@ void CXFA_LayoutPageMgr::LayoutPageSetContents() {
}
}
}
-void XFA_SyncContainer(CXFA_FFNotify* pNotify,
- CXFA_LayoutProcessor* pDocLayout,
- CXFA_LayoutItem* pContainerItem,
- uint32_t dwRelevant,
- FX_BOOL bVisible,
- int32_t nPageIndex) {
- FX_BOOL bVisibleItem = FALSE;
- uint32_t dwStatus = 0;
- uint32_t dwRelevantContainer = 0;
- if (bVisible) {
- XFA_ATTRIBUTEENUM eAttributeValue =
- pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence);
- if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible ||
- eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) {
- bVisibleItem = TRUE;
- }
- dwRelevantContainer =
- XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant);
- dwStatus =
- (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer;
- }
- pNotify->OnLayoutEvent(pDocLayout, pContainerItem, XFA_LAYOUTEVENT_ItemAdded,
- (void*)(uintptr_t)nPageIndex,
- (void*)(uintptr_t)dwStatus);
- for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild;
- pChild = pChild->m_pNextSibling) {
- if (pChild->IsContentLayoutItem()) {
- XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer,
- bVisibleItem, nPageIndex);
- }
- }
-}
+
void CXFA_LayoutPageMgr::SyncLayoutData() {
MergePageSetContents();
LayoutPageSetContents();
@@ -1845,7 +1858,7 @@ void CXFA_LayoutPageMgr::SyncLayoutData() {
case XFA_ELEMENT_PageArea: {
nPageIdx++;
uint32_t dwRelevant =
- XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable;
+ XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable;
CXFA_NodeIteratorTemplate<CXFA_LayoutItem,
CXFA_TraverseStrategy_LayoutItem>
iterator(pContainerItem);
@@ -1861,9 +1874,9 @@ void CXFA_LayoutPageMgr::SyncLayoutData() {
(pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) ==
XFA_ATTRIBUTEENUM_Visible);
uint32_t dwRelevantChild =
- XFA_GetRelevant(pContentItem->m_pFormNode, dwRelevant);
- XFA_SyncContainer(pNotify, m_pLayoutProcessor, pContentItem,
- dwRelevantChild, bVisible, nPageIdx);
+ GetRelevant(pContentItem->m_pFormNode, dwRelevant);
+ SyncContainer(pNotify, m_pLayoutProcessor, pContentItem,
+ dwRelevantChild, bVisible, nPageIdx);
pChildLayoutItem = iterator.SkipChildrenAndMoveToNext();
}
} break;
@@ -1876,7 +1889,7 @@ void CXFA_LayoutPageMgr::SyncLayoutData() {
for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) {
CXFA_ContainerLayoutItem* pPage = m_PageArray[i];
m_PageArray.RemoveAt(i);
- pNotify->OnPageEvent(pPage, XFA_PAGEEVENT_PageRemoved);
+ pNotify->OnPageEvent(pPage, XFA_PAGEVIEWEVENT_PostRemoved);
delete pPage;
}
ClearRecordList();
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_locale.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_locale.cpp
index c77dc2637dc..7883856b676 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_locale.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_locale.cpp
@@ -8,7 +8,6 @@
#include "core/fxcrt/include/fx_xml.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -22,14 +21,13 @@ static const FX_WCHAR g_FX_Currency[] = L"$z,zzz,zzz,zzz,zzz,zz9.99";
static const FX_WCHAR g_FX_Decimal[] = L"z,zzz,zzz,zzz,zzz,zz9.zzz";
static const FX_WCHAR g_FX_Integer[] = L"z,zzz,zzz,zzz,zzz,zzz";
-CXFA_XMLLocale::CXFA_XMLLocale(CXML_Element* pLocaleData) {
- m_pLocaleData = pLocaleData;
-}
+CXFA_XMLLocale::CXFA_XMLLocale(CXML_Element* pLocaleData)
+ : m_pLocaleData(pLocaleData) {}
+
CXFA_XMLLocale::~CXFA_XMLLocale() {
- if (m_pLocaleData) {
- delete m_pLocaleData;
- }
+ delete m_pLocaleData;
}
+
void CXFA_XMLLocale::Release() {
delete this;
}
@@ -72,14 +70,13 @@ void CXFA_XMLLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
default:
return;
}
- CXML_Element* pElement =
- m_pLocaleData->GetElement("", bsSymbols.AsByteStringC());
+ CXML_Element* pElement = m_pLocaleData->GetElement("", bsSymbols.AsStringC());
if (!pElement) {
return;
}
- GetPattern(pElement, CFX_ByteStringC((const FX_CHAR*)bsSymbols,
- bsSymbols.GetLength() - 1),
- wsName.AsWideStringC(), wsNumSymbol);
+ GetPattern(pElement,
+ CFX_ByteStringC(bsSymbols.c_str(), bsSymbols.GetLength() - 1),
+ wsName.AsStringC(), wsNumSymbol);
}
void CXFA_XMLLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const {
if (!m_pLocaleData) {
@@ -87,7 +84,7 @@ void CXFA_XMLLocale::GetDateTimeSymbols(CFX_WideString& wsDtSymbol) const {
}
CFX_ByteString bsSpace;
CXML_Element* pNumberSymbols =
- m_pLocaleData->GetElement(bsSpace.AsByteStringC(), "dateTimeSymbols");
+ m_pLocaleData->GetElement(bsSpace.AsStringC(), "dateTimeSymbols");
if (!pNumberSymbols) {
return;
}
@@ -122,11 +119,10 @@ CFX_WideString CXFA_XMLLocale::GetCalendarSymbol(const CFX_ByteStringC& symbol,
CXML_Element* pChild = m_pLocaleData->GetElement("", "calendarSymbols");
if (pChild) {
CXML_Element* pSymbolNames =
- pChild->GetElement("", pstrSymbolNames.AsByteStringC());
+ pChild->GetElement("", pstrSymbolNames.AsStringC());
if (pSymbolNames) {
if (pSymbolNames->GetAttrInteger("abbr") != bAbbr) {
- pSymbolNames =
- pChild->GetElement("", pstrSymbolNames.AsByteStringC(), 1);
+ pSymbolNames = pChild->GetElement("", pstrSymbolNames.AsStringC(), 1);
}
if (pSymbolNames && pSymbolNames->GetAttrInteger("abbr") == bAbbr) {
CXML_Element* pSymbolName =
@@ -162,7 +158,7 @@ void CXFA_XMLLocale::GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
wsName = L"long";
break;
}
- GetPattern(pElement, "datePattern", wsName.AsWideStringC(), wsPattern);
+ GetPattern(pElement, "datePattern", wsName.AsStringC(), wsPattern);
}
void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
CFX_WideString& wsPattern) const {
@@ -186,7 +182,7 @@ void CXFA_XMLLocale::GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY eType,
wsName = L"long";
break;
}
- GetPattern(pElement, "timePattern", wsName.AsWideStringC(), wsPattern);
+ GetPattern(pElement, "timePattern", wsName.AsStringC(), wsPattern);
}
void CXFA_XMLLocale::GetNumPattern(FX_LOCALENUMSUBCATEGORY eType,
CFX_WideString& wsPattern) const {
@@ -230,7 +226,8 @@ void CXFA_NodeLocale::Release() {
delete this;
}
CFX_WideString CXFA_NodeLocale::GetName() {
- return m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name) : NULL;
+ return CFX_WideString(m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name)
+ : nullptr);
}
void CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType,
CFX_WideString& wsNumSymbol) const {
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.cpp
index 0c098300940..0982537b157 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.cpp
@@ -6,11 +6,10 @@
#include "xfa/fxfa/parser/xfa_localemgr.h"
+#include "core/fxcodec/include/fx_codec.h"
#include "core/fxcrt/include/fx_xml.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_locale.h"
@@ -1132,17 +1131,14 @@ CXFA_LocaleMgr::CXFA_LocaleMgr(CXFA_Node* pLocaleSet, CFX_WideString wsDeflcid)
pNodeLocale = pNodeLocale->GetNodeItem(XFA_NODEITEM_NextSibling);
}
}
- m_pDefLocale = GetLocaleByName(wsDeflcid.AsWideStringC());
+ m_pDefLocale = GetLocaleByName(wsDeflcid);
}
CXFA_LocaleMgr::~CXFA_LocaleMgr() {
- int32_t iCount = m_LocaleArray.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- ((IFX_Locale*)m_LocaleArray[i])->Release();
- }
- int32_t iXmls = m_XMLLocaleArray.GetSize();
- for (int32_t j = 0; j < iXmls; j++) {
- ((IFX_Locale*)m_XMLLocaleArray[j])->Release();
- }
+ for (int32_t i = 0; i < m_LocaleArray.GetSize(); i++)
+ m_LocaleArray[i]->Release();
+
+ for (int32_t j = 0; j < m_XMLLocaleArray.GetSize(); j++)
+ m_XMLLocaleArray[j]->Release();
}
void CXFA_LocaleMgr::Release() {
delete this;
@@ -1150,19 +1146,24 @@ void CXFA_LocaleMgr::Release() {
uint16_t CXFA_LocaleMgr::GetDefLocaleID() {
return m_dwDeflcid;
}
+
IFX_Locale* CXFA_LocaleMgr::GetDefLocale() {
- if (m_pDefLocale) {
+ if (m_pDefLocale)
return m_pDefLocale;
- } else if (m_LocaleArray.GetSize()) {
- return (IFX_Locale*)m_LocaleArray[0];
- } else if (m_XMLLocaleArray.GetSize()) {
- return (IFX_Locale*)m_XMLLocaleArray[0];
- }
+
+ if (m_LocaleArray.GetSize())
+ return m_LocaleArray[0];
+
+ if (m_XMLLocaleArray.GetSize())
+ return m_XMLLocaleArray[0];
+
m_pDefLocale = GetLocale(m_dwDeflcid);
if (m_pDefLocale)
m_XMLLocaleArray.Add(m_pDefLocale);
+
return m_pDefLocale;
}
+
IFX_Locale* CXFA_LocaleMgr::GetLocale(uint16_t lcid) {
IFX_Locale* pLocal = NULL;
switch (lcid) {
@@ -1216,11 +1217,11 @@ IFX_Locale* CXFA_LocaleMgr::GetLocale(uint16_t lcid) {
return pLocal;
}
IFX_Locale* CXFA_LocaleMgr::GetLocaleByName(
- const CFX_WideStringC& wsLocaleName) {
+ const CFX_WideString& wsLocaleName) {
int32_t iCount = m_LocaleArray.GetSize();
int32_t i = 0;
for (i = 0; i < iCount; i++) {
- IFX_Locale* pLocale = ((IFX_Locale*)m_LocaleArray[i]);
+ IFX_Locale* pLocale = m_LocaleArray[i];
if (pLocale->GetName() == wsLocaleName) {
return pLocale;
}
@@ -1231,7 +1232,7 @@ IFX_Locale* CXFA_LocaleMgr::GetLocaleByName(
}
iCount = m_XMLLocaleArray.GetSize();
for (i = 0; i < iCount; i++) {
- IFX_Locale* pLocale = ((IFX_Locale*)m_XMLLocaleArray[i]);
+ IFX_Locale* pLocale = m_XMLLocaleArray[i];
if (pLocale->GetName() == wsLocaleName) {
return pLocale;
}
@@ -1247,7 +1248,7 @@ void CXFA_LocaleMgr::SetDefLocale(IFX_Locale* pLocale) {
}
CFX_WideStringC CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) {
if (!(m_dwLocaleFlags & 0x01)) {
- m_wsConfigLocale.Empty();
+ m_wsConfigLocale.clear();
if (pConfig) {
CXFA_Node* pChildfConfig =
pConfig->GetFirstChildByClass(XFA_ELEMENT_Acrobat);
@@ -1266,13 +1267,13 @@ CFX_WideStringC CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) {
}
m_dwLocaleFlags |= 0x01;
}
- return m_wsConfigLocale.AsWideStringC();
+ return m_wsConfigLocale.AsStringC();
}
static CXFA_TimeZoneProvider* g_pProvider = NULL;
// Static.
CXFA_TimeZoneProvider* CXFA_TimeZoneProvider::Create() {
- FXSYS_assert(!g_pProvider);
+ ASSERT(!g_pProvider);
g_pProvider = new CXFA_TimeZoneProvider();
return g_pProvider;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.h
index 62b8c679242..a3a1d4c2b9d 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localemgr.h
@@ -10,7 +10,6 @@
#include "xfa/fgas/localization/fgas_datetime.h"
#include "xfa/fgas/localization/fgas_locale.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
-#include "xfa/include/fxfa/fxfa_objectacc.h"
class CXFA_Node;
class IFX_Locale;
@@ -34,18 +33,20 @@ class IFX_Locale;
class CXFA_LocaleMgr : public IFX_LocaleMgr {
public:
CXFA_LocaleMgr(CXFA_Node* pLocaleSet, CFX_WideString wsDeflcid);
- virtual void Release();
- virtual uint16_t GetDefLocaleID();
- virtual IFX_Locale* GetDefLocale();
- virtual IFX_Locale* GetLocale(uint16_t lcid);
- virtual IFX_Locale* GetLocaleByName(const CFX_WideStringC& wsLocaleName);
+
+ void Release() override;
+ uint16_t GetDefLocaleID() override;
+ IFX_Locale* GetDefLocale() override;
+ IFX_Locale* GetLocale(uint16_t lcid) override;
+ IFX_Locale* GetLocaleByName(const CFX_WideString& wsLocaleName) override;
+
~CXFA_LocaleMgr();
void SetDefLocale(IFX_Locale* pLocale);
CFX_WideStringC GetConfigLocaleName(CXFA_Node* pConfig);
protected:
- CFX_PtrArray m_LocaleArray;
- CFX_PtrArray m_XMLLocaleArray;
+ CFX_ArrayTemplate<IFX_Locale*> m_LocaleArray;
+ CFX_ArrayTemplate<IFX_Locale*> m_XMLLocaleArray;
IFX_Locale* m_pDefLocale;
CFX_WideString m_wsConfigLocale;
uint16_t m_dwDeflcid;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.cpp
index 99738c60ae5..7530d80f5ac 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.cpp
@@ -6,8 +6,8 @@
#include "xfa/fxfa/parser/xfa_localevalue.h"
+#include "xfa/fgas/localization/fgas_localeimp.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -105,7 +105,10 @@ FX_BOOL CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue,
if (pLocale) {
m_pLocaleMgr->SetDefLocale(pLocale);
}
- IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE);
+ CFX_FormatString* pFormat = nullptr;
+ if (m_pLocaleMgr)
+ pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);
+
CFX_WideStringArray wsPatterns;
pFormat->SplitFormatString(wsPattern, wsPatterns);
FX_BOOL bRet = FALSE;
@@ -138,7 +141,7 @@ FX_BOOL CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue,
}
case FX_LOCALECATEGORY_Text:
bRet = pFormat->ParseText(wsValue, wsFormat, wsOutput);
- wsOutput.Empty();
+ wsOutput.clear();
if (!bRet) {
bRet = pFormat->FormatText(wsValue, wsFormat, wsOutput);
}
@@ -215,7 +218,7 @@ FX_FLOAT CXFA_LocaleValue::GetNum() const {
int32_t nExponent = 0;
int cc = 0;
FX_BOOL bNegative = FALSE, bExpSign = FALSE;
- const FX_WCHAR* str = (const FX_WCHAR*)m_wsValue;
+ const FX_WCHAR* str = m_wsValue.c_str();
int len = m_wsValue.GetLength();
while (XFA_IsSpace(str[cc]) && cc < len) {
cc++;
@@ -290,7 +293,7 @@ FX_DOUBLE CXFA_LocaleValue::GetDoubleNum() const {
int32_t nExponent = 0;
int32_t cc = 0;
FX_BOOL bNegative = FALSE, bExpSign = FALSE;
- const FX_WCHAR* str = (const FX_WCHAR*)m_wsValue;
+ const FX_WCHAR* str = m_wsValue.c_str();
int len = m_wsValue.GetLength();
while (XFA_IsSpace(str[cc]) && cc < len) {
cc++;
@@ -368,8 +371,8 @@ CFX_Unitime CXFA_LocaleValue::GetDate() const {
CFX_Unitime CXFA_LocaleValue::GetTime() const {
if (m_bValid && m_dwType == XFA_VT_TIME) {
CFX_Unitime dt(0);
- FXSYS_assert(m_pLocaleMgr);
- FX_TimeFromCanonical(m_wsValue.AsWideStringC(), dt,
+ ASSERT(m_pLocaleMgr);
+ FX_TimeFromCanonical(m_wsValue.AsStringC(), dt,
m_pLocaleMgr->GetDefLocale());
return dt;
}
@@ -380,9 +383,9 @@ CFX_Unitime CXFA_LocaleValue::GetDateTime() const {
int32_t index = m_wsValue.Find('T');
CFX_Unitime dt;
FX_DateFromCanonical(m_wsValue.Left(index), dt);
- FXSYS_assert(m_pLocaleMgr);
+ ASSERT(m_pLocaleMgr);
FX_TimeFromCanonical(
- m_wsValue.Right(m_wsValue.GetLength() - index - 1).AsWideStringC(), dt,
+ m_wsValue.Right(m_wsValue.GetLength() - index - 1).AsStringC(), dt,
m_pLocaleMgr->GetDefLocale());
return dt;
}
@@ -460,9 +463,13 @@ FX_BOOL CXFA_LocaleValue::FormatPatterns(CFX_WideString& wsResult,
const CFX_WideString& wsFormat,
IFX_Locale* pLocale,
XFA_VALUEPICTURE eValueType) const {
- wsResult.Empty();
+ wsResult.clear();
FX_BOOL bRet = FALSE;
- IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE);
+
+ CFX_FormatString* pFormat = nullptr;
+ if (m_pLocaleMgr)
+ pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);
+
CFX_WideStringArray wsPatterns;
pFormat->SplitFormatString(wsFormat, wsPatterns);
int32_t iCount = wsPatterns.GetSize();
@@ -484,9 +491,13 @@ FX_BOOL CXFA_LocaleValue::FormatSinglePattern(
if (pLocale) {
m_pLocaleMgr->SetDefLocale(pLocale);
}
- wsResult.Empty();
+ wsResult.clear();
FX_BOOL bRet = FALSE;
- IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE);
+
+ CFX_FormatString* pFormat = nullptr;
+ if (m_pLocaleMgr)
+ pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);
+
FX_LOCALECATEGORY eCategory = pFormat->GetCategory(wsFormat);
eCategory = XFA_ValugeCategory(eCategory, m_dwType);
switch (eCategory) {
@@ -603,7 +614,7 @@ FX_BOOL CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate,
uint16_t wYear = 0;
uint16_t wMonth = 0;
uint16_t wDay = 0;
- const FX_WCHAR* pDate = (const FX_WCHAR*)wsDate;
+ const FX_WCHAR* pDate = wsDate.c_str();
int nIndex = 0, nStart = 0;
while (pDate[nIndex] != '\0' && nIndex < wCountY) {
if (!XFA_IsDigit(pDate[nIndex])) {
@@ -689,7 +700,7 @@ FX_BOOL CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) {
uint16_t wMinute = 0;
uint16_t wSecond = 0;
uint16_t wFraction = 0;
- const FX_WCHAR* pTime = (const FX_WCHAR*)wsTime;
+ const FX_WCHAR* pTime = wsTime.c_str();
int nIndex = 0;
int nStart = 0;
while (nIndex - nStart < wCountH && pTime[nIndex]) {
@@ -793,7 +804,11 @@ FX_BOOL CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue,
if (pLocale) {
m_pLocaleMgr->SetDefLocale(pLocale);
}
- IFX_FormatString* pFormat = IFX_FormatString::Create(m_pLocaleMgr, FALSE);
+
+ CFX_FormatString* pFormat = nullptr;
+ if (m_pLocaleMgr)
+ pFormat = new CFX_FormatString(m_pLocaleMgr, FALSE);
+
CFX_WideStringArray wsPatterns;
pFormat->SplitFormatString(wsPattern, wsPatterns);
FX_BOOL bRet = FALSE;
@@ -806,7 +821,7 @@ FX_BOOL CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue,
case FX_LOCALECATEGORY_Null:
bRet = pFormat->ParseNull(wsValue, wsFormat);
if (bRet) {
- m_wsValue.Empty();
+ m_wsValue.clear();
}
break;
case FX_LOCALECATEGORY_Zero:
@@ -875,8 +890,8 @@ void CXFA_LocaleValue::GetNumbericFormat(CFX_WideString& wsFormat,
int32_t nIntLen,
int32_t nDecLen,
FX_BOOL bSign) {
- FXSYS_assert(wsFormat.IsEmpty());
- FXSYS_assert(nIntLen >= -1 && nDecLen >= -1);
+ ASSERT(wsFormat.IsEmpty());
+ ASSERT(nIntLen >= -1 && nDecLen >= -1);
int32_t nTotalLen = (nIntLen >= 0 ? nIntLen : 2) + (bSign ? 1 : 0) +
(nDecLen >= 0 ? nDecLen : 2) + (nDecLen == 0 ? 0 : 1);
FX_WCHAR* lpBuf = wsFormat.GetBuffer(nTotalLen);
@@ -948,7 +963,7 @@ FX_BOOL CXFA_LocaleValue::ValidateNumericTemp(CFX_WideString& wsNumeric,
return FALSE;
}
while (nf < nCountFmt && (cf = pFmt[nf]) != L'.') {
- FXSYS_assert(cf == L'z' || cf == L'*');
+ ASSERT(cf == L'z' || cf == L'*');
++nf;
}
CFX_WideString wsDecimalSymbol;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.h
index bd88b0c325d..912af93eebf 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_localevalue.h
@@ -7,7 +7,9 @@
#ifndef XFA_FXFA_PARSER_XFA_LOCALEVALUE_H_
#define XFA_FXFA_PARSER_XFA_LOCALEVALUE_H_
-#include "xfa/include/fxfa/fxfa_objectacc.h"
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fxfa/parser/cxfa_widgetdata.h"
class IFX_Locale;
class CFX_Unitime;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object.h
index 3279941a4a3..f6267b5998b 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXFA_PARSER_XFA_OBJECT_H_
#define XFA_FXFA_PARSER_XFA_OBJECT_H_
+#include <unordered_set>
+
#include "xfa/fde/xml/fde_xml.h"
#include "xfa/fxfa/parser/xfa_utils.h"
#include "xfa/fxjse/cfxjse_arguments.h"
@@ -48,22 +50,22 @@ class CXFA_Object {
return (XFA_OBJECTTYPE)(m_uFlags & XFA_OBJECTTYPEMASK);
}
- FX_BOOL IsNode() const {
+ bool IsNode() const {
return (m_uFlags & XFA_OBJECTTYPEMASK) >= XFA_OBJECTTYPE_Node;
}
- FX_BOOL IsOrdinaryObject() const {
+ bool IsOrdinaryObject() const {
return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_OrdinaryObject;
}
- FX_BOOL IsNodeList() const {
+ bool IsNodeList() const {
return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_NodeList;
}
- FX_BOOL IsOrdinaryList() const {
+ bool IsOrdinaryList() const {
return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_OrdinaryList;
}
- FX_BOOL IsContentNode() const {
+ bool IsContentNode() const {
return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_ContentNode;
}
- FX_BOOL IsContainerNode() const {
+ bool IsContainerNode() const {
return (m_uFlags & XFA_OBJECTTYPEMASK) == XFA_OBJECTTYPE_ContainerNode;
}
@@ -87,6 +89,7 @@ class CXFA_Object {
CXFA_Document* const m_pDocument;
uint32_t m_uFlags;
};
+using CXFA_ObjArray = CFX_ArrayTemplate<CXFA_Object*>;
#define XFA_NODEFILTER_Children 0x01
#define XFA_NODEFILTER_Properties 0x02
@@ -104,9 +107,9 @@ enum XFA_SOM_MESSAGETYPE {
XFA_SOM_MandatoryMessage
};
-typedef CFX_ArrayTemplate<CXFA_Node*> CXFA_NodeArray;
-typedef CFX_StackTemplate<CXFA_Node*> CXFA_NodeStack;
-typedef CXFA_PtrSetTemplate<CXFA_Node*> CXFA_NodeSet;
+using CXFA_NodeArray = CFX_ArrayTemplate<CXFA_Node*>;
+using CXFA_NodeStack = CFX_StackTemplate<CXFA_Node*>;
+using CXFA_NodeSet = std::unordered_set<CXFA_Node*>;
typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData);
struct XFA_MAPDATABLOCKCALLBACKINFO {
@@ -133,9 +136,11 @@ class CXFA_Node : public CXFA_Object {
XFA_ELEMENT GetClassID() const { return (XFA_ELEMENT)m_eNodeClass; }
uint32_t GetPacketID() const { return m_ePacket; }
FX_BOOL HasFlag(uint32_t dwFlag) const;
- void SetFlag(uint32_t dwFlag, FX_BOOL bOn = TRUE, FX_BOOL bNotify = TRUE);
+ void SetFlag(uint32_t dwFlag, bool bNotify);
+ void ClearFlag(uint32_t dwFlag);
+
FX_BOOL IsAttributeInXML();
- FX_BOOL IsFormContainer() {
+ bool IsFormContainer() const {
return m_ePacket == XFA_XDPPACKET_Form && IsContainerNode();
}
void SetXMLMappingNode(CFDE_XMLNode* pXMLNode) { m_pXMLNode = pXMLNode; }
@@ -149,20 +154,20 @@ class CXFA_Node : public CXFA_Object {
FX_BOOL HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit = FALSE);
FX_BOOL SetAttribute(XFA_ATTRIBUTE eAttr,
const CFX_WideStringC& wsValue,
- FX_BOOL bNotify = FALSE);
+ bool bNotify = false);
FX_BOOL GetAttribute(XFA_ATTRIBUTE eAttr,
CFX_WideString& wsValue,
FX_BOOL bUseDefault = TRUE);
FX_BOOL SetAttribute(const CFX_WideStringC& wsAttr,
const CFX_WideStringC& wsValue,
- FX_BOOL bNotify = FALSE);
+ bool bNotify = false);
FX_BOOL GetAttribute(const CFX_WideStringC& wsAttr,
CFX_WideString& wsValue,
FX_BOOL bUseDefault = TRUE);
FX_BOOL RemoveAttribute(const CFX_WideStringC& wsAttr);
FX_BOOL SetContent(const CFX_WideString& wsContent,
const CFX_WideString& wsXMLValue,
- FX_BOOL bNotify = FALSE,
+ bool bNotify = false,
FX_BOOL bScriptModify = FALSE,
FX_BOOL bSyncData = TRUE);
FX_BOOL TryContent(CFX_WideString& wsContent,
@@ -174,7 +179,7 @@ class CXFA_Node : public CXFA_Object {
FX_BOOL SetBoolean(XFA_ATTRIBUTE eAttr,
FX_BOOL bValue,
- FX_BOOL bNotify = FALSE) {
+ bool bNotify = false) {
return SetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, (void*)(uintptr_t)bValue,
bNotify);
}
@@ -187,7 +192,7 @@ class CXFA_Node : public CXFA_Object {
}
FX_BOOL SetInteger(XFA_ATTRIBUTE eAttr,
int32_t iValue,
- FX_BOOL bNotify = FALSE) {
+ bool bNotify = false) {
return SetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, (void*)(uintptr_t)iValue,
bNotify);
}
@@ -200,7 +205,7 @@ class CXFA_Node : public CXFA_Object {
}
FX_BOOL SetEnum(XFA_ATTRIBUTE eAttr,
XFA_ATTRIBUTEENUM eValue,
- FX_BOOL bNotify = FALSE) {
+ bool bNotify = false) {
return SetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, (void*)(uintptr_t)eValue,
bNotify);
}
@@ -213,11 +218,11 @@ class CXFA_Node : public CXFA_Object {
}
FX_BOOL SetCData(XFA_ATTRIBUTE eAttr,
const CFX_WideString& wsValue,
- FX_BOOL bNotify = FALSE,
+ bool bNotify = false,
FX_BOOL bScriptModify = FALSE);
FX_BOOL SetAttributeValue(const CFX_WideString& wsValue,
const CFX_WideString& wsXMLValue,
- FX_BOOL bNotify = FALSE,
+ bool bNotify = false,
FX_BOOL bScriptModify = FALSE);
FX_BOOL TryCData(XFA_ATTRIBUTE eAttr,
CFX_WideString& wsValue,
@@ -233,7 +238,7 @@ class CXFA_Node : public CXFA_Object {
}
FX_BOOL SetMeasure(XFA_ATTRIBUTE eAttr,
CXFA_Measurement mValue,
- FX_BOOL bNotify = FALSE);
+ bool bNotify = false);
FX_BOOL TryMeasure(XFA_ATTRIBUTE eAttr,
CXFA_Measurement& mValue,
FX_BOOL bUseDefault = TRUE) const;
@@ -263,7 +268,7 @@ class CXFA_Node : public CXFA_Object {
FX_BOOL bOnlyChild = FALSE);
int32_t InsertChild(int32_t index, CXFA_Node* pNode);
FX_BOOL InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode = NULL);
- FX_BOOL RemoveChild(CXFA_Node* pNode, FX_BOOL bNotify = TRUE);
+ FX_BOOL RemoveChild(CXFA_Node* pNode, bool bNotify = true);
CXFA_Node* Clone(FX_BOOL bRecursive);
CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const;
CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_OBJECTTYPE eType) const;
@@ -375,8 +380,7 @@ class CXFA_Node : public CXFA_Object {
void Script_Delta_Target(FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute);
- void Script_Attribute_SendAttributeChangeMessage(void* eAttribute,
- void* eValue,
+ void Script_Attribute_SendAttributeChangeMessage(XFA_ATTRIBUTE eAttribute,
FX_BOOL bScriptModify);
void Script_Attribute_Integer(FXJSE_HVALUE hValue,
FX_BOOL bSetting,
@@ -592,22 +596,19 @@ class CXFA_Node : public CXFA_Object {
FX_BOOL SetValue(XFA_ATTRIBUTE eAttr,
XFA_ATTRIBUTETYPE eType,
void* pValue,
- FX_BOOL bNotify);
+ bool bNotify);
FX_BOOL GetValue(XFA_ATTRIBUTE eAttr,
XFA_ATTRIBUTETYPE eType,
FX_BOOL bUseDefault,
void*& pValue);
- void OnRemoved(CXFA_Node* pParent, CXFA_Node* pRemoved, FX_BOOL bNotify);
- void OnChanging(XFA_ATTRIBUTE eAttr, void* pNewValue, FX_BOOL bNotify);
- void OnChanged(XFA_ATTRIBUTE eAttr,
- void* pNewValue,
- FX_BOOL bNotify,
- FX_BOOL bScriptModify = FALSE);
+ void OnRemoved(bool bNotify);
+ void OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify);
+ void OnChanged(XFA_ATTRIBUTE eAttr, bool bNotify, FX_BOOL bScriptModify);
int32_t execSingleEventByName(const CFX_WideStringC& wsEventName,
XFA_ELEMENT eElementType);
FX_BOOL SetScriptContent(const CFX_WideString& wsContent,
const CFX_WideString& wsXMLValue,
- FX_BOOL bNotify = TRUE,
+ bool bNotify = true,
FX_BOOL bScriptModify = FALSE,
FX_BOOL bSyncData = TRUE);
CFX_WideString GetScriptContent(FX_BOOL bScriptModify = FALSE);
@@ -784,21 +785,9 @@ inline const CXFA_NodeList* CXFA_Object::AsNodeList() const {
inline CXFA_Node* ToNode(CXFA_Object* pObj) {
return pObj ? pObj->AsNode() : nullptr;
}
-inline CXFA_OrdinaryObject* ToOrdinaryObject(CXFA_Object* pObj) {
- return pObj ? pObj->AsOrdinaryObject() : nullptr;
-}
-inline CXFA_NodeList* ToNodeList(CXFA_Object* pObj) {
- return pObj ? pObj->AsNodeList() : nullptr;
-}
inline const CXFA_Node* ToNode(const CXFA_Object* pObj) {
return pObj ? pObj->AsNode() : nullptr;
}
-inline const CXFA_OrdinaryObject* ToOrdinaryObject(const CXFA_Object* pObj) {
- return pObj ? pObj->AsOrdinaryObject() : nullptr;
-}
-inline const CXFA_NodeList* ToNodeList(const CXFA_Object* pObj) {
- return pObj ? pObj->AsNodeList() : nullptr;
-}
#endif // XFA_FXFA_PARSER_XFA_OBJECT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object_imp.cpp
index 1dd526571d4..0fbde1f1605 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -6,14 +6,17 @@
#include "xfa/fxfa/parser/xfa_object.h"
+#include <memory>
+
#include "core/fxcrt/include/fx_ext.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fgas/crt/fgas_system.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
+#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/xfa_basic_imp.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
@@ -56,24 +59,24 @@ void CXFA_Object::Script_ObjectClass_ClassName(FXJSE_HVALUE hValue,
CFX_WideStringC className;
GetClassName(className);
FXJSE_Value_SetUTF8String(
- hValue, FX_UTF8Encode(className.raw_str(), className.GetLength())
- .AsByteStringC());
+ hValue,
+ FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC());
} else {
ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET);
}
}
void CXFA_Object::ThrowScriptErrorMessage(int32_t iStringID, ...) {
IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
- FXSYS_assert(pAppProvider);
+ ASSERT(pAppProvider);
CFX_WideString wsFormat;
pAppProvider->LoadString(iStringID, wsFormat);
CFX_WideString wsMessage;
va_list arg_ptr;
va_start(arg_ptr, iStringID);
- wsMessage.FormatV((const FX_WCHAR*)wsFormat, arg_ptr);
+ wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
va_end(arg_ptr);
FXJSE_ThrowMessage(
- "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC());
+ "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
}
static void XFA_DeleteWideString(void* pData) {
@@ -108,7 +111,7 @@ CXFA_Node::CXFA_Node(CXFA_Document* pDoc,
ASSERT(m_pDocument);
}
CXFA_Node::~CXFA_Node() {
- FXSYS_assert(m_pParent == NULL);
+ ASSERT(m_pParent == NULL);
RemoveMapModuleKey();
CXFA_Node *pNext, *pNode = m_pChild;
while (pNode) {
@@ -137,7 +140,7 @@ CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) {
CFDE_XMLElement* pCloneXMLElement = new CFDE_XMLElement(wsName);
CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value);
if (!wsValue.IsEmpty()) {
- pCloneXMLElement->SetTextData(wsValue);
+ pCloneXMLElement->SetTextData(CFX_WideString(wsValue));
}
pCloneXML = pCloneXMLElement;
pCloneXMLElement = NULL;
@@ -146,7 +149,7 @@ CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) {
pCloneXML = m_pXMLNode->Clone(FALSE);
}
pClone->SetXMLMappingNode(pCloneXML);
- pClone->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE);
+ pClone->SetFlag(XFA_NODEFLAG_OwnXMLNode, false);
}
if (bRecursive) {
for (CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild); pChild;
@@ -154,7 +157,7 @@ CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) {
pClone->InsertChild(pChild->Clone(bRecursive));
}
}
- pClone->SetFlag(XFA_NODEFLAG_Initialized);
+ pClone->SetFlag(XFA_NODEFLAG_Initialized, true);
pClone->SetObject(XFA_ATTRIBUTE_BindingNode, NULL);
return pClone;
}
@@ -299,7 +302,7 @@ int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes,
break;
}
InsertChild(pNewNode, NULL);
- pNewNode->SetFlag(XFA_NODEFLAG_Initialized);
+ pNewNode->SetFlag(XFA_NODEFLAG_Initialized, true);
nodes.Add(pNewNode);
break;
}
@@ -312,11 +315,11 @@ CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_ELEMENT eElement,
uint32_t dwFlags) {
CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory();
CXFA_Node* pNode = pFactory->CreateNode(m_ePacket, eElement);
- pNode->SetFlag(dwFlags);
+ pNode->SetFlag(dwFlags, true);
return pNode;
}
CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) {
- FXSYS_assert(m_ePacket == XFA_XDPPACKET_Template);
+ ASSERT(m_ePacket == XFA_XDPPACKET_Template);
CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory();
CXFA_Node* pClone = pFactory->CreateNode(XFA_XDPPACKET_Form, m_eNodeClass);
if (!pClone) {
@@ -331,7 +334,7 @@ CXFA_Node* CXFA_Node::CloneTemplateToForm(FX_BOOL bRecursive) {
pClone->InsertChild(pChild->CloneTemplateToForm(bRecursive));
}
}
- pClone->SetFlag(XFA_NODEFLAG_Initialized);
+ pClone->SetFlag(XFA_NODEFLAG_Initialized, true);
return pClone;
}
@@ -500,7 +503,7 @@ CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() {
FX_BOOL CXFA_Node::GetLocaleName(CFX_WideString& wsLocaleName) {
CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode();
CXFA_Node* pTopSubform = pForm->GetFirstChildByClass(XFA_ELEMENT_Subform);
- FXSYS_assert(pTopSubform);
+ ASSERT(pTopSubform);
CXFA_Node* pLocaleNode = this;
FX_BOOL bLocale = FALSE;
do {
@@ -623,7 +626,7 @@ CXFA_Node* CXFA_Node::GetDataDescriptionNode() {
return NULL;
}
void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) {
- FXSYS_assert(m_ePacket == XFA_XDPPACKET_Datasets);
+ ASSERT(m_ePacket == XFA_XDPPACKET_Datasets);
m_pAuxNode = pDataDescriptionNode;
}
void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
@@ -632,10 +635,8 @@ void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resolveNode");
return;
}
- CFX_WideString wsExpression;
- CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ CFX_WideString wsExpression =
+ CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
if (!pScriptContext) {
return;
@@ -649,7 +650,7 @@ void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
- refNode, wsExpression.AsWideStringC(), resoveNodeRS, dwFlag);
+ refNode, wsExpression.AsStringC(), resoveNodeRS, dwFlag);
if (iRet < 1) {
return FXJSE_Value_SetNull(pArguments->GetReturnValue());
}
@@ -679,10 +680,8 @@ void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) {
L"resolveNodes");
return;
}
- CFX_WideString wsExpression;
- CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ CFX_WideString wsExpression =
+ CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
FXJSE_HVALUE hValue = pArguments->GetReturnValue();
if (!hValue) {
return;
@@ -708,7 +707,7 @@ void CXFA_Node::Script_Som_ResolveNodeList(FXJSE_HVALUE hValue,
if (refNode == NULL) {
refNode = this;
}
- pScriptContext->ResolveObjects(refNode, wsExpression.AsWideStringC(),
+ pScriptContext->ResolveObjects(refNode, wsExpression.AsStringC(),
resoveNodeRS, dwFlag);
CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(m_pDocument);
if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
@@ -752,11 +751,12 @@ void CXFA_Node::Script_TreeClass_Nodes(FXJSE_HVALUE hValue,
}
if (bSetting) {
IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
- FXSYS_assert(pAppProvider);
+ ASSERT(pAppProvider);
CFX_WideString wsMessage;
pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage);
FXJSE_ThrowMessage(
- "", FX_UTF8Encode(wsMessage, wsMessage.GetLength()).AsByteStringC());
+ "",
+ FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
} else {
CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this);
FXJSE_Value_SetObject(hValue, (CXFA_Object*)pNodeList,
@@ -818,7 +818,7 @@ void CXFA_Node::Script_TreeClass_SomExpression(FXJSE_HVALUE hValue,
CFX_WideString wsSOMExpression;
GetSOMExpression(wsSOMExpression);
FXJSE_Value_SetUTF8String(hValue,
- FX_UTF8Encode(wsSOMExpression).AsByteStringC());
+ FX_UTF8Encode(wsSOMExpression).AsStringC());
}
}
void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) {
@@ -827,10 +827,9 @@ void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) {
ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"applyXSL");
return;
}
- CFX_WideString wsExpression;
- CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ CFX_WideString wsExpression =
+ CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
+ // TODO(tsepez): actually do something here?
}
void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
@@ -843,12 +842,11 @@ void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) {
int32_t iAction = 0;
if (iLength >= 1) {
CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC());
}
if (iLength >= 2) {
CFX_ByteString bsValue = pArguments->GetUTF8String(1);
- wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
}
if (iLength >= 3) {
iAction = pArguments->GetInt32(2);
@@ -874,15 +872,13 @@ void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) {
L"getAttribute");
return;
}
- CFX_WideString wsExpression;
- CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ CFX_WideString wsExpression =
+ CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
CFX_WideString wsValue;
- GetAttribute(wsExpression.AsWideStringC(), wsValue);
+ GetAttribute(wsExpression.AsStringC(), wsValue);
FXJSE_HVALUE hValue = pArguments->GetReturnValue();
if (hValue) {
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsStringC());
}
}
void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) {
@@ -895,14 +891,13 @@ void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) {
int32_t iValue = 0;
if (iLength >= 1) {
CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC());
}
if (iLength >= 2) {
iValue = pArguments->GetInt32(1);
}
const XFA_ELEMENTINFO* pElementInfo =
- XFA_GetElementByName(wsExpression.AsWideStringC());
+ XFA_GetElementByName(wsExpression.AsStringC());
CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName);
FXJSE_Value_Set(pArguments->GetReturnValue(),
m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode));
@@ -920,8 +915,7 @@ void CXFA_Node::Script_NodeClass_IsPropertySpecified(
int32_t iIndex = 0;
if (iLength >= 1) {
CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC());
}
if (iLength >= 2) {
bParent = pArguments->GetInt32(1) == 0 ? FALSE : TRUE;
@@ -931,14 +925,14 @@ void CXFA_Node::Script_NodeClass_IsPropertySpecified(
}
FX_BOOL bHas = FALSE;
const XFA_ATTRIBUTEINFO* pAttributeInfo =
- XFA_GetAttributeByName(wsExpression.AsWideStringC());
+ XFA_GetAttributeByName(wsExpression.AsStringC());
CFX_WideString wsValue;
if (pAttributeInfo) {
bHas = HasAttribute(pAttributeInfo->eName);
}
if (!bHas) {
const XFA_ELEMENTINFO* pElementInfo =
- XFA_GetElementByName(wsExpression.AsWideStringC());
+ XFA_GetElementByName(wsExpression.AsStringC());
bHas = (GetProperty(iIndex, pElementInfo->eName) != NULL);
}
FXJSE_HVALUE hValue = pArguments->GetReturnValue();
@@ -957,8 +951,7 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
FX_BOOL bOverwrite = 0;
if (iLength >= 1) {
CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC());
if (wsExpression.IsEmpty()) {
return;
}
@@ -988,7 +981,8 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
CXFA_Node* pFakeRoot = Clone(FALSE);
CFX_WideStringC wsContentType = GetCData(XFA_ATTRIBUTE_ContentType);
if (!wsContentType.IsEmpty()) {
- pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+ pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType,
+ CFX_WideString(wsContentType));
}
CFDE_XMLNode* pFakeXMLRoot = pFakeRoot->GetXMLMappingNode();
if (!pFakeXMLRoot) {
@@ -998,7 +992,7 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
if (!pFakeXMLRoot) {
CFX_WideStringC wsClassName;
GetClassName(wsClassName);
- pFakeXMLRoot = new CFDE_XMLElement(wsClassName);
+ pFakeXMLRoot = new CFDE_XMLElement(CFX_WideString(wsClassName));
}
if (bIgnoreRoot) {
CFDE_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFDE_XMLNode::FirstChild);
@@ -1027,7 +1021,7 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
CXFA_Node* pItem = pNewChild->GetNodeItem(XFA_NODEITEM_NextSibling);
pFakeRoot->RemoveChild(pNewChild);
InsertChild(index++, pNewChild);
- pNewChild->SetFlag(XFA_NODEFLAG_Initialized);
+ pNewChild->SetFlag(XFA_NODEFLAG_Initialized, true);
pNewChild = pItem;
}
while (pChild) {
@@ -1040,7 +1034,7 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
GetClassID() == XFA_ELEMENT_ExData) {
CFDE_XMLNode* pTempXMLNode = GetXMLMappingNode();
SetXMLMappingNode(pFakeXMLRoot);
- SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE);
+ SetFlag(XFA_NODEFLAG_OwnXMLNode, false);
if (pTempXMLNode &&
pTempXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL) {
pFakeXMLRoot = pTempXMLNode;
@@ -1055,15 +1049,15 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
pFakeRoot->RemoveChild(pChild);
InsertChild(pChild);
- pChild->SetFlag(XFA_NODEFLAG_Initialized);
+ pChild->SetFlag(XFA_NODEFLAG_Initialized, true);
pChild = pItem;
}
}
if (pFakeXMLRoot) {
pFakeRoot->SetXMLMappingNode(pFakeXMLRoot);
- pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE);
+ pFakeRoot->SetFlag(XFA_NODEFLAG_OwnXMLNode, false);
}
- pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, TRUE, FALSE);
+ pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, false);
} else {
if (pFakeXMLRoot) {
pFakeXMLRoot->Release();
@@ -1154,15 +1148,11 @@ void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) {
L"setAttribute");
return;
}
- CFX_WideString wsAttribute;
- CFX_WideString wsAttributeValue;
- CFX_ByteString bsAttributeValue = pArguments->GetUTF8String(0);
- CFX_ByteString bsAttribute = pArguments->GetUTF8String(1);
- wsAttributeValue =
- CFX_WideString::FromUTF8(bsAttributeValue, bsAttributeValue.GetLength());
- wsAttribute = CFX_WideString::FromUTF8(bsAttribute, bsAttribute.GetLength());
- SetAttribute(wsAttribute.AsWideStringC(), wsAttributeValue.AsWideStringC(),
- TRUE);
+ CFX_WideString wsAttributeValue =
+ CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
+ CFX_WideString wsAttribute =
+ CFX_WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringC());
+ SetAttribute(wsAttribute.AsStringC(), wsAttributeValue.AsStringC(), TRUE);
}
void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) {
int32_t iLength = pArguments->GetLength();
@@ -1177,7 +1167,7 @@ void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) {
}
if (iLength >= 2) {
CFX_ByteString bsName = pArguments->GetUTF8String(1);
- wsName = CFX_WideString::FromUTF8(bsName, bsName.GetLength());
+ wsName = CFX_WideString::FromUTF8(bsName.AsStringC());
}
}
void CXFA_Node::Script_NodeClass_Ns(FXJSE_HVALUE hValue,
@@ -1188,8 +1178,7 @@ void CXFA_Node::Script_NodeClass_Ns(FXJSE_HVALUE hValue,
} else {
CFX_WideString wsNameSpace;
TryNamespace(wsNameSpace);
- FXJSE_Value_SetUTF8String(hValue,
- FX_UTF8Encode(wsNameSpace).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsNameSpace).AsStringC());
}
}
void CXFA_Node::Script_NodeClass_Model(FXJSE_HVALUE hValue,
@@ -1261,8 +1250,7 @@ void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) {
CFX_WideString wsNameSpace;
if (iLength >= 1) {
CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0);
- wsNameSpace =
- CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength());
+ wsNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC());
}
CFX_WideString wsNodeNameSpace;
TryNamespace(wsNodeNameSpace);
@@ -1281,7 +1269,7 @@ void CXFA_Node::Script_Attribute_Integer(FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- SetInteger(eAttribute, FXJSE_Value_ToInteger(hValue), TRUE);
+ SetInteger(eAttribute, FXJSE_Value_ToInteger(hValue), true);
} else {
FXJSE_Value_SetInteger(hValue, GetInteger(eAttribute));
}
@@ -1299,7 +1287,7 @@ void CXFA_Node::Script_Attribute_BOOL(FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- SetBoolean(eAttribute, FXJSE_Value_ToBoolean(hValue), TRUE);
+ SetBoolean(eAttribute, FXJSE_Value_ToBoolean(hValue), true);
} else {
FXJSE_Value_SetUTF8String(hValue, GetBoolean(eAttribute) ? "1" : "0");
}
@@ -1313,181 +1301,169 @@ void CXFA_Node::Script_Attribute_BOOLRead(FXJSE_HVALUE hValue,
ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET);
}
}
+
void CXFA_Node::Script_Attribute_SendAttributeChangeMessage(
- void* eAttribute,
- void* eValue,
+ XFA_ATTRIBUTE eAttribute,
FX_BOOL bScriptModify) {
CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
- if (!pLayoutPro) {
+ if (!pLayoutPro)
return;
- }
+
CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
- if (!pNotify) {
+ if (!pNotify)
return;
- }
+
uint32_t dwPacket = GetPacketID();
- if (dwPacket & XFA_XDPPACKET_Form) {
- FX_BOOL bNeedFindContainer = FALSE;
- XFA_ELEMENT eType = GetClassID();
- switch (eType) {
- case XFA_ELEMENT_Caption:
- bNeedFindContainer = TRUE;
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, this, GetNodeItem(XFA_NODEITEM_Parent));
- break;
- case XFA_ELEMENT_Font:
- case XFA_ELEMENT_Para: {
- bNeedFindContainer = TRUE;
- CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent);
- if (pParentNode->GetClassID() == XFA_ELEMENT_Caption) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pParentNode,
- pParentNode->GetNodeItem(XFA_NODEITEM_Parent));
- } else {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, this, pParentNode);
- }
- } break;
- case XFA_ELEMENT_Margin: {
- bNeedFindContainer = TRUE;
- CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent);
- XFA_ELEMENT eParentType = pParentNode->GetClassID();
- if (pParentNode->IsContainerNode()) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, this, pParentNode);
- } else if (eParentType == XFA_ELEMENT_Caption) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pParentNode,
- pParentNode->GetNodeItem(XFA_NODEITEM_Parent));
- } else {
- CXFA_Node* pNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (pNode && pNode->GetClassID() == XFA_ELEMENT_Ui) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pNode,
- pNode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- }
- } break;
- case XFA_ELEMENT_Comb: {
- CXFA_Node* pEditNode = GetNodeItem(XFA_NODEITEM_Parent);
- XFA_ELEMENT eUIType = pEditNode->GetClassID();
- if (pEditNode && (eUIType == XFA_ELEMENT_DateTimeEdit ||
- eUIType == XFA_ELEMENT_NumericEdit ||
- eUIType == XFA_ELEMENT_TextEdit)) {
- CXFA_Node* pUINode = pEditNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (pUINode) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pUINode,
- pUINode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- }
- } break;
- case XFA_ELEMENT_Button:
- case XFA_ELEMENT_Barcode:
- case XFA_ELEMENT_ChoiceList:
- case XFA_ELEMENT_DateTimeEdit:
- case XFA_ELEMENT_NumericEdit:
- case XFA_ELEMENT_PasswordEdit:
- case XFA_ELEMENT_TextEdit: {
- CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent);
- if (pUINode) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pUINode,
- pUINode->GetNodeItem(XFA_NODEITEM_Parent));
+ if (!(dwPacket & XFA_XDPPACKET_Form)) {
+ pNotify->OnValueChanged(this, eAttribute, this, this);
+ return;
+ }
+
+ bool bNeedFindContainer = false;
+ XFA_ELEMENT eType = GetClassID();
+ switch (eType) {
+ case XFA_ELEMENT_Caption:
+ bNeedFindContainer = true;
+ pNotify->OnValueChanged(this, eAttribute, this,
+ GetNodeItem(XFA_NODEITEM_Parent));
+ break;
+ case XFA_ELEMENT_Font:
+ case XFA_ELEMENT_Para: {
+ bNeedFindContainer = true;
+ CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent);
+ if (pParentNode->GetClassID() == XFA_ELEMENT_Caption) {
+ pNotify->OnValueChanged(this, eAttribute, pParentNode,
+ pParentNode->GetNodeItem(XFA_NODEITEM_Parent));
+ } else {
+ pNotify->OnValueChanged(this, eAttribute, this, pParentNode);
+ }
+ } break;
+ case XFA_ELEMENT_Margin: {
+ bNeedFindContainer = true;
+ CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent);
+ XFA_ELEMENT eParentType = pParentNode->GetClassID();
+ if (pParentNode->IsContainerNode()) {
+ pNotify->OnValueChanged(this, eAttribute, this, pParentNode);
+ } else if (eParentType == XFA_ELEMENT_Caption) {
+ pNotify->OnValueChanged(this, eAttribute, pParentNode,
+ pParentNode->GetNodeItem(XFA_NODEITEM_Parent));
+ } else {
+ CXFA_Node* pNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent);
+ if (pNode && pNode->GetClassID() == XFA_ELEMENT_Ui) {
+ pNotify->OnValueChanged(this, eAttribute, pNode,
+ pNode->GetNodeItem(XFA_NODEITEM_Parent));
}
- } break;
- case XFA_ELEMENT_CheckButton: {
- bNeedFindContainer = TRUE;
- CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent);
+ }
+ } break;
+ case XFA_ELEMENT_Comb: {
+ CXFA_Node* pEditNode = GetNodeItem(XFA_NODEITEM_Parent);
+ XFA_ELEMENT eUIType = pEditNode->GetClassID();
+ if (pEditNode && (eUIType == XFA_ELEMENT_DateTimeEdit ||
+ eUIType == XFA_ELEMENT_NumericEdit ||
+ eUIType == XFA_ELEMENT_TextEdit)) {
+ CXFA_Node* pUINode = pEditNode->GetNodeItem(XFA_NODEITEM_Parent);
if (pUINode) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pUINode,
- pUINode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- } break;
- case XFA_ELEMENT_Keep:
- case XFA_ELEMENT_Bookend:
- case XFA_ELEMENT_Break:
- case XFA_ELEMENT_BreakAfter:
- case XFA_ELEMENT_BreakBefore:
- case XFA_ELEMENT_Overflow:
- bNeedFindContainer = TRUE;
- break;
- case XFA_ELEMENT_Area:
- case XFA_ELEMENT_Draw:
- case XFA_ELEMENT_ExclGroup:
- case XFA_ELEMENT_Field:
- case XFA_ELEMENT_Subform:
- case XFA_ELEMENT_SubformSet:
- pLayoutPro->AddChangedContainer(this);
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, this, this);
- break;
- case XFA_ELEMENT_Sharptext:
- case XFA_ELEMENT_Sharpxml:
- case XFA_ELEMENT_SharpxHTML: {
- CXFA_Node* pTextNode = GetNodeItem(XFA_NODEITEM_Parent);
- if (!pTextNode) {
- return;
+ pNotify->OnValueChanged(this, eAttribute, pUINode,
+ pUINode->GetNodeItem(XFA_NODEITEM_Parent));
}
- CXFA_Node* pValueNode = pTextNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (!pValueNode) {
- return;
+ }
+ } break;
+ case XFA_ELEMENT_Button:
+ case XFA_ELEMENT_Barcode:
+ case XFA_ELEMENT_ChoiceList:
+ case XFA_ELEMENT_DateTimeEdit:
+ case XFA_ELEMENT_NumericEdit:
+ case XFA_ELEMENT_PasswordEdit:
+ case XFA_ELEMENT_TextEdit: {
+ CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent);
+ if (pUINode) {
+ pNotify->OnValueChanged(this, eAttribute, pUINode,
+ pUINode->GetNodeItem(XFA_NODEITEM_Parent));
+ }
+ } break;
+ case XFA_ELEMENT_CheckButton: {
+ bNeedFindContainer = true;
+ CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent);
+ if (pUINode) {
+ pNotify->OnValueChanged(this, eAttribute, pUINode,
+ pUINode->GetNodeItem(XFA_NODEITEM_Parent));
+ }
+ } break;
+ case XFA_ELEMENT_Keep:
+ case XFA_ELEMENT_Bookend:
+ case XFA_ELEMENT_Break:
+ case XFA_ELEMENT_BreakAfter:
+ case XFA_ELEMENT_BreakBefore:
+ case XFA_ELEMENT_Overflow:
+ bNeedFindContainer = true;
+ break;
+ case XFA_ELEMENT_Area:
+ case XFA_ELEMENT_Draw:
+ case XFA_ELEMENT_ExclGroup:
+ case XFA_ELEMENT_Field:
+ case XFA_ELEMENT_Subform:
+ case XFA_ELEMENT_SubformSet:
+ pLayoutPro->AddChangedContainer(this);
+ pNotify->OnValueChanged(this, eAttribute, this, this);
+ break;
+ case XFA_ELEMENT_Sharptext:
+ case XFA_ELEMENT_Sharpxml:
+ case XFA_ELEMENT_SharpxHTML: {
+ CXFA_Node* pTextNode = GetNodeItem(XFA_NODEITEM_Parent);
+ if (!pTextNode) {
+ return;
+ }
+ CXFA_Node* pValueNode = pTextNode->GetNodeItem(XFA_NODEITEM_Parent);
+ if (!pValueNode) {
+ return;
+ }
+ XFA_ELEMENT eType = pValueNode->GetClassID();
+ if (eType == XFA_ELEMENT_Value) {
+ bNeedFindContainer = true;
+ CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent);
+ if (pNode && pNode->IsContainerNode()) {
+ if (bScriptModify) {
+ pValueNode = pNode;
+ }
+ pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode);
+ } else {
+ pNotify->OnValueChanged(this, eAttribute, pNode,
+ pNode->GetNodeItem(XFA_NODEITEM_Parent));
}
- XFA_ELEMENT eType = pValueNode->GetClassID();
- if (eType == XFA_ELEMENT_Value) {
- bNeedFindContainer = TRUE;
+ } else {
+ if (eType == XFA_ELEMENT_Items) {
CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent);
if (pNode && pNode->IsContainerNode()) {
- if (bScriptModify) {
- pValueNode = pNode;
- }
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pValueNode, pNode);
- } else {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pNode,
- pNode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- } else {
- if (eType == XFA_ELEMENT_Items) {
- CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (pNode && pNode->IsContainerNode()) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute,
- eValue, pValueNode, pNode);
- }
+ pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode);
}
}
- } break;
- default:
+ }
+ } break;
+ default:
+ break;
+ }
+ if (bNeedFindContainer) {
+ CXFA_Node* pParent = this;
+ while (pParent) {
+ if (pParent->IsContainerNode())
break;
+
+ pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
}
- if (bNeedFindContainer) {
- CXFA_Node* pParent = this;
- while (pParent) {
- if (pParent->IsContainerNode()) {
- break;
- }
- pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
- }
- if (pParent) {
- pLayoutPro->AddChangedContainer(pParent);
- }
+ if (pParent) {
+ pLayoutPro->AddChangedContainer(pParent);
}
- } else {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanged, eAttribute, eValue,
- this, this);
}
}
+
void CXFA_Node::Script_Attribute_String(FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
CFX_ByteString szValue;
FXJSE_Value_ToUTF8String(hValue, szValue);
- CFX_WideString wsValue =
- CFX_WideString::FromUTF8(szValue, szValue.GetLength());
- SetAttribute(eAttribute, wsValue.AsWideStringC(), TRUE);
+ CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC());
+ SetAttribute(eAttribute, wsValue.AsStringC(), true);
if (eAttribute == XFA_ATTRIBUTE_Use && GetClassID() == XFA_ELEMENT_Desc) {
CFX_WideString wsUseVal = wsValue, wsID, wsSOM;
CXFA_Node* pTemplateNode =
@@ -1497,11 +1473,9 @@ void CXFA_Node::Script_Attribute_String(FXJSE_HVALUE hValue,
->GetFirstChildByClass(XFA_ELEMENT_Proto);
if (!wsUseVal.IsEmpty()) {
if (wsUseVal[0] == '#') {
- wsID = CFX_WideString((const FX_WCHAR*)wsUseVal + 1,
- wsUseVal.GetLength() - 1);
+ wsID = CFX_WideString(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1);
} else {
- wsSOM =
- CFX_WideString((const FX_WCHAR*)wsUseVal, wsUseVal.GetLength());
+ wsSOM = wsUseVal;
}
}
CXFA_Node* pProtoNode = NULL;
@@ -1512,12 +1486,12 @@ void CXFA_Node::Script_Attribute_String(FXJSE_HVALUE hValue,
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = m_pDocument->GetScriptContext()->ResolveObjects(
- pProtoRoot, wsSOM.AsWideStringC(), resoveNodeRS, dwFlag);
+ pProtoRoot, wsSOM.AsStringC(), resoveNodeRS, dwFlag);
if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) {
pProtoNode = resoveNodeRS.nodes[0]->AsNode();
}
} else if (!wsID.IsEmpty()) {
- pProtoNode = m_pDocument->GetNodeByID(pProtoRoot, wsID.AsWideStringC());
+ pProtoNode = m_pDocument->GetNodeByID(pProtoRoot, wsID.AsStringC());
}
if (pProtoNode) {
CXFA_Node* pHeadChild = GetNodeItem(XFA_NODEITEM_FirstChild);
@@ -1544,7 +1518,8 @@ void CXFA_Node::Script_Attribute_String(FXJSE_HVALUE hValue,
CFX_WideString wsValue;
GetAttribute(eAttribute, wsValue);
FXJSE_Value_SetUTF8String(
- hValue, FX_UTF8Encode(wsValue, wsValue.GetLength()).AsByteStringC());
+ hValue,
+ FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
}
}
void CXFA_Node::Script_Attribute_StringRead(FXJSE_HVALUE hValue,
@@ -1554,7 +1529,8 @@ void CXFA_Node::Script_Attribute_StringRead(FXJSE_HVALUE hValue,
CFX_WideString wsValue;
GetAttribute(eAttribute, wsValue);
FXJSE_Value_SetUTF8String(
- hValue, FX_UTF8Encode(wsValue, wsValue.GetLength()).AsByteStringC());
+ hValue,
+ FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
} else {
ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET);
}
@@ -1602,15 +1578,15 @@ void CXFA_Node::Script_Som_Message(FXJSE_HVALUE hValue,
switch (iMessageType) {
case XFA_SOM_ValidationMessage:
validate.SetScriptMessageText(
- CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength()));
+ CFX_WideString::FromUTF8(bsMessage.AsStringC()));
break;
case XFA_SOM_FormatMessage:
validate.SetFormatMessageText(
- CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength()));
+ CFX_WideString::FromUTF8(bsMessage.AsStringC()));
break;
case XFA_SOM_MandatoryMessage:
validate.SetNullMessageText(
- CFX_WideString::FromUTF8(bsMessage, bsMessage.GetLength()));
+ CFX_WideString::FromUTF8(bsMessage.AsStringC()));
break;
default:
break;
@@ -1637,7 +1613,7 @@ void CXFA_Node::Script_Som_Message(FXJSE_HVALUE hValue,
default:
break;
}
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsMessage).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsMessage).AsStringC());
}
}
void CXFA_Node::Script_Som_ValidationMessage(FXJSE_HVALUE hValue,
@@ -1678,8 +1654,7 @@ void CXFA_Node::Script_Som_DefaultValue(FXJSE_HVALUE hValue,
if (!(FXJSE_Value_IsNull(hValue) || FXJSE_Value_IsUndefined(hValue))) {
FXJSE_Value_ToUTF8String(hValue, newValue);
}
- CFX_WideString wsNewValue =
- CFX_WideString::FromUTF8(newValue, newValue.GetLength());
+ CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC());
CFX_WideString wsFormatValue(wsNewValue);
CXFA_WidgetData* pContainerWidgetData = NULL;
if (GetPacketID() == XFA_XDPPACKET_Datasets) {
@@ -1705,23 +1680,23 @@ void CXFA_Node::Script_Som_DefaultValue(FXJSE_HVALUE hValue,
pContainerWidgetData = GetContainerWidgetData();
}
if (pContainerWidgetData) {
- pContainerWidgetData->GetFormatDataValue(wsNewValue.AsWideStringC(),
- wsFormatValue);
+ pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue);
}
- SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE);
+ SetScriptContent(wsNewValue, wsFormatValue, true, TRUE);
} else {
CFX_WideString content = GetScriptContent(TRUE);
if (content.IsEmpty() && classID != XFA_ELEMENT_Text &&
classID != XFA_ELEMENT_SubmitUrl) {
FXJSE_Value_SetNull(hValue);
} else if (classID == XFA_ELEMENT_Integer) {
- FXJSE_Value_SetInteger(hValue, FXSYS_wtoi(content));
+ FXJSE_Value_SetInteger(hValue, FXSYS_wtoi(content.c_str()));
} else if (classID == XFA_ELEMENT_Float || classID == XFA_ELEMENT_Decimal) {
- CFX_Decimal decimal(content.AsWideStringC());
+ CFX_Decimal decimal(content.AsStringC());
FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal);
} else {
FXJSE_Value_SetUTF8String(
- hValue, FX_UTF8Encode(content, content.GetLength()).AsByteStringC());
+ hValue,
+ FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
}
}
}
@@ -1737,7 +1712,8 @@ void CXFA_Node::Script_Som_DefaultValue_Read(FXJSE_HVALUE hValue,
FXJSE_Value_SetNull(hValue);
} else {
FXJSE_Value_SetUTF8String(
- hValue, FX_UTF8Encode(content, content.GetLength()).AsByteStringC());
+ hValue,
+ FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
}
}
void CXFA_Node::Script_Boolean_Value(FXJSE_HVALUE hValue,
@@ -1748,15 +1724,14 @@ void CXFA_Node::Script_Boolean_Value(FXJSE_HVALUE hValue,
if (!(FXJSE_Value_IsNull(hValue) || FXJSE_Value_IsUndefined(hValue))) {
FXJSE_Value_ToUTF8String(hValue, newValue);
}
- int32_t iValue = FXSYS_atoi(newValue);
- CFX_WideString wsNewValue = (iValue == 0) ? FX_WSTRC(L"0") : FX_WSTRC(L"1");
+ int32_t iValue = FXSYS_atoi(newValue.c_str());
+ CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1");
CFX_WideString wsFormatValue(wsNewValue);
CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData();
if (pContainerWidgetData) {
- pContainerWidgetData->GetFormatDataValue(wsNewValue.AsWideStringC(),
- wsFormatValue);
+ pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue);
}
- SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE);
+ SetScriptContent(wsNewValue, wsFormatValue, true, TRUE);
} else {
CFX_WideString wsValue = GetScriptContent(TRUE);
FXJSE_Value_SetBoolean(hValue, wsValue == FX_WSTRC(L"1"));
@@ -1798,24 +1773,22 @@ static const XFA_ExecEventParaInfo gs_eventParaInfos[] = {
};
const XFA_ExecEventParaInfo* GetEventParaInfoByName(
const CFX_WideStringC& wsEventName) {
- int32_t iLength = wsEventName.GetLength();
- uint32_t uHash = FX_HashCode_String_GetW(wsEventName.raw_str(), iLength);
- const XFA_ExecEventParaInfo* eventParaInfo = NULL;
- int32_t iStart = 0,
- iEnd = (sizeof(gs_eventParaInfos) / sizeof(gs_eventParaInfos[0])) - 1;
- int32_t iMid = (iStart + iEnd) / 2;
+ uint32_t uHash = FX_HashCode_GetW(wsEventName, false);
+ int32_t iStart = 0;
+ int32_t iEnd = (sizeof(gs_eventParaInfos) / sizeof(gs_eventParaInfos[0])) - 1;
do {
- iMid = (iStart + iEnd) / 2;
- eventParaInfo = &gs_eventParaInfos[iMid];
+ int32_t iMid = (iStart + iEnd) / 2;
+ const XFA_ExecEventParaInfo* eventParaInfo = &gs_eventParaInfos[iMid];
if (uHash == eventParaInfo->m_uHash) {
return eventParaInfo;
- } else if (uHash < eventParaInfo->m_uHash) {
+ }
+ if (uHash < eventParaInfo->m_uHash) {
iEnd = iMid - 1;
} else {
iStart = iMid + 1;
}
} while (iStart <= iEnd);
- return NULL;
+ return nullptr;
}
void XFA_STRING_TO_RGB(CFX_WideString& strRGB,
int32_t& r,
@@ -1864,7 +1837,7 @@ void CXFA_Node::Script_Som_BorderColor(FXJSE_HVALUE hValue,
if (bSetting) {
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
- strColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ strColor = CFX_WideString::FromUTF8(bsValue.AsStringC());
int32_t r = 0, g = 0, b = 0;
XFA_STRING_TO_RGB(strColor, r, g, b);
FX_ARGB rgb = ArgbEncode(100, r, g, b);
@@ -1878,7 +1851,7 @@ void CXFA_Node::Script_Som_BorderColor(FXJSE_HVALUE hValue,
int32_t a, r, g, b;
ArgbDecode(color, a, r, g, b);
strColor.Format(L"%d,%d,%d", r, g, b);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(strColor).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(strColor).AsStringC());
}
}
void CXFA_Node::Script_Som_BorderWidth(FXJSE_HVALUE hValue,
@@ -1894,18 +1867,17 @@ void CXFA_Node::Script_Som_BorderWidth(FXJSE_HVALUE hValue,
if (bSetting) {
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
- wsThickness = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsThickness = CFX_WideString::FromUTF8(bsValue.AsStringC());
for (int32_t i = 0; i < iSize; ++i) {
CXFA_Edge edge = border.GetEdge(i);
- CXFA_Measurement thickness(wsThickness.AsWideStringC());
+ CXFA_Measurement thickness(wsThickness.AsStringC());
edge.SetMSThickness(thickness);
}
} else {
CXFA_Edge edge = border.GetEdge(0);
CXFA_Measurement thickness = edge.GetMSThickness();
thickness.ToString(wsThickness);
- FXJSE_Value_SetUTF8String(hValue,
- FX_UTF8Encode(wsThickness).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsThickness).AsStringC());
}
}
void CXFA_Node::Script_Som_FillColor(FXJSE_HVALUE hValue,
@@ -1925,7 +1897,7 @@ void CXFA_Node::Script_Som_FillColor(FXJSE_HVALUE hValue,
if (bSetting) {
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
- wsColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsColor = CFX_WideString::FromUTF8(bsValue.AsStringC());
int32_t r, g, b;
XFA_STRING_TO_RGB(wsColor, r, g, b);
FX_ARGB color = ArgbEncode(0xff, r, g, b);
@@ -1935,7 +1907,7 @@ void CXFA_Node::Script_Som_FillColor(FXJSE_HVALUE hValue,
int32_t a, r, g, b;
ArgbDecode(color, a, r, g, b);
wsColor.Format(L"%d,%d,%d", r, g, b);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsColor).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsColor).AsStringC());
}
}
void CXFA_Node::Script_Som_DataNode(FXJSE_HVALUE hValue,
@@ -1960,15 +1932,15 @@ void CXFA_Node::Script_Draw_DefaultValue(FXJSE_HVALUE hValue,
if (bSetting) {
if (FXJSE_Value_IsUTF8String(hValue)) {
CXFA_WidgetData* pWidgetData = GetWidgetData();
- FXSYS_assert(pWidgetData);
+ ASSERT(pWidgetData);
XFA_ELEMENT uiType = pWidgetData->GetUIType();
if (uiType == XFA_ELEMENT_Text) {
CFX_ByteString newValue;
FXJSE_Value_ToUTF8String(hValue, newValue);
CFX_WideString wsNewValue =
- CFX_WideString::FromUTF8(newValue, newValue.GetLength());
+ CFX_WideString::FromUTF8(newValue.AsStringC());
CFX_WideString wsFormatValue(wsNewValue);
- SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE);
+ SetScriptContent(wsNewValue, wsFormatValue, true, TRUE);
} else if (uiType != XFA_ELEMENT_Image) {
}
}
@@ -1978,7 +1950,8 @@ void CXFA_Node::Script_Draw_DefaultValue(FXJSE_HVALUE hValue,
FXJSE_Value_SetNull(hValue);
} else {
FXJSE_Value_SetUTF8String(
- hValue, FX_UTF8Encode(content, content.GetLength()).AsByteStringC());
+ hValue,
+ FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
}
}
}
@@ -2001,23 +1974,22 @@ void CXFA_Node::Script_Field_DefaultValue(FXJSE_HVALUE hValue,
if (!(FXJSE_Value_IsNull(hValue) || FXJSE_Value_IsUndefined(hValue))) {
FXJSE_Value_ToUTF8String(hValue, newValue);
}
- CFX_WideString wsNewText =
- CFX_WideString::FromUTF8(newValue, newValue.GetLength());
+ CFX_WideString wsNewText = CFX_WideString::FromUTF8(newValue.AsStringC());
CXFA_Node* pUIChild = pWidgetData->GetUIChild();
if (pUIChild->GetClassID() == XFA_ELEMENT_NumericEdit) {
int32_t iLeadDigits = 0;
int32_t iFracDigits = 0;
pWidgetData->GetLeadDigits(iLeadDigits);
pWidgetData->GetFracDigits(iFracDigits);
- wsNewText = XFA_NumericLimit(wsNewText, iLeadDigits, iFracDigits);
+ wsNewText =
+ pWidgetData->NumericLimit(wsNewText, iLeadDigits, iFracDigits);
}
CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData();
CFX_WideString wsFormatText(wsNewText);
if (pContainerWidgetData) {
- pContainerWidgetData->GetFormatDataValue(wsNewText.AsWideStringC(),
- wsFormatText);
+ pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText);
}
- SetScriptContent(wsNewText, wsFormatText, TRUE, TRUE);
+ SetScriptContent(wsNewText, wsFormatText, true, TRUE);
} else {
CFX_WideString content = GetScriptContent(TRUE);
if (content.IsEmpty()) {
@@ -2032,22 +2004,23 @@ void CXFA_Node::Script_Field_DefaultValue(FXJSE_HVALUE hValue,
(pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) {
FXJSE_Value_SetUTF8String(
hValue,
- FX_UTF8Encode(content, content.GetLength()).AsByteStringC());
+ FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
} else {
- CFX_Decimal decimal(content.AsWideStringC());
+ CFX_Decimal decimal(content.AsStringC());
FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal);
}
} else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Integer) {
- FXJSE_Value_SetInteger(hValue, FXSYS_wtoi(content));
+ FXJSE_Value_SetInteger(hValue, FXSYS_wtoi(content.c_str()));
} else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Boolean) {
- FXJSE_Value_SetBoolean(hValue, FXSYS_wtoi(content) == 0 ? FALSE : TRUE);
+ FXJSE_Value_SetBoolean(hValue,
+ FXSYS_wtoi(content.c_str()) == 0 ? FALSE : TRUE);
} else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Float) {
- CFX_Decimal decimal(content.AsWideStringC());
+ CFX_Decimal decimal(content.AsStringC());
FXJSE_Value_SetFloat(hValue, (FX_FLOAT)(double)decimal);
} else {
FXJSE_Value_SetUTF8String(
hValue,
- FX_UTF8Encode(content, content.GetLength()).AsByteStringC());
+ FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC());
}
}
}
@@ -2063,11 +2036,11 @@ void CXFA_Node::Script_Field_EditValue(FXJSE_HVALUE hValue,
if (bSetting) {
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
- wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Edit);
} else {
pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsStringC());
}
}
void CXFA_Node::Script_Som_FontColor(FXJSE_HVALUE hValue,
@@ -2086,7 +2059,7 @@ void CXFA_Node::Script_Som_FontColor(FXJSE_HVALUE hValue,
if (bSetting) {
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
- wsColor = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsColor = CFX_WideString::FromUTF8(bsValue.AsStringC());
int32_t r, g, b;
XFA_STRING_TO_RGB(wsColor, r, g, b);
FX_ARGB color = ArgbEncode(0xff, r, g, b);
@@ -2096,7 +2069,7 @@ void CXFA_Node::Script_Som_FontColor(FXJSE_HVALUE hValue,
int32_t a, r, g, b;
ArgbDecode(color, a, r, g, b);
wsColor.Format(L"%d,%d,%d", r, g, b);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsColor).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsColor).AsStringC());
}
}
void CXFA_Node::Script_Field_FormatMessage(FXJSE_HVALUE hValue,
@@ -2115,11 +2088,11 @@ void CXFA_Node::Script_Field_FormattedValue(FXJSE_HVALUE hValue,
if (bSetting) {
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
- wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Display);
} else {
pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsStringC());
}
}
void CXFA_Node::Script_Som_Mandatory(FXJSE_HVALUE hValue,
@@ -2134,7 +2107,7 @@ void CXFA_Node::Script_Som_Mandatory(FXJSE_HVALUE hValue,
if (bSetting) {
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
- wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
validate.SetNullTest(wsValue);
} else {
int32_t iValue = validate.GetNullTest();
@@ -2143,7 +2116,7 @@ void CXFA_Node::Script_Som_Mandatory(FXJSE_HVALUE hValue,
if (pInfo) {
wsValue = pInfo->pName;
}
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsStringC());
}
}
void CXFA_Node::Script_Som_MandatoryMessage(FXJSE_HVALUE hValue,
@@ -2190,8 +2163,7 @@ void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) {
if (argc == 1) {
CFX_ByteString eventString = pArguments->GetUTF8String(0);
int32_t iRet = execSingleEventByName(
- CFX_WideString::FromUTF8(eventString, eventString.GetLength())
- .AsWideStringC(),
+ CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
XFA_ELEMENT_Field);
if (eventString == "validate") {
FXJSE_Value_SetBoolean(pArguments->GetReturnValue(),
@@ -2252,7 +2224,7 @@ void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) {
if (bHasItem) {
FXJSE_Value_SetUTF8String(
pArguments->GetReturnValue(),
- FX_UTF8Encode(wsValue, wsValue.GetLength()).AsByteStringC());
+ FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
} else {
FXJSE_Value_SetNull(pArguments->GetReturnValue());
}
@@ -2268,14 +2240,12 @@ void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) {
return;
}
CFX_ByteString bsValue = pArguments->GetUTF8String(0);
- CFX_WideString wsValue =
- CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ CFX_WideString wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
CFX_WideString wsBoundValue;
- pWidgetData->GetItemValue(wsValue.AsWideStringC(), wsBoundValue);
+ pWidgetData->GetItemValue(wsValue.AsStringC(), wsBoundValue);
FXJSE_HVALUE hValue = pArguments->GetReturnValue();
if (hValue) {
- FXJSE_Value_SetUTF8String(hValue,
- FX_UTF8Encode(wsBoundValue).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsBoundValue).AsStringC());
}
}
void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) {
@@ -2332,7 +2302,7 @@ void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) {
if (bHasItem) {
FXJSE_Value_SetUTF8String(
pArguments->GetReturnValue(),
- FX_UTF8Encode(wsValue, wsValue.GetLength()).AsByteStringC());
+ FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC());
} else {
FXJSE_Value_SetNull(pArguments->GetReturnValue());
}
@@ -2370,12 +2340,12 @@ void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) {
CFX_WideString wsLabel;
CFX_WideString wsValue;
if (iLength >= 1) {
- CFX_ByteString bsLable = pArguments->GetUTF8String(0);
- wsLabel = CFX_WideString::FromUTF8(bsLable, bsLable.GetLength());
+ CFX_ByteString bsLabel = pArguments->GetUTF8String(0);
+ wsLabel = CFX_WideString::FromUTF8(bsLabel.AsStringC());
}
if (iLength >= 2) {
CFX_ByteString bsValue = pArguments->GetUTF8String(1);
- wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
}
pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE);
}
@@ -2415,15 +2385,14 @@ void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(FXJSE_HVALUE hValue,
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
pWidgetData->SetSelectedMemberByValue(
- CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()).AsWideStringC(),
- TRUE, TRUE);
+ CFX_WideString::FromUTF8(bsValue.AsStringC()).AsStringC(), TRUE, TRUE);
} else {
CFX_WideString wsValue = GetScriptContent(TRUE);
XFA_VERSION curVersion = GetDocument()->GetCurVersionMode();
if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) {
FXJSE_Value_SetNull(hValue);
} else {
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsStringC());
}
}
}
@@ -2435,8 +2404,7 @@ void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) {
if (argc == 1) {
CFX_ByteString eventString = pArguments->GetUTF8String(0);
execSingleEventByName(
- CFX_WideString::FromUTF8(eventString, eventString.GetLength())
- .AsWideStringC(),
+ CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
XFA_ELEMENT_ExclGroup);
} else {
ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
@@ -2456,8 +2424,7 @@ void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) {
CFX_ByteString szName;
szName = pArguments->GetUTF8String(0);
pReturnNode = pWidgetData->SetSelectedMember(
- CFX_WideString::FromUTF8(szName, szName.GetLength())
- .AsWideStringC());
+ CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC());
}
if (pReturnNode) {
FXJSE_Value_Set(
@@ -2618,14 +2585,13 @@ void CXFA_Node::Script_Subform_Locale(FXJSE_HVALUE hValue,
CFX_ByteString bsLocaleName;
FXJSE_Value_ToUTF8String(hValue, bsLocaleName);
SetCData(XFA_ATTRIBUTE_Locale,
- CFX_WideString::FromUTF8(bsLocaleName, bsLocaleName.GetLength()),
- TRUE, TRUE);
+ CFX_WideString::FromUTF8(bsLocaleName.AsStringC()), true, TRUE);
} else {
CFX_WideString wsLocaleName;
GetLocaleName(wsLocaleName);
FXJSE_Value_SetUTF8String(
- hValue,
- FX_UTF8Encode(wsLocaleName, wsLocaleName.GetLength()).AsByteStringC());
+ hValue, FX_UTF8Encode(wsLocaleName.c_str(), wsLocaleName.GetLength())
+ .AsStringC());
}
}
void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) {
@@ -2633,8 +2599,7 @@ void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) {
if (argc == 1) {
CFX_ByteString eventString = pArguments->GetUTF8String(0);
execSingleEventByName(
- CFX_WideString::FromUTF8(eventString, eventString.GetLength())
- .AsWideStringC(),
+ CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(),
XFA_ELEMENT_Subform);
} else {
ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent");
@@ -2740,18 +2705,17 @@ void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) {
CFX_WideString strName;
CFX_WideString strNameSpace;
CFX_ByteString bsTagName = pArguments->GetUTF8String(0);
- strTagName = CFX_WideString::FromUTF8(bsTagName, bsTagName.GetLength());
+ strTagName = CFX_WideString::FromUTF8(bsTagName.AsStringC());
if (argc > 1) {
CFX_ByteString bsName = pArguments->GetUTF8String(1);
- strName = CFX_WideString::FromUTF8(bsName, bsName.GetLength());
+ strName = CFX_WideString::FromUTF8(bsName.AsStringC());
if (argc == 3) {
CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2);
- strNameSpace =
- CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength());
+ strNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC());
}
}
const XFA_ELEMENTINFO* pElement =
- XFA_GetElementByName(strTagName.AsWideStringC());
+ XFA_GetElementByName(strTagName.AsStringC());
CXFA_Node* pNewNode = CreateSamePacketNode(pElement->eName);
if (!pNewNode) {
FXJSE_Value_SetNull(pArguments->GetReturnValue());
@@ -2759,8 +2723,7 @@ void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) {
if (!strName.IsEmpty()) {
if (XFA_GetAttributeOfElement(pElement->eName, XFA_ATTRIBUTE_Name,
XFA_XDPPACKET_UNKNOWN)) {
- pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName.AsWideStringC(),
- TRUE);
+ pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName.AsStringC(), true);
if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) {
pNewNode->CreateXMLMappingNode();
}
@@ -2768,8 +2731,8 @@ void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) {
pArguments->GetReturnValue(),
m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode));
} else {
- ThrowScriptErrorMessage(XFA_IDS_NOT_HAVE_PROPERTY,
- (const FX_WCHAR*)strTagName, L"name");
+ ThrowScriptErrorMessage(XFA_IDS_NOT_HAVE_PROPERTY, strTagName.c_str(),
+ L"name");
}
} else {
FXJSE_Value_Set(
@@ -2884,112 +2847,91 @@ XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx(
const CXFA_NodeSet& rgNodeSet,
CXFA_NodeArray& rgNodeArray,
CFX_ArrayTemplate<int32_t>& rgIdxArray) {
- int32_t iCount = rgNodeSet.GetCount();
+ int32_t iCount = pdfium::CollectionSize<int32_t>(rgNodeSet);
rgNodeArray.SetSize(iCount);
rgIdxArray.SetSize(iCount);
- if (iCount == 0) {
+ if (iCount == 0)
return;
- }
- int32_t iIndex = -1, iTotalIndex = -1;
- CXFA_Node* pNode = NULL;
- FX_POSITION pos = rgNodeSet.GetStartPosition();
- rgNodeSet.GetNextAssoc(pos, pNode);
- for (pNode = pNode->GetNodeItem(XFA_NODEITEM_Parent)
- ->GetNodeItem(XFA_NODEITEM_FirstChild);
+
+ int32_t iIndex = -1;
+ int32_t iTotalIndex = -1;
+ CXFA_Node* pCommonParent =
+ (*rgNodeSet.begin())->GetNodeItem(XFA_NODEITEM_Parent);
+ for (CXFA_Node* pNode = pCommonParent->GetNodeItem(XFA_NODEITEM_FirstChild);
pNode && iIndex < iCount;
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
iTotalIndex++;
- if (rgNodeSet.Lookup(pNode)) {
+ if (pdfium::ContainsValue(rgNodeSet, pNode)) {
iIndex++;
rgNodeArray[iIndex] = pNode;
rgIdxArray[iIndex] = iTotalIndex;
}
}
}
-struct CXFA_DualNodeArray {
- CXFA_NodeSet firstNodeList;
- CXFA_NodeSet secondNodeList;
-};
-static void XFA_ScriptInstanceManager_ReorderDataNodes(CXFA_NodeSet& sSet1,
- CXFA_NodeSet& sSet2,
- FX_BOOL bInsertBefore) {
- CFX_MapPtrTemplate<CXFA_Node*,
- CFX_MapPtrTemplate<uint32_t, CXFA_DualNodeArray*>*>
- rgNodeListMap;
- FX_POSITION pos;
- pos = sSet1.GetStartPosition();
- while (pos) {
- CXFA_Node* pNode = NULL;
- sSet1.GetNextAssoc(pos, pNode);
- CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent);
- uint32_t dwNameHash = pNode->GetNameHash();
- if (!pParentNode || !dwNameHash) {
- continue;
- }
- CFX_MapPtrTemplate<uint32_t, CXFA_DualNodeArray*>* pNodeListChildMap =
- rgNodeListMap[pParentNode];
- if (!pNodeListChildMap) {
- rgNodeListMap[pParentNode] = pNodeListChildMap =
- new CFX_MapPtrTemplate<uint32_t, CXFA_DualNodeArray*>;
- }
- CXFA_DualNodeArray* pDualNodeArray = (*pNodeListChildMap)[dwNameHash];
- if (!pDualNodeArray) {
- (*pNodeListChildMap)[dwNameHash] = pDualNodeArray =
- new CXFA_DualNodeArray;
- }
- pDualNodeArray->firstNodeList.Add(pNode);
- }
- pos = sSet2.GetStartPosition();
- while (pos) {
- CXFA_Node* pNode = NULL;
- sSet2.GetNextAssoc(pos, pNode);
- CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent);
- uint32_t dwNameHash = pNode->GetNameHash();
- if (!pParentNode || !dwNameHash) {
- continue;
- }
- CFX_MapPtrTemplate<uint32_t, CXFA_DualNodeArray*>* pNodeListChildMap =
- rgNodeListMap[pParentNode];
- if (!pNodeListChildMap) {
- rgNodeListMap[pParentNode] = pNodeListChildMap =
- new CFX_MapPtrTemplate<uint32_t, CXFA_DualNodeArray*>;
- }
- CXFA_DualNodeArray* pDualNodeArray = (*pNodeListChildMap)[dwNameHash];
- if (!pDualNodeArray) {
- (*pNodeListChildMap)[dwNameHash] = pDualNodeArray =
- new CXFA_DualNodeArray;
- }
- if (pDualNodeArray->firstNodeList.Lookup(pNode)) {
- pDualNodeArray->firstNodeList.RemoveKey(pNode);
- } else {
- pDualNodeArray->secondNodeList.Add(pNode);
- }
- }
- pos = rgNodeListMap.GetStartPosition();
- while (pos) {
- CXFA_Node* pParentNode = NULL;
- CFX_MapPtrTemplate<uint32_t, CXFA_DualNodeArray*>* pNodeListChildMap = NULL;
- rgNodeListMap.GetNextAssoc(pos, pParentNode, pNodeListChildMap);
- if (!pNodeListChildMap) {
+
+using CXFA_NodeSetPair = std::pair<CXFA_NodeSet, CXFA_NodeSet>;
+using CXFA_NodeSetPairMap =
+ std::map<uint32_t, std::unique_ptr<CXFA_NodeSetPair>>;
+using CXFA_NodeSetPairMapMap =
+ std::map<CXFA_Node*, std::unique_ptr<CXFA_NodeSetPairMap>>;
+
+static CXFA_NodeSetPair* NodeSetPairForNode(CXFA_Node* pNode,
+ CXFA_NodeSetPairMapMap* pMap) {
+ CXFA_Node* pParentNode = pNode->GetNodeItem(XFA_NODEITEM_Parent);
+ uint32_t dwNameHash = pNode->GetNameHash();
+ if (!pParentNode || !dwNameHash)
+ return nullptr;
+
+ if (!(*pMap)[pParentNode])
+ (*pMap)[pParentNode].reset(new CXFA_NodeSetPairMap);
+
+ CXFA_NodeSetPairMap* pNodeSetPairMap = (*pMap)[pParentNode].get();
+ if (!(*pNodeSetPairMap)[dwNameHash])
+ (*pNodeSetPairMap)[dwNameHash].reset(new CXFA_NodeSetPair);
+
+ return (*pNodeSetPairMap)[dwNameHash].get();
+}
+
+static void XFA_ScriptInstanceManager_ReorderDataNodes(
+ const CXFA_NodeSet& sSet1,
+ const CXFA_NodeSet& sSet2,
+ FX_BOOL bInsertBefore) {
+ CXFA_NodeSetPairMapMap rgMap;
+ for (CXFA_Node* pNode : sSet1) {
+ CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap);
+ if (pNodeSetPair)
+ pNodeSetPair->first.insert(pNode);
+ }
+ for (CXFA_Node* pNode : sSet2) {
+ CXFA_NodeSetPair* pNodeSetPair = NodeSetPairForNode(pNode, &rgMap);
+ if (pNodeSetPair) {
+ if (pdfium::ContainsValue(pNodeSetPair->first, pNode))
+ pNodeSetPair->first.erase(pNode);
+ else
+ pNodeSetPair->second.insert(pNode);
+ }
+ }
+ for (const auto& iter1 : rgMap) {
+ CXFA_NodeSetPairMap* pNodeSetPairMap = iter1.second.get();
+ if (!pNodeSetPairMap) {
continue;
}
- FX_POSITION childpos = pNodeListChildMap->GetStartPosition();
- while (childpos) {
- uint32_t dwNameHash = 0;
- CXFA_DualNodeArray* pDualNodeArray = NULL;
- pNodeListChildMap->GetNextAssoc(childpos, dwNameHash, pDualNodeArray);
- if (!pDualNodeArray) {
+ for (const auto& iter2 : *pNodeSetPairMap) {
+ CXFA_NodeSetPair* pNodeSetPair = iter2.second.get();
+ if (!pNodeSetPair) {
continue;
}
- if (pDualNodeArray->firstNodeList.GetCount() != 0 &&
- pDualNodeArray->secondNodeList.GetCount() != 0) {
- CXFA_NodeArray rgNodeArray1, rgNodeArray2;
- CFX_ArrayTemplate<int32_t> rgIdxArray1, rgIdxArray2;
+ if (!pNodeSetPair->first.empty() && !pNodeSetPair->second.empty()) {
+ CXFA_NodeArray rgNodeArray1;
+ CXFA_NodeArray rgNodeArray2;
+ CFX_ArrayTemplate<int32_t> rgIdxArray1;
+ CFX_ArrayTemplate<int32_t> rgIdxArray2;
XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx(
- pDualNodeArray->firstNodeList, rgNodeArray1, rgIdxArray1);
+ pNodeSetPair->first, rgNodeArray1, rgIdxArray1);
XFA_ScriptInstanceManager_ReorderDataNodes_SortNodeArrayByDocumentIdx(
- pDualNodeArray->secondNodeList, rgNodeArray2, rgIdxArray2);
- CXFA_Node *pParentNode = NULL, *pBeforeNode = NULL;
+ pNodeSetPair->second, rgNodeArray2, rgIdxArray2);
+ CXFA_Node* pParentNode = nullptr;
+ CXFA_Node* pBeforeNode = nullptr;
if (bInsertBefore) {
pBeforeNode = rgNodeArray2[0];
pParentNode = pBeforeNode->GetNodeItem(XFA_NODEITEM_Parent);
@@ -2998,19 +2940,17 @@ static void XFA_ScriptInstanceManager_ReorderDataNodes(CXFA_NodeSet& sSet1,
pParentNode = pLastNode->GetNodeItem(XFA_NODEITEM_Parent);
pBeforeNode = pLastNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
- for (int32_t iIdx = 0, iCount = rgIdxArray1.GetSize(); iIdx < iCount;
- iIdx++) {
+ for (int32_t iIdx = 0; iIdx < rgIdxArray1.GetSize(); iIdx++) {
CXFA_Node* pCurNode = rgNodeArray1[iIdx];
pParentNode->RemoveChild(pCurNode);
pParentNode->InsertChild(pCurNode, pBeforeNode);
}
}
- delete pDualNodeArray;
}
- pNodeListChildMap->RemoveAll();
+ pNodeSetPairMap->clear();
}
- rgNodeListMap.RemoveAll();
}
+
static void XFA_ScriptInstanceManager_InsertItem(
CXFA_Node* pInstMgrNode,
CXFA_Node* pNewInstance,
@@ -3032,7 +2972,8 @@ static void XFA_ScriptInstanceManager_InsertItem(
pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)
->InsertChild(pNewInstance, pNextSibling);
if (bMoveDataBindingNodes) {
- CXFA_NodeSet sNew, sAfter;
+ CXFA_NodeSet sNew;
+ CXFA_NodeSet sAfter;
CXFA_NodeIteratorTemplate<CXFA_Node,
CXFA_TraverseStrategy_XFAContainerNode>
sIteratorNew(pNewInstance);
@@ -3042,7 +2983,7 @@ static void XFA_ScriptInstanceManager_InsertItem(
if (!pDataNode) {
continue;
}
- sNew.Add(pDataNode);
+ sNew.insert(pDataNode);
}
CXFA_NodeIteratorTemplate<CXFA_Node,
CXFA_TraverseStrategy_XFAContainerNode>
@@ -3053,7 +2994,7 @@ static void XFA_ScriptInstanceManager_InsertItem(
if (!pDataNode) {
continue;
}
- sAfter.Add(pDataNode);
+ sAfter.insert(pDataNode);
}
XFA_ScriptInstanceManager_ReorderDataNodes(sNew, sAfter, FALSE);
}
@@ -3063,7 +3004,8 @@ static void XFA_ScriptInstanceManager_InsertItem(
pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)
->InsertChild(pNewInstance, pBeforeInstance);
if (bMoveDataBindingNodes) {
- CXFA_NodeSet sNew, sBefore;
+ CXFA_NodeSet sNew;
+ CXFA_NodeSet sBefore;
CXFA_NodeIteratorTemplate<CXFA_Node,
CXFA_TraverseStrategy_XFAContainerNode>
sIteratorNew(pNewInstance);
@@ -3073,7 +3015,7 @@ static void XFA_ScriptInstanceManager_InsertItem(
if (!pDataNode) {
continue;
}
- sNew.Add(pDataNode);
+ sNew.insert(pDataNode);
}
CXFA_NodeIteratorTemplate<CXFA_Node,
CXFA_TraverseStrategy_XFAContainerNode>
@@ -3084,7 +3026,7 @@ static void XFA_ScriptInstanceManager_InsertItem(
if (!pDataNode) {
continue;
}
- sBefore.Add(pDataNode);
+ sBefore.insert(pDataNode);
}
XFA_ScriptInstanceManager_ReorderDataNodes(sNew, sBefore, TRUE);
}
@@ -3322,13 +3264,11 @@ int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
}
if (iDesired < iCount) {
CFX_WideStringC wsInstManagerName = GetCData(XFA_ATTRIBUTE_Name);
- CFX_WideString wsInstanceName = wsInstManagerName.IsEmpty()
- ? wsInstManagerName
- : wsInstManagerName.Mid(1);
+ CFX_WideString wsInstanceName =
+ CFX_WideString(wsInstManagerName.IsEmpty() ? wsInstManagerName
+ : wsInstManagerName.Mid(1));
uint32_t dInstanceNameHash =
- wsInstanceName.IsEmpty() ? 0 : FX_HashCode_String_GetW(
- wsInstanceName,
- wsInstanceName.GetLength());
+ FX_HashCode_GetW(wsInstanceName.AsStringC(), false);
CXFA_Node* pPrevSibling =
(iDesired == 0) ? this
: XFA_ScriptInstanceManager_GetItem(this, iDesired - 1);
@@ -3340,7 +3280,7 @@ int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
continue;
}
if (pRemoveInstance->GetClassID() == XFA_ELEMENT_InstanceManager) {
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
if (pRemoveInstance->GetNameHash() == dInstanceNameHash) {
@@ -3518,14 +3458,13 @@ void CXFA_Node::Script_Form_Checksum(FXJSE_HVALUE hValue,
CFX_ByteString bsChecksum;
FXJSE_Value_ToUTF8String(hValue, bsChecksum);
SetAttribute(XFA_ATTRIBUTE_Checksum,
- CFX_WideString::FromUTF8(bsChecksum, bsChecksum.GetLength())
- .AsWideStringC());
+ CFX_WideString::FromUTF8(bsChecksum.AsStringC()).AsStringC());
} else {
CFX_WideString wsChecksum;
GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE);
FXJSE_Value_SetUTF8String(
hValue,
- FX_UTF8Encode(wsChecksum, wsChecksum.GetLength()).AsByteStringC());
+ FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC());
}
}
void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) {
@@ -3535,15 +3474,14 @@ void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) {
CFX_WideString wsAttributeValue;
CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
- static_cast<CFDE_XMLElement*>(pXMLNode)
- ->GetString(CFX_WideString::FromUTF8(bsAttributeName,
- bsAttributeName.GetLength()),
- wsAttributeValue);
+ static_cast<CFDE_XMLElement*>(pXMLNode)->GetString(
+ CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(),
+ wsAttributeValue);
}
FXJSE_Value_SetUTF8String(
pArguments->GetReturnValue(),
- FX_UTF8Encode(wsAttributeValue, wsAttributeValue.GetLength())
- .AsByteStringC());
+ FX_UTF8Encode(wsAttributeValue.c_str(), wsAttributeValue.GetLength())
+ .AsStringC());
} else {
ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
L"getAttribute");
@@ -3557,8 +3495,8 @@ void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) {
CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
static_cast<CFDE_XMLElement*>(pXMLNode)
- ->SetString(CFX_WideString::FromUTF8(bsName, bsName.GetLength()),
- CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()));
+ ->SetString(CFX_WideString::FromUTF8(bsName.AsStringC()),
+ CFX_WideString::FromUTF8(bsValue.AsStringC()));
}
FXJSE_Value_SetNull(pArguments->GetReturnValue());
} else {
@@ -3570,13 +3508,12 @@ void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) {
int32_t argc = pArguments->GetLength();
if (argc == 1) {
CFX_ByteString bsName = pArguments->GetUTF8String(0);
- CFX_WideString wsName =
- CFX_WideString::FromUTF8(bsName, bsName.GetLength());
+ CFX_WideString wsName = CFX_WideString::FromUTF8(bsName.AsStringC());
CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
- if (pXMLElement->HasAttribute(wsName)) {
- pXMLElement->RemoveAttribute(wsName);
+ if (pXMLElement->HasAttribute(wsName.c_str())) {
+ pXMLElement->RemoveAttribute(wsName.c_str());
}
}
FXJSE_Value_SetNull(pArguments->GetReturnValue());
@@ -3595,7 +3532,7 @@ void CXFA_Node::Script_Packet_Content(FXJSE_HVALUE hValue,
if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
pXMLElement->SetTextData(
- CFX_WideString::FromUTF8(bsNewContent, bsNewContent.GetLength()));
+ CFX_WideString::FromUTF8(bsNewContent.AsStringC()));
}
} else {
CFX_WideString wsTextData;
@@ -3606,7 +3543,7 @@ void CXFA_Node::Script_Packet_Content(FXJSE_HVALUE hValue,
}
FXJSE_Value_SetUTF8String(
hValue,
- FX_UTF8Encode(wsTextData, wsTextData.GetLength()).AsByteStringC());
+ FX_UTF8Encode(wsTextData.c_str(), wsTextData.GetLength()).AsStringC());
}
}
void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) {
@@ -3737,7 +3674,7 @@ void CXFA_Node::Script_Xfa_This(FXJSE_HVALUE hValue,
XFA_ATTRIBUTE eAttribute) {
if (!bSetting) {
CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject();
- FXSYS_assert(pThis);
+ ASSERT(pThis);
FXJSE_Value_Set(hValue,
m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis));
}
@@ -3758,8 +3695,7 @@ void CXFA_Node::Script_Script_Stateless(FXJSE_HVALUE hValue,
ThrowScriptErrorMessage(XFA_IDS_INVAlID_PROP_SET);
return;
}
- FXJSE_Value_SetUTF8String(hValue,
- FX_UTF8Encode(FX_WSTRC(L"0")).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(FX_WSTRC(L"0")).AsStringC());
}
void CXFA_Node::Script_Encrypt_Format(FXJSE_HVALUE hValue,
FX_BOOL bSetting,
@@ -3769,7 +3705,7 @@ enum XFA_KEYTYPE {
XFA_KEYTYPE_Element,
};
void* XFA_GetMapKey_Custom(const CFX_WideStringC& wsKey) {
- uint32_t dwKey = FX_HashCode_String_GetW(wsKey.raw_str(), wsKey.GetLength());
+ uint32_t dwKey = FX_HashCode_GetW(wsKey, false);
return (void*)(uintptr_t)((dwKey << 1) | XFA_KEYTYPE_Custom);
}
void* XFA_GetMapKey_Element(XFA_ELEMENT eElement, XFA_ATTRIBUTE eAttribute) {
@@ -3782,7 +3718,7 @@ FX_BOOL CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit) {
}
FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr,
const CFX_WideStringC& wsValue,
- FX_BOOL bNotify) {
+ bool bNotify) {
const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr);
if (pAttr == NULL) {
return FALSE;
@@ -3802,13 +3738,13 @@ FX_BOOL CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr,
bNotify);
} break;
case XFA_ATTRIBUTETYPE_Cdata:
- return SetCData(pAttr->eName, wsValue, bNotify);
+ return SetCData(pAttr->eName, CFX_WideString(wsValue), bNotify);
case XFA_ATTRIBUTETYPE_Boolean:
return SetBoolean(pAttr->eName, wsValue != FX_WSTRC(L"0"), bNotify);
case XFA_ATTRIBUTETYPE_Integer:
return SetInteger(
pAttr->eName,
- FXSYS_round(FX_wcstof(wsValue.raw_str(), wsValue.GetLength())),
+ FXSYS_round(FX_wcstof(wsValue.c_str(), wsValue.GetLength())),
bNotify);
case XFA_ATTRIBUTETYPE_Measure:
return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify);
@@ -3878,7 +3814,7 @@ FX_BOOL CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr,
}
FX_BOOL CXFA_Node::SetAttribute(const CFX_WideStringC& wsAttr,
const CFX_WideStringC& wsValue,
- FX_BOOL bNotify) {
+ bool bNotify) {
const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue);
if (pAttributeInfo) {
return SetAttribute(pAttributeInfo->eName, wsValue, bNotify);
@@ -3936,15 +3872,17 @@ FX_BOOL CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr,
eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue;
return TRUE;
}
+
FX_BOOL CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr,
CXFA_Measurement mValue,
- FX_BOOL bNotify) {
+ bool bNotify) {
void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr);
- OnChanging(eAttr, &mValue, bNotify);
+ OnChanging(eAttr, bNotify);
SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement));
- OnChanged(eAttr, &mValue, bNotify);
+ OnChanged(eAttr, bNotify, FALSE);
return TRUE;
}
+
FX_BOOL CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr,
CXFA_Measurement& mValue,
FX_BOOL bUseDefault) const {
@@ -3971,90 +3909,96 @@ CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const {
FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr,
const CFX_WideString& wsValue,
- FX_BOOL bNotify,
+ bool bNotify,
FX_BOOL bScriptModify) {
void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr);
- OnChanging(eAttr, (void*)(const FX_WCHAR*)wsValue, bNotify);
+ OnChanging(eAttr, bNotify);
if (eAttr == XFA_ATTRIBUTE_Value) {
CFX_WideString* pClone = new CFX_WideString(wsValue);
SetUserData(pKey, pClone, &deleteWideStringCallBack);
} else {
- SetMapModuleString(pKey, wsValue.AsWideStringC());
+ SetMapModuleString(pKey, wsValue.AsStringC());
if (eAttr == XFA_ATTRIBUTE_Name)
UpdateNameHash();
}
- OnChanged(eAttr, (void*)(const FX_WCHAR*)wsValue, bNotify, bScriptModify);
- if (IsNeedSavingXMLNode() && eAttr != XFA_ATTRIBUTE_QualifiedName &&
- eAttr != XFA_ATTRIBUTE_BindingNode) {
- if (eAttr == XFA_ATTRIBUTE_Name &&
- (m_eNodeClass == XFA_ELEMENT_DataValue ||
- m_eNodeClass == XFA_ELEMENT_DataGroup)) {
- return TRUE;
- }
- if (eAttr == XFA_ATTRIBUTE_Value) {
- FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType();
- switch (eXMLType) {
- case FDE_XMLNODE_Element:
- if (IsAttributeInXML()) {
- static_cast<CFDE_XMLElement*>(m_pXMLNode)
- ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsValue);
- } else {
- FX_BOOL bDeleteChildren = TRUE;
- if (GetPacketID() == XFA_XDPPACKET_Datasets) {
- for (CXFA_Node* pChildDataNode =
- GetNodeItem(XFA_NODEITEM_FirstChild);
- pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
- XFA_NODEITEM_NextSibling)) {
- CXFA_NodeArray formNodes;
- if (pChildDataNode->GetBindItems(formNodes) > 0) {
- bDeleteChildren = FALSE;
- break;
- }
+ OnChanged(eAttr, bNotify, bScriptModify);
+
+ if (!IsNeedSavingXMLNode() || eAttr == XFA_ATTRIBUTE_QualifiedName ||
+ eAttr == XFA_ATTRIBUTE_BindingNode) {
+ return TRUE;
+ }
+
+ if (eAttr == XFA_ATTRIBUTE_Name && (m_eNodeClass == XFA_ELEMENT_DataValue ||
+ m_eNodeClass == XFA_ELEMENT_DataGroup)) {
+ return TRUE;
+ }
+
+ if (eAttr == XFA_ATTRIBUTE_Value) {
+ FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType();
+ switch (eXMLType) {
+ case FDE_XMLNODE_Element:
+ if (IsAttributeInXML()) {
+ static_cast<CFDE_XMLElement*>(m_pXMLNode)
+ ->SetString(CFX_WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)),
+ wsValue);
+ } else {
+ FX_BOOL bDeleteChildren = TRUE;
+ if (GetPacketID() == XFA_XDPPACKET_Datasets) {
+ for (CXFA_Node* pChildDataNode =
+ GetNodeItem(XFA_NODEITEM_FirstChild);
+ pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
+ XFA_NODEITEM_NextSibling)) {
+ CXFA_NodeArray formNodes;
+ if (pChildDataNode->GetBindItems(formNodes) > 0) {
+ bDeleteChildren = FALSE;
+ break;
}
}
- if (bDeleteChildren) {
- static_cast<CFDE_XMLElement*>(m_pXMLNode)->DeleteChildren();
- }
- static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetTextData(wsValue);
}
- break;
- case FDE_XMLNODE_Text:
- static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsValue);
- break;
- default:
- FXSYS_assert(0);
- }
- return TRUE;
+ if (bDeleteChildren) {
+ static_cast<CFDE_XMLElement*>(m_pXMLNode)->DeleteChildren();
+ }
+ static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetTextData(wsValue);
+ }
+ break;
+ case FDE_XMLNODE_Text:
+ static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsValue);
+ break;
+ default:
+ ASSERT(0);
}
- const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr);
- if (pInfo) {
- FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element);
- CFX_WideString wsAttrName = pInfo->pName;
- if (pInfo->eName == XFA_ATTRIBUTE_ContentType) {
- wsAttrName = FX_WSTRC(L"xfa:") + wsAttrName;
- }
- static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue);
+ return TRUE;
+ }
+
+ const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr);
+ if (pInfo) {
+ ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element);
+ CFX_WideString wsAttrName = pInfo->pName;
+ if (pInfo->eName == XFA_ATTRIBUTE_ContentType) {
+ wsAttrName = FX_WSTRC(L"xfa:") + wsAttrName;
}
+ static_cast<CFDE_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue);
}
return TRUE;
}
+
FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue,
const CFX_WideString& wsXMLValue,
- FX_BOOL bNotify,
+ bool bNotify,
FX_BOOL bScriptModify) {
void* pKey = XFA_GetMapKey_Element(GetClassID(), XFA_ATTRIBUTE_Value);
- OnChanging(XFA_ATTRIBUTE_Value, (void*)(const FX_WCHAR*)wsValue, bNotify);
+ OnChanging(XFA_ATTRIBUTE_Value, bNotify);
CFX_WideString* pClone = new CFX_WideString(wsValue);
SetUserData(pKey, pClone, &deleteWideStringCallBack);
- OnChanged(XFA_ATTRIBUTE_Value, (void*)(const FX_WCHAR*)wsValue, bNotify,
- bScriptModify);
+ OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify);
if (IsNeedSavingXMLNode()) {
FDE_XMLNODETYPE eXMLType = m_pXMLNode->GetType();
switch (eXMLType) {
case FDE_XMLNODE_Element:
if (IsAttributeInXML()) {
static_cast<CFDE_XMLElement*>(m_pXMLNode)
- ->SetString(GetCData(XFA_ATTRIBUTE_QualifiedName), wsXMLValue);
+ ->SetString(CFX_WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)),
+ wsXMLValue);
} else {
FX_BOOL bDeleteChildren = TRUE;
if (GetPacketID() == XFA_XDPPACKET_Datasets) {
@@ -4079,7 +4023,7 @@ FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue,
static_cast<CFDE_XMLText*>(m_pXMLNode)->SetText(wsXMLValue);
break;
default:
- FXSYS_assert(0);
+ ASSERT(0);
}
}
return TRUE;
@@ -4121,7 +4065,7 @@ FX_BOOL CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr,
if (eAttr == XFA_ATTRIBUTE_Value) {
CFX_WideString* pStr = (CFX_WideString*)GetUserData(pKey, bProto);
if (pStr) {
- wsValue = *pStr;
+ wsValue = pStr->AsStringC();
return TRUE;
}
} else {
@@ -4154,13 +4098,13 @@ FX_BOOL CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) {
FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr,
XFA_ATTRIBUTETYPE eType,
void* pValue,
- FX_BOOL bNotify) {
+ bool bNotify) {
void* pKey = XFA_GetMapKey_Element(GetClassID(), eAttr);
- OnChanging(eAttr, pValue, bNotify);
+ OnChanging(eAttr, bNotify);
SetMapModuleValue(pKey, pValue);
- OnChanged(eAttr, pValue, bNotify);
+ OnChanged(eAttr, bNotify, FALSE);
if (IsNeedSavingXMLNode()) {
- FXSYS_assert(m_pXMLNode->GetType() == FDE_XMLNODE_Element);
+ ASSERT(m_pXMLNode->GetType() == FDE_XMLNODE_Element);
const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr);
if (pInfo) {
switch (eType) {
@@ -4173,15 +4117,14 @@ FX_BOOL CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr,
break;
case XFA_ATTRIBUTETYPE_Boolean:
static_cast<CFDE_XMLElement*>(m_pXMLNode)
- ->SetString(pInfo->pName,
- pValue ? FX_WSTRC(L"1") : FX_WSTRC(L"0"));
+ ->SetString(pInfo->pName, pValue ? L"1" : L"0");
break;
case XFA_ATTRIBUTETYPE_Integer:
static_cast<CFDE_XMLElement*>(m_pXMLNode)
->SetInteger(pInfo->pName, (int32_t)(uintptr_t)pValue);
break;
default:
- FXSYS_assert(0);
+ ASSERT(0);
}
}
}
@@ -4220,7 +4163,7 @@ FX_BOOL CXFA_Node::TryUserData(void* pKey, void*& pData, FX_BOOL bProtoAlso) {
}
FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
const CFX_WideString& wsXMLValue,
- FX_BOOL bNotify,
+ bool bNotify,
FX_BOOL bScriptModify,
FX_BOOL bSyncData) {
CXFA_Node* pNode = NULL;
@@ -4230,8 +4173,8 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
if (XFA_FieldIsMultiListBox(this)) {
CXFA_Node* pValue = GetProperty(0, XFA_ELEMENT_Value);
CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild);
- FXSYS_assert(pChildValue);
- pChildValue->SetCData(XFA_ATTRIBUTE_ContentType, FX_WSTRC(L"text/xml"));
+ ASSERT(pChildValue);
+ pChildValue->SetCData(XFA_ATTRIBUTE_ContentType, L"text/xml");
pChildValue->SetScriptContent(wsContent, wsContent, bNotify,
bScriptModify, FALSE);
CXFA_Node* pBind = GetBindData();
@@ -4271,7 +4214,7 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
while (iAddNodes-- > 0) {
pValueNodes =
pBind->CreateSamePacketNode(XFA_ELEMENT_DataValue);
- pValueNodes->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"value"));
+ pValueNodes->SetCData(XFA_ATTRIBUTE_Name, L"value");
pValueNodes->CreateXMLMappingNode();
pBind->InsertChild(pValueNodes);
}
@@ -4309,7 +4252,7 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
} else {
CXFA_Node* pValue = GetProperty(0, XFA_ELEMENT_Value);
CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild);
- FXSYS_assert(pChildValue);
+ ASSERT(pChildValue);
pChildValue->SetScriptContent(wsContent, wsContent, bNotify,
bScriptModify, FALSE);
}
@@ -4324,7 +4267,7 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
if (pNode == this) {
continue;
}
- pNode->SetScriptContent(wsContent, wsContent, bNotify, TRUE, FALSE);
+ pNode->SetScriptContent(wsContent, wsContent, bNotify, true, FALSE);
}
}
pBindNode = NULL;
@@ -4336,8 +4279,7 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE);
if (wsContentType == FX_WSTRC(L"text/html")) {
wsContentType = FX_WSTRC(L"");
- SetAttribute(XFA_ATTRIBUTE_ContentType,
- wsContentType.AsWideStringC());
+ SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType.AsStringC());
}
}
CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild);
@@ -4397,7 +4339,7 @@ FX_BOOL CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
}
FX_BOOL CXFA_Node::SetContent(const CFX_WideString& wsContent,
const CFX_WideString& wsXMLValue,
- FX_BOOL bNotify,
+ bool bNotify,
FX_BOOL bScriptModify,
FX_BOOL bSyncData) {
return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify,
@@ -4497,7 +4439,7 @@ CXFA_Node* CXFA_Node::GetModelNode() {
}
}
FX_BOOL CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) {
- wsNamespace.Empty();
+ wsNamespace.clear();
if (GetObjectType() == XFA_OBJECTTYPE_ModelNode ||
GetClassID() == XFA_ELEMENT_Packet) {
CFDE_XMLNode* pXMLNode = GetXMLMappingNode();
@@ -4569,7 +4511,7 @@ CXFA_Node* CXFA_Node::GetProperty(int32_t index,
return NULL;
}
InsertChild(pNewNode, nullptr);
- pNewNode->SetFlag(XFA_NODEFLAG_Initialized);
+ pNewNode->SetFlag(XFA_NODEFLAG_Initialized, true);
}
return pNewNode;
}
@@ -4593,7 +4535,7 @@ int32_t CXFA_Node::CountChildren(XFA_ELEMENT eElement, FX_BOOL bOnlyChild) {
CXFA_Node* CXFA_Node::GetChild(int32_t index,
XFA_ELEMENT eElement,
FX_BOOL bOnlyChild) {
- FXSYS_assert(index > -1);
+ ASSERT(index > -1);
CXFA_Node* pNode = m_pChild;
int32_t iCount = 0;
for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
@@ -4616,9 +4558,9 @@ CXFA_Node* CXFA_Node::GetChild(int32_t index,
int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) {
ASSERT(!pNode->m_pNext);
pNode->m_pParent = this;
- FX_BOOL bWasPurgeNode = m_pDocument->RemovePurgeNode(pNode);
- if (!bWasPurgeNode)
- FXSYS_assert(false);
+ FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode);
+ ASSERT(ret);
+ (void)ret; // Avoid unused variable warning.
if (m_pChild == NULL || index == 0) {
if (index > 0) {
@@ -4647,27 +4589,28 @@ int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) {
}
ASSERT(m_pLastChild);
ASSERT(m_pLastChild->m_pNext == NULL);
- pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE);
+ pNode->ClearFlag(XFA_NODEFLAG_HasRemoved);
CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
- if (pNotify) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode);
- }
+ if (pNotify)
+ pNotify->OnChildAdded(this);
+
if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) {
- FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL);
+ ASSERT(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL);
m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index);
- pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE);
+ pNode->ClearFlag(XFA_NODEFLAG_OwnXMLNode);
}
return index;
}
+
FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) {
if (!pNode || pNode->m_pParent ||
(pBeforeNode && pBeforeNode->m_pParent != this)) {
- FXSYS_assert(false);
+ ASSERT(false);
return FALSE;
}
- FX_BOOL bWasPurgeNode = m_pDocument->RemovePurgeNode(pNode);
- if (!bWasPurgeNode)
- FXSYS_assert(false);
+ FX_BOOL ret = m_pDocument->RemovePurgeNode(pNode);
+ ASSERT(ret);
+ (void)ret; // Avoid unused variable warning.
int32_t nIndex = -1;
pNode->m_pParent = this;
@@ -4693,15 +4636,15 @@ FX_BOOL CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) {
}
ASSERT(m_pLastChild);
ASSERT(m_pLastChild->m_pNext == NULL);
- pNode->SetFlag(XFA_NODEFLAG_HasRemoved, FALSE);
+ pNode->ClearFlag(XFA_NODEFLAG_HasRemoved);
CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
- if (pNotify) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ChildAdded, pNode);
- }
+ if (pNotify)
+ pNotify->OnChildAdded(this);
+
if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) {
- FXSYS_assert(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL);
+ ASSERT(pNode->m_pXMLNode->GetNodeItem(CFDE_XMLNode::Parent) == NULL);
m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex);
- pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, FALSE, FALSE);
+ pNode->ClearFlag(XFA_NODEFLAG_OwnXMLNode);
}
return TRUE;
}
@@ -4717,9 +4660,9 @@ CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() {
}
return NULL;
}
-FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, FX_BOOL bNotify) {
+FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) {
if (pNode == NULL || pNode->m_pParent != this) {
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
return FALSE;
}
if (m_pChild == pNode) {
@@ -4739,40 +4682,38 @@ FX_BOOL CXFA_Node::RemoveChild(CXFA_Node* pNode, FX_BOOL bNotify) {
pNode->m_pParent = NULL;
}
ASSERT(m_pLastChild == NULL || m_pLastChild->m_pNext == NULL);
- OnRemoved(this, pNode, bNotify);
- pNode->SetFlag(XFA_NODEFLAG_HasRemoved);
+ OnRemoved(bNotify);
+ pNode->SetFlag(XFA_NODEFLAG_HasRemoved, true);
m_pDocument->AddPurgeNode(pNode);
if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) {
if (pNode->IsAttributeInXML()) {
- FXSYS_assert(pNode->m_pXMLNode == m_pXMLNode &&
- m_pXMLNode->GetType() == FDE_XMLNODE_Element);
+ ASSERT(pNode->m_pXMLNode == m_pXMLNode &&
+ m_pXMLNode->GetType() == FDE_XMLNODE_Element);
if (pNode->m_pXMLNode->GetType() == FDE_XMLNODE_Element) {
CFDE_XMLElement* pXMLElement =
static_cast<CFDE_XMLElement*>(pNode->m_pXMLNode);
CFX_WideStringC wsAttributeName =
pNode->GetCData(XFA_ATTRIBUTE_QualifiedName);
- pXMLElement->RemoveAttribute(wsAttributeName.raw_str());
+ pXMLElement->RemoveAttribute(wsAttributeName.c_str());
}
CFX_WideString wsName;
pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE);
CFDE_XMLElement* pNewXMLElement = new CFDE_XMLElement(wsName);
CFX_WideStringC wsValue = GetCData(XFA_ATTRIBUTE_Value);
if (!wsValue.IsEmpty()) {
- pNewXMLElement->SetTextData(wsValue);
+ pNewXMLElement->SetTextData(CFX_WideString(wsValue));
}
pNode->m_pXMLNode = pNewXMLElement;
pNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown);
} else {
m_pXMLNode->RemoveChildNode(pNode->m_pXMLNode);
}
- pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE);
+ pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, false);
}
return TRUE;
}
CXFA_Node* CXFA_Node::GetFirstChildByName(const CFX_WideStringC& wsName) const {
- return GetFirstChildByName(
- wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.raw_str(),
- wsName.GetLength()));
+ return GetFirstChildByName(FX_HashCode_GetW(wsName, false));
}
CXFA_Node* CXFA_Node::GetFirstChildByName(uint32_t dwNameHash) const {
for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
@@ -4803,10 +4744,7 @@ CXFA_Node* CXFA_Node::GetNextSameNameSibling(uint32_t dwNameHash) const {
}
CXFA_Node* CXFA_Node::GetNextSameNameSibling(
const CFX_WideStringC& wsNodeName) const {
- return GetNextSameNameSibling(
- wsNodeName.IsEmpty() ? 0
- : FX_HashCode_String_GetW(wsNodeName.raw_str(),
- wsNodeName.GetLength()));
+ return GetNextSameNameSibling(FX_HashCode_GetW(wsNodeName, false));
}
CXFA_Node* CXFA_Node::GetNextSameClassSibling(XFA_ELEMENT eElement) const {
for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_NextSibling); pNode;
@@ -4880,58 +4818,52 @@ FX_BOOL CXFA_Node::HasFlag(uint32_t dwFlag) const {
}
return FALSE;
}
-void CXFA_Node::SetFlag(uint32_t dwFlag, FX_BOOL bOn, FX_BOOL bNotify) {
- if (bOn) {
- switch (dwFlag) {
- case XFA_NODEFLAG_Initialized:
- if (bNotify && !HasFlag(XFA_NODEFLAG_Initialized)) {
- CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
- if (pNotify) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_Ready);
- }
- }
- break;
- default:
- break;
+
+void CXFA_Node::SetFlag(uint32_t dwFlag, bool bNotify) {
+ if (dwFlag == XFA_NODEFLAG_Initialized && bNotify &&
+ !HasFlag(XFA_NODEFLAG_Initialized)) {
+ CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
+ if (pNotify) {
+ pNotify->OnNodeReady(this);
}
- m_uFlags |= dwFlag;
- } else {
- m_uFlags &= ~dwFlag;
}
+ m_uFlags |= dwFlag;
+}
+
+void CXFA_Node::ClearFlag(uint32_t dwFlag) {
+ m_uFlags &= ~dwFlag;
}
+
FX_BOOL CXFA_Node::IsAttributeInXML() {
return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData;
}
-void CXFA_Node::OnRemoved(CXFA_Node* pParent,
- CXFA_Node* pRemoved,
- FX_BOOL bNotify) {
- if (bNotify && pParent) {
- CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
- if (pNotify) {
- pNotify->OnNodeEvent(pParent, XFA_NODEEVENT_ChildRemoved, pRemoved);
- }
- }
+
+void CXFA_Node::OnRemoved(bool bNotify) {
+ if (!bNotify)
+ return;
+
+ CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
+ if (pNotify)
+ pNotify->OnChildRemoved();
}
-void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr,
- void* pNewValue,
- FX_BOOL bNotify) {
+
+void CXFA_Node::OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify) {
if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) {
CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify();
if (pNotify) {
- pNotify->OnNodeEvent(this, XFA_NODEEVENT_ValueChanging,
- (void*)(uintptr_t)eAttr, pNewValue);
+ pNotify->OnValueChanging(this, eAttr);
}
}
}
+
void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr,
- void* pNewValue,
- FX_BOOL bNotify,
+ bool bNotify,
FX_BOOL bScriptModify) {
if (bNotify && HasFlag(XFA_NODEFLAG_Initialized)) {
- Script_Attribute_SendAttributeChangeMessage((void*)(uintptr_t)eAttr,
- pNewValue, bScriptModify);
+ Script_Attribute_SendAttributeChangeMessage(eAttr, bScriptModify);
}
}
+
int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName,
XFA_ELEMENT eElementType) {
int32_t iRet = XFA_EVENTERROR_NotExist;
@@ -4995,24 +4927,20 @@ int32_t CXFA_Node::execSingleEventByName(const CFX_WideStringC& wsEventName,
void CXFA_Node::UpdateNameHash() {
const XFA_NOTSUREATTRIBUTE* pNotsure =
XFA_GetNotsureAttribute(GetClassID(), XFA_ATTRIBUTE_Name);
+ CFX_WideStringC wsName;
if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) {
- CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name);
- m_dwNameHash =
- wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.raw_str(),
- wsName.GetLength());
+ wsName = GetCData(XFA_ATTRIBUTE_Name);
+ m_dwNameHash = FX_HashCode_GetW(wsName, false);
} else if (pNotsure->eType == XFA_ATTRIBUTETYPE_Enum) {
- CFX_WideStringC wsName =
- XFA_GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName;
- m_dwNameHash =
- wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.raw_str(),
- wsName.GetLength());
+ wsName = XFA_GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName;
+ m_dwNameHash = FX_HashCode_GetW(wsName, false);
}
}
CFDE_XMLNode* CXFA_Node::CreateXMLMappingNode() {
if (!m_pXMLNode) {
- CFX_WideStringC wsTag = GetCData(XFA_ATTRIBUTE_Name);
+ CFX_WideString wsTag(GetCData(XFA_ATTRIBUTE_Name));
m_pXMLNode = new CFDE_XMLElement(wsTag);
- SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE);
+ SetFlag(XFA_NODEFLAG_OwnXMLNode, false);
}
return m_pXMLNode;
}
@@ -5050,7 +4978,7 @@ FX_BOOL CXFA_Node::GetMapModuleValue(void* pKey, void*& pValue) {
return FALSE;
}
void CXFA_Node::SetMapModuleString(void* pKey, const CFX_WideStringC& wsValue) {
- SetMapModuleBuffer(pKey, (void*)wsValue.raw_str(),
+ SetMapModuleBuffer(pKey, (void*)wsValue.c_str(),
wsValue.GetLength() * sizeof(FX_WCHAR));
}
FX_BOOL CXFA_Node::GetMapModuleString(void* pKey, CFX_WideStringC& wsValue) {
@@ -5249,9 +5177,9 @@ void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) {
CFX_WideString wsFormatValue(wsValue);
CXFA_WidgetData* pWidgetData = pDstModule->GetContainerWidgetData();
if (pWidgetData) {
- pWidgetData->GetFormatDataValue(wsValue.AsWideStringC(), wsFormatValue);
+ pWidgetData->GetFormatDataValue(wsValue, wsFormatValue);
}
- pDstModule->SetScriptContent(wsValue, wsFormatValue, TRUE, TRUE);
+ pDstModule->SetScriptContent(wsValue, wsFormatValue, true, TRUE);
}
}
void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule,
@@ -5277,14 +5205,12 @@ CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument)
m_pDocument->GetScriptContext()->CacheList(this);
}
CXFA_Node* CXFA_NodeList::NamedItem(const CFX_WideStringC& wsName) {
+ uint32_t dwHashCode = FX_HashCode_GetW(wsName, false);
int32_t iCount = GetLength();
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsName.raw_str(), wsName.GetLength());
for (int32_t i = 0; i < iCount; i++) {
CXFA_Node* ret = Item(i);
- if (dwHashCode == ret->GetNameHash()) {
+ if (dwHashCode == ret->GetNameHash())
return ret;
- }
}
return NULL;
}
@@ -5348,8 +5274,8 @@ void CXFA_NodeList::Script_TreelistClass_NamedItem(
int32_t argc = pArguments->GetLength();
if (argc == 1) {
CFX_ByteString szName = pArguments->GetUTF8String(0);
- CXFA_Node* pNode = NamedItem(
- CFX_WideString::FromUTF8(szName, szName.GetLength()).AsWideStringC());
+ CXFA_Node* pNode =
+ NamedItem(CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC());
if (!pNode) {
return;
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_parser_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_parser_imp.cpp
index 4c831d5b8fa..01ea1d6fae7 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_parser_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_parser_imp.cpp
@@ -9,8 +9,8 @@
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
+#include "xfa/fxfa/include/xfa_checksum.h"
#include "xfa/fxfa/parser/xfa_basic_imp.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -18,7 +18,6 @@
#include "xfa/fxfa/parser/xfa_parser.h"
#include "xfa/fxfa/parser/xfa_script.h"
#include "xfa/fxfa/parser/xfa_utils.h"
-#include "xfa/include/fxfa/xfa_checksum.h"
IXFA_Parser* IXFA_Parser::Create(CXFA_Document* pFactory,
FX_BOOL bDocumentParser) {
@@ -175,7 +174,7 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode,
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLChild);
- pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false);
break;
}
}
@@ -212,12 +211,12 @@ FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier(
if (pNode->GetType() != FDE_XMLNODE_Element) {
continue;
}
- if (pNode->HasAttribute(wsNSAttribute)) {
- pNode->GetString(wsNSAttribute, wsNamespaceURI);
+ if (pNode->HasAttribute(wsNSAttribute.c_str())) {
+ pNode->GetString(wsNSAttribute.c_str(), wsNamespaceURI);
return TRUE;
}
}
- wsNamespaceURI.Empty();
+ wsNamespaceURI.clear();
return bRet;
}
static inline void XFA_FDEExtension_GetElementTagNamespaceURI(
@@ -226,8 +225,8 @@ static inline void XFA_FDEExtension_GetElementTagNamespaceURI(
CFX_WideString wsNodeStr;
pElement->GetNamespacePrefix(wsNodeStr);
if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNodeStr.AsWideStringC(), wsNamespaceURI)) {
- wsNamespaceURI.Empty();
+ pElement, wsNodeStr.AsStringC(), wsNamespaceURI)) {
+ wsNamespaceURI.clear();
}
}
static FX_BOOL XFA_FDEExtension_MatchNodeName(
@@ -284,8 +283,8 @@ static FX_BOOL XFA_FDEExtension_ResolveAttribute(
return FALSE;
}
if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNSPrefix.AsWideStringC(), wsNamespaceURI)) {
- wsNamespaceURI.Empty();
+ pElement, wsNSPrefix.AsStringC(), wsNamespaceURI)) {
+ wsNamespaceURI.clear();
return FALSE;
}
return TRUE;
@@ -319,7 +318,7 @@ static FX_BOOL XFA_FDEExtension_FindAttributeWithNS(
wsNSPrefix = wsAttrName.Left(iFind);
}
if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNSPrefix.AsWideStringC(), wsAttrNS)) {
+ pElement, wsNSPrefix.AsStringC(), wsAttrNS)) {
continue;
}
if (bMatchNSAsPrefix) {
@@ -378,7 +377,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
return nullptr;
}
m_pRootNode = pXFARootNode;
- pXFARootNode->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L"xfa"));
+ pXFARootNode->SetCData(XFA_ATTRIBUTE_Name, L"xfa");
{
CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLDocumentNode);
int32_t iAttributeCount = pElement->CountAttributes();
@@ -434,7 +433,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
CFX_WideString wsPacketName;
pElement->GetLocalTagName(wsPacketName);
const XFA_PACKETINFO* pPacketInfo =
- XFA_GetPacketByName(wsPacketName.AsWideStringC());
+ XFA_GetPacketByName(wsPacketName.AsStringC());
if (pPacketInfo && pPacketInfo->pURI) {
if (!XFA_FDEExtension_MatchNodeName(pElement, pPacketInfo->pName,
pPacketInfo->pURI,
@@ -586,7 +585,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm(
}
pNode->SetCData(XFA_ATTRIBUTE_Name,
XFA_GetPacketByIndex(XFA_PACKET_Form)->pName);
- pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum.AsWideStringC());
+ pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum.AsStringC());
CXFA_Node* pTemplateRoot =
m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template);
CXFA_Node* pTemplateChosen =
@@ -663,13 +662,13 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
->RemoveAttribute(L"xmlns:xfa");
pDataXMLNode = pXMLDocumentNode;
} else {
- CFDE_XMLElement* pDataElement = new CFDE_XMLElement(FX_WSTRC(L"xfa:data"));
+ CFDE_XMLElement* pDataElement = new CFDE_XMLElement(L"xfa:data");
CFDE_XMLNode* pParentXMLNode =
pXMLDocumentNode->GetNodeItem(CFDE_XMLNode::Parent);
if (pParentXMLNode) {
pParentXMLNode->RemoveChildNode(pXMLDocumentNode);
}
- FXSYS_assert(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element);
+ ASSERT(pXMLDocumentNode->GetType() == FDE_XMLNODE_Element);
if (pXMLDocumentNode->GetType() == FDE_XMLNODE_Element) {
static_cast<CFDE_XMLElement*>(pXMLDocumentNode)
->RemoveAttribute(L"xmlns:xfa");
@@ -694,7 +693,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
}
pNode->SetXMLMappingNode(pDataXMLNode);
if (pDataXMLNode != pXMLDocumentNode) {
- pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, TRUE, FALSE);
+ pNode->SetFlag(XFA_NODEFLAG_OwnXMLNode, false);
}
return pNode;
}
@@ -823,7 +822,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
CFX_WideString wsTagName;
pXMLElement->GetLocalTagName(wsTagName);
const XFA_ELEMENTINFO* pElemInfo =
- XFA_GetElementByName(wsTagName.AsWideStringC());
+ XFA_GetElementByName(wsTagName.AsStringC());
if (!pElemInfo) {
continue;
}
@@ -843,8 +842,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
return NULL;
}
if (ePacketID == XFA_XDPPACKET_Config) {
- pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name,
- wsTagName.AsWideStringC());
+ pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringC());
}
FX_BOOL IsNeedValue = TRUE;
for (int32_t i = 0, count = pXMLElement->CountAttributes(); i < count;
@@ -854,13 +852,13 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
CFX_WideString wsAttrValue;
pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue);
XFA_FDEExtension_GetAttributeLocalName(
- wsAttrQualifiedName.AsWideStringC(), wsAttrName);
+ wsAttrQualifiedName.AsStringC(), wsAttrName);
if (wsAttrName == FX_WSTRC(L"nil") &&
wsAttrValue == FX_WSTRC(L"true")) {
IsNeedValue = FALSE;
}
const XFA_ATTRIBUTEINFO* lpAttrInfo =
- XFA_GetAttributeByName(wsAttrName.AsWideStringC());
+ XFA_GetAttributeByName(wsAttrName.AsStringC());
if (!lpAttrInfo) {
continue;
}
@@ -868,8 +866,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
lpAttrInfo->eName != XFA_ATTRIBUTE_Save) {
continue;
}
- pXFAChild->SetAttribute(lpAttrInfo->eName,
- wsAttrValue.AsWideStringC());
+ pXFAChild->SetAttribute(lpAttrInfo->eName, wsAttrValue.AsStringC());
}
pXFANode->InsertChild(pXFAChild);
if (pElemInfo->eName == XFA_ELEMENT_Validate ||
@@ -961,7 +958,7 @@ void XFA_ConvertXMLToPlainText(CFDE_XMLElement* pRootXMLNode,
}
} break;
default:
- FXSYS_assert(FALSE);
+ ASSERT(FALSE);
break;
}
}
@@ -1017,7 +1014,7 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode,
if (pXFANode->GetObjectType() == XFA_OBJECTTYPE_ContentNode) {
CXFA_Node* pContentRawDataNode =
m_pFactory->CreateNode(ePacketID, element);
- FXSYS_assert(pContentRawDataNode);
+ ASSERT(pContentRawDataNode);
pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsValue);
pXFANode->InsertChild(pContentRawDataNode);
} else {
@@ -1112,8 +1109,8 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
CFX_WideString wsAttrNamespaceURI;
pXMLElement->GetAttribute(i, wsAttrQualifiedName, wsAttrValue);
if (!XFA_FDEExtension_ResolveAttribute(
- pXMLElement, wsAttrQualifiedName.AsWideStringC(),
- wsAttrName, wsAttrNamespaceURI)) {
+ pXMLElement, wsAttrQualifiedName.AsStringC(), wsAttrName,
+ wsAttrNamespaceURI)) {
continue;
}
if (wsAttrName == FX_WSTRC(L"nil") &&
@@ -1147,11 +1144,11 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
XFA_ATTRIBUTEENUM_MetaData);
pXFAChild->InsertChild(pXFAMetaData);
pXFAMetaData->SetXMLMappingNode(pXMLElement);
- pXFAMetaData->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pXFAMetaData->SetFlag(XFA_NODEFLAG_Initialized, false);
}
if (!bNeedValue) {
- CFX_WideString wsNilName = FX_WSTRC(L"xsi:nil");
- pXMLElement->RemoveAttribute(wsNilName);
+ CFX_WideString wsNilName(L"xsi:nil");
+ pXMLElement->RemoveAttribute(wsNilName.c_str());
}
}
pXFANode->InsertChild(pXFAChild);
@@ -1163,7 +1160,7 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
}
}
pXFAChild->SetXMLMappingNode(pXMLElement);
- pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false);
}
continue;
case FDE_XMLNODE_CharData: {
@@ -1182,7 +1179,7 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCharData);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLCharData);
- pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false);
}
continue;
case FDE_XMLNODE_Text: {
@@ -1200,7 +1197,7 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLText);
- pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false);
}
continue;
case FDE_XMLNODE_Instruction:
@@ -1250,18 +1247,18 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
} else {
bMarkAsCompound = TRUE;
if (pXMLCurValueNode) {
- CFX_WideStringC wsCurValue = wsCurValueTextBuf.GetWideString();
+ CFX_WideString wsCurValue = wsCurValueTextBuf.MakeString();
if (!wsCurValue.IsEmpty()) {
CXFA_Node* pXFAChild =
m_pFactory->CreateNode(ePacketID, XFA_ELEMENT_DataValue);
if (!pXFAChild)
return;
- pXFAChild->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L""));
+ pXFAChild->SetCData(XFA_ATTRIBUTE_Name, L"");
pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCurValue);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLCurValueNode);
- pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false);
wsValueTextBuf << wsCurValue;
wsCurValueTextBuf.Clear();
}
@@ -1278,13 +1275,13 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
ParseDataValue(pXFAChild, pXMLChild, ePacketID);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLChild);
- pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false);
CFX_WideStringC wsCurValue = pXFAChild->GetCData(XFA_ATTRIBUTE_Value);
wsValueTextBuf << wsCurValue;
}
}
if (pXMLCurValueNode) {
- CFX_WideStringC wsCurValue = wsCurValueTextBuf.GetWideString();
+ CFX_WideString wsCurValue = wsCurValueTextBuf.MakeString();
if (!wsCurValue.IsEmpty()) {
if (bMarkAsCompound) {
CXFA_Node* pXFAChild =
@@ -1292,18 +1289,18 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->SetCData(XFA_ATTRIBUTE_Name, FX_WSTRC(L""));
+ pXFAChild->SetCData(XFA_ATTRIBUTE_Name, L"");
pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCurValue);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLCurValueNode);
- pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, TRUE, FALSE);
+ pXFAChild->SetFlag(XFA_NODEFLAG_Initialized, false);
}
wsValueTextBuf << wsCurValue;
wsCurValueTextBuf.Clear();
}
pXMLCurValueNode = nullptr;
}
- CFX_WideStringC wsNodeValue = wsValueTextBuf.GetWideString();
+ CFX_WideString wsNodeValue = wsValueTextBuf.MakeString();
pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsNodeValue);
}
@@ -1320,7 +1317,7 @@ void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode,
if (pXMLInstruction->GetData(0, wsData) &&
(pXFANode->GetDocument()->RecognizeXFAVersionNumber(wsData) !=
XFA_VERSION_UNKNOWN)) {
- wsData.Empty();
+ wsData.clear();
if (pXMLInstruction->GetData(1, wsData) &&
wsData == FX_WSTRC(L"v2.7-scripting:1")) {
pXFANode->GetDocument()->SetFlag(XFA_DOCFLAG_Scripting, TRUE);
@@ -1366,7 +1363,7 @@ int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream,
int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) {
int32_t nRetStatus = m_nodeParser.DoParse(pPause);
if (nRetStatus >= XFA_PARSESTATUS_Done) {
- FXSYS_assert(m_pDocument);
+ ASSERT(m_pDocument);
m_pDocument->SetRoot(m_nodeParser.GetRootNode());
}
return nRetStatus;
@@ -1393,13 +1390,13 @@ void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode,
m_pDocument->SetRoot(pRootNode);
}
}
+
void CXFA_DocumentParser::CloseParser() {
- if (m_pDocument) {
- delete m_pDocument;
- m_pDocument = NULL;
- }
+ delete m_pDocument;
+ m_pDocument = nullptr;
m_nodeParser.CloseParser();
}
+
CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream)
: m_nElementStart(0),
m_dwCheckStatus(0),
@@ -1421,8 +1418,8 @@ CXFA_XMLParser::~CXFA_XMLParser() {
m_pParser->Release();
}
m_NodeStack.RemoveAll();
- m_ws1.Empty();
- m_ws2.Empty();
+ m_ws1.clear();
+ m_ws2.clear();
}
int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error)
@@ -1487,7 +1484,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
} else {
m_pChild = NULL;
}
- m_ws1.Empty();
+ m_ws1.clear();
break;
case FDE_XmlSyntaxResult::TagName:
m_pParser->GetTagName(m_ws1);
@@ -1522,7 +1519,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
static_cast<CFDE_XMLElement*>(m_pChild)->SetString(m_ws1, m_ws2);
}
}
- m_ws1.Empty();
+ m_ws1.clear();
break;
case FDE_XmlSyntaxResult::Text:
m_pParser->GetTextData(m_ws1);
@@ -1548,7 +1545,7 @@ int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
m_pParser->GetTargetData(m_ws1);
static_cast<CFDE_XMLInstruction*>(m_pChild)->AppendData(m_ws1);
}
- m_ws1.Empty();
+ m_ws1.clear();
break;
default:
break;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script.h
index 80601c5b97e..971fe06b564 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script.h
@@ -7,8 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_SCRIPT_H_
#define XFA_FXFA_PARSER_XFA_SCRIPT_H_
-#include "xfa/include/fxfa/fxfa.h"
-#include "xfa/include/fxfa/fxfa_objectacc.h"
+#include "xfa/fxfa/include/fxfa.h"
#define XFA_RESOLVENODE_Children 0x0001
#define XFA_RESOLVENODE_Attributes 0x0004
@@ -75,11 +74,4 @@ struct XFA_RESOLVENODE_RS {
const XFA_SCRIPTATTRIBUTEINFO* pScriptAttribute;
};
-struct XFA_JSBUILTININFO {
- uint32_t uUnicodeHash;
- const FX_CHAR* pName;
-};
-
-const XFA_JSBUILTININFO* XFA_GetJSBuiltinByHash(uint32_t uHashCode);
-
#endif // XFA_FXFA_PARSER_XFA_SCRIPT_H_
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_datawindow.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_datawindow.cpp
index c3383938fcc..8ce5061c035 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_datawindow.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_datawindow.cpp
@@ -7,7 +7,6 @@
#include "xfa/fxfa/parser/xfa_script_datawindow.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
index 4cfcf1cbc71..335df6a32ea 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.cpp
@@ -8,7 +8,7 @@
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
+#include "xfa/fxfa/include/xfa_ffwidgethandler.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -19,7 +19,6 @@
#include "xfa/fxfa/parser/xfa_script_imp.h"
#include "xfa/fxfa/parser/xfa_utils.h"
#include "xfa/fxjse/cfxjse_arguments.h"
-#include "xfa/include/fxfa/xfa_ffwidgethandler.h"
CScript_EventPseudoModel::CScript_EventPseudoModel(CXFA_Document* pDocument)
: CXFA_OrdinaryObject(pDocument, XFA_ELEMENT_EventPseudoModel) {
@@ -32,9 +31,9 @@ void Script_EventPseudoModel_StringProperty(FXJSE_HVALUE hValue,
if (bSetting) {
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
- wsValue = CFX_WideString::FromUTF8(bsValue, bsValue.GetLength());
+ wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC());
} else {
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsStringC());
}
}
void Script_EventPseudoModel_InterProperty(FXJSE_HVALUE hValue,
@@ -49,196 +48,192 @@ void Script_EventPseudoModel_InterProperty(FXJSE_HVALUE hValue,
void Script_EventPseudoModel_BooleanProperty(FXJSE_HVALUE hValue,
FX_BOOL& bValue,
FX_BOOL bSetting) {
- if (bSetting) {
+ if (bSetting)
bValue = FXJSE_Value_ToBoolean(hValue);
- } else {
+ else
FXJSE_Value_SetBoolean(hValue, bValue);
- }
}
+
void CScript_EventPseudoModel::Script_EventPseudoModel_Property(
FXJSE_HVALUE hValue,
- uint32_t dwFlag,
+ XFA_Event dwFlag,
FX_BOOL bSetting) {
CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
- if (!pScriptContext) {
+ if (!pScriptContext)
return;
- }
+
CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
- if (!pEventParam) {
+ if (!pEventParam)
return;
- }
+
switch (dwFlag) {
- case XFA_EVENT_CANCELACTION:
+ case XFA_Event::CancelAction:
Script_EventPseudoModel_BooleanProperty(
hValue, pEventParam->m_bCancelAction, bSetting);
break;
- case XFA_EVENT_CHANGE:
+ case XFA_Event::Change:
Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsChange,
bSetting);
break;
- case XFA_EVENT_COMMITKEY:
+ case XFA_Event::CommitKey:
Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iCommitKey,
bSetting);
break;
- case XFA_EVENT_FULLTEXT:
+ case XFA_Event::FullText:
Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsFullText,
bSetting);
break;
- case XFA_EVENT_KEYDOWN:
+ case XFA_Event::Keydown:
Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bKeyDown,
bSetting);
break;
- case XFA_EVENT_MODIFIER:
+ case XFA_Event::Modifier:
Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bModifier,
bSetting);
break;
- case XFA_EVENT_NEWCONTENTTYPE:
+ case XFA_Event::NewContentType:
Script_EventPseudoModel_StringProperty(
hValue, pEventParam->m_wsNewContentType, bSetting);
break;
- case XFA_EVENT_NEWTEXT:
+ case XFA_Event::NewText:
Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsNewText,
bSetting);
break;
- case XFA_EVENT_PREVCONTENTTYPE:
+ case XFA_Event::PreviousContentType:
Script_EventPseudoModel_StringProperty(
hValue, pEventParam->m_wsPrevContentType, bSetting);
break;
- case XFA_EVENT_PREVTEXT:
+ case XFA_Event::PreviousText:
Script_EventPseudoModel_StringProperty(hValue, pEventParam->m_wsPrevText,
bSetting);
break;
- case XFA_EVENT_REENTER:
+ case XFA_Event::Reenter:
Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bReenter,
bSetting);
break;
- case XFA_EVENT_SELEND:
+ case XFA_Event::SelectionEnd:
Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iSelEnd,
bSetting);
break;
- case XFA_EVENT_SELSTART:
+ case XFA_Event::SelectionStart:
Script_EventPseudoModel_InterProperty(hValue, pEventParam->m_iSelStart,
bSetting);
break;
- case XFA_EVENT_SHIFT:
+ case XFA_Event::Shift:
Script_EventPseudoModel_BooleanProperty(hValue, pEventParam->m_bShift,
bSetting);
break;
- case XFA_EVENT_SOAPFAULTCODE:
+ case XFA_Event::SoapFaultCode:
Script_EventPseudoModel_StringProperty(
hValue, pEventParam->m_wsSoapFaultCode, bSetting);
break;
- case XFA_EVENT_SOAPFAULTSTRING:
+ case XFA_Event::SoapFaultString:
Script_EventPseudoModel_StringProperty(
hValue, pEventParam->m_wsSoapFaultString, bSetting);
break;
- case XFA_EVENT_TARGET:
+ case XFA_Event::Target:
break;
default:
break;
}
}
-void CScript_EventPseudoModel::Script_EventPseudoModel_CancelAction(
- FXJSE_HVALUE hValue,
- FX_BOOL bSetting,
- XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_CANCELACTION, bSetting);
-}
void CScript_EventPseudoModel::Script_EventPseudoModel_Change(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_CHANGE, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::Change, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_CommitKey(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_COMMITKEY, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::CommitKey, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_FullText(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_FULLTEXT, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::FullText, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_KeyDown(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_KEYDOWN, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::Keydown, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_Modifier(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_MODIFIER, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::Modifier, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_NewContentType(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_NEWCONTENTTYPE, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::NewContentType, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_NewText(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_NEWTEXT, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::NewText, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_PrevContentType(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_PREVCONTENTTYPE, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::PreviousContentType,
+ bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_PrevText(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_PREVTEXT, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::PreviousText, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_Reenter(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_REENTER, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::Reenter, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_SelEnd(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_SELEND, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::SelectionEnd, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_SelStart(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_SELSTART, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::SelectionStart, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_Shift(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_SHIFT, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::Shift, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_SoapFaultCode(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_SOAPFAULTCODE, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::SoapFaultCode, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_SoapFaultString(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_SOAPFAULTSTRING, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::SoapFaultString,
+ bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_Target(
FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_EventPseudoModel_Property(hValue, XFA_EVENT_TARGET, bSetting);
+ Script_EventPseudoModel_Property(hValue, XFA_Event::Target, bSetting);
}
void CScript_EventPseudoModel::Script_EventPseudoModel_Emit(
CFXJSE_Arguments* pArguments) {
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.h
index 1c185f54625..d840329b4cb 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_eventpseudomodel.h
@@ -10,32 +10,31 @@
#include "xfa/fxfa/parser/xfa_object.h"
#include "xfa/fxjse/cfxjse_arguments.h"
-#define XFA_EVENT_CHANGE 0
-#define XFA_EVENT_COMMITKEY 1
-#define XFA_EVENT_FULLTEXT 2
-#define XFA_EVENT_KEYDOWN 3
-#define XFA_EVENT_MODIFIER 4
-#define XFA_EVENT_NEWCONTENTTYPE 5
-#define XFA_EVENT_NEWTEXT 6
-#define XFA_EVENT_PREVCONTENTTYPE 7
-#define XFA_EVENT_PREVTEXT 8
-#define XFA_EVENT_REENTER 9
-#define XFA_EVENT_SELEND 10
-#define XFA_EVENT_SELSTART 11
-#define XFA_EVENT_SHIFT 12
-#define XFA_EVENT_SOAPFAULTCODE 13
-#define XFA_EVENT_SOAPFAULTSTRING 14
-#define XFA_EVENT_TARGET 15
-#define XFA_EVENT_CANCELACTION 16
+enum class XFA_Event {
+ Change = 0,
+ CommitKey,
+ FullText,
+ Keydown,
+ Modifier,
+ NewContentType,
+ NewText,
+ PreviousContentType,
+ PreviousText,
+ Reenter,
+ SelectionEnd,
+ SelectionStart,
+ Shift,
+ SoapFaultCode,
+ SoapFaultString,
+ Target,
+ CancelAction
+};
class CScript_EventPseudoModel : public CXFA_OrdinaryObject {
public:
explicit CScript_EventPseudoModel(CXFA_Document* pDocument);
virtual ~CScript_EventPseudoModel();
- void Script_EventPseudoModel_CancelAction(FXJSE_HVALUE hValue,
- FX_BOOL bSetting,
- XFA_ATTRIBUTE eAttribute);
void Script_EventPseudoModel_Change(FXJSE_HVALUE hValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute);
@@ -90,7 +89,7 @@ class CScript_EventPseudoModel : public CXFA_OrdinaryObject {
protected:
void Script_EventPseudoModel_Property(FXJSE_HVALUE hValue,
- uint32_t dwFlag,
+ XFA_Event dwFlag,
FX_BOOL bSetting);
};
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
index 08e9cede928..94fa8db96c0 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
@@ -8,7 +8,6 @@
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
@@ -32,7 +31,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_LoadString(
uint32_t dwFlag) {
CFX_WideString wsValue;
pNotify->GetAppProvider()->LoadString(dwFlag, wsValue);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_AppType(
FXJSE_HVALUE hValue,
@@ -48,7 +47,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_AppType(
}
CFX_WideString wsAppType;
pNotify->GetAppProvider()->GetAppType(wsAppType);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppType).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppType).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType(
FXJSE_HVALUE hValue,
@@ -64,7 +63,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitAppType(
}
CFX_WideString wsAppType;
pNotify->GetAppProvider()->GetFoxitAppType(wsAppType);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppType).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppType).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_CalculationsEnabled(
FXJSE_HVALUE hValue,
@@ -114,7 +113,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_Language(
}
CFX_WideString wsLanguage;
pNotify->GetAppProvider()->GetLanguage(wsLanguage);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsLanguage).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsLanguage).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_NumPages(
FXJSE_HVALUE hValue,
@@ -146,7 +145,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_Platform(
}
CFX_WideString wsPlatform;
pNotify->GetAppProvider()->GetPlatform(wsPlatform);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsPlatform).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsPlatform).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_Title(
FXJSE_HVALUE hValue,
@@ -164,13 +163,12 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_Title(
CFX_ByteString bsValue;
FXJSE_Value_ToUTF8String(hValue, bsValue);
pNotify->GetDocProvider()->SetTitle(
- hDoc,
- CFX_WideString::FromUTF8(bsValue, bsValue.GetLength()).AsWideStringC());
+ hDoc, CFX_WideString::FromUTF8(bsValue.AsStringC()));
return;
}
CFX_WideString wsTitle;
pNotify->GetDocProvider()->GetTitle(hDoc, wsTitle);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsTitle).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsTitle).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_ValidationsEnabled(
FXJSE_HVALUE hValue,
@@ -206,7 +204,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_Variation(
}
CFX_WideString wsVariation;
pNotify->GetAppProvider()->GetVariation(wsVariation);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVariation).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVariation).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_Version(
FXJSE_HVALUE hValue,
@@ -222,7 +220,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_Version(
}
CFX_WideString wsVersion;
pNotify->GetAppProvider()->GetVersion(wsVersion);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVersion).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVersion).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion(
FXJSE_HVALUE hValue,
@@ -238,7 +236,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitVersion(
}
CFX_WideString wsVersion;
pNotify->GetAppProvider()->GetFoxitVersion(wsVersion);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVersion).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsVersion).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_Name(
FXJSE_HVALUE hValue,
@@ -254,7 +252,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_Name(
}
CFX_WideString wsAppName;
pNotify->GetAppProvider()->GetAppName(wsAppName);
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppName).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAppName).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName(
FXJSE_HVALUE hValue,
@@ -270,8 +268,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_FoxitName(
}
CFX_WideString wsFoxitAppName;
pNotify->GetAppProvider()->GetFoxitAppName(wsFoxitAppName);
- FXJSE_Value_SetUTF8String(hValue,
- FX_UTF8Encode(wsFoxitAppName).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsFoxitAppName).AsStringC());
}
void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL(
CFXJSE_Arguments* pArguments) {
@@ -291,9 +288,9 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_GotoURL(
CFX_WideString wsURL;
if (iLength >= 1) {
CFX_ByteString bsURL = pArguments->GetUTF8String(0);
- wsURL = CFX_WideString::FromUTF8(bsURL, bsURL.GetLength());
+ wsURL = CFX_WideString::FromUTF8(bsURL.AsStringC());
}
- pNotify->GetDocProvider()->GotoURL(hDoc, wsURL.AsWideStringC());
+ pNotify->GetDocProvider()->GotoURL(hDoc, wsURL);
}
void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList(
CFXJSE_Arguments* pArguments) {
@@ -318,7 +315,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList(
CFX_ByteString bsString;
FXJSE_Value_ToUTF8String(hValue, bsString);
CFX_WideString wsExpression =
- CFX_WideString::FromUTF8(bsString, bsString.GetLength());
+ CFX_WideString::FromUTF8(bsString.AsStringC());
CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
if (!pScriptContext) {
FXJSE_Value_Release(hValue);
@@ -333,7 +330,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList(
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
- pObject, wsExpression.AsWideStringC(), resoveNodeRS, dwFlag);
+ pObject, wsExpression.AsStringC(), resoveNodeRS, dwFlag);
if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) {
FXJSE_Value_Release(hValue);
return;
@@ -371,27 +368,24 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_Response(
FX_BOOL bMark = FALSE;
if (iLength >= 1) {
CFX_ByteString bsQuestion = pArguments->GetUTF8String(0);
- wsQuestion = CFX_WideString::FromUTF8(bsQuestion, bsQuestion.GetLength());
+ wsQuestion = CFX_WideString::FromUTF8(bsQuestion.AsStringC());
}
if (iLength >= 2) {
CFX_ByteString bsTitle = pArguments->GetUTF8String(1);
- wsTitle = CFX_WideString::FromUTF8(bsTitle, bsTitle.GetLength());
+ wsTitle = CFX_WideString::FromUTF8(bsTitle.AsStringC());
}
if (iLength >= 3) {
CFX_ByteString bsDefaultAnswer = pArguments->GetUTF8String(2);
- wsDefaultAnswer =
- CFX_WideString::FromUTF8(bsDefaultAnswer, bsDefaultAnswer.GetLength());
+ wsDefaultAnswer = CFX_WideString::FromUTF8(bsDefaultAnswer.AsStringC());
}
if (iLength >= 4) {
bMark = pArguments->GetInt32(3) == 0 ? FALSE : TRUE;
}
- CFX_WideString wsAnswer;
- pNotify->GetAppProvider()->Response(wsAnswer, wsQuestion.AsWideStringC(),
- wsTitle.AsWideStringC(),
- wsDefaultAnswer.AsWideStringC(), bMark);
+ CFX_WideString wsAnswer = pNotify->GetAppProvider()->Response(
+ wsQuestion, wsTitle, wsDefaultAnswer, bMark);
FXJSE_HVALUE hValue = pArguments->GetReturnValue();
if (hValue) {
- FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAnswer).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsAnswer).AsStringC());
}
}
void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch(
@@ -409,14 +403,14 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_DocumentInBatch(
static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression,
int32_t nStart,
CFX_WideString& wsFilter) {
- FXSYS_assert(nStart > -1);
+ ASSERT(nStart > -1);
int32_t iLength = wsExpression.GetLength();
if (nStart >= iLength) {
return iLength;
}
FX_WCHAR* pBuf = wsFilter.GetBuffer(iLength - nStart);
int32_t nCount = 0;
- const FX_WCHAR* pSrc = wsExpression.raw_str();
+ const FX_WCHAR* pSrc = wsExpression.c_str();
FX_WCHAR wCur;
while (nStart < iLength) {
wCur = pSrc[nStart++];
@@ -444,8 +438,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData(
CFX_WideString wsExpression;
if (iLength >= 1) {
CFX_ByteString bsExpression = pArguments->GetUTF8String(0);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC());
}
if (wsExpression.IsEmpty()) {
pNotify->ResetData();
@@ -456,7 +449,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData(
CXFA_Node* pNode = NULL;
int32_t iExpLength = wsExpression.GetLength();
while (iStart < iExpLength) {
- iStart = XFA_FilterName(wsExpression.AsWideStringC(), iStart, wsName);
+ iStart = XFA_FilterName(wsExpression.AsStringC(), iStart, wsName);
CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
if (!pScriptContext) {
return;
@@ -468,8 +461,8 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_ResetData(
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resoveNodeRS;
- int32_t iRet = pScriptContext->ResolveObjects(
- pObject, wsName.AsWideStringC(), resoveNodeRS, dwFlag);
+ int32_t iRet = pScriptContext->ResolveObjects(pObject, wsName.AsStringC(),
+ resoveNodeRS, dwFlag);
if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) {
continue;
}
@@ -523,7 +516,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus(
CFX_ByteString bsString;
FXJSE_Value_ToUTF8String(hValue, bsString);
CFX_WideString wsExpression =
- CFX_WideString::FromUTF8(bsString, bsString.GetLength());
+ CFX_WideString::FromUTF8(bsString.AsStringC());
CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
if (!pScriptContext) {
FXJSE_Value_Release(hValue);
@@ -538,7 +531,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus(
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
- pObject, wsExpression.AsWideStringC(), resoveNodeRS, dwFlag);
+ pObject, wsExpression.AsStringC(), resoveNodeRS, dwFlag);
if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) {
FXJSE_Value_Release(hValue);
return;
@@ -603,8 +596,7 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_MessageBox(
}
}
int32_t iValue = pNotify->GetAppProvider()->MsgBox(
- wsMessage.AsWideStringC(), bsTitle.AsWideStringC(), dwMessageType,
- dwButtonType);
+ wsMessage, bsTitle, dwMessageType, dwButtonType);
FXJSE_HVALUE hValue = pArguments->GetReturnValue();
if (hValue) {
FXJSE_Value_SetInteger(hValue, iValue);
@@ -633,7 +625,7 @@ FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg(
} else {
CFX_ByteString byMessage;
FXJSE_Value_ToUTF8String(hValueArg, byMessage);
- wsValue = CFX_WideString::FromUTF8(byMessage, byMessage.GetLength());
+ wsValue = CFX_WideString::FromUTF8(byMessage.AsStringC());
}
FXJSE_Value_Release(hValueArg);
return TRUE;
@@ -733,10 +725,10 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_ImportData(
CFX_WideString wsFilePath;
if (iLength > 0) {
CFX_ByteString bsFilePath = pArguments->GetUTF8String(0);
- wsFilePath = CFX_WideString::FromUTF8(bsFilePath, bsFilePath.GetLength());
+ wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC());
}
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
- pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath.AsWideStringC());
+ pNotify->GetDocProvider()->ImportData(hDoc, wsFilePath);
}
void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData(
CFXJSE_Arguments* pArguments) {
@@ -754,12 +746,12 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_ExportData(
FX_BOOL bXDP = TRUE;
if (iLength >= 1) {
CFX_ByteString bsFilePath = pArguments->GetUTF8String(0);
- wsFilePath = CFX_WideString::FromUTF8(bsFilePath, bsFilePath.GetLength());
+ wsFilePath = CFX_WideString::FromUTF8(bsFilePath.AsStringC());
}
if (iLength >= 2) {
bXDP = pArguments->GetInt32(1) == 0 ? FALSE : TRUE;
}
- pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath.AsWideStringC(), bXDP);
+ pNotify->GetDocProvider()->ExportData(hDoc, wsFilePath, bXDP);
}
void CScript_HostPseudoModel::Script_HostPseudoModel_PageUp(
CFXJSE_Arguments* pArguments) {
@@ -805,7 +797,6 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_CurrentDateTime(
CFX_WideString wsDataTime = pNotify->GetCurrentDateTime();
FXJSE_HVALUE hValue = pArguments->GetReturnValue();
if (hValue) {
- FXJSE_Value_SetUTF8String(hValue,
- FX_UTF8Encode(wsDataTime).AsByteStringC());
+ FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsDataTime).AsStringC());
}
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.cpp
index fe6caa84bc3..893c5b79ea5 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.cpp
@@ -9,7 +9,6 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -54,15 +53,10 @@ CXFA_ScriptContext::~CXFA_ScriptContext() {
FXJSE_Context_Release(m_hJsContext);
m_hJsContext = NULL;
}
- if (m_pResolveProcessor) {
- delete m_pResolveProcessor;
- m_pResolveProcessor = NULL;
- }
+ delete m_pResolveProcessor;
m_upObjectArray.RemoveAll();
- for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++) {
- delete ((CXFA_NodeList*)m_CacheListArray[i]);
- }
- m_CacheListArray.RemoveAll();
+ for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++)
+ delete m_CacheListArray[i];
}
void CXFA_ScriptContext::Initialize(FXJSE_HRUNTIME hRuntime) {
m_hJsRuntime = hRuntime;
@@ -96,12 +90,13 @@ FX_BOOL CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType,
btScript =
FX_UTF8Encode(wsJavaScript.GetBuffer(), wsJavaScript.GetLength());
} else {
- btScript = FX_UTF8Encode(wsScript.raw_str(), wsScript.GetLength());
+ btScript = FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength());
}
CXFA_Object* pOriginalObject = m_pThisObject;
m_pThisObject = pThisObject;
FXJSE_HVALUE pValue = pThisObject ? GetJSValueFromMap(pThisObject) : NULL;
- FX_BOOL bRet = FXJSE_ExecuteScript(m_hJsContext, btScript, hRetValue, pValue);
+ FX_BOOL bRet =
+ FXJSE_ExecuteScript(m_hJsContext, btScript.c_str(), hRetValue, pValue);
m_pThisObject = pOriginalObject;
m_eScriptType = eSaveType;
return bRet;
@@ -115,8 +110,7 @@ void CXFA_ScriptContext::GlobalPropertySetter(FXJSE_HOBJECT hObject,
CXFA_ScriptContext* lpScriptContext =
(CXFA_ScriptContext*)pDoc->GetScriptContext();
CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(lpOrginalNode);
- CFX_WideString wsPropName = CFX_WideString::FromUTF8(
- (const FX_CHAR*)szPropName.raw_str(), szPropName.GetLength());
+ CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
uint32_t dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings |
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
XFA_RESOLVENODE_Attributes;
@@ -124,8 +118,8 @@ void CXFA_ScriptContext::GlobalPropertySetter(FXJSE_HOBJECT hObject,
if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
pRefNode = ToNode(lpCurNode);
}
- if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsWideStringC(),
- hValue, dwFlag, TRUE)) {
+ if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), hValue,
+ dwFlag, TRUE)) {
return;
}
if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
@@ -174,15 +168,13 @@ void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject,
CXFA_ScriptContext* lpScriptContext =
(CXFA_ScriptContext*)pDoc->GetScriptContext();
CXFA_Object* lpCurNode = lpScriptContext->GetVariablesThis(pOrginalObject);
- CFX_WideString wsPropName = CFX_WideString::FromUTF8(
- (const FX_CHAR*)szPropName.raw_str(), szPropName.GetLength());
+ CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
if (lpScriptContext->GetType() == XFA_SCRIPTLANGTYPE_Formcalc) {
if (szPropName == FOXIT_XFA_FM2JS_FORMCALC_RUNTIME) {
XFA_FM2JS_GlobalPropertyGetter(lpScriptContext->m_hFM2JSContext, hValue);
return;
}
- uint32_t uHashCode =
- FX_HashCode_String_GetW(wsPropName, wsPropName.GetLength());
+ uint32_t uHashCode = FX_HashCode_GetW(wsPropName.AsStringC(), false);
if (uHashCode != XFA_HASHCODE_Layout) {
CXFA_Object* pObject =
lpScriptContext->GetDocument()->GetXFAObject(uHashCode);
@@ -198,13 +190,13 @@ void CXFA_ScriptContext::GlobalPropertyGetter(FXJSE_HOBJECT hObject,
if (pOrginalObject->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
pRefNode = ToNode(lpCurNode);
}
- if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsWideStringC(),
- hValue, dwFlag, FALSE)) {
+ if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), hValue,
+ dwFlag, FALSE)) {
return;
}
dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
- if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsWideStringC(),
- hValue, dwFlag, FALSE)) {
+ if (lpScriptContext->QueryNodeByFlag(pRefNode, wsPropName.AsStringC(), hValue,
+ dwFlag, FALSE)) {
return;
}
CXFA_Object* pScriptObject =
@@ -230,8 +222,7 @@ void CXFA_ScriptContext::NormalPropertyGetter(FXJSE_HOBJECT hObject,
FXJSE_Value_SetUndefined(hValue);
return;
}
- CFX_WideString wsPropName = CFX_WideString::FromUTF8(
- (const FX_CHAR*)szPropName.raw_str(), szPropName.GetLength());
+ CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
CXFA_ScriptContext* lpScriptContext =
(CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext();
CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject);
@@ -244,7 +235,7 @@ void CXFA_ScriptContext::NormalPropertyGetter(FXJSE_HOBJECT hObject,
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
XFA_RESOLVENODE_Attributes;
FX_BOOL bRet = lpScriptContext->QueryNodeByFlag(
- ToNode(pObject), wsPropName.AsWideStringC(), hValue, dwFlag, FALSE);
+ ToNode(pObject), wsPropName.AsStringC(), hValue, dwFlag, FALSE);
if (bRet) {
return;
}
@@ -253,7 +244,7 @@ void CXFA_ScriptContext::NormalPropertyGetter(FXJSE_HOBJECT hObject,
!lpScriptContext->IsStrictScopeInJavaScript())) {
dwFlag = XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings;
bRet = lpScriptContext->QueryNodeByFlag(
- ToNode(pObject), wsPropName.AsWideStringC(), hValue, dwFlag, FALSE);
+ ToNode(pObject), wsPropName.AsStringC(), hValue, dwFlag, FALSE);
}
if (bRet) {
return;
@@ -279,10 +270,9 @@ void CXFA_ScriptContext::NormalPropertySetter(FXJSE_HOBJECT hObject,
CXFA_ScriptContext* lpScriptContext =
(CXFA_ScriptContext*)pOrginalObject->GetDocument()->GetScriptContext();
CXFA_Object* pObject = lpScriptContext->GetVariablesThis(pOrginalObject);
- CFX_WideString wsPropName = CFX_WideString::FromUTF8(
- (const FX_CHAR*)szPropName.raw_str(), szPropName.GetLength());
+ CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = XFA_GetScriptAttributeByName(
- pObject->GetClassID(), wsPropName.AsWideStringC());
+ pObject->GetClassID(), wsPropName.AsStringC());
if (lpAttributeInfo) {
(pObject->*(lpAttributeInfo->lpfnCallback))(
hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
@@ -294,17 +284,17 @@ void CXFA_ScriptContext::NormalPropertySetter(FXJSE_HOBJECT hObject,
CXFA_Node* pNode = ToNode(pObject);
CXFA_Node* pPropOrChild = NULL;
const XFA_ELEMENTINFO* lpElementInfo =
- XFA_GetElementByName(wsPropName.AsWideStringC());
+ XFA_GetElementByName(wsPropName.AsStringC());
if (lpElementInfo) {
pPropOrChild = pNode->GetProperty(0, lpElementInfo->eName);
} else {
- pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsWideStringC());
+ pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsStringC());
}
if (pPropOrChild) {
- CFX_WideString wsDefaultName = FX_WSTRC(L"{default}");
+ CFX_WideString wsDefaultName(L"{default}");
const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
XFA_GetScriptAttributeByName(pPropOrChild->GetClassID(),
- wsDefaultName.AsWideStringC());
+ wsDefaultName.AsStringC());
if (lpAttributeInfo) {
(pPropOrChild->*(lpAttributeInfo->lpfnCallback))(
hValue, TRUE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
@@ -332,13 +322,12 @@ int32_t CXFA_ScriptContext::NormalPropTypeGetter(
(CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
pObject = lpScriptContext->GetVariablesThis(pObject);
XFA_ELEMENT objElement = pObject->GetClassID();
- CFX_WideString wsPropName = CFX_WideString::FromUTF8(
- (const FX_CHAR*)szPropName.raw_str(), szPropName.GetLength());
- if (XFA_GetMethodByName(objElement, wsPropName.AsWideStringC())) {
+ CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
+ if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) {
return FXJSE_ClassPropType_Method;
}
if (bQueryIn &&
- !XFA_GetScriptAttributeByName(objElement, wsPropName.AsWideStringC())) {
+ !XFA_GetScriptAttributeByName(objElement, wsPropName.AsStringC())) {
return FXJSE_ClassPropType_None;
}
return FXJSE_ClassPropType_Property;
@@ -355,9 +344,8 @@ int32_t CXFA_ScriptContext::GlobalPropTypeGetter(
(CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
pObject = lpScriptContext->GetVariablesThis(pObject);
XFA_ELEMENT objElement = pObject->GetClassID();
- CFX_WideString wsPropName = CFX_WideString::FromUTF8(
- (const FX_CHAR*)szPropName.raw_str(), szPropName.GetLength());
- if (XFA_GetMethodByName(objElement, wsPropName.AsWideStringC())) {
+ CFX_WideString wsPropName = CFX_WideString::FromUTF8(szPropName);
+ if (XFA_GetMethodByName(objElement, wsPropName.AsStringC())) {
return FXJSE_ClassPropType_Method;
}
return FXJSE_ClassPropType_Property;
@@ -372,10 +360,9 @@ void CXFA_ScriptContext::NormalMethodCall(FXJSE_HOBJECT hThis,
CXFA_ScriptContext* lpScriptContext =
(CXFA_ScriptContext*)pObject->GetDocument()->GetScriptContext();
pObject = lpScriptContext->GetVariablesThis(pObject);
- CFX_WideString wsFunName = CFX_WideString::FromUTF8(
- (const FX_CHAR*)szFuncName.raw_str(), szFuncName.GetLength());
+ CFX_WideString wsFunName = CFX_WideString::FromUTF8(szFuncName);
const XFA_METHODINFO* lpMethodInfo =
- XFA_GetMethodByName(pObject->GetClassID(), wsFunName.AsWideStringC());
+ XFA_GetMethodByName(pObject->GetClassID(), wsFunName.AsStringC());
if (NULL == lpMethodInfo) {
return;
}
@@ -408,29 +395,29 @@ void CXFA_ScriptContext::DefineJsContext() {
FXJSE_HCONTEXT CXFA_ScriptContext::CreateVariablesContext(
CXFA_Node* pScriptNode,
CXFA_Node* pSubform) {
- if (pScriptNode == NULL || pSubform == NULL) {
- return NULL;
- }
+ if (!pScriptNode || !pSubform)
+ return nullptr;
+
if (m_mapVariableToHValue.GetCount() == 0) {
- m_JsGlobalVariablesClass.constructor = NULL;
+ m_JsGlobalVariablesClass.constructor = nullptr;
m_JsGlobalVariablesClass.name = "XFAScriptObject";
m_JsGlobalVariablesClass.propNum = 0;
- m_JsGlobalVariablesClass.properties = NULL;
+ m_JsGlobalVariablesClass.properties = nullptr;
m_JsGlobalVariablesClass.methNum = 0;
- m_JsGlobalVariablesClass.methods = NULL;
+ m_JsGlobalVariablesClass.methods = nullptr;
m_JsGlobalVariablesClass.dynPropGetter =
CXFA_ScriptContext::GlobalPropertyGetter;
m_JsGlobalVariablesClass.dynPropSetter =
CXFA_ScriptContext::GlobalPropertySetter;
m_JsGlobalVariablesClass.dynPropTypeGetter =
CXFA_ScriptContext::NormalPropTypeGetter;
- m_JsGlobalVariablesClass.dynPropDeleter = NULL;
+ m_JsGlobalVariablesClass.dynPropDeleter = nullptr;
m_JsGlobalVariablesClass.dynMethodCall =
CXFA_ScriptContext::NormalMethodCall;
}
- CXFA_ThisProxy* lpVariableNode = new CXFA_ThisProxy(pSubform, pScriptNode);
- FXJSE_HCONTEXT hVariablesContext = FXJSE_Context_Create(
- m_hJsRuntime, &m_JsGlobalVariablesClass, (CXFA_Object*)lpVariableNode);
+ FXJSE_HCONTEXT hVariablesContext =
+ FXJSE_Context_Create(m_hJsRuntime, &m_JsGlobalVariablesClass,
+ new CXFA_ThisProxy(pSubform, pScriptNode));
RemoveBuiltInObjs(hVariablesContext);
FXJSE_Context_EnableCompatibleMode(
hVariablesContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS);
@@ -445,96 +432,96 @@ CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject,
}
return pObject;
}
+
FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) {
- if (pScriptNode == NULL) {
+ if (!pScriptNode)
return FALSE;
- }
- if (pScriptNode->GetClassID() == XFA_ELEMENT_Script) {
- CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (!pParent || pParent->GetClassID() != XFA_ELEMENT_Variables) {
- return FALSE;
- }
- if (m_mapVariableToHValue.GetValueAt(pScriptNode)) {
- return TRUE;
- }
- CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pTextNode) {
- return FALSE;
- }
- CFX_WideStringC wsScript;
- if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript)) {
- return FALSE;
- }
- CFX_ByteString btScript =
- FX_UTF8Encode(wsScript.raw_str(), wsScript.GetLength());
- FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_hJsRuntime);
- CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent);
- FXJSE_HCONTEXT hVariablesContext =
- CreateVariablesContext(pScriptNode, pThisObject);
- CXFA_Object* pOriginalObject = m_pThisObject;
- m_pThisObject = pThisObject;
- FX_BOOL bRet = FXJSE_ExecuteScript(hVariablesContext, btScript, hRetValue);
- m_pThisObject = pOriginalObject;
- FXJSE_Value_Release(hRetValue);
- return bRet;
- }
- return TRUE;
+
+ if (pScriptNode->GetClassID() != XFA_ELEMENT_Script)
+ return TRUE;
+
+ CXFA_Node* pParent = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
+ if (!pParent || pParent->GetClassID() != XFA_ELEMENT_Variables)
+ return FALSE;
+
+ if (m_mapVariableToHValue.GetValueAt(pScriptNode))
+ return TRUE;
+
+ CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (!pTextNode)
+ return FALSE;
+
+ CFX_WideStringC wsScript;
+ if (!pTextNode->TryCData(XFA_ATTRIBUTE_Value, wsScript))
+ return FALSE;
+
+ CFX_ByteString btScript =
+ FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength());
+ FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_hJsRuntime);
+ CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent);
+ FXJSE_HCONTEXT hVariablesContext =
+ CreateVariablesContext(pScriptNode, pThisObject);
+ CXFA_Object* pOriginalObject = m_pThisObject;
+ m_pThisObject = pThisObject;
+ FX_BOOL bRet =
+ FXJSE_ExecuteScript(hVariablesContext, btScript.c_str(), hRetValue);
+ m_pThisObject = pOriginalObject;
+ FXJSE_Value_Release(hRetValue);
+ return bRet;
}
+
FX_BOOL CXFA_ScriptContext::QueryVariableHValue(
CXFA_Node* pScriptNode,
const CFX_ByteStringC& szPropName,
FXJSE_HVALUE hValue,
FX_BOOL bGetter) {
- if (!pScriptNode || pScriptNode->GetClassID() != XFA_ELEMENT_Script) {
+ if (!pScriptNode || pScriptNode->GetClassID() != XFA_ELEMENT_Script)
return FALSE;
- }
+
CXFA_Node* variablesNode = pScriptNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (!variablesNode || variablesNode->GetClassID() != XFA_ELEMENT_Variables) {
+ if (!variablesNode || variablesNode->GetClassID() != XFA_ELEMENT_Variables)
return FALSE;
- }
- FX_BOOL bRes = FALSE;
+
void* lpVariables = m_mapVariableToHValue.GetValueAt(pScriptNode);
- if (lpVariables) {
- FXJSE_HCONTEXT hVariableContext = (FXJSE_HCONTEXT)lpVariables;
- FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext);
- FXJSE_HVALUE hVariableValue = FXJSE_Value_Create(m_hJsRuntime);
- if (!bGetter) {
- FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue);
- bRes = TRUE;
- } else if (FXJSE_Value_ObjectHasOwnProp(hObject, szPropName, FALSE)) {
- FXJSE_Value_GetObjectProp(hObject, szPropName, hVariableValue);
- if (FXJSE_Value_IsFunction(hVariableValue)) {
- FXJSE_Value_SetFunctionBind(hValue, hVariableValue, hObject);
- } else if (bGetter) {
- FXJSE_Value_Set(hValue, hVariableValue);
- } else {
- FXJSE_Value_Set(hVariableValue, hValue);
- }
- bRes = TRUE;
- }
- FXJSE_Value_Release(hVariableValue);
- FXJSE_Value_Release(hObject);
- }
+ if (!lpVariables)
+ return FALSE;
+
+ FX_BOOL bRes = FALSE;
+ FXJSE_HCONTEXT hVariableContext = (FXJSE_HCONTEXT)lpVariables;
+ FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext);
+ FXJSE_HVALUE hVariableValue = FXJSE_Value_Create(m_hJsRuntime);
+ if (!bGetter) {
+ FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue);
+ bRes = TRUE;
+ } else if (FXJSE_Value_ObjectHasOwnProp(hObject, szPropName, FALSE)) {
+ FXJSE_Value_GetObjectProp(hObject, szPropName, hVariableValue);
+ if (FXJSE_Value_IsFunction(hVariableValue))
+ FXJSE_Value_SetFunctionBind(hValue, hVariableValue, hObject);
+ else if (bGetter)
+ FXJSE_Value_Set(hValue, hVariableValue);
+ else
+ FXJSE_Value_Set(hVariableValue, hValue);
+ bRes = TRUE;
+ }
+ FXJSE_Value_Release(hVariableValue);
+ FXJSE_Value_Release(hObject);
return bRes;
}
+
void CXFA_ScriptContext::ReleaseVariablesMap() {
FX_POSITION ps = m_mapVariableToHValue.GetStartPosition();
while (ps) {
CXFA_Object* pScriptNode;
- FXJSE_HCONTEXT hVariableContext;
+ FXJSE_HCONTEXT hVariableContext = nullptr;
m_mapVariableToHValue.GetNextAssoc(ps, pScriptNode, hVariableContext);
FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext);
- CXFA_Object* lpCurNode = (CXFA_Object*)FXJSE_Value_ToObject(hObject, NULL);
- if (lpCurNode) {
- delete (CXFA_ThisProxy*)lpCurNode;
- lpCurNode = NULL;
- }
+ delete static_cast<CXFA_ThisProxy*>(FXJSE_Value_ToObject(hObject, nullptr));
FXJSE_Value_Release(hObject);
FXJSE_Context_Release(hVariableContext);
- hVariableContext = NULL;
}
m_mapVariableToHValue.RemoveAll();
}
+
void CXFA_ScriptContext::DefineJsClass() {
m_JsNormalClass.constructor = NULL;
m_JsNormalClass.name = "XFAObject";
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.h
index 414e403d19e..1ff8f76745b 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_imp.h
@@ -113,7 +113,7 @@ class CXFA_ScriptContext {
CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HCONTEXT> m_mapVariableToHValue;
CXFA_EventParam m_eventParam;
CXFA_NodeArray m_upObjectArray;
- CFX_PtrArray m_CacheListArray;
+ CFX_ArrayTemplate<CXFA_NodeList*> m_CacheListArray;
CXFA_NodeArray* m_pScriptNodeArray;
CXFA_ResolveProcessor* m_pResolveProcessor;
XFA_HFM2JSCONTEXT m_hFM2JSContext;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
index 1b70dffb199..e48d3d5ffa0 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp
@@ -8,7 +8,6 @@
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_document_layout_imp.h"
@@ -66,7 +65,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_HWXY(
return;
}
CXFA_Node* pNode = NULL;
- CFX_WideString wsUnit = FX_WSTRC(L"pt");
+ CFX_WideString wsUnit(L"pt");
int32_t iIndex = 0;
if (iLength >= 1) {
pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
@@ -74,7 +73,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_HWXY(
if (iLength >= 2) {
CFX_ByteString bsUnit = pArguments->GetUTF8String(1);
if (!bsUnit.IsEmpty()) {
- wsUnit = CFX_WideString::FromUTF8(bsUnit, bsUnit.GetLength());
+ wsUnit = CFX_WideString::FromUTF8(bsUnit.AsStringC());
}
}
if (iLength >= 3) {
@@ -117,7 +116,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_HWXY(
measure.Set(rtRect.top, XFA_UNIT_Pt);
break;
}
- XFA_UNIT unit = measure.GetUnit(wsUnit.AsWideStringC());
+ XFA_UNIT unit = measure.GetUnit(wsUnit.AsStringC());
FX_FLOAT fValue = measure.ToUnit(unit);
fValue = FXSYS_round(fValue * 1000) / 1000.0f;
if (hValue) {
@@ -367,7 +366,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageContent(
}
if (iLength >= 2) {
CFX_ByteString bsType = pArguments->GetUTF8String(1);
- wsType = CFX_WideString::FromUTF8(bsType, bsType.GetLength());
+ wsType = CFX_WideString::FromUTF8(bsType.AsStringC());
}
if (iLength >= 3) {
bOnPageArea = pArguments->GetInt32(2) == 0 ? FALSE : TRUE;
@@ -423,7 +422,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_Relayout(
CFXJSE_Arguments* pArguments) {
CXFA_Node* pRootNode = m_pDocument->GetRoot();
CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_ELEMENT_Form);
- FXSYS_assert(pFormRoot);
+ ASSERT(pFormRoot);
CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor();
if (pContentRootNode) {
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
index f2d7f1aaf85..86d3803a46e 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_logpseudomodel.cpp
@@ -7,7 +7,6 @@
#include "xfa/fxfa/parser/xfa_script_logpseudomodel.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_nodehelper.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_nodehelper.cpp
index 9e8ff5191c9..93bf40e324f 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_nodehelper.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_nodehelper.cpp
@@ -8,7 +8,6 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -34,7 +33,7 @@ CXFA_Node* CXFA_NodeHelper::XFA_ResolveNodes_GetOneChild(
return NULL;
}
CXFA_NodeArray siblings;
- uint32_t uNameHash = FX_HashCode_String_GetW(pwsName, FXSYS_wcslen(pwsName));
+ uint32_t uNameHash = FX_HashCode_GetW(CFX_WideStringC(pwsName), false);
XFA_NodeAcc_TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName);
if (siblings.GetSize() == 0) {
return NULL;
@@ -261,7 +260,7 @@ void CXFA_NodeHelper::XFA_GetNameExpression(CXFA_Node* refNode,
CFX_WideString& wsName,
FX_BOOL bIsAllPath,
XFA_LOGIC_TYPE eLogicType) {
- wsName.Empty();
+ wsName.clear();
if (bIsAllPath) {
XFA_GetNameExpression(refNode, wsName, FALSE, eLogicType);
CFX_WideString wsParent;
@@ -284,13 +283,13 @@ void CXFA_NodeHelper::XFA_GetNameExpression(CXFA_Node* refNode,
(bIsProperty && refNode->GetClassID() != XFA_ELEMENT_PageSet)) {
refNode->GetClassName(wsTagName);
ws = wsTagName;
- wsName.Format(L"#%s[%d]", (const FX_WCHAR*)ws,
+ wsName.Format(L"#%s[%d]", ws.c_str(),
XFA_GetIndex(refNode, eLogicType, bIsProperty, TRUE));
return;
}
ws = refNode->GetCData(XFA_ATTRIBUTE_Name);
ws.Replace(L".", L"\\.");
- wsName.Format(L"%s[%d]", (const FX_WCHAR*)ws,
+ wsName.Format(L"%s[%d]", ws.c_str(),
XFA_GetIndex(refNode, eLogicType, bIsProperty, FALSE));
}
@@ -309,9 +308,8 @@ FX_BOOL CXFA_NodeHelper::XFA_NodeIsTransparent(CXFA_Node* refNode) {
FX_BOOL CXFA_NodeHelper::XFA_CreateNode_ForCondition(
CFX_WideString& wsCondition) {
int32_t iLen = wsCondition.GetLength();
- CFX_WideString wsIndex = FX_WSTRC(L"0");
+ CFX_WideString wsIndex(L"0");
FX_BOOL bAll = FALSE;
-
if (iLen == 0) {
m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne;
return FALSE;
@@ -368,8 +366,7 @@ FX_BOOL CXFA_NodeHelper::XFA_ResolveNodes_CreateNode(
XFA_CreateNode_ForCondition(wsCondition);
}
if (bIsClassName) {
- const XFA_ELEMENTINFO* lpElement =
- XFA_GetElementByName(wsName.AsWideStringC());
+ const XFA_ELEMENTINFO* lpElement = XFA_GetElementByName(wsName.AsStringC());
if (lpElement == NULL) {
return FALSE;
}
@@ -392,7 +389,7 @@ FX_BOOL CXFA_NodeHelper::XFA_ResolveNodes_CreateNode(
for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) {
CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType);
if (pNewNode) {
- pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName.AsWideStringC());
+ pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName.AsStringC());
pNewNode->CreateXMLMappingNode();
m_pCreateParent->InsertChild(pNewNode);
if (iIndex == m_iCreateCount - 1) {
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
index 8ad8b13176d..fa21a50b3e2 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
@@ -8,7 +8,6 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -20,15 +19,12 @@
#include "xfa/fxfa/parser/xfa_utils.h"
CXFA_ResolveProcessor::CXFA_ResolveProcessor(void)
- : m_pNodeHelper(NULL), m_iCurStart(0) {
- m_pNodeHelper = new CXFA_NodeHelper;
-}
+ : m_pNodeHelper(new CXFA_NodeHelper), m_iCurStart(0) {}
+
CXFA_ResolveProcessor::~CXFA_ResolveProcessor(void) {
- if (m_pNodeHelper) {
- delete m_pNodeHelper;
- m_pNodeHelper = NULL;
- }
+ delete m_pNodeHelper;
}
+
int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) {
if (rnd.m_CurNode == NULL) {
return -1;
@@ -36,7 +32,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) {
if (!rnd.m_CurNode->IsNode()) {
if (rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) {
return XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd,
- rnd.m_wsName.AsWideStringC());
+ rnd.m_wsName.AsStringC());
}
return 0;
}
@@ -71,7 +67,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) {
rnd.m_Nodes.Add(rnd.m_CurNode);
} else if ((rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) &&
XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd,
- rnd.m_wsName.AsWideStringC())) {
+ rnd.m_wsName.AsStringC())) {
return 1;
}
if (rnd.m_Nodes.GetSize() > 0) {
@@ -96,8 +92,8 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_AnyChild(
bClassName = TRUE;
wsName = wsName.Right(wsName.GetLength() - 1);
}
- findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild(ToNode(rnd.m_CurNode),
- wsName, bClassName);
+ findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild(
+ ToNode(rnd.m_CurNode), wsName.c_str(), bClassName);
if (findNode == NULL) {
return 0;
}
@@ -123,8 +119,8 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar(
if (rnd.m_nLevel > 0) {
return -1;
}
- uint32_t dwNameHash =
- FX_HashCode_String_GetW((const FX_WCHAR*)wsName + 1, iNameLen - 1);
+ uint32_t dwNameHash = FX_HashCode_GetW(
+ CFX_WideStringC(wsName.c_str() + 1, iNameLen - 1), false);
if (dwNameHash == XFA_HASHCODE_Xfa) {
nodes.Add(rnd.m_pSC->GetDocument()->GetRoot());
} else {
@@ -152,8 +148,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Excalmatory(
rndFind.m_pSC = rnd.m_pSC;
rndFind.m_CurNode = datasets;
rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1);
- rndFind.m_uHashName =
- FX_HashCode_String_GetW(rndFind.m_wsName, rndFind.m_wsName.GetLength());
+ rndFind.m_uHashName = FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false);
rndFind.m_nLevel = rnd.m_nLevel + 1;
rndFind.m_dwStyles = XFA_RESOLVENODE_Children;
rndFind.m_wsCondition = rnd.m_wsCondition;
@@ -169,7 +164,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign(
CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1);
CFX_WideString wsCondition = rnd.m_wsCondition;
CXFA_Node* curNode = ToNode(rnd.m_CurNode);
- if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsWideStringC())) {
+ if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsStringC())) {
return 1;
}
CXFA_ResolveNodesData rndFind;
@@ -179,8 +174,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_NumberSign(
rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName;
rndFind.m_dwStyles &= ~XFA_RESOLVENODE_Attributes;
rndFind.m_wsName = wsName;
- rndFind.m_uHashName =
- FX_HashCode_String_GetW(rndFind.m_wsName, rndFind.m_wsName.GetLength());
+ rndFind.m_uHashName = FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false);
rndFind.m_wsCondition = wsCondition;
rndFind.m_CurNode = curNode;
XFA_ResolveNodes_Normal(rndFind);
@@ -262,7 +256,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal(
rndFind.m_CurNode = pVariablesNode;
XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind);
CFX_WideString wsSaveCondition = rndFind.m_wsCondition;
- rndFind.m_wsCondition.Empty();
+ rndFind.m_wsCondition.clear();
XFA_ResolveNodes_Normal(rndFind);
rndFind.m_wsCondition = wsSaveCondition;
if (rndFind.m_Nodes.GetSize() > 0) {
@@ -300,7 +294,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal(
}
rndFind.m_CurNode = child;
CFX_WideString wsSaveCondition = rndFind.m_wsCondition;
- rndFind.m_wsCondition.Empty();
+ rndFind.m_wsCondition.clear();
XFA_ResolveNodes_Normal(rndFind);
rndFind.m_wsCondition = wsSaveCondition;
if (rndFind.m_Nodes.GetSize() > 0) {
@@ -332,7 +326,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal(
}
}
if (dwStyles & XFA_RESOLVENODE_Attributes) {
- if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsWideStringC())) {
+ if (XFA_ResolveNodes_ForAttributeRs(curNode, rnd, wsName.AsStringC())) {
return 1;
}
}
@@ -367,7 +361,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal(
}
} else {
const XFA_ELEMENTINFO* pElement =
- XFA_GetElementByName(wsName.AsWideStringC());
+ XFA_GetElementByName(wsName.AsStringC());
if (pElement) {
pProp = curNode->AsNode()->GetProperty(
0, pElement->eName, pElement->eName != XFA_ELEMENT_PageSet);
@@ -444,7 +438,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal(
if (bInnerSearch) {
rndFind.m_CurNode = child;
CFX_WideString wsOriginCondition = rndFind.m_wsCondition;
- rndFind.m_wsCondition.Empty();
+ rndFind.m_wsCondition.clear();
uint32_t dwOriginStyle = rndFind.m_dwStyles;
rndFind.m_dwStyles = dwOriginStyle | XFA_RESOLVENODE_ALL;
XFA_ResolveNodes_Normal(rndFind);
@@ -525,7 +519,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_GetFilter(
const CFX_WideStringC& wsExpression,
int32_t nStart,
CXFA_ResolveNodesData& rnd) {
- FXSYS_assert(nStart > -1);
+ ASSERT(nStart > -1);
int32_t iLength = wsExpression.GetLength();
if (nStart >= iLength) {
return 0;
@@ -538,7 +532,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_GetFilter(
int32_t nConditionCount = 0;
CFX_Int32Array stack;
int32_t nType = -1;
- const FX_WCHAR* pSrc = wsExpression.raw_str();
+ const FX_WCHAR* pSrc = wsExpression.c_str();
FX_WCHAR wPrev = 0, wCur;
FX_BOOL bIsCondition = FALSE;
while (nStart < iLength) {
@@ -618,7 +612,7 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_GetFilter(
wsCondition.ReleaseBuffer(nConditionCount);
wsCondition.TrimLeft();
wsCondition.TrimRight();
- rnd.m_uHashName = FX_HashCode_String_GetW(wsName, wsName.GetLength());
+ rnd.m_uHashName = FX_HashCode_GetW(wsName.AsStringC(), false);
return nStart;
}
void CXFA_ResolveProcessor::XFA_ResolveNode_ConditionArray(
@@ -694,7 +688,7 @@ void CXFA_ResolveProcessor::XFA_ResolveNode_DoPredicateFilter(
int32_t iFoundCount,
CXFA_ResolveNodesData& rnd) {
CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes;
- FXSYS_assert(iFoundCount == findNodes.GetSize());
+ ASSERT(iFoundCount == findNodes.GetSize());
CFX_WideString wsExpression;
XFA_SCRIPTLANGTYPE eLangType = XFA_SCRIPTLANGTYPE_Unkown;
if (wsCondition.Left(2) == FX_WSTRC(L".[") &&
@@ -713,8 +707,8 @@ void CXFA_ResolveProcessor::XFA_ResolveNode_DoPredicateFilter(
CXFA_Object* node = findNodes[i];
FX_BOOL bRet = FALSE;
FXJSE_HVALUE pRetValue = FXJSE_Value_Create(rnd.m_pSC->GetRuntime());
- bRet = pContext->RunScript(eLangType, wsExpression.AsWideStringC(),
- pRetValue, node);
+ bRet = pContext->RunScript(eLangType, wsExpression.AsStringC(), pRetValue,
+ node);
if (!bRet || !FXJSE_Value_ToBoolean(pRetValue)) {
findNodes.RemoveAt(i);
}
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.h
index ee0cd82b7c5..b63cced721f 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_resolveprocessor.h
@@ -9,7 +9,6 @@
#include "xfa/fxfa/parser/xfa_object.h"
#include "xfa/fxfa/parser/xfa_script.h"
-#include "xfa/include/fxfa/fxfa_objectacc.h"
class CXFA_NodeHelper;
class CXFA_ScriptContext;
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
index f460cf764b4..913269fd80b 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp
@@ -8,7 +8,6 @@
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -68,16 +67,14 @@ void CScript_SignaturePseudoModel::Script_SignaturePseudoModel_Sign(
}
if (iLength >= 2) {
CFX_ByteString bsExpression = pArguments->GetUTF8String(1);
- wsExpression =
- CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength());
+ wsExpression = CFX_WideString::FromUTF8(bsExpression.AsStringC());
}
if (iLength >= 3) {
CFX_ByteString bsXMLIdent = pArguments->GetUTF8String(2);
- wsXMLIdent = CFX_WideString::FromUTF8(bsXMLIdent, bsXMLIdent.GetLength());
+ wsXMLIdent = CFX_WideString::FromUTF8(bsXMLIdent.AsStringC());
}
- FX_BOOL bSign = pNotify->GetDocProvider()->Sign(hDoc, pNodeList,
- wsExpression.AsWideStringC(),
- wsXMLIdent.AsWideStringC());
+ FX_BOOL bSign = pNotify->GetDocProvider()->Sign(
+ hDoc, pNodeList, wsExpression.AsStringC(), wsXMLIdent.AsStringC());
FXJSE_HVALUE hValue = pArguments->GetReturnValue();
if (hValue) {
FXJSE_Value_SetBoolean(hValue, bSign);
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils.h b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils.h
index 9070b97e0e8..821e485e257 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils.h
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils.h
@@ -8,11 +8,20 @@
#define XFA_FXFA_PARSER_XFA_UTILS_H_
#include "xfa/fde/xml/fde_xml.h"
-#include "xfa/include/fxfa/fxfa_basic.h"
+#include "xfa/fxfa/include/fxfa_basic.h"
class CFDE_XMLElement;
class CFDE_XMLNode;
class CXFA_LocaleValue;
+class CXFA_Node;
+class CXFA_WidgetData;
+
+inline FX_BOOL XFA_IsSpace(FX_WCHAR c) {
+ return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09);
+}
+inline FX_BOOL XFA_IsDigit(FX_WCHAR c) {
+ return c >= '0' && c <= '9';
+}
FX_BOOL XFA_FDEExtension_ResolveNamespaceQualifier(
CFDE_XMLElement* pNode,
@@ -155,49 +164,9 @@ class CXFA_NodeIteratorTemplate {
NodeType* m_pRoot;
CFX_StackTemplate<NodeType*> m_NodeStack;
};
-template <class KeyType>
-class CXFA_PtrSetTemplate : private CFX_MapPtrToPtr {
- public:
- CXFA_PtrSetTemplate() : CFX_MapPtrToPtr(10) {}
-
- int GetCount() const { return CFX_MapPtrToPtr::GetCount(); }
-
- FX_BOOL IsEmpty() const { return CFX_MapPtrToPtr::IsEmpty(); }
-
- FX_BOOL Lookup(KeyType key) const {
- void* pValue = NULL;
- return CFX_MapPtrToPtr::Lookup((void*)key, pValue);
- }
-
- FX_BOOL operator[](KeyType key) { return Lookup(key); }
-
- void Add(KeyType key) { CFX_MapPtrToPtr::SetAt((void*)key, (void*)key); }
-
- FX_BOOL RemoveKey(KeyType key) {
- return CFX_MapPtrToPtr::RemoveKey((void*)key);
- }
-
- void RemoveAll() { CFX_MapPtrToPtr::RemoveAll(); }
-
- FX_POSITION GetStartPosition() const {
- return CFX_MapPtrToPtr::GetStartPosition();
- }
-
- void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey) const {
- void* pKey = NULL;
- void* pValue = NULL;
- CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
- rKey = (KeyType)(uintptr_t)pKey;
- }
-};
-class CXFA_Node;
-class CXFA_WidgetData;
CXFA_Node* XFA_CreateUIChild(CXFA_Node* pNode, XFA_ELEMENT& eWidgetType);
CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData);
-CFX_WideString XFA_NumericLimit(const CFX_WideString& wsValue,
- int32_t iLead,
- int32_t iTread);
FX_DOUBLE XFA_WideStringToDouble(const CFX_WideString& wsStringVal);
FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal);
int32_t XFA_MapRotation(int32_t nRotation);
@@ -209,9 +178,7 @@ FX_BOOL XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode);
IFX_Stream* XFA_CreateWideTextRead(const CFX_WideString& wsBuffer);
FX_BOOL XFA_IsLayoutElement(XFA_ELEMENT eElement,
FX_BOOL bLayoutContainer = FALSE);
-FX_BOOL XFA_IsTakingupSpace(XFA_ATTRIBUTEENUM ePresence);
-FX_BOOL XFA_IsFlowingLayout(XFA_ATTRIBUTEENUM eLayout);
-FX_BOOL XFA_IsHorizontalFlow(XFA_ATTRIBUTEENUM eLayout);
+
void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode);
void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode,
IFX_Stream* pStream,
diff --git a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils_imp.cpp b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils_imp.cpp
index 3d2e8bed4e7..77cac00b893 100644
--- a/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils_imp.cpp
+++ b/chromium/third_party/pdfium/xfa/fxfa/parser/xfa_utils_imp.cpp
@@ -9,7 +9,6 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
-#include "xfa/fxfa/parser/xfa_docdata.h"
#include "xfa/fxfa/parser/xfa_doclayout.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -197,7 +196,7 @@ void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode,
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
CFX_WideString wsTag;
pXMLElement->GetLocalTagName(wsTag);
- uint32_t uTag = FX_HashCode_String_GetW(wsTag, wsTag.GetLength(), TRUE);
+ uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringC(), true);
if (uTag == 0x0001f714) {
wsPlainText += L"\n";
} else if (uTag == 0x00000070) {
@@ -265,37 +264,7 @@ FX_BOOL XFA_IsLayoutElement(XFA_ELEMENT eElement, FX_BOOL bLayoutContainer) {
}
return FALSE;
}
-FX_BOOL XFA_IsTakingupSpace(XFA_ATTRIBUTEENUM ePresence) {
- switch (ePresence) {
- case XFA_ATTRIBUTEENUM_Visible:
- case XFA_ATTRIBUTEENUM_Invisible:
- return TRUE;
- default:
- return FALSE;
- }
- return FALSE;
-}
-FX_BOOL XFA_IsFlowingLayout(XFA_ATTRIBUTEENUM eLayout) {
- switch (eLayout) {
- case XFA_ATTRIBUTEENUM_Tb:
- case XFA_ATTRIBUTEENUM_Lr_tb:
- case XFA_ATTRIBUTEENUM_Rl_tb:
- return TRUE;
- default:
- return FALSE;
- }
- return FALSE;
-}
-FX_BOOL XFA_IsHorizontalFlow(XFA_ATTRIBUTEENUM eLayout) {
- switch (eLayout) {
- case XFA_ATTRIBUTEENUM_Lr_tb:
- case XFA_ATTRIBUTEENUM_Rl_tb:
- return TRUE;
- default:
- return FALSE;
- }
- return FALSE;
-}
+
static const FX_DOUBLE fraction_scales[] = {0.1,
0.01,
0.001,
@@ -321,7 +290,7 @@ FX_DOUBLE XFA_WideStringToDouble(const CFX_WideString& wsStringVal) {
int32_t nExponent = 0;
int32_t cc = 0;
FX_BOOL bNegative = FALSE, bExpSign = FALSE;
- const FX_WCHAR* str = (const FX_WCHAR*)wsValue;
+ const FX_WCHAR* str = wsValue.c_str();
int32_t len = wsValue.GetLength();
if (str[0] == '+') {
cc++;
@@ -392,8 +361,7 @@ FX_DOUBLE XFA_WideStringToDouble(const CFX_WideString& wsStringVal) {
}
FX_DOUBLE XFA_ByteStringToDouble(const CFX_ByteStringC& szStringVal) {
- CFX_WideString wsValue =
- CFX_WideString::FromUTF8(szStringVal.c_str(), szStringVal.GetLength());
+ CFX_WideString wsValue = CFX_WideString::FromUTF8(szStringVal);
return XFA_WideStringToDouble(wsValue);
}
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.cpp b/chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.cpp
index 4c9e41fea3c..564a2b14ccc 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.cpp
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.cpp
@@ -8,25 +8,23 @@
CAGG_Graphics::CAGG_Graphics() : m_owner(nullptr) {}
-FX_ERR CAGG_Graphics::Create(CFX_Graphics* owner,
- int32_t width,
- int32_t height,
- FXDIB_Format format) {
+FWL_Error CAGG_Graphics::Create(CFX_Graphics* owner,
+ int32_t width,
+ int32_t height,
+ FXDIB_Format format) {
if (owner->m_renderDevice)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_owner)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_FxgeDevice* device = new CFX_FxgeDevice;
device->Create(width, height, format);
m_owner = owner;
m_owner->m_renderDevice = device;
m_owner->m_renderDevice->GetBitmap()->Clear(0xFFFFFFFF);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CAGG_Graphics::~CAGG_Graphics() {
- if (m_owner->m_renderDevice)
- delete (CFX_FxgeDevice*)m_owner->m_renderDevice;
- m_owner = nullptr;
+ delete m_owner->m_renderDevice;
}
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.h b/chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.h
index d19773a42b0..5f53c736950 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.h
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cagg_graphics.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXGRAPHICS_CAGG_GRAPHICS_H_
#define XFA_FXGRAPHICS_CAGG_GRAPHICS_H_
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
class CFX_Graphics;
@@ -17,10 +17,10 @@ class CAGG_Graphics {
CAGG_Graphics();
virtual ~CAGG_Graphics();
- FX_ERR Create(CFX_Graphics* owner,
- int32_t width,
- int32_t height,
- FXDIB_Format format);
+ FWL_Error Create(CFX_Graphics* owner,
+ int32_t width,
+ int32_t height,
+ FXDIB_Format format);
private:
CFX_Graphics* m_owner;
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.cpp b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.cpp
index 9cc9c14bbdb..2044b76054b 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.cpp
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.cpp
@@ -24,26 +24,26 @@ CFX_Color::~CFX_Color() {
m_type = FX_COLOR_None;
}
-FX_ERR CFX_Color::Set(const FX_ARGB argb) {
+FWL_Error CFX_Color::Set(const FX_ARGB argb) {
m_type = FX_COLOR_Solid;
m_info.argb = argb;
m_info.pattern = nullptr;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) {
+FWL_Error CFX_Color::Set(CFX_Pattern* pattern, const FX_ARGB argb) {
if (!pattern)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
m_type = FX_COLOR_Pattern;
m_info.argb = argb;
m_info.pattern = pattern;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Color::Set(CFX_Shading* shading) {
+FWL_Error CFX_Color::Set(CFX_Shading* shading) {
if (!shading)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
m_type = FX_COLOR_Shading;
m_shading = shading;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.h b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.h
index 5ab99d8d87f..bf61c6859a0 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.h
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_color.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXGRAPHICS_CFX_COLOR_H_
#define XFA_FXGRAPHICS_CFX_COLOR_H_
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#include "xfa/fxgraphics/include/cfx_graphics.h"
class CFX_Pattern;
@@ -25,9 +25,9 @@ class CFX_Color {
explicit CFX_Color(CFX_Shading* shading);
virtual ~CFX_Color();
- FX_ERR Set(const FX_ARGB argb);
- FX_ERR Set(CFX_Pattern* pattern, const FX_ARGB argb = 0x0);
- FX_ERR Set(CFX_Shading* shading);
+ FWL_Error Set(const FX_ARGB argb);
+ FWL_Error Set(CFX_Pattern* pattern, const FX_ARGB argb = 0x0);
+ FWL_Error Set(CFX_Shading* shading);
private:
friend class CFX_Graphics;
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_graphics.cpp b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_graphics.cpp
index 82017f49a04..179e470e90f 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_graphics.cpp
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_graphics.cpp
@@ -570,28 +570,28 @@ CFX_Graphics::CFX_Graphics()
m_renderDevice(nullptr),
m_aggGraphics(nullptr) {}
-FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice,
- FX_BOOL isAntialiasing) {
+FWL_Error CFX_Graphics::Create(CFX_RenderDevice* renderDevice,
+ FX_BOOL isAntialiasing) {
if (!renderDevice)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type != FX_CONTEXT_None)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_type = FX_CONTEXT_Device;
m_info.isAntialiasing = isAntialiasing;
m_renderDevice = renderDevice;
if (m_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)
- return FX_ERR_Succeeded;
- return FX_ERR_Indefinite;
+ return FWL_Error::Succeeded;
+ return FWL_Error::Indefinite;
}
-FX_ERR CFX_Graphics::Create(int32_t width,
- int32_t height,
- FXDIB_Format format,
- FX_BOOL isNative,
- FX_BOOL isAntialiasing) {
+FWL_Error CFX_Graphics::Create(int32_t width,
+ int32_t height,
+ FXDIB_Format format,
+ FX_BOOL isNative,
+ FX_BOOL isAntialiasing) {
if (m_type != FX_CONTEXT_None)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_type = FX_CONTEXT_Device;
m_info.isAntialiasing = isAntialiasing;
@@ -603,100 +603,100 @@ CFX_Graphics::~CFX_Graphics() {
delete m_aggGraphics;
}
-FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) {
+FWL_Error CFX_Graphics::GetDeviceCap(const int32_t capID,
+ FX_DeviceCap& capVal) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
capVal = m_renderDevice->GetDeviceCaps(capID);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) {
+FWL_Error CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
isPrinter = m_renderDevice->GetDeviceClass() == FXDC_PRINTER;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) {
+FWL_Error CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.isAntialiasing = isAntialiasing;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SaveGraphState() {
+FWL_Error CFX_Graphics::SaveGraphState() {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_renderDevice->SaveState();
m_infoStack.Add(new TInfo(m_info));
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::RestoreGraphState() {
+FWL_Error CFX_Graphics::RestoreGraphState() {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_renderDevice->RestoreState();
int32_t size = m_infoStack.GetSize();
if (size <= 0) {
- return FX_ERR_Intermediate_Value_Invalid;
+ return FWL_Error::IntermediateValueInvalid;
}
int32_t topIndex = size - 1;
- std::unique_ptr<TInfo> info(
- reinterpret_cast<TInfo*>(m_infoStack.GetAt(topIndex)));
+ std::unique_ptr<TInfo> info(m_infoStack.GetAt(topIndex));
if (!info)
- return FX_ERR_Intermediate_Value_Invalid;
+ return FWL_Error::IntermediateValueInvalid;
m_info = *info;
m_infoStack.RemoveAt(topIndex);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) const {
+FWL_Error CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) const {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
lineCap = m_info.graphState.m_LineCap;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) {
+FWL_Error CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.graphState.m_LineCap = lineCap;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) const {
+FWL_Error CFX_Graphics::GetDashCount(int32_t& dashCount) const {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
dashCount = m_info.graphState.m_DashCount;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase,
- FX_FLOAT* dashArray) const {
+FWL_Error CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase,
+ FX_FLOAT* dashArray) const {
if (!dashArray)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
dashPhase = m_info.graphState.m_DashPhase;
FXSYS_memcpy(dashArray, m_info.graphState.m_DashArray,
m_info.graphState.m_DashCount * sizeof(FX_FLOAT));
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase,
- FX_FLOAT* dashArray,
- int32_t dashCount) {
+FWL_Error CFX_Graphics::SetLineDash(FX_FLOAT dashPhase,
+ FX_FLOAT* dashArray,
+ int32_t dashCount) {
if (dashCount > 0 && !dashArray)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
dashCount = dashCount < 0 ? 0 : dashCount;
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
@@ -709,164 +709,165 @@ FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase,
for (int32_t i = 0; i < dashCount; i++) {
m_info.graphState.m_DashArray[i] = dashArray[i] * scale;
}
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) {
+FWL_Error CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) {
if (m_type == FX_CONTEXT_Device && m_renderDevice)
return RenderDeviceSetLineDash(dashStyle);
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const {
+FWL_Error CFX_Graphics::GetLineJoin(
+ CFX_GraphStateData::LineJoin& lineJoin) const {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
lineJoin = m_info.graphState.m_LineJoin;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) {
+FWL_Error CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.graphState.m_LineJoin = lineJoin;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) const {
+FWL_Error CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) const {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
miterLimit = m_info.graphState.m_MiterLimit;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) {
+FWL_Error CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.graphState.m_MiterLimit = miterLimit;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const {
+FWL_Error CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
lineWidth = m_info.graphState.m_LineWidth;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) {
+FWL_Error CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.graphState.m_LineWidth = lineWidth;
m_info.isActOnDash = isActOnDash;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::GetStrokeAlignment(
+FWL_Error CFX_Graphics::GetStrokeAlignment(
FX_StrokeAlignment& strokeAlignment) const {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
strokeAlignment = m_info.strokeAlignment;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) {
+FWL_Error CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.strokeAlignment = strokeAlignment;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) {
+FWL_Error CFX_Graphics::SetStrokeColor(CFX_Color* color) {
if (!color)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.strokeColor = color;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) {
+FWL_Error CFX_Graphics::SetFillColor(CFX_Color* color) {
if (!color)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.fillColor = color;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) {
if (!path)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice)
return RenderDeviceStrokePath(path, matrix);
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::FillPath(CFX_Path* path,
- FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::FillPath(CFX_Path* path,
+ FX_FillMode fillMode,
+ CFX_Matrix* matrix) {
if (!path)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice)
return RenderDeviceFillPath(path, fillMode, matrix);
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::ClipPath(CFX_Path* path,
- FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::ClipPath(CFX_Path* path,
+ FX_FillMode fillMode,
+ CFX_Matrix* matrix) {
if (!path)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
FX_BOOL result = m_renderDevice->SetClip_PathFill(
path->GetPathData(), (CFX_Matrix*)matrix, fillMode);
if (!result)
- return FX_ERR_Indefinite;
- return FX_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source,
- const CFX_PointF& point,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::DrawImage(CFX_DIBSource* source,
+ const CFX_PointF& point,
+ CFX_Matrix* matrix) {
if (!source)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice)
return RenderDeviceDrawImage(source, point, matrix);
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source,
- const CFX_RectF& rect,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::StretchImage(CFX_DIBSource* source,
+ const CFX_RectF& rect,
+ CFX_Matrix* matrix) {
if (!source)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice)
return RenderDeviceStretchImage(source, rect, matrix);
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) {
if (!matrix)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.CTM.Concat(*matrix);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
CFX_Matrix* CFX_Graphics::GetMatrix() {
@@ -875,88 +876,88 @@ CFX_Matrix* CFX_Graphics::GetMatrix() {
return nullptr;
}
-FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) const {
+FWL_Error CFX_Graphics::GetClipRect(CFX_RectF& rect) const {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
FX_RECT r = m_renderDevice->GetClipBox();
rect.left = (FX_FLOAT)r.left;
rect.top = (FX_FLOAT)r.top;
rect.width = (FX_FLOAT)r.Width();
rect.height = (FX_FLOAT)r.Height();
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) {
+FWL_Error CFX_Graphics::SetClipRect(const CFX_RectF& rect) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
if (!m_renderDevice->SetClip_Rect(
FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top),
FXSYS_round(rect.right()), FXSYS_round(rect.bottom())))) {
- return FX_ERR_Method_Not_Supported;
+ return FWL_Error::MethodNotSupported;
}
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::ClearClip() {
+FWL_Error CFX_Graphics::ClearClip() {
if (m_type == FX_CONTEXT_Device && m_renderDevice)
- return FX_ERR_Succeeded;
- return FX_ERR_Property_Invalid;
+ return FWL_Error::Succeeded;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetFont(CFX_Font* font) {
+FWL_Error CFX_Graphics::SetFont(CFX_Font* font) {
if (!font)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.font = font;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) {
+FWL_Error CFX_Graphics::SetFontSize(const FX_FLOAT size) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.fontSize = size <= 0 ? 1.0f : size;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) {
+FWL_Error CFX_Graphics::SetFontHScale(const FX_FLOAT scale) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.fontHScale = scale <= 0 ? 1.0f : scale;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) {
+FWL_Error CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.fontSpacing = spacing < 0 ? 0 : spacing;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) {
+FWL_Error CFX_Graphics::SetTextDrawingMode(const int32_t mode) {
if (m_type == FX_CONTEXT_Device && m_renderDevice)
- return FX_ERR_Succeeded;
- return FX_ERR_Property_Invalid;
+ return FWL_Error::Succeeded;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point,
- const CFX_WideString& text,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::ShowText(const CFX_PointF& point,
+ const CFX_WideString& text,
+ CFX_Matrix* matrix) {
if (m_type == FX_CONTEXT_Device && m_renderDevice)
return RenderDeviceShowText(point, text, matrix);
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect,
- const CFX_WideString& text,
- FX_BOOL isMultiline,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::CalcTextRect(CFX_RectF& rect,
+ const CFX_WideString& text,
+ FX_BOOL isMultiline,
+ CFX_Matrix* matrix) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
int32_t length = text.GetLength();
uint32_t* charCodes = FX_Alloc(uint32_t, length);
@@ -964,15 +965,15 @@ FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect,
CalcTextInfo(text, charCodes, charPos, rect);
FX_Free(charPos);
FX_Free(charCodes);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics,
- const CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics,
+ const CFX_Matrix* matrix) {
if (!graphics || !graphics->m_renderDevice)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
CFX_Matrix m;
m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
m_info.CTM.f);
@@ -983,19 +984,19 @@ FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics,
CFX_DIBitmap* bitmap = graphics->m_renderDevice->GetBitmap();
FX_BOOL result = m_renderDevice->SetDIBits(bitmap, 0, 0);
if (!result)
- return FX_ERR_Method_Not_Supported;
- return FX_ERR_Succeeded;
+ return FWL_Error::MethodNotSupported;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics,
- FX_FLOAT srcLeft,
- FX_FLOAT srcTop,
- const CFX_RectF& dstRect,
- const CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics,
+ FX_FLOAT srcLeft,
+ FX_FLOAT srcTop,
+ const CFX_RectF& dstRect,
+ const CFX_Matrix* matrix) {
if (!graphics || !graphics->m_renderDevice)
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
CFX_Matrix m;
m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
m_info.CTM.f);
@@ -1008,37 +1009,37 @@ FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics,
bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height,
graphics->m_renderDevice->GetBitmap()->GetFormat());
if (!result)
- return FX_ERR_Intermediate_Value_Invalid;
+ return FWL_Error::IntermediateValueInvalid;
result = graphics->m_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft,
(int32_t)srcTop);
if (!result)
- return FX_ERR_Method_Not_Supported;
+ return FWL_Error::MethodNotSupported;
result = m_renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left,
(int32_t)dstRect.top);
if (!result)
- return FX_ERR_Method_Not_Supported;
- return FX_ERR_Succeeded;
+ return FWL_Error::MethodNotSupported;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
CFX_RenderDevice* CFX_Graphics::GetRenderDevice() {
return m_renderDevice;
}
-FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) {
+FWL_Error CFX_Graphics::InverseRect(const CFX_RectF& rect) {
if (!m_renderDevice)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
if (!bitmap)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_RectF temp(rect);
m_info.CTM.TransformRect(temp);
CFX_RectF r;
r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth());
r.Intersect(temp);
if (r.IsEmpty()) {
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
}
FX_ARGB* pBuf =
(FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch());
@@ -1052,23 +1053,23 @@ FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) {
}
pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch());
}
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap,
- const CFX_RectF& rect) {
+FWL_Error CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap,
+ const CFX_RectF& rect) {
if (!m_renderDevice)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_DIBitmap* dst = m_renderDevice->GetBitmap();
if (!dst)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_RectF temp(rect);
m_info.CTM.TransformRect(temp);
CFX_RectF r;
r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth());
r.Intersect(temp);
if (r.IsEmpty()) {
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
}
FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() +
int32_t(r.top) * srcBitmap->GetPitch());
@@ -1088,23 +1089,23 @@ FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap,
pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch());
pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch());
}
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap,
- const CFX_RectF& rect) {
+FWL_Error CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap,
+ const CFX_RectF& rect) {
if (!m_renderDevice)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_DIBitmap* dst = m_renderDevice->GetBitmap();
if (!dst)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_RectF temp(rect);
m_info.CTM.TransformRect(temp);
CFX_RectF r;
r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth());
r.Intersect(temp);
if (r.IsEmpty()) {
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
}
FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() +
int32_t(r.top) * srcBitmap->GetPitch());
@@ -1124,44 +1125,44 @@ FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap,
pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch());
pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch());
}
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) {
+FWL_Error CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) {
switch (dashStyle) {
case FX_DASHSTYLE_Solid: {
m_info.graphState.SetDashCount(0);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
case FX_DASHSTYLE_Dash: {
FX_FLOAT dashArray[] = {3, 1};
SetLineDash(0, dashArray, 2);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
case FX_DASHSTYLE_Dot: {
FX_FLOAT dashArray[] = {1, 1};
SetLineDash(0, dashArray, 2);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
case FX_DASHSTYLE_DashDot: {
FX_FLOAT dashArray[] = {3, 1, 1, 1};
SetLineDash(0, dashArray, 4);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
case FX_DASHSTYLE_DashDotDot: {
FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1};
SetLineDash(0, dashArray, 6);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
default:
- return FX_ERR_Parameter_Invalid;
+ return FWL_Error::ParameterInvalid;
}
}
-FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path,
+ CFX_Matrix* matrix) {
if (!m_info.strokeColor)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_Matrix m;
m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
m_info.CTM.f);
@@ -1174,23 +1175,23 @@ FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path,
path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, 0x0,
m_info.strokeColor->m_info.argb, 0);
if (!result)
- return FX_ERR_Indefinite;
- return FX_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+ return FWL_Error::Succeeded;
}
case FX_COLOR_Pattern:
return StrokePathWithPattern(path, &m);
case FX_COLOR_Shading:
return StrokePathWithShading(path, &m);
default:
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
}
-FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path,
- FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::RenderDeviceFillPath(CFX_Path* path,
+ FX_FillMode fillMode,
+ CFX_Matrix* matrix) {
if (!m_info.fillColor)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
CFX_Matrix m;
m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
m_info.CTM.f);
@@ -1203,21 +1204,21 @@ FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path,
path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState,
m_info.fillColor->m_info.argb, 0x0, fillMode);
if (!result)
- return FX_ERR_Indefinite;
- return FX_ERR_Succeeded;
+ return FWL_Error::Indefinite;
+ return FWL_Error::Succeeded;
}
case FX_COLOR_Pattern:
return FillPathWithPattern(path, fillMode, &m);
case FX_COLOR_Shading:
return FillPathWithShading(path, fillMode, &m);
default:
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
}
}
-FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source,
- const CFX_PointF& point,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source,
+ const CFX_PointF& point,
+ CFX_Matrix* matrix) {
CFX_Matrix m1;
m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
m_info.CTM.f);
@@ -1243,14 +1244,14 @@ FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source,
bmp2.get(), FXSYS_round(r.left - left),
FXSYS_round(r.top - top)) &&
m_renderDevice->SetDIBits(&bmp, 0, 0)) {
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
-FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source,
- const CFX_RectF& rect,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source,
+ const CFX_RectF& rect,
+ CFX_Matrix* matrix) {
CFX_Matrix m1;
m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
m_info.CTM.f);
@@ -1273,14 +1274,14 @@ FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source,
FXSYS_round(r.Width()), FXSYS_round(r.Height()),
bmp3.get(), FXSYS_round(r.left - left),
FXSYS_round(r.top - top))) {
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
- return FX_ERR_Indefinite;
+ return FWL_Error::Indefinite;
}
-FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point,
- const CFX_WideString& text,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point,
+ const CFX_WideString& text,
+ CFX_Matrix* matrix) {
int32_t length = text.GetLength();
uint32_t* charCodes = FX_Alloc(uint32_t, length);
FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length);
@@ -1299,23 +1300,25 @@ FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point,
-m_info.fontSize * m_info.fontHScale, (CFX_Matrix*)&m,
m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE);
if (!result)
- return FX_ERR_Indefinite;
+ return FWL_Error::Indefinite;
FX_Free(charPos);
FX_Free(charCodes);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) {
- return FX_ERR_Method_Not_Supported;
+FWL_Error CFX_Graphics::StrokePathWithPattern(CFX_Path* path,
+ CFX_Matrix* matrix) {
+ return FWL_Error::MethodNotSupported;
}
-FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) {
- return FX_ERR_Method_Not_Supported;
+FWL_Error CFX_Graphics::StrokePathWithShading(CFX_Path* path,
+ CFX_Matrix* matrix) {
+ return FWL_Error::MethodNotSupported;
}
-FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path,
- FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::FillPathWithPattern(CFX_Path* path,
+ FX_FillMode fillMode,
+ CFX_Matrix* matrix) {
CFX_Pattern* pattern = m_info.fillColor->m_info.pattern;
CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
@@ -1327,7 +1330,7 @@ FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path,
FX_HatchStyle hatchStyle = m_info.fillColor->m_info.pattern->m_hatchStyle;
if (hatchStyle < FX_HATCHSTYLE_Horizontal ||
hatchStyle > FX_HATCHSTYLE_SolidDiamond) {
- return FX_ERR_Intermediate_Value_Invalid;
+ return FWL_Error::IntermediateValueInvalid;
}
const FX_HATCHDATA& data = hatchBitmapData[hatchStyle];
CFX_DIBitmap mask;
@@ -1354,12 +1357,12 @@ FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path,
fillMode);
SetDIBitsWithMatrix(&bmp, &pattern->m_matrix);
m_renderDevice->RestoreState();
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path,
- FX_FillMode fillMode,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::FillPathWithShading(CFX_Path* path,
+ FX_FillMode fillMode,
+ CFX_Matrix* matrix) {
CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
int32_t height = bitmap->GetHeight();
@@ -1371,7 +1374,7 @@ FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path,
bmp.Create(width, height, FXDIB_Argb);
m_renderDevice->GetDIBits(&bmp, 0, 0);
int32_t pitch = bmp.GetPitch();
- FX_BOOL result = FALSE;
+ bool result = false;
switch (m_info.fillColor->m_shading->m_type) {
case FX_SHADING_Axial: {
FX_FLOAT x_span = end_x - start_x;
@@ -1400,7 +1403,7 @@ FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path,
dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index];
}
}
- result = TRUE;
+ result = true;
break;
}
case FX_SHADING_Radial: {
@@ -1461,10 +1464,13 @@ FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path,
dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index];
}
}
- result = TRUE;
+ result = true;
+ break;
+ }
+ default: {
+ result = false;
break;
}
- default: { result = FALSE; }
}
if (result) {
m_renderDevice->SaveState();
@@ -1473,11 +1479,11 @@ FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path,
SetDIBitsWithMatrix(&bmp, matrix);
m_renderDevice->RestoreState();
}
- return result;
+ return result ? FWL_Error::Succeeded : FWL_Error::PropertyInvalid;
}
-FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source,
- CFX_Matrix* matrix) {
+FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source,
+ CFX_Matrix* matrix) {
if (matrix->IsIdentity()) {
m_renderDevice->SetDIBits(source, 0, 0);
} else {
@@ -1491,13 +1497,13 @@ FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source,
bmp1->TransformTo((CFX_Matrix*)&m, left, top));
m_renderDevice->SetDIBits(bmp2.get(), left, top);
}
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text,
- uint32_t* charCodes,
- FXTEXT_CHARPOS* charPos,
- CFX_RectF& rect) {
+FWL_Error CFX_Graphics::CalcTextInfo(const CFX_WideString& text,
+ uint32_t* charCodes,
+ FXTEXT_CHARPOS* charPos,
+ CFX_RectF& rect) {
std::unique_ptr<CFX_UnicodeEncoding> encoding(
new CFX_UnicodeEncoding(m_info.font));
int32_t length = text.GetLength();
@@ -1536,7 +1542,7 @@ FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text,
}
rect.width = (FX_FLOAT)penX - rect.left;
rect.height = rect.top + m_info.fontSize * m_info.fontHScale - rect.top;
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFX_Graphics::TInfo::TInfo(const TInfo& info)
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.cpp b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.cpp
index 2acdc3eac25..fe956d3fcc3 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.cpp
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.cpp
@@ -12,163 +12,165 @@ CFX_Path::CFX_Path() {
m_generator = nullptr;
}
-FX_ERR CFX_Path::Create() {
+FWL_Error CFX_Path::Create() {
if (m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator = new CFX_PathGenerator;
m_generator->Create();
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
CFX_Path::~CFX_Path() {
delete m_generator;
}
-FX_ERR CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) {
+FWL_Error CFX_Path::MoveTo(FX_FLOAT x, FX_FLOAT y) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->MoveTo(x, y);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) {
+FWL_Error CFX_Path::LineTo(FX_FLOAT x, FX_FLOAT y) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->LineTo(x, y);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::BezierTo(FX_FLOAT ctrlX1,
- FX_FLOAT ctrlY1,
- FX_FLOAT ctrlX2,
- FX_FLOAT ctrlY2,
- FX_FLOAT toX,
- FX_FLOAT toY) {
+FWL_Error CFX_Path::BezierTo(FX_FLOAT ctrlX1,
+ FX_FLOAT ctrlY1,
+ FX_FLOAT ctrlX2,
+ FX_FLOAT ctrlY2,
+ FX_FLOAT toX,
+ FX_FLOAT toY) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->BezierTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, toX, toY);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::ArcTo(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
+FWL_Error CFX_Path::ArcTo(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->ArcTo(left + width / 2, top + height / 2, width / 2, height / 2,
startAngle, sweepAngle);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::Close() {
+FWL_Error CFX_Path::Close() {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->Close();
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2) {
+FWL_Error CFX_Path::AddLine(FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->AddLine(x1, y1, x2, y2);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::AddBezier(FX_FLOAT startX,
- FX_FLOAT startY,
- FX_FLOAT ctrlX1,
- FX_FLOAT ctrlY1,
- FX_FLOAT ctrlX2,
- FX_FLOAT ctrlY2,
- FX_FLOAT endX,
- FX_FLOAT endY) {
+FWL_Error CFX_Path::AddBezier(FX_FLOAT startX,
+ FX_FLOAT startY,
+ FX_FLOAT ctrlX1,
+ FX_FLOAT ctrlY1,
+ FX_FLOAT ctrlX2,
+ FX_FLOAT ctrlY2,
+ FX_FLOAT endX,
+ FX_FLOAT endY) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->AddBezier(startX, startY, ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX,
endY);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::AddRectangle(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height) {
+FWL_Error CFX_Path::AddRectangle(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->AddRectangle(left, top, left + width, top + height);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::AddEllipse(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height) {
+FWL_Error CFX_Path::AddEllipse(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->AddEllipse(left + width / 2, top + height / 2, width / 2,
height / 2);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::AddEllipse(const CFX_RectF& rect) {
+FWL_Error CFX_Path::AddEllipse(const CFX_RectF& rect) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->AddEllipse(rect.left + rect.Width() / 2,
rect.top + rect.Height() / 2, rect.Width() / 2,
rect.Height() / 2);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::AddArc(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
+FWL_Error CFX_Path::AddArc(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->AddArc(left + width / 2, top + height / 2, width / 2, height / 2,
startAngle, sweepAngle);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::AddPie(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle) {
+FWL_Error CFX_Path::AddPie(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->AddPie(left + width / 2, top + height / 2, width / 2, height / 2,
startAngle, sweepAngle);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::AddSubpath(CFX_Path* path) {
+FWL_Error CFX_Path::AddSubpath(CFX_Path* path) {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->AddPathData(path->GetPathData());
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
-FX_ERR CFX_Path::Clear() {
+FWL_Error CFX_Path::Clear() {
if (!m_generator)
- return FX_ERR_Property_Invalid;
+ return FWL_Error::PropertyInvalid;
m_generator->GetPathData()->SetPointCount(0);
- return FX_ERR_Succeeded;
+ return FWL_Error::Succeeded;
}
FX_BOOL CFX_Path::IsEmpty() {
if (!m_generator)
- return FX_ERR_Property_Invalid;
- if (m_generator->GetPathData()->GetPointCount() == 0) {
+ return FALSE;
+ if (m_generator->GetPathData()->GetPointCount() == 0)
return TRUE;
- }
return FALSE;
}
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.h b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.h
index 5b5840fa0b2..f42586f0deb 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.h
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path.h
@@ -18,55 +18,55 @@ class CFX_Path {
CFX_Path();
virtual ~CFX_Path();
- FX_ERR Create();
- FX_ERR MoveTo(FX_FLOAT x, FX_FLOAT y);
- FX_ERR LineTo(FX_FLOAT x, FX_FLOAT y);
- FX_ERR BezierTo(FX_FLOAT ctrlX1,
- FX_FLOAT ctrlY1,
- FX_FLOAT ctrlX2,
- FX_FLOAT ctrlY2,
- FX_FLOAT toX,
- FX_FLOAT toY);
- FX_ERR ArcTo(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FX_ERR Close();
+ FWL_Error Create();
+ FWL_Error MoveTo(FX_FLOAT x, FX_FLOAT y);
+ FWL_Error LineTo(FX_FLOAT x, FX_FLOAT y);
+ FWL_Error BezierTo(FX_FLOAT ctrlX1,
+ FX_FLOAT ctrlY1,
+ FX_FLOAT ctrlX2,
+ FX_FLOAT ctrlY2,
+ FX_FLOAT toX,
+ FX_FLOAT toY);
+ FWL_Error ArcTo(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle);
+ FWL_Error Close();
- FX_ERR AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2);
- FX_ERR AddBezier(FX_FLOAT startX,
- FX_FLOAT startY,
- FX_FLOAT ctrlX1,
- FX_FLOAT ctrlY1,
- FX_FLOAT ctrlX2,
- FX_FLOAT ctrlY2,
- FX_FLOAT endX,
- FX_FLOAT endY);
- FX_ERR AddRectangle(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height);
- FX_ERR AddEllipse(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height);
- FX_ERR AddEllipse(const CFX_RectF& rect);
- FX_ERR AddArc(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FX_ERR AddPie(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
- FX_ERR AddSubpath(CFX_Path* path);
- FX_ERR Clear();
+ FWL_Error AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2);
+ FWL_Error AddBezier(FX_FLOAT startX,
+ FX_FLOAT startY,
+ FX_FLOAT ctrlX1,
+ FX_FLOAT ctrlY1,
+ FX_FLOAT ctrlX2,
+ FX_FLOAT ctrlY2,
+ FX_FLOAT endX,
+ FX_FLOAT endY);
+ FWL_Error AddRectangle(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height);
+ FWL_Error AddEllipse(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height);
+ FWL_Error AddEllipse(const CFX_RectF& rect);
+ FWL_Error AddArc(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle);
+ FWL_Error AddPie(FX_FLOAT left,
+ FX_FLOAT top,
+ FX_FLOAT width,
+ FX_FLOAT height,
+ FX_FLOAT startAngle,
+ FX_FLOAT sweepAngle);
+ FWL_Error AddSubpath(CFX_Path* path);
+ FWL_Error Clear();
FX_BOOL IsEmpty();
CFX_PathData* GetPathData();
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.cpp b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.cpp
index ace3da154f0..984e2e9d1a7 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.cpp
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.cpp
@@ -6,18 +6,16 @@
#include "xfa/fxgraphics/cfx_path_generator.h"
-CFX_PathGenerator::CFX_PathGenerator() {
- m_pPathData = NULL;
-}
+CFX_PathGenerator::CFX_PathGenerator() : m_pPathData(nullptr) {}
+
void CFX_PathGenerator::Create() {
m_pPathData = new CFX_PathData;
}
+
CFX_PathGenerator::~CFX_PathGenerator() {
- if (m_pPathData) {
- delete m_pPathData;
- m_pPathData = NULL;
- }
+ delete m_pPathData;
}
+
void CFX_PathGenerator::AddPathData(CFX_PathData* pPathData) {
if (pPathData && pPathData->GetPointCount() > 0) {
int nCount = pPathData->GetPointCount();
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.h b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.h
index efe316697d9..02aa4230d5c 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.h
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_path_generator.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_
#define XFA_FXGRAPHICS_CFX_PATH_GENERATOR_H_
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_ge.h"
class CFX_PathGenerator {
public:
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_shading.h b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_shading.h
index 8bfd3ca9d4e..302aa65be5e 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/cfx_shading.h
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/cfx_shading.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
+#include "core/fxge/include/fx_dib.h"
#define FX_SHADING_Steps 256
diff --git a/chromium/third_party/pdfium/xfa/fxgraphics/include/cfx_graphics.h b/chromium/third_party/pdfium/xfa/fxgraphics/include/cfx_graphics.h
index be9176ebc29..3f969432eaa 100644
--- a/chromium/third_party/pdfium/xfa/fxgraphics/include/cfx_graphics.h
+++ b/chromium/third_party/pdfium/xfa/fxgraphics/include/cfx_graphics.h
@@ -8,22 +8,14 @@
#define XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_
#include "core/fxcrt/include/fx_system.h"
-#include "core/include/fxge/fx_dib.h"
-#include "core/include/fxge/fx_ge.h"
+#include "core/fxge/include/fx_dib.h"
+#include "core/fxge/include/fx_ge.h"
+#include "xfa/fwl/core/fwl_error.h"
class CFX_Color;
class CFX_Path;
class CAGG_Graphics;
-#define FX_ERR_Succeeded 0
-#define FX_ERR_Indefinite -1
-#define FX_ERR_Parameter_Invalid -100
-#define FX_ERR_Property_Invalid -200
-#define FX_ERR_Intermediate_Value_Invalid -300
-#define FX_ERR_Method_Not_Supported -400
-#define FX_ERR_Out_Of_Memory -500
-
-using FX_ERR = int;
using FX_DeviceCap = int32_t;
using FX_FillMode = int32_t;
@@ -106,81 +98,82 @@ class CFX_Graphics {
CFX_Graphics();
virtual ~CFX_Graphics();
- FX_ERR Create(CFX_RenderDevice* renderDevice, FX_BOOL isAntialiasing = TRUE);
- FX_ERR Create(int32_t width,
- int32_t height,
- FXDIB_Format format,
- FX_BOOL isNative = TRUE,
- FX_BOOL isAntialiasing = TRUE);
-
- FX_ERR GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal);
- FX_ERR IsPrinterDevice(FX_BOOL& isPrinter);
- FX_ERR EnableAntialiasing(FX_BOOL isAntialiasing);
-
- FX_ERR SaveGraphState();
- FX_ERR RestoreGraphState();
-
- FX_ERR GetLineCap(CFX_GraphStateData::LineCap& lineCap) const;
- FX_ERR GetDashCount(int32_t& dashCount) const;
- FX_ERR GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) const;
- FX_ERR GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const;
- FX_ERR GetMiterLimit(FX_FLOAT& miterLimit) const;
- FX_ERR GetLineWidth(FX_FLOAT& lineWidth) const;
- FX_ERR GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) const;
- FX_ERR GetClipRect(CFX_RectF& rect) const;
+ FWL_Error Create(CFX_RenderDevice* renderDevice,
+ FX_BOOL isAntialiasing = TRUE);
+ FWL_Error Create(int32_t width,
+ int32_t height,
+ FXDIB_Format format,
+ FX_BOOL isNative = TRUE,
+ FX_BOOL isAntialiasing = TRUE);
+
+ FWL_Error GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal);
+ FWL_Error IsPrinterDevice(FX_BOOL& isPrinter);
+ FWL_Error EnableAntialiasing(FX_BOOL isAntialiasing);
+
+ FWL_Error SaveGraphState();
+ FWL_Error RestoreGraphState();
+
+ FWL_Error GetLineCap(CFX_GraphStateData::LineCap& lineCap) const;
+ FWL_Error GetDashCount(int32_t& dashCount) const;
+ FWL_Error GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) const;
+ FWL_Error GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const;
+ FWL_Error GetMiterLimit(FX_FLOAT& miterLimit) const;
+ FWL_Error GetLineWidth(FX_FLOAT& lineWidth) const;
+ FWL_Error GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) const;
+ FWL_Error GetClipRect(CFX_RectF& rect) const;
CFX_Matrix* GetMatrix();
CFX_RenderDevice* GetRenderDevice();
- FX_ERR SetLineCap(CFX_GraphStateData::LineCap lineCap);
- FX_ERR SetLineDash(FX_FLOAT dashPhase,
- FX_FLOAT* dashArray,
- int32_t dashCount);
- FX_ERR SetLineDash(FX_DashStyle dashStyle);
- FX_ERR SetLineJoin(CFX_GraphStateData::LineJoin lineJoin);
- FX_ERR SetMiterLimit(FX_FLOAT miterLimit);
- FX_ERR SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash = FALSE);
- FX_ERR SetStrokeAlignment(FX_StrokeAlignment strokeAlignment);
- FX_ERR SetStrokeColor(CFX_Color* color);
- FX_ERR SetFillColor(CFX_Color* color);
- FX_ERR SetClipRect(const CFX_RectF& rect);
- FX_ERR SetFont(CFX_Font* font);
- FX_ERR SetFontSize(const FX_FLOAT size);
- FX_ERR SetFontHScale(const FX_FLOAT scale);
- FX_ERR SetCharSpacing(const FX_FLOAT spacing);
- FX_ERR SetTextDrawingMode(const int32_t mode);
-
- FX_ERR StrokePath(CFX_Path* path, CFX_Matrix* matrix = NULL);
- FX_ERR FillPath(CFX_Path* path,
- FX_FillMode fillMode = FXFILL_WINDING,
- CFX_Matrix* matrix = NULL);
- FX_ERR ClipPath(CFX_Path* path,
- FX_FillMode fillMode = FXFILL_WINDING,
- CFX_Matrix* matrix = NULL);
- FX_ERR DrawImage(CFX_DIBSource* source,
- const CFX_PointF& point,
- CFX_Matrix* matrix = NULL);
- FX_ERR StretchImage(CFX_DIBSource* source,
- const CFX_RectF& rect,
- CFX_Matrix* matrix = NULL);
- FX_ERR ConcatMatrix(const CFX_Matrix* matrix);
- FX_ERR ClearClip();
- FX_ERR ShowText(const CFX_PointF& point,
- const CFX_WideString& text,
- CFX_Matrix* matrix = NULL);
- FX_ERR CalcTextRect(CFX_RectF& rect,
- const CFX_WideString& text,
- FX_BOOL isMultiline = FALSE,
+ FWL_Error SetLineCap(CFX_GraphStateData::LineCap lineCap);
+ FWL_Error SetLineDash(FX_FLOAT dashPhase,
+ FX_FLOAT* dashArray,
+ int32_t dashCount);
+ FWL_Error SetLineDash(FX_DashStyle dashStyle);
+ FWL_Error SetLineJoin(CFX_GraphStateData::LineJoin lineJoin);
+ FWL_Error SetMiterLimit(FX_FLOAT miterLimit);
+ FWL_Error SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash = FALSE);
+ FWL_Error SetStrokeAlignment(FX_StrokeAlignment strokeAlignment);
+ FWL_Error SetStrokeColor(CFX_Color* color);
+ FWL_Error SetFillColor(CFX_Color* color);
+ FWL_Error SetClipRect(const CFX_RectF& rect);
+ FWL_Error SetFont(CFX_Font* font);
+ FWL_Error SetFontSize(const FX_FLOAT size);
+ FWL_Error SetFontHScale(const FX_FLOAT scale);
+ FWL_Error SetCharSpacing(const FX_FLOAT spacing);
+ FWL_Error SetTextDrawingMode(const int32_t mode);
+
+ FWL_Error StrokePath(CFX_Path* path, CFX_Matrix* matrix = NULL);
+ FWL_Error FillPath(CFX_Path* path,
+ FX_FillMode fillMode = FXFILL_WINDING,
+ CFX_Matrix* matrix = NULL);
+ FWL_Error ClipPath(CFX_Path* path,
+ FX_FillMode fillMode = FXFILL_WINDING,
+ CFX_Matrix* matrix = NULL);
+ FWL_Error DrawImage(CFX_DIBSource* source,
+ const CFX_PointF& point,
CFX_Matrix* matrix = NULL);
- FX_ERR Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix);
- FX_ERR Transfer(CFX_Graphics* graphics,
- FX_FLOAT srcLeft,
- FX_FLOAT srcTop,
- const CFX_RectF& dstRect,
- const CFX_Matrix* matrix);
-
- FX_ERR InverseRect(const CFX_RectF& rect);
- FX_ERR XorDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect);
- FX_ERR EqvDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect);
+ FWL_Error StretchImage(CFX_DIBSource* source,
+ const CFX_RectF& rect,
+ CFX_Matrix* matrix = NULL);
+ FWL_Error ConcatMatrix(const CFX_Matrix* matrix);
+ FWL_Error ClearClip();
+ FWL_Error ShowText(const CFX_PointF& point,
+ const CFX_WideString& text,
+ CFX_Matrix* matrix = NULL);
+ FWL_Error CalcTextRect(CFX_RectF& rect,
+ const CFX_WideString& text,
+ FX_BOOL isMultiline = FALSE,
+ CFX_Matrix* matrix = NULL);
+ FWL_Error Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix);
+ FWL_Error Transfer(CFX_Graphics* graphics,
+ FX_FLOAT srcLeft,
+ FX_FLOAT srcTop,
+ const CFX_RectF& dstRect,
+ const CFX_Matrix* matrix);
+
+ FWL_Error InverseRect(const CFX_RectF& rect);
+ FWL_Error XorDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect);
+ FWL_Error EqvDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect);
protected:
int32_t m_type;
@@ -213,39 +206,39 @@ class CFX_Graphics {
FX_FLOAT fontSpacing;
} m_info;
- FX_ERR RenderDeviceSetLineDash(FX_DashStyle dashStyle);
- FX_ERR RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix);
- FX_ERR RenderDeviceFillPath(CFX_Path* path,
- FX_FillMode fillMode,
- CFX_Matrix* matrix);
- FX_ERR RenderDeviceDrawImage(CFX_DIBSource* source,
- const CFX_PointF& point,
- CFX_Matrix* matrix);
- FX_ERR RenderDeviceStretchImage(CFX_DIBSource* source,
- const CFX_RectF& rect,
+ FWL_Error RenderDeviceSetLineDash(FX_DashStyle dashStyle);
+ FWL_Error RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix);
+ FWL_Error RenderDeviceFillPath(CFX_Path* path,
+ FX_FillMode fillMode,
+ CFX_Matrix* matrix);
+ FWL_Error RenderDeviceDrawImage(CFX_DIBSource* source,
+ const CFX_PointF& point,
CFX_Matrix* matrix);
- FX_ERR RenderDeviceShowText(const CFX_PointF& point,
- const CFX_WideString& text,
- CFX_Matrix* matrix);
-
- FX_ERR StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix);
- FX_ERR StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix);
-
- FX_ERR FillPathWithPattern(CFX_Path* path,
- FX_FillMode fillMode,
- CFX_Matrix* matrix);
- FX_ERR FillPathWithShading(CFX_Path* path,
- FX_FillMode fillMode,
- CFX_Matrix* matrix);
-
- FX_ERR SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix);
- FX_ERR CalcTextInfo(const CFX_WideString& text,
- uint32_t* charCodes,
- FXTEXT_CHARPOS* charPos,
- CFX_RectF& rect);
+ FWL_Error RenderDeviceStretchImage(CFX_DIBSource* source,
+ const CFX_RectF& rect,
+ CFX_Matrix* matrix);
+ FWL_Error RenderDeviceShowText(const CFX_PointF& point,
+ const CFX_WideString& text,
+ CFX_Matrix* matrix);
+
+ FWL_Error StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix);
+ FWL_Error StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix);
+
+ FWL_Error FillPathWithPattern(CFX_Path* path,
+ FX_FillMode fillMode,
+ CFX_Matrix* matrix);
+ FWL_Error FillPathWithShading(CFX_Path* path,
+ FX_FillMode fillMode,
+ CFX_Matrix* matrix);
+
+ FWL_Error SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix);
+ FWL_Error CalcTextInfo(const CFX_WideString& text,
+ uint32_t* charCodes,
+ FXTEXT_CHARPOS* charPos,
+ CFX_RectF& rect);
CFX_RenderDevice* m_renderDevice;
- CFX_PtrArray m_infoStack;
+ CFX_ArrayTemplate<TInfo*> m_infoStack;
CAGG_Graphics* m_aggGraphics;
friend class CAGG_Graphics;
};
diff --git a/chromium/third_party/pdfium/xfa/fxjse/DEPS b/chromium/third_party/pdfium/xfa/fxjse/DEPS
index 5cec1f887f4..3b4b780a7d3 100644
--- a/chromium/third_party/pdfium/xfa/fxjse/DEPS
+++ b/chromium/third_party/pdfium/xfa/fxjse/DEPS
@@ -1,5 +1,5 @@
include_rules = [
# TODO(dsinclair): Layering violation. XFA can't include FPDFSDK.
- '+fpdfsdk/include/jsapi',
+ '+fpdfsdk/jsapi/include',
'+v8/include',
]
diff --git a/chromium/third_party/pdfium/xfa/fxjse/class.cpp b/chromium/third_party/pdfium/xfa/fxjse/class.cpp
index c93e0bc581f..d6744a61126 100644
--- a/chromium/third_party/pdfium/xfa/fxjse/class.cpp
+++ b/chromium/third_party/pdfium/xfa/fxjse/class.cpp
@@ -24,29 +24,6 @@ static void FXJSE_V8SetterCallback_Wrapper(
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info);
-void FXJSE_DefineFunctions(FXJSE_HCONTEXT hContext,
- const FXJSE_FUNCTION* lpFunctions,
- int nNum) {
- CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext);
- ASSERT(lpContext);
- CFXJSE_ScopeUtil_IsolateHandleContext scope(lpContext);
- v8::Isolate* pIsolate = lpContext->GetRuntime();
- v8::Local<v8::Object> hGlobalObject =
- FXJSE_GetGlobalObjectFromContext(scope.GetLocalContext());
- for (int32_t i = 0; i < nNum; i++) {
- v8::Maybe<bool> maybe_success = hGlobalObject->DefineOwnProperty(
- scope.GetLocalContext(),
- v8::String::NewFromUtf8(pIsolate, lpFunctions[i].name),
- v8::Function::New(
- pIsolate, FXJSE_V8FunctionCallback_Wrapper,
- v8::External::New(pIsolate,
- const_cast<FXJSE_FUNCTION*>(lpFunctions + i))),
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
- if (!maybe_success.FromMaybe(false))
- return;
- }
-}
-
FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext,
const FXJSE_CLASS* lpClass) {
CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext);
@@ -55,12 +32,6 @@ FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext,
CFXJSE_Class::Create(lpContext, lpClass, FALSE));
}
-FXJSE_HCLASS FXJSE_GetClass(FXJSE_HCONTEXT hContext,
- const CFX_ByteStringC& szName) {
- return reinterpret_cast<FXJSE_HCLASS>(CFXJSE_Class::GetClassFromContext(
- reinterpret_cast<CFXJSE_Context*>(hContext), szName));
-}
-
static void FXJSE_V8FunctionCallback_Wrapper(
const v8::FunctionCallbackInfo<v8::Value>& info) {
const FXJSE_FUNCTION* lpFunctionInfo =
@@ -161,7 +132,7 @@ static void FXJSE_V8ConstructorCallback_Wrapper(
if (!lpClassDefinition) {
return;
}
- FXSYS_assert(info.This()->InternalFieldCount());
+ ASSERT(info.This()->InternalFieldCount());
info.This()->SetAlignedPointerInInternalField(0, NULL);
}
@@ -241,8 +212,8 @@ static void FXJSE_Context_GlobalObjToString(
CFX_ByteString szStringVal;
szStringVal.Format("[object %s]", lpClass->name);
info.GetReturnValue().Set(v8::String::NewFromUtf8(
- info.GetIsolate(), (const FX_CHAR*)szStringVal,
- v8::String::kNormalString, szStringVal.GetLength()));
+ info.GetIsolate(), szStringVal.c_str(), v8::String::kNormalString,
+ szStringVal.GetLength()));
} else {
v8::Local<v8::String> local_str =
info.This()
diff --git a/chromium/third_party/pdfium/xfa/fxjse/context.cpp b/chromium/third_party/pdfium/xfa/fxjse/context.cpp
index 83af4876329..9a6b9120a20 100644
--- a/chromium/third_party/pdfium/xfa/fxjse/context.cpp
+++ b/chromium/third_party/pdfium/xfa/fxjse/context.cpp
@@ -11,6 +11,14 @@
#include "xfa/fxjse/util_inline.h"
#include "xfa/fxjse/value.h"
+namespace {
+
+CFXJSE_Context* CFXContextFromHContext(FXJSE_HCONTEXT hContext) {
+ return reinterpret_cast<CFXJSE_Context*>(hContext);
+}
+
+} // namespace
+
FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime,
const FXJSE_CLASS* lpGlobalClass,
void* lpGlobalObject) {
@@ -20,29 +28,20 @@ FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime,
}
void FXJSE_Context_Release(FXJSE_HCONTEXT hContext) {
- CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
- if (pContext) {
- delete pContext;
- }
+ delete CFXContextFromHContext(hContext);
}
FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext) {
- CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
- if (!pContext) {
- return NULL;
- }
+ CFXJSE_Context* pContext = CFXContextFromHContext(hContext);
+ if (!pContext)
+ return nullptr;
+
CFXJSE_Value* lpValue = CFXJSE_Value::Create(pContext->GetRuntime());
ASSERT(lpValue);
pContext->GetGlobalObject(lpValue);
return reinterpret_cast<FXJSE_HVALUE>(lpValue);
}
-FXJSE_HRUNTIME FXJSE_Context_GetRuntime(FXJSE_HCONTEXT hContext) {
- CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
- return pContext ? reinterpret_cast<FXJSE_HRUNTIME>(pContext->GetRuntime())
- : NULL;
-}
-
static const FX_CHAR* szCompatibleModeScripts[] = {
"(function(global, list) {\n"
" 'use strict';\n"
@@ -82,8 +81,7 @@ FX_BOOL FXJSE_ExecuteScript(FXJSE_HCONTEXT hContext,
const FX_CHAR* szScript,
FXJSE_HVALUE hRetValue,
FXJSE_HVALUE hNewThisObject) {
- CFXJSE_Context* pContext = reinterpret_cast<CFXJSE_Context*>(hContext);
- ASSERT(pContext);
+ CFXJSE_Context* pContext = CFXContextFromHContext(hContext);
return pContext->ExecuteScript(
szScript, reinterpret_cast<CFXJSE_Value*>(hRetValue),
reinterpret_cast<CFXJSE_Value*>(hNewThisObject));
@@ -127,52 +125,6 @@ v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate,
return hReturnValue;
}
-FX_BOOL FXJSE_ReturnValue_GetMessage(FXJSE_HVALUE hRetValue,
- CFX_ByteString& utf8Name,
- CFX_ByteString& utf8Message) {
- CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hRetValue);
- if (!lpValue) {
- return FALSE;
- }
- v8::Isolate* pIsolate = lpValue->GetIsolate();
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(pIsolate, lpValue->DirectGetValue());
- if (!hValue->IsObject()) {
- return FALSE;
- }
- v8::String::Utf8Value hStringVal0(
- hValue.As<v8::Object>()->Get(0)->ToString());
- utf8Name = *hStringVal0;
- v8::String::Utf8Value hStringVal1(
- hValue.As<v8::Object>()->Get(1)->ToString());
- utf8Message = *hStringVal1;
- return TRUE;
-}
-
-FX_BOOL FXJSE_ReturnValue_GetLineInfo(FXJSE_HVALUE hRetValue,
- int32_t& nLine,
- int32_t& nCol) {
- CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hRetValue);
- if (!lpValue) {
- return FALSE;
- }
- v8::Isolate* pIsolate = lpValue->GetIsolate();
- CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
- v8::Local<v8::Value> hValue =
- v8::Local<v8::Value>::New(pIsolate, lpValue->DirectGetValue());
- if (!hValue->IsObject()) {
- return FALSE;
- }
- v8::MaybeLocal<v8::Int32> maybe_int =
- hValue.As<v8::Object>()->Get(3)->ToInt32(pIsolate->GetCurrentContext());
- nLine = maybe_int.FromMaybe(v8::Local<v8::Int32>())->Value();
- maybe_int =
- hValue.As<v8::Object>()->Get(5)->ToInt32(pIsolate->GetCurrentContext());
- nCol = maybe_int.FromMaybe(v8::Local<v8::Int32>())->Value();
- return TRUE;
-}
-
CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate,
const FXJSE_CLASS* lpGlobalClass,
void* lpGlobalObject) {
@@ -204,12 +156,8 @@ CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate,
}
CFXJSE_Context::~CFXJSE_Context() {
- for (int32_t i = 0, count = m_rgClasses.GetSize(); i < count; i++) {
- CFXJSE_Class* pClass = m_rgClasses[i];
- if (pClass) {
- delete pClass;
- }
- }
+ for (int32_t i = 0, count = m_rgClasses.GetSize(); i < count; i++)
+ delete m_rgClasses[i];
m_rgClasses.RemoveAll();
}
diff --git a/chromium/third_party/pdfium/xfa/fxjse/include/fxjse.h b/chromium/third_party/pdfium/xfa/fxjse/include/fxjse.h
index 54901704be5..a93c3716a0e 100644
--- a/chromium/third_party/pdfium/xfa/fxjse/include/fxjse.h
+++ b/chromium/third_party/pdfium/xfa/fxjse/include/fxjse.h
@@ -79,33 +79,24 @@ FXJSE_HCONTEXT FXJSE_Context_Create(FXJSE_HRUNTIME hRuntime,
void* lpGlobalObject = nullptr);
void FXJSE_Context_Release(FXJSE_HCONTEXT hContext);
FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext);
-FXJSE_HRUNTIME FXJSE_Context_GetRuntime(FXJSE_HCONTEXT hContext);
void FXJSE_Context_EnableCompatibleMode(FXJSE_HCONTEXT hContext,
uint32_t dwCompatibleFlags);
-void FXJSE_DefineFunctions(FXJSE_HCONTEXT hContext,
- const FXJSE_FUNCTION* lpFunctions,
- int nNum);
FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext,
const FXJSE_CLASS* lpClass);
-FXJSE_HCLASS FXJSE_GetClass(FXJSE_HCONTEXT hContext,
- const CFX_ByteStringC& szName);
FXJSE_HVALUE FXJSE_Value_Create(FXJSE_HRUNTIME hRuntime);
void FXJSE_Value_Release(FXJSE_HVALUE hValue);
-FXJSE_HRUNTIME FXJSE_Value_GetRuntime(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_IsUndefined(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_IsNull(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_IsBoolean(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_IsUTF8String(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_IsNumber(FXJSE_HVALUE hValue);
-FX_BOOL FXJSE_Value_IsInteger(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_IsObject(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_IsArray(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_IsFunction(FXJSE_HVALUE hValue);
-FX_BOOL FXJSE_Value_IsDate(FXJSE_HVALUE hValue);
FX_BOOL FXJSE_Value_ToBoolean(FXJSE_HVALUE hValue);
FX_FLOAT FXJSE_Value_ToFloat(FXJSE_HVALUE hValue);
@@ -128,7 +119,6 @@ void FXJSE_Value_SetObject(FXJSE_HVALUE hValue,
void FXJSE_Value_SetArray(FXJSE_HVALUE hValue,
uint32_t uValueCount,
FXJSE_HVALUE* rgValues);
-void FXJSE_Value_SetDate(FXJSE_HVALUE hValue, double dDouble);
void FXJSE_Value_Set(FXJSE_HVALUE hValue, FXJSE_HVALUE hOriginalValue);
FX_BOOL FXJSE_Value_GetObjectProp(FXJSE_HVALUE hValue,
@@ -140,9 +130,6 @@ FX_BOOL FXJSE_Value_SetObjectProp(FXJSE_HVALUE hValue,
FX_BOOL FXJSE_Value_GetObjectPropByIdx(FXJSE_HVALUE hValue,
uint32_t uPropIdx,
FXJSE_HVALUE hPropValue);
-FX_BOOL FXJSE_Value_SetObjectPropByIdx(FXJSE_HVALUE hValue,
- uint32_t uPropIdx,
- FXJSE_HVALUE hPropValue);
FX_BOOL FXJSE_Value_DeleteObjectProp(FXJSE_HVALUE hValue,
const CFX_ByteStringC& szPropName);
FX_BOOL FXJSE_Value_ObjectHasOwnProp(FXJSE_HVALUE hValue,
@@ -152,11 +139,6 @@ FX_BOOL FXJSE_Value_SetObjectOwnProp(FXJSE_HVALUE hValue,
const CFX_ByteStringC& szPropName,
FXJSE_HVALUE hPropValue);
-FX_BOOL FXJSE_Value_CallFunction(FXJSE_HVALUE hFunction,
- FXJSE_HVALUE hThis,
- FXJSE_HVALUE hRetValue,
- uint32_t nArgCount,
- FXJSE_HVALUE* lpArgs);
FX_BOOL FXJSE_Value_SetFunctionBind(FXJSE_HVALUE hValue,
FXJSE_HVALUE hOldFunction,
FXJSE_HVALUE hNewThis);
@@ -169,11 +151,4 @@ FX_BOOL FXJSE_ExecuteScript(FXJSE_HCONTEXT hContext,
void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name,
const CFX_ByteStringC& utf8Message);
-FX_BOOL FXJSE_ReturnValue_GetMessage(FXJSE_HVALUE hRetValue,
- CFX_ByteString& utf8Name,
- CFX_ByteString& utf8Message);
-FX_BOOL FXJSE_ReturnValue_GetLineInfo(FXJSE_HVALUE hRetValue,
- int32_t& nLine,
- int32_t& nCol);
-
#endif // XFA_FXJSE_INCLUDE_FXJSE_H_
diff --git a/chromium/third_party/pdfium/xfa/fxjse/runtime.cpp b/chromium/third_party/pdfium/xfa/fxjse/runtime.cpp
index 83affe550d1..7b621748992 100644
--- a/chromium/third_party/pdfium/xfa/fxjse/runtime.cpp
+++ b/chromium/third_party/pdfium/xfa/fxjse/runtime.cpp
@@ -6,7 +6,7 @@
#include "xfa/fxjse/runtime.h"
-#include "fpdfsdk/include/jsapi/fxjs_v8.h"
+#include "fpdfsdk/jsapi/include/fxjs_v8.h"
#include "xfa/fxjse/scope_inline.h"
// Duplicates fpdfsdk's cjs_runtime.h, but keeps XFA from depending on it.
diff --git a/chromium/third_party/pdfium/xfa/fxjse/value.cpp b/chromium/third_party/pdfium/xfa/fxjse/value.cpp
index cd3220a17a3..dd07b6cbb83 100644
--- a/chromium/third_party/pdfium/xfa/fxjse/value.cpp
+++ b/chromium/third_party/pdfium/xfa/fxjse/value.cpp
@@ -36,11 +36,6 @@ FX_BOOL FXJSE_Value_IsNumber(FXJSE_HVALUE hValue) {
return lpValue && lpValue->IsNumber();
}
-FX_BOOL FXJSE_Value_IsInteger(FXJSE_HVALUE hValue) {
- CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
- return lpValue && lpValue->IsInteger();
-}
-
FX_BOOL FXJSE_Value_IsObject(FXJSE_HVALUE hValue) {
CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
return lpValue && lpValue->IsObject();
@@ -56,11 +51,6 @@ FX_BOOL FXJSE_Value_IsFunction(FXJSE_HVALUE hValue) {
return lpValue && lpValue->IsFunction();
}
-FX_BOOL FXJSE_Value_IsDate(FXJSE_HVALUE hValue) {
- CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
- return lpValue && lpValue->IsDate();
-}
-
FX_BOOL FXJSE_Value_ToBoolean(FXJSE_HVALUE hValue) {
return reinterpret_cast<CFXJSE_Value*>(hValue)->ToBoolean();
}
@@ -136,10 +126,6 @@ void FXJSE_Value_SetArray(FXJSE_HVALUE hValue,
->SetArray(uValueCount, reinterpret_cast<CFXJSE_Value**>(rgValues));
}
-void FXJSE_Value_SetDate(FXJSE_HVALUE hValue, double dDouble) {
- reinterpret_cast<CFXJSE_Value*>(hValue)->SetDate(dDouble);
-}
-
void FXJSE_Value_Set(FXJSE_HVALUE hValue, FXJSE_HVALUE hOriginalValue) {
CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
CFXJSE_Value* lpOriginalValue =
@@ -175,15 +161,6 @@ FX_BOOL FXJSE_Value_GetObjectPropByIdx(FXJSE_HVALUE hValue,
return lpValue->GetObjectProperty(uPropIdx, lpPropValue);
}
-FX_BOOL FXJSE_Value_SetObjectPropByIdx(FXJSE_HVALUE hValue,
- uint32_t uPropIdx,
- FXJSE_HVALUE hPropValue) {
- CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
- CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue);
- ASSERT(lpValue && lpPropValue);
- return lpValue->SetObjectProperty(uPropIdx, lpPropValue);
-}
-
FX_BOOL FXJSE_Value_DeleteObjectProp(FXJSE_HVALUE hValue,
const CFX_ByteStringC& szPropName) {
return reinterpret_cast<CFXJSE_Value*>(hValue)
@@ -216,17 +193,6 @@ FX_BOOL FXJSE_Value_SetFunctionBind(FXJSE_HVALUE hValue,
return lpValue->SetFunctionBind(lpOldFunction, lpNewThis);
}
-FX_BOOL FXJSE_Value_CallFunction(FXJSE_HVALUE hFunction,
- FXJSE_HVALUE hThis,
- FXJSE_HVALUE hRetValue,
- uint32_t nArgCount,
- FXJSE_HVALUE* lpArgs) {
- CFXJSE_Value* lpThis = reinterpret_cast<CFXJSE_Value*>(hThis);
- CFXJSE_Value* lpRetValue = reinterpret_cast<CFXJSE_Value*>(hRetValue);
- return reinterpret_cast<CFXJSE_Value*>(hFunction)
- ->Call(lpThis, lpRetValue, nArgCount, lpArgs);
-}
-
FXJSE_HVALUE FXJSE_Value_Create(FXJSE_HRUNTIME hRuntime) {
return reinterpret_cast<FXJSE_HVALUE>(
CFXJSE_Value::Create(reinterpret_cast<v8::Isolate*>(hRuntime)));
@@ -237,11 +203,6 @@ void FXJSE_Value_Release(FXJSE_HVALUE hValue) {
delete lpValue;
}
-FXJSE_HRUNTIME FXJSE_Value_GetRuntime(FXJSE_HVALUE hValue) {
- return reinterpret_cast<FXJSE_HRUNTIME>(
- reinterpret_cast<CFXJSE_Value*>(hValue)->GetIsolate());
-}
-
void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name,
const CFX_ByteStringC& utf8Message) {
v8::Isolate* pIsolate = v8::Isolate::GetCurrent();
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/fxfa_objectacc.h b/chromium/third_party/pdfium/xfa/include/fxfa/fxfa_objectacc.h
deleted file mode 100644
index 782b62f9d1a..00000000000
--- a/chromium/third_party/pdfium/xfa/include/fxfa/fxfa_objectacc.h
+++ /dev/null
@@ -1,561 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_INCLUDE_FXFA_FXFA_OBJECTACC_H_
-#define XFA_INCLUDE_FXFA_FXFA_OBJECTACC_H_
-
-#include "core/include/fxge/fx_dib.h"
-#include "xfa/fxfa/parser/xfa_object.h"
-
-class CXFA_Node;
-class IFX_Locale;
-class CXFA_Margin;
-class CXFA_Caption;
-class CXFA_Para;
-class CXFA_Event;
-class CXFA_Script;
-class CXFA_Value;
-class CXFA_Calculate;
-class CXFA_Line;
-class CXFA_Text;
-class CXFA_ExData;
-class CXFA_Image;
-class CXFA_Validate;
-class CXFA_Bind;
-class CXFA_Assist;
-class CXFA_ToolTip;
-class CXFA_Submit;
-class CXFA_BindItems;
-class CXFA_Stroke;
-class CXFA_Corner;
-class CXFA_Edge;
-class CXFA_Box;
-class CXFA_Arc;
-class CXFA_Border;
-class CXFA_Rectangle;
-class CXFA_WidgetData;
-class CXFA_Occur;
-
-inline FX_BOOL XFA_IsSpace(FX_WCHAR c) {
- return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09);
-}
-inline FX_BOOL XFA_IsDigit(FX_WCHAR c) {
- return c >= '0' && c <= '9';
-}
-typedef CFX_ArrayTemplate<CXFA_Object*> CXFA_ObjArray;
-
-class CXFA_Data {
- public:
- explicit CXFA_Data(CXFA_Node* pNode) : m_pNode(pNode) {}
-
- operator bool() const { return !!m_pNode; }
- CXFA_Node* GetNode() const { return m_pNode; }
- XFA_ELEMENT GetClassID() const;
-
- protected:
- FX_BOOL TryMeasure(XFA_ATTRIBUTE eAttr,
- FX_FLOAT& fValue,
- FX_BOOL bUseDefault = FALSE) const;
- FX_BOOL SetMeasure(XFA_ATTRIBUTE eAttr, FX_FLOAT fValue);
-
- CXFA_Node* m_pNode;
-};
-
-class CXFA_Fill : public CXFA_Data {
- public:
- explicit CXFA_Fill(CXFA_Node* pNode);
- ~CXFA_Fill();
-
- int32_t GetPresence();
- FX_ARGB GetColor(FX_BOOL bText = FALSE);
- int32_t GetFillType();
- int32_t GetPattern(FX_ARGB& foreColor);
- int32_t GetStipple(FX_ARGB& stippleColor);
- int32_t GetLinear(FX_ARGB& endColor);
- int32_t GetRadial(FX_ARGB& endColor);
- void SetColor(FX_ARGB color);
-};
-
-class CXFA_Margin : public CXFA_Data {
- public:
- explicit CXFA_Margin(CXFA_Node* pNode);
- FX_BOOL GetLeftInset(FX_FLOAT& fInset, FX_FLOAT fDefInset = 0) const;
- FX_BOOL GetTopInset(FX_FLOAT& fInset, FX_FLOAT fDefInset = 0) const;
- FX_BOOL GetRightInset(FX_FLOAT& fInset, FX_FLOAT fDefInset = 0) const;
- FX_BOOL GetBottomInset(FX_FLOAT& fInset, FX_FLOAT fDefInset = 0) const;
-};
-
-class CXFA_Font : public CXFA_Data {
- public:
- explicit CXFA_Font(CXFA_Node* pNode);
-
- FX_FLOAT GetBaselineShift();
- FX_FLOAT GetHorizontalScale();
- FX_FLOAT GetVerticalScale();
- FX_FLOAT GetLetterSpacing();
- int32_t GetLineThrough();
- int32_t GetUnderline();
- int32_t GetUnderlinePeriod();
- FX_FLOAT GetFontSize();
- void GetTypeface(CFX_WideStringC& wsTypeFace);
-
- FX_BOOL IsBold();
- FX_BOOL IsItalic();
-
- FX_ARGB GetColor();
- void SetColor(FX_ARGB color);
-
-};
-
-class CXFA_Caption : public CXFA_Data {
- public:
- explicit CXFA_Caption(CXFA_Node* pNode);
-
- int32_t GetPresence();
- int32_t GetPlacementType();
- FX_FLOAT GetReserve();
- CXFA_Margin GetMargin();
- CXFA_Font GetFont();
- CXFA_Value GetValue();
-};
-
-class CXFA_Para : public CXFA_Data {
- public:
- explicit CXFA_Para(CXFA_Node* pNode);
-
- int32_t GetHorizontalAlign();
- int32_t GetVerticalAlign();
- FX_FLOAT GetLineHeight();
- FX_FLOAT GetMarginLeft();
- FX_FLOAT GetMarginRight();
- FX_FLOAT GetSpaceAbove();
- FX_FLOAT GetSpaceBelow();
- FX_FLOAT GetTextIndent();
-};
-
-enum XFA_TEXTENCODING {
- XFA_TEXTENCODING_None,
- XFA_TEXTENCODING_Big5,
- XFA_TEXTENCODING_FontSpecific,
- XFA_TEXTENCODING_GBK,
- XFA_TEXTENCODING_GB18030,
- XFA_TEXTENCODING_GB2312,
- XFA_TEXTENCODING_ISO8859NN,
- XFA_TEXTENCODING_KSC5601,
- XFA_TEXTENCODING_ShiftJIS,
- XFA_TEXTENCODING_UCS2,
- XFA_TEXTENCODING_UTF16,
- XFA_TEXTENCODING_UTF8
-};
-
-class CXFA_Event : public CXFA_Data {
- public:
- explicit CXFA_Event(CXFA_Node* pNode);
-
- int32_t GetActivity();
- int32_t GetEventType();
- void GetRef(CFX_WideStringC& wsRef);
-
-
- CXFA_Script GetScript();
- CXFA_Submit GetSubmit();
-
- void GetSignDataTarget(CFX_WideString& wsTarget);
-};
-
-enum XFA_SCRIPTTYPE {
- XFA_SCRIPTTYPE_Formcalc = 0,
- XFA_SCRIPTTYPE_Javascript,
- XFA_SCRIPTTYPE_Unkown,
-};
-
-class CXFA_Script : public CXFA_Data {
- public:
- explicit CXFA_Script(CXFA_Node* pNode);
-
- XFA_SCRIPTTYPE GetContentType();
- int32_t GetRunAt();
- void GetExpression(CFX_WideString& wsExpression);
-};
-
-class CXFA_Submit : public CXFA_Data {
- public:
- explicit CXFA_Submit(CXFA_Node* pNode);
-
- FX_BOOL IsSubmitEmbedPDF();
- int32_t GetSubmitFormat();
- void GetSubmitTarget(CFX_WideStringC& wsTarget);
- void GetSubmitXDPContent(CFX_WideStringC& wsContent);
-};
-
-class CXFA_Value : public CXFA_Data {
- public:
- explicit CXFA_Value(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-
- XFA_ELEMENT GetChildValueClassID();
- FX_BOOL GetChildValueContent(CFX_WideString& wsContent);
- CXFA_Arc GetArc();
- CXFA_Line GetLine();
- CXFA_Rectangle GetRectangle();
- CXFA_Text GetText();
- CXFA_ExData GetExData();
- CXFA_Image GetImage();
-};
-
-class CXFA_Line : public CXFA_Data {
- public:
- explicit CXFA_Line(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-
- int32_t GetHand();
- FX_BOOL GetSlop();
- CXFA_Edge GetEdge();
-};
-
-class CXFA_Text : public CXFA_Data {
- public:
- explicit CXFA_Text(CXFA_Node* pNode);
-
- void GetContent(CFX_WideString& wsText);
-};
-
-class CXFA_ExData : public CXFA_Data {
- public:
- explicit CXFA_ExData(CXFA_Node* pNode);
-
- FX_BOOL SetContentType(const CFX_WideString& wsContentType);
-};
-
-class CXFA_Image : public CXFA_Data {
- public:
- CXFA_Image(CXFA_Node* pNode, FX_BOOL bDefValue);
-
- int32_t GetAspect();
- FX_BOOL GetContentType(CFX_WideString& wsContentType);
- FX_BOOL GetHref(CFX_WideString& wsHref);
- int32_t GetTransferEncoding();
- FX_BOOL GetContent(CFX_WideString& wsText);
- FX_BOOL SetContentType(const CFX_WideString& wsContentType);
- FX_BOOL SetHref(const CFX_WideString& wsHref);
- FX_BOOL SetTransferEncoding(int32_t iTransferEncoding);
-
- protected:
- FX_BOOL m_bDefValue;
-};
-
-class CXFA_Calculate : public CXFA_Data {
- public:
- explicit CXFA_Calculate(CXFA_Node* pNode);
-
- int32_t GetOverride();
- CXFA_Script GetScript();
- void GetMessageText(CFX_WideString& wsMessage);
-};
-
-class CXFA_Validate : public CXFA_Data {
- public:
- explicit CXFA_Validate(CXFA_Node* pNode);
-
- int32_t GetFormatTest();
- int32_t GetNullTest();
- FX_BOOL SetNullTest(CFX_WideString wsValue);
- int32_t GetScriptTest();
- void GetFormatMessageText(CFX_WideString& wsMessage);
- void SetFormatMessageText(CFX_WideString wsMessage);
- void GetNullMessageText(CFX_WideString& wsMessage);
- void SetNullMessageText(CFX_WideString wsMessage);
- void GetScriptMessageText(CFX_WideString& wsMessage);
- void SetScriptMessageText(CFX_WideString wsMessage);
- void GetPicture(CFX_WideString& wsPicture);
- CXFA_Script GetScript();
-
- protected:
- void GetMessageText(CFX_WideString& wsMessage,
- const CFX_WideStringC& wsMessageType);
- void SetMessageText(CFX_WideString& wsMessage,
- const CFX_WideStringC& wsMessageType);
- FX_BOOL SetTestValue(int32_t iType,
- CFX_WideString& wsValue,
- XFA_ATTRIBUTEENUM eName);
-};
-
-class CXFA_Bind : public CXFA_Data {
- public:
- explicit CXFA_Bind(CXFA_Node* pNode);
-
- void GetPicture(CFX_WideString& wsPicture);
-};
-
-class CXFA_Assist : public CXFA_Data {
- public:
- explicit CXFA_Assist(CXFA_Node* pNode);
-
- CXFA_ToolTip GetToolTip();
-};
-
-class CXFA_ToolTip : public CXFA_Data {
- public:
- explicit CXFA_ToolTip(CXFA_Node* pNode);
-
- FX_BOOL GetTip(CFX_WideString& wsTip);
-};
-
-class CXFA_BindItems : public CXFA_Data {
- public:
- explicit CXFA_BindItems(CXFA_Node* pNode);
-
- void GetLabelRef(CFX_WideStringC& wsLabelRef);
- void GetValueRef(CFX_WideStringC& wsValueRef);
- void GetRef(CFX_WideStringC& wsRef);
- FX_BOOL SetConnection(const CFX_WideString& wsConnection);
-};
-
-#define XFA_STROKE_SAMESTYLE_NoPresence 1
-#define XFA_STROKE_SAMESTYLE_Corner 2
-
-class CXFA_Stroke : public CXFA_Data {
- public:
- explicit CXFA_Stroke(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-
- bool IsCorner() const { return GetClassID() == XFA_ELEMENT_Corner; }
- bool IsEdge() const { return GetClassID() == XFA_ELEMENT_Edge; }
- bool IsVisible() const { return GetPresence() == XFA_ATTRIBUTEENUM_Visible; }
- int32_t GetPresence() const;
- int32_t GetCapType() const;
- int32_t GetStrokeType() const;
- FX_FLOAT GetThickness() const;
- CXFA_Measurement GetMSThickness() const;
- void SetMSThickness(CXFA_Measurement msThinkness);
- FX_ARGB GetColor() const;
- void SetColor(FX_ARGB argb);
- int32_t GetJoinType() const;
- FX_BOOL IsInverted() const;
- FX_FLOAT GetRadius() const;
- FX_BOOL SameStyles(CXFA_Stroke stroke, uint32_t dwFlags = 0) const;
-};
-
-class CXFA_Corner : public CXFA_Stroke {
- public:
- explicit CXFA_Corner(CXFA_Node* pNode) : CXFA_Stroke(pNode) {}
-};
-
-class CXFA_Edge : public CXFA_Stroke {
- public:
- explicit CXFA_Edge(CXFA_Node* pNode) : CXFA_Stroke(pNode) {}
-};
-
-typedef CFX_ArrayTemplate<CXFA_Stroke> CXFA_StrokeArray;
-typedef CFX_ArrayTemplate<CXFA_Edge> CXFA_EdgeArray;
-typedef CFX_ArrayTemplate<CXFA_Corner> CXFA_CornerArray;
-
-class CXFA_Box : public CXFA_Data {
- public:
- explicit CXFA_Box(CXFA_Node* pNode) : CXFA_Data(pNode) {}
-
- bool IsArc() const { return GetClassID() == XFA_ELEMENT_Arc; }
- bool IsBorder() const { return GetClassID() == XFA_ELEMENT_Border; }
- bool IsRectangle() const { return GetClassID() == XFA_ELEMENT_Rectangle; }
- int32_t GetHand() const;
- int32_t GetPresence() const;
- int32_t CountEdges() const;
- CXFA_Edge GetEdge(int32_t nIndex = 0) const;
- void GetStrokes(CXFA_StrokeArray& strokes) const;
- FX_BOOL IsCircular() const;
- FX_BOOL GetStartAngle(FX_FLOAT& fStartAngle) const;
- FX_FLOAT GetStartAngle() const {
- FX_FLOAT fStartAngle;
- GetStartAngle(fStartAngle);
- return fStartAngle;
- }
-
- FX_BOOL GetSweepAngle(FX_FLOAT& fSweepAngle) const;
- FX_FLOAT GetSweepAngle() const {
- FX_FLOAT fSweepAngle;
- GetSweepAngle(fSweepAngle);
- return fSweepAngle;
- }
-
- CXFA_Fill GetFill(FX_BOOL bModified = FALSE) const;
- CXFA_Margin GetMargin() const;
- int32_t Get3DStyle(FX_BOOL& bVisible, FX_FLOAT& fThickness) const;
-};
-
-class CXFA_Arc : public CXFA_Box {
- public:
- explicit CXFA_Arc(CXFA_Node* pNode) : CXFA_Box(pNode) {}
-};
-
-class CXFA_Border : public CXFA_Box {
- public:
- explicit CXFA_Border(CXFA_Node* pNode) : CXFA_Box(pNode) {}
-};
-
-class CXFA_Rectangle : public CXFA_Box {
- public:
- explicit CXFA_Rectangle(CXFA_Node* pNode) : CXFA_Box(pNode) {}
-};
-
-enum XFA_CHECKSTATE {
- XFA_CHECKSTATE_On = 0,
- XFA_CHECKSTATE_Off = 1,
- XFA_CHECKSTATE_Neutral = 2,
-};
-
-enum XFA_VALUEPICTURE {
- XFA_VALUEPICTURE_Raw = 0,
- XFA_VALUEPICTURE_Display,
- XFA_VALUEPICTURE_Edit,
- XFA_VALUEPICTURE_DataBind,
-};
-
-class CXFA_WidgetData : public CXFA_Data {
- public:
- explicit CXFA_WidgetData(CXFA_Node* pNode);
-
- CXFA_Node* GetUIChild();
- XFA_ELEMENT GetUIType();
- CFX_WideString GetRawValue();
- int32_t GetAccess(FX_BOOL bTemplate = FALSE);
- int32_t GetRotate();
- CXFA_Border GetBorder(FX_BOOL bModified = FALSE);
- CXFA_Caption GetCaption(FX_BOOL bModified = FALSE);
- CXFA_Font GetFont(FX_BOOL bModified = FALSE);
- CXFA_Margin GetMargin(FX_BOOL bModified = FALSE);
- CXFA_Para GetPara(FX_BOOL bModified = FALSE);
- void GetEventList(CXFA_NodeArray& events);
- int32_t GetEventByActivity(int32_t iActivity,
- CXFA_NodeArray& events,
- FX_BOOL bIsFormReady = FALSE);
- CXFA_Value GetDefaultValue(FX_BOOL bModified = FALSE);
- CXFA_Value GetFormValue(FX_BOOL bModified = FALSE);
- CXFA_Calculate GetCalculate(FX_BOOL bModified = FALSE);
- CXFA_Validate GetValidate(FX_BOOL bModified = FALSE);
- CXFA_Bind GetBind(FX_BOOL bModified = FALSE);
- CXFA_Assist GetAssist(FX_BOOL bModified = FALSE);
- uint32_t GetRelevantStatus();
- FX_BOOL GetWidth(FX_FLOAT& fWidth);
- FX_BOOL GetHeight(FX_FLOAT& fHeight);
- FX_BOOL GetMinWidth(FX_FLOAT& fMinWidth);
- FX_BOOL GetMinHeight(FX_FLOAT& fMinHeight);
- FX_BOOL GetMaxWidth(FX_FLOAT& fMaxWidth);
- FX_BOOL GetMaxHeight(FX_FLOAT& fMaxHeight);
- CXFA_Border GetUIBorder(FX_BOOL bModified = FALSE);
- CXFA_Margin GetUIMargin(FX_BOOL bModified = FALSE);
- void GetUIMargin(CFX_RectF& rtUIMargin);
- int32_t GetButtonHighlight();
- FX_BOOL GetButtonRollover(CFX_WideString& wsRollover, FX_BOOL& bRichText);
- FX_BOOL GetButtonDown(CFX_WideString& wsDown, FX_BOOL& bRichText);
- int32_t GetCheckButtonShape();
- int32_t GetCheckButtonMark();
- FX_FLOAT GetCheckButtonSize();
- FX_BOOL IsAllowNeutral();
- FX_BOOL IsRadioButton();
- XFA_CHECKSTATE GetCheckState();
- void SetCheckState(XFA_CHECKSTATE eCheckState, FX_BOOL bNotify = TRUE);
- CXFA_Node* GetExclGroupNode();
- CXFA_Node* GetSelectedMember();
- CXFA_Node* SetSelectedMember(const CFX_WideStringC& wsName,
- FX_BOOL bNotify = TRUE);
- void SetSelectedMemberByValue(const CFX_WideStringC& wsValue,
- FX_BOOL bNotify = TRUE,
- FX_BOOL bScriptModify = FALSE,
- FX_BOOL bSyncData = TRUE);
- CXFA_Node* GetExclGroupFirstMember();
- CXFA_Node* GetExclGroupNextMember(CXFA_Node* pNode);
- int32_t GetChoiceListCommitOn();
- FX_BOOL IsChoiceListAllowTextEntry();
- int32_t GetChoiceListOpen();
- FX_BOOL IsListBox();
- int32_t CountChoiceListItems(FX_BOOL bSaveValue = FALSE);
- FX_BOOL GetChoiceListItem(CFX_WideString& wsText,
- int32_t nIndex,
- FX_BOOL bSaveValue = FALSE);
- void GetChoiceListItems(CFX_WideStringArray& wsTextArray,
- FX_BOOL bSaveValue = FALSE);
- int32_t CountSelectedItems();
- int32_t GetSelectedItem(int32_t nIndex = 0);
- void GetSelectedItems(CFX_Int32Array& iSelArray);
- void GetSelectedItemsValue(CFX_WideStringArray& wsSelTextArray);
- FX_BOOL GetItemState(int32_t nIndex);
- void SetItemState(int32_t nIndex,
- FX_BOOL bSelected,
- FX_BOOL bNotify = FALSE,
- FX_BOOL bScriptModify = FALSE,
- FX_BOOL bSyncData = TRUE);
- void SetSelectdItems(CFX_Int32Array& iSelArray,
- FX_BOOL bNotify = FALSE,
- FX_BOOL bScriptModify = FALSE,
- FX_BOOL bSyncData = TRUE);
- void ClearAllSelections();
- void InsertItem(const CFX_WideString& wsLabel,
- const CFX_WideString& wsValue,
- int32_t nIndex = -1,
- FX_BOOL bNotify = FALSE);
- void GetItemLabel(const CFX_WideStringC& wsValue, CFX_WideString& wsLabel);
- void GetItemValue(const CFX_WideStringC& wsLabel, CFX_WideString& wsValue);
- FX_BOOL DeleteItem(int32_t nIndex,
- FX_BOOL bNotify = FALSE,
- FX_BOOL bScriptModify = FALSE,
- FX_BOOL bSyncData = TRUE);
- int32_t GetHorizontalScrollPolicy();
- int32_t GetNumberOfCells();
- FX_BOOL SetValue(const CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType);
- FX_BOOL GetPictureContent(CFX_WideString& wsPicture,
- XFA_VALUEPICTURE ePicture);
- IFX_Locale* GetLocal();
- FX_BOOL GetValue(CFX_WideString& wsValue, XFA_VALUEPICTURE eValueType);
- FX_BOOL GetNormalizeDataValue(const CFX_WideStringC& wsValue,
- CFX_WideString& wsNormalizeValue);
- FX_BOOL GetFormatDataValue(const CFX_WideStringC& wsValue,
- CFX_WideString& wsFormatedValue);
- void NormalizeNumStr(const CFX_WideString& wsValue, CFX_WideString& wsOutput);
- CFX_WideString GetBarcodeType();
- FX_BOOL GetBarcodeAttribute_CharEncoding(int32_t& val);
- FX_BOOL GetBarcodeAttribute_Checksum(int32_t& val);
- FX_BOOL GetBarcodeAttribute_DataLength(int32_t& val);
- FX_BOOL GetBarcodeAttribute_StartChar(FX_CHAR& val);
- FX_BOOL GetBarcodeAttribute_EndChar(FX_CHAR& val);
- FX_BOOL GetBarcodeAttribute_ECLevel(int32_t& val);
- FX_BOOL GetBarcodeAttribute_ModuleWidth(int32_t& val);
- FX_BOOL GetBarcodeAttribute_ModuleHeight(int32_t& val);
- FX_BOOL GetBarcodeAttribute_PrintChecksum(FX_BOOL& val);
- FX_BOOL GetBarcodeAttribute_TextLocation(int32_t& val);
- FX_BOOL GetBarcodeAttribute_Truncate(FX_BOOL& val);
- FX_BOOL GetBarcodeAttribute_WideNarrowRatio(FX_FLOAT& val);
- void GetPasswordChar(CFX_WideString& wsPassWord);
- FX_BOOL IsMultiLine();
- int32_t GetVerticalScrollPolicy();
- int32_t GetMaxChars(XFA_ELEMENT& eType);
- FX_BOOL GetFracDigits(int32_t& iFracDigits);
- FX_BOOL GetLeadDigits(int32_t& iLeadDigits);
-
- FX_BOOL m_bIsNull;
- FX_BOOL m_bPreNull;
-
- protected:
- void SyncValue(const CFX_WideString& wsValue, FX_BOOL bNotify);
- void InsertListTextItem(CXFA_Node* pItems,
- const CFX_WideStringC& wsText,
- int32_t nIndex = -1);
- void FormatNumStr(const CFX_WideString& wsValue,
- IFX_Locale* pLocale,
- CFX_WideString& wsOutput);
-
- CXFA_Node* m_pUiChildNode;
- XFA_ELEMENT m_eUIType;
-};
-
-class CXFA_Occur : public CXFA_Data {
- public:
- explicit CXFA_Occur(CXFA_Node* pNode);
-
- int32_t GetMax();
- int32_t GetMin();
- FX_BOOL GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit);
- void SetMax(int32_t iMax);
- void SetMin(int32_t iMin);
-};
-
-#endif // XFA_INCLUDE_FXFA_FXFA_OBJECTACC_H_
diff --git a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_checksum.h b/chromium/third_party/pdfium/xfa/include/fxfa/xfa_checksum.h
deleted file mode 100644
index 3ca79efe583..00000000000
--- a/chromium/third_party/pdfium/xfa/include/fxfa/xfa_checksum.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_INCLUDE_FXFA_XFA_CHECKSUM_H_
-#define XFA_INCLUDE_FXFA_XFA_CHECKSUM_H_
-
-#include "xfa/fgas/xml/fgas_sax.h"
-#include "xfa/include/fxfa/fxfa.h"
-
-class CXFA_SAXReaderHandler;
-class CXFA_ChecksumContext;
-
-class CXFA_SAXContext {
- public:
- CXFA_SAXContext() : m_eNode(FX_SAXNODE_Unknown) {}
- CFX_ByteTextBuf m_TextBuf;
- CFX_ByteString m_bsTagName;
- FX_SAXNODE m_eNode;
-};
-class CXFA_SAXReaderHandler : public IFX_SAXReaderHandler {
- public:
- CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext);
- virtual ~CXFA_SAXReaderHandler();
- virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName,
- FX_SAXNODE eType,
- uint32_t dwStartPos);
- virtual void OnTagAttribute(void* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue);
- virtual void OnTagBreak(void* pTag);
- virtual void OnTagData(void* pTag,
- FX_SAXNODE eType,
- const CFX_ByteStringC& bsData,
- uint32_t dwStartPos);
- virtual void OnTagClose(void* pTag, uint32_t dwEndPos);
- virtual void OnTagEnd(void* pTag,
- const CFX_ByteStringC& bsTagName,
- uint32_t dwEndPos);
-
- virtual void OnTargetData(void* pTag,
- FX_SAXNODE eType,
- const CFX_ByteStringC& bsData,
- uint32_t dwStartPos);
-
- protected:
- void UpdateChecksum(FX_BOOL bCheckSpace);
- CXFA_ChecksumContext* m_pContext;
- CXFA_SAXContext m_SAXContext;
-};
-
-class CXFA_ChecksumContext {
- public:
- CXFA_ChecksumContext();
- ~CXFA_ChecksumContext();
-
- void Release() { delete this; }
- FX_BOOL StartChecksum();
- FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile,
- FX_FILESIZE offset = 0,
- size_t size = 0);
- void FinishChecksum();
- void GetChecksum(CFX_ByteString& bsChecksum);
- void Update(const CFX_ByteStringC& bsText);
-
- protected:
- IFX_SAXReader* m_pSAXReader;
- uint8_t* m_pByteContext;
- CFX_ByteString m_bsChecksum;
-};
-
-#endif // XFA_INCLUDE_FXFA_XFA_CHECKSUM_H_